diff options
author | Milan Crha <mcrha@redhat.com> | 2007-10-11 22:03:13 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2007-10-11 22:03:13 +0800 |
commit | eeb89358f6f3aa8f211b33c23842a8deb08171a8 (patch) | |
tree | 5874c18c42397a4a387d6c4aa87718044b31431d | |
parent | aa70b15ea030e8c5a42ea9512c522140e6b8f5e7 (diff) | |
download | gsoc2013-evolution-eeb89358f6f3aa8f211b33c23842a8deb08171a8.tar gsoc2013-evolution-eeb89358f6f3aa8f211b33c23842a8deb08171a8.tar.gz gsoc2013-evolution-eeb89358f6f3aa8f211b33c23842a8deb08171a8.tar.bz2 gsoc2013-evolution-eeb89358f6f3aa8f211b33c23842a8deb08171a8.tar.lz gsoc2013-evolution-eeb89358f6f3aa8f211b33c23842a8deb08171a8.tar.xz gsoc2013-evolution-eeb89358f6f3aa8f211b33c23842a8deb08171a8.tar.zst gsoc2013-evolution-eeb89358f6f3aa8f211b33c23842a8deb08171a8.zip |
** Fix for bug #329823
2007-10-11 Milan Crha <mcrha@redhat.com>
** Fix for bug #329823
* Evolution-Shell.idl: (setButtonIcon):
* e-sidebar.h: (e_sidebar_change_button_icon):
* e-sidebar.c: (struct Button), (button_new), (button_free),
(e_sidebar_change_button_icon):
* e-shell.h: (EMainShellFunc), (e_shell_foreach_shell_window):
* e-shell.c: (EMainShellFunc), (e_shell_foreach_shell_window):
* e-component-view.h: (e_component_view_set_button_icon):
* e-component-view.c: (e_component_view_set_button_icon):
* e-shell-window.h: (e_shell_window_change_component_button_icon):
* e-shell-window.c: (e_shell_window_change_component_button_icon):
* e-shell-view.c: (struct change_icon_struct),
(change_button_icon_func), (impl_ShellView_setButtonIcon),
(e_shell_view_class_init):
Added support to change component's button icon.
* mail-component.h: (mail_indicate_new_mail):
* mail-component.c: (mail_indicate_new_mail),
(struct _MailComponentPrivate), (impl_dispose), (impl_createView):
New function to indicate new mails on sidebar's button and storing
component_view in priv struct for later use.
* em-folder-view.c: (emfv_list_done_message_selected):
* mail-folder-cache.c: (real_flush_updates):
Indicate changes like for plugins for new mails.
svn path=/trunk/; revision=34374
-rw-r--r-- | mail/ChangeLog | 13 | ||||
-rw-r--r-- | mail/em-folder-view.c | 4 | ||||
-rw-r--r-- | mail/mail-component.c | 28 | ||||
-rw-r--r-- | mail/mail-component.h | 3 | ||||
-rw-r--r-- | mail/mail-folder-cache.c | 4 | ||||
-rw-r--r-- | shell/ChangeLog | 19 | ||||
-rw-r--r-- | shell/Evolution-Shell.idl | 1 | ||||
-rw-r--r-- | shell/e-component-view.c | 10 | ||||
-rw-r--r-- | shell/e-component-view.h | 1 | ||||
-rw-r--r-- | shell/e-shell-view.c | 39 | ||||
-rw-r--r-- | shell/e-shell-window.c | 33 | ||||
-rw-r--r-- | shell/e-shell-window.h | 2 | ||||
-rw-r--r-- | shell/e-shell.c | 38 | ||||
-rw-r--r-- | shell/e-shell.h | 2 | ||||
-rw-r--r-- | shell/e-sidebar.c | 43 | ||||
-rw-r--r-- | shell/e-sidebar.h | 4 |
16 files changed, 242 insertions, 2 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index b7205a1efc..bf51ec4540 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,16 @@ +2007-10-11 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #329823 + + * mail-component.h: (mail_indicate_new_mail): + * mail-component.c: (mail_indicate_new_mail), + (struct _MailComponentPrivate), (impl_dispose), (impl_createView): + New function to indicate new mails on sidebar's button and storing + component_view in priv struct for later use. + * em-folder-view.c: (emfv_list_done_message_selected): + * mail-folder-cache.c: (real_flush_updates): + Indicate changes like for plugins for new mails. + 2007-10-09 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #437579 diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 3c2fdab81c..5c4cd27bc2 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -2322,7 +2322,9 @@ emfv_list_done_message_selected(CamelFolder *folder, const char *uid, CamelMimeM } e_profile_event_emit("goto.loaded", emfv->displayed_uid, 0); - + + mail_indicate_new_mail (FALSE); + /** @Event: message.reading * @Title: Viewing a message * @Target: EMEventTargetMessage diff --git a/mail/mail-component.c b/mail/mail-component.c index 2aa9274b30..383e8d5c5c 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -139,6 +139,8 @@ struct _MailComponentPrivate { char *context_path; /* current path for right-click menu */ CamelStore *local_store; + + EComponentView *component_view; }; /* indexed by _mail_component_folder_t */ @@ -455,7 +457,9 @@ impl_dispose (GObject *object) camel_object_unref (priv->local_store); priv->local_store = NULL; } - + + priv->component_view = NULL; + (* G_OBJECT_CLASS (parent_class)->dispose) (object); } @@ -742,6 +746,8 @@ impl_createView (PortableServer_Servant servant, g_object_set_data((GObject*)info, "folderview", view_widget); g_object_set_data((GObject*)view_widget, "foldertree", tree_widget); + priv->component_view = component_view; + return BONOBO_OBJREF(component_view); } @@ -1463,4 +1469,24 @@ mail_component_get_folder_uri(MailComponent *mc, enum _mail_component_folder_t i return mc_default_folders[id].uri; } +/** + * mail_indicate_new_mail + * Indicates new mail in a shell window. + * @param have_new_mail TRUE when have new mail, false otherwise. + **/ +void +mail_indicate_new_mail (gboolean have_new_mail) +{ + const char *icon = NULL; + MailComponent *mc = mail_component_peek (); + + g_return_if_fail (mc != NULL); + + if (have_new_mail) + icon = "mail-unread"; + + if (mc->priv->component_view) + e_component_view_set_button_icon (mc->priv->component_view, icon); +} + BONOBO_TYPE_FUNC_FULL (MailComponent, GNOME_Evolution_MailComponent, PARENT_TYPE, mail_component) diff --git a/mail/mail-component.h b/mail/mail-component.h index 63147e38af..901e612a21 100644 --- a/mail/mail-component.h +++ b/mail/mail-component.h @@ -99,4 +99,7 @@ struct _CamelFolder *mail_component_get_folder(MailComponent *mc, enum _mail_com const char *mail_component_get_folder_uri(MailComponent *mc, enum _mail_component_folder_t id); int status_check (GNOME_Evolution_ShellState shell_state); + +void mail_indicate_new_mail (gboolean have_new_mail); + #endif /* _MAIL_COMPONENT_H_ */ diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 58ddf04e4d..65daffc821 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -251,6 +251,10 @@ real_flush_updates(void *o, void *event_data, void *data) EMEventTargetFolder *t = em_event_target_new_folder(e, up->uri, up->new); t->is_inbox = em_folder_tree_model_is_type_inbox (model, up->store, up->full_name); + + if (t->new > 0) + mail_indicate_new_mail (TRUE); + /** @Event: folder.changed * @Title: Folder changed * @Target: EMEventTargetFolder diff --git a/shell/ChangeLog b/shell/ChangeLog index 2738ec117a..ffab9f9ccc 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,22 @@ +2007-10-11 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #329823 + + * Evolution-Shell.idl: (setButtonIcon): + * e-sidebar.h: (e_sidebar_change_button_icon): + * e-sidebar.c: (struct Button), (button_new), (button_free), + (e_sidebar_change_button_icon): + * e-shell.h: (EMainShellFunc), (e_shell_foreach_shell_window): + * e-shell.c: (EMainShellFunc), (e_shell_foreach_shell_window): + * e-component-view.h: (e_component_view_set_button_icon): + * e-component-view.c: (e_component_view_set_button_icon): + * e-shell-window.h: (e_shell_window_change_component_button_icon): + * e-shell-window.c: (e_shell_window_change_component_button_icon): + * e-shell-view.c: (struct change_icon_struct), + (change_button_icon_func), (impl_ShellView_setButtonIcon), + (e_shell_view_class_init): + Added support to change component's button icon. + 2007-10-09 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #437579 diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl index 49875ea95a..d39ec8edeb 100644 --- a/shell/Evolution-Shell.idl +++ b/shell/Evolution-Shell.idl @@ -30,6 +30,7 @@ module Evolution { /* Should really use a ComponentView i guess */ void setTitle(in string component, in string title); void setComponent(in string component); + void setButtonIcon(in string component, in string iconName); }; interface Shell : Bonobo::Unknown { diff --git a/shell/e-component-view.c b/shell/e-component-view.c index c7080d334e..51b6310ef0 100644 --- a/shell/e-component-view.c +++ b/shell/e-component-view.c @@ -137,5 +137,15 @@ e_component_view_set_title(EComponentView *ecv, const char *title) CORBA_exception_free(&ev); } +void +e_component_view_set_button_icon (EComponentView *ecv, const char *iconName) +{ + CORBA_Environment ev = { 0 }; + + /* save roundtrips, check title is the same */ + GNOME_Evolution_ShellView_setButtonIcon(ecv->shell_view, ecv->id, iconName, &ev); + CORBA_exception_free(&ev); +} + BONOBO_TYPE_FUNC_FULL (EComponentView, GNOME_Evolution_ComponentView, bonobo_object_get_type(), e_component_view) diff --git a/shell/e-component-view.h b/shell/e-component-view.h index 4b5ade05f9..d0c8d56a09 100644 --- a/shell/e-component-view.h +++ b/shell/e-component-view.h @@ -69,6 +69,7 @@ EComponentView *e_component_view_new(GNOME_Evolution_ShellView shell_view, const EComponentView *e_component_view_new_controls(GNOME_Evolution_ShellView parent, const char *id, struct _BonoboControl *side, struct _BonoboControl *view, struct _BonoboControl *statusbar); void e_component_view_set_title(EComponentView *ecv, const char *title); +void e_component_view_set_button_icon (EComponentView *ecv, const char *iconName); #ifdef __cplusplus } diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index f386a7c64d..9e4f66b0d0 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -32,6 +32,7 @@ #include "e-shell-view.h" #include "e-shell-window.h" +#include "e-util/e-icon-factory.h" static BonoboObjectClass *parent_class = NULL; @@ -57,6 +58,43 @@ impl_ShellView_setComponent(PortableServer_Servant _servant, const CORBA_char *i e_shell_window_switch_to_component(esw->window, id); } +struct change_icon_struct { + const char *component_name; + GdkPixbuf *icon; +}; + +static gboolean +change_button_icon_func (EShell *shell, EShellWindow *window, gpointer user_data) +{ + struct change_icon_struct *cis = (struct change_icon_struct*)user_data; + + g_return_val_if_fail (window != NULL, FALSE); + g_return_val_if_fail (cis != NULL, FALSE); + + e_shell_window_change_component_button_icon (window, cis->component_name, cis->icon); + + return TRUE; +} + +static void +impl_ShellView_setButtonIcon (PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * iconName, CORBA_Environment * ev) +{ + EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant); + EShell *shell = e_shell_window_peek_shell (esw->window); + + struct change_icon_struct cis; + cis.component_name = id; + cis.icon = NULL; + + if (iconName) + cis.icon = e_icon_factory_get_icon (iconName, E_ICON_SIZE_BUTTON); + + e_shell_foreach_shell_window (shell, change_button_icon_func, &cis); + + if (cis.icon) + g_object_unref (cis.icon); +} + static void impl_dispose (GObject *object) { @@ -86,6 +124,7 @@ e_shell_view_class_init (EShellViewClass *klass) epv = & klass->epv; epv->setTitle = impl_ShellView_setTitle; epv->setComponent = impl_ShellView_setComponent; + epv->setButtonIcon = impl_ShellView_setButtonIcon; } static void diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 14a1a439a2..5bf644e8d8 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -1290,3 +1290,36 @@ e_shell_window_set_title(EShellWindow *window, const char *component_id, const c } } +/** + * e_shell_window_change_component_button_icon + * Changes icon of components button at sidebar. For more info how this behaves see + * info at @ref e_sidebar_change_button_icon. + * @param window EShellWindow instance. + * @param component_id ID of the component. + * @param icon Icon buffer. + **/ +void +e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, GdkPixbuf *icon) +{ + EShellWindowPrivate *priv; + GSList *p; + + g_return_if_fail (window != NULL); + g_return_if_fail (component_id != NULL); + + priv = window->priv; + + if (priv->destroyed) + return; + + for (p = priv->component_views; p != NULL; p = p->next) { + ComponentView *this_view = p->data; + + if (strcmp (this_view->component_id, component_id) == 0 + || (this_view->component_alias != NULL + && strcmp (this_view->component_alias, component_id) == 0)) { + e_sidebar_change_button_icon (E_SIDEBAR (priv->sidebar), icon, this_view->button_id); + break; + } + } +} diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index c19d2781a9..7646372e62 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -73,4 +73,6 @@ void e_shell_window_set_title(EShellWindow *window, const char *component_id, co void e_shell_window_save_defaults (EShellWindow *window); void e_shell_window_show_settings (EShellWindow *window); +void e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, GdkPixbuf *icon); + #endif /* _E_SHELL_WINDOW_H_ */ diff --git a/shell/e-shell.c b/shell/e-shell.c index 2dec47b734..fdc8e6a15d 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -1382,4 +1382,42 @@ e_shell_quit(EShell *shell) return can_quit; } +/** + * gboolean (*EMainShellFunc) (EShell *shell, EShellWindow *window, gpointer user_data); + * Function used in @ref e_shell_foreach_shell_window. + * @param shell Pointer to EShell. + * @param window Pointer to EShellWindow. + * @param user_data User's data passed to @ref main_shell_foreach_shell_window. + * @return TRUE if need to go to next window, FALSE when stop looking for next window. + **/ + +/** + * e_shell_foreach_shell_window + * This will call function callback for all known EShellWindow of main shell. + * When there is no shell active, then this will do nothing. + * @param shell EShell instance. + * @param func Function to be called. + * @param user_data User data to pass to func. + **/ +void +e_shell_foreach_shell_window (EShell *shell, EMainShellFunc func, gpointer user_data) +{ + EShellPrivate *priv; + GList *p; + + if (!shell) + return; + + priv = shell->priv; + + for (p = priv->windows; p != NULL; p = p->next) { + EShellWindow *window; + + window = E_SHELL_WINDOW (p->data); + + if (window && !func (shell, window, user_data)) + break; + } +} + BONOBO_TYPE_FUNC_FULL (EShell, GNOME_Evolution_Shell, PARENT_TYPE, e_shell) diff --git a/shell/e-shell.h b/shell/e-shell.h index ed125b5cb7..2cd9921af0 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -133,6 +133,8 @@ gboolean e_shell_quit (EShell *shell); const char *e_shell_construct_result_to_string (EShellConstructResult result); +typedef gboolean (*EMainShellFunc) (EShell *shell, EShellWindow *window, gpointer user_data); +void e_shell_foreach_shell_window (EShell *shell, EMainShellFunc func, gpointer user_data); #ifdef __cplusplus } diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c index 4fd2e0e3c0..24f685a525 100644 --- a/shell/e-sidebar.c +++ b/shell/e-sidebar.c @@ -43,6 +43,7 @@ typedef struct { GtkWidget *icon; GtkWidget *hbox; GtkTooltips *tooltips; + GdkPixbuf *default_icon; int id; } Button; @@ -89,6 +90,7 @@ button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, GtkTool button->hbox = hbox; button->tooltips = tooltips; button->id = id; + button->default_icon = NULL; g_object_ref (button_widget); g_object_ref (label); @@ -107,6 +109,8 @@ button_free (Button *button) g_object_unref (button->icon); g_object_unref (button->hbox); g_object_unref (button->tooltips); + if (button->default_icon) + g_object_unref (button->default_icon); g_free (button); } @@ -578,6 +582,45 @@ e_sidebar_add_button (ESidebar *sidebar, gtk_widget_queue_resize (GTK_WIDGET (sidebar)); } +/** + * e_sidebar_change_button_icon + * This will change icon in icon_widget of the button of known component. + * You cannot change icon as in a stack, only one default icon will be stored. + * @param sidebar ESidebar instance. + * @param icon Pointer to buffer with icon. Can by NULL, in this case the icon will be + * put back to default one for the component. + * @param button_id Component's button ID, for which change the icon. + **/ + +void +e_sidebar_change_button_icon (ESidebar *sidebar, GdkPixbuf *icon, int button_id) +{ + GSList *p; + + g_return_if_fail (sidebar != NULL); + + for (p = sidebar->priv->buttons; p != NULL; p = p->next) { + Button *button = p->data; + + if (button->id == button_id) { + if (!button->icon) + break; + + if (icon) { + if (!button->default_icon) + button->default_icon = gdk_pixbuf_copy (gtk_image_get_pixbuf (GTK_IMAGE (button->icon))); + + gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), icon); + } else if (button->default_icon) { + gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), button->default_icon); + g_object_unref (button->default_icon); + button->default_icon = NULL; + } + + break; + } + } +} void e_sidebar_select_button (ESidebar *sidebar, int id) diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h index 765f390bb8..15280580a9 100644 --- a/shell/e-sidebar.h +++ b/shell/e-sidebar.h @@ -73,6 +73,10 @@ void e_sidebar_add_button (ESidebar *sidebar, void e_sidebar_select_button (ESidebar *sidebar, int id); +void e_sidebar_change_button_icon (ESidebar *sidebar, + GdkPixbuf *icon, + int button_id); + ESidebarMode e_sidebar_get_mode (ESidebar *sidebar); void e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode); |