diff options
Diffstat (limited to 'shell')
-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 |
11 files changed, 192 insertions, 0 deletions
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); |