diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/e-shell-content.c | 6 | ||||
-rw-r--r-- | shell/e-shell-sidebar.c | 87 | ||||
-rw-r--r-- | shell/e-shell-switcher.c | 2 | ||||
-rw-r--r-- | shell/e-shell-view.c | 132 | ||||
-rw-r--r-- | shell/e-shell-view.h | 12 | ||||
-rw-r--r-- | shell/e-shell-window-actions.c | 3 | ||||
-rw-r--r-- | shell/e-shell-window-private.c | 5 | ||||
-rw-r--r-- | shell/e-shell-window.c | 32 | ||||
-rw-r--r-- | shell/e-shell-window.h | 3 | ||||
-rw-r--r-- | shell/test/e-test-shell-view.c | 6 |
10 files changed, 188 insertions, 100 deletions
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index e1871da412..efa3b663f0 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -509,12 +509,15 @@ shell_content_constructed (GObject *object) EShellWindow *shell_window; EShellContent *shell_content; EIconEntry *icon_entry; + GtkSizeGroup *size_group; GtkAction *action; + GtkWidget *widget; shell_content = E_SHELL_CONTENT (object); shell_view = e_shell_content_get_shell_view (shell_content); shell_window = e_shell_view_get_shell_window (shell_view); icon_entry = E_ICON_ENTRY (shell_content->priv->search_entry); + size_group = e_shell_view_get_size_group (shell_view); action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window); e_icon_entry_add_action_end (icon_entry, action); @@ -526,6 +529,9 @@ shell_content_constructed (GObject *object) action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window); e_icon_entry_add_action_start (icon_entry, action); + + widget = shell_content->priv->search_bar; + gtk_size_group_add_widget (size_group, widget); } static void diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 0ce80d9e54..6694eacd96 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -50,52 +50,13 @@ static void shell_sidebar_set_shell_view (EShellSidebar *shell_sidebar, EShellView *shell_view) { - GtkAction *action; - GtkWidget *container; - GtkWidget *widget; - gchar *label; - g_return_if_fail (shell_sidebar->priv->shell_view == NULL); shell_sidebar->priv->shell_view = shell_view; - action = e_shell_view_get_action (shell_view); g_object_add_weak_pointer ( G_OBJECT (shell_view), &shell_sidebar->priv->shell_view); - - /* Initialize the rest of the internal widgets. */ - - container = shell_sidebar->priv->event_box; - - widget = gtk_hbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (widget), 6); - gtk_container_add (GTK_CONTAINER (container), widget); - gtk_widget_show (widget); - - container = widget; - - widget = gtk_action_create_icon (action, GTK_ICON_SIZE_MENU); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - gtk_widget_show (widget); - - widget = gtk_label_new (NULL); - gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END); - gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); - shell_sidebar->priv->primary_label = g_object_ref (widget); - gtk_widget_show (widget); - - widget = gtk_label_new (NULL); - gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_MIDDLE); - gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); - shell_sidebar->priv->secondary_label = g_object_ref (widget); - gtk_widget_show (widget); - - g_object_get (action, "label", &label, NULL); - e_shell_sidebar_set_primary_text (shell_sidebar, label); - g_free (label); } static void @@ -205,8 +166,52 @@ shell_sidebar_finalize (GObject *object) static void shell_sidebar_constructed (GObject *object) { - /* XXX This is here to let subclasses safely chain up. - * GObject does not define a constructed() method. */ + EShellView *shell_view; + EShellSidebar *shell_sidebar; + GtkSizeGroup *size_group; + GtkAction *action; + GtkWidget *container; + GtkWidget *widget; + gchar *label; + + shell_sidebar = E_SHELL_SIDEBAR (object); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + size_group = e_shell_view_get_size_group (shell_view); + action = e_shell_view_get_action (shell_view); + + widget = shell_sidebar->priv->event_box; + gtk_size_group_add_widget (size_group, widget); + + container = widget; + + widget = gtk_hbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (widget), 6); + gtk_container_add (GTK_CONTAINER (container), widget); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_action_create_icon (action, GTK_ICON_SIZE_MENU); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + widget = gtk_label_new (NULL); + gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END); + gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + shell_sidebar->priv->primary_label = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_label_new (NULL); + gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_MIDDLE); + gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + shell_sidebar->priv->secondary_label = g_object_ref (widget); + gtk_widget_show (widget); + + g_object_get (action, "label", &label, NULL); + e_shell_sidebar_set_primary_text (shell_sidebar, label); + g_free (label); } static void diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c index bcab54cf9f..2910e1d0a0 100644 --- a/shell/e-shell-switcher.c +++ b/shell/e-shell-switcher.c @@ -119,7 +119,7 @@ shell_switcher_layout_actions (EShellSwitcher *switcher) row_last = row_number; /* Layout the buttons. */ - for (i = 0; i < row_last + 1; i++) { + for (i = row_last; i >= 0; i--) { int len, extra_width; x = H_PADDING + allocation->x; diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index f2d7b0ec0c..ab1039b0e5 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -23,12 +23,14 @@ #include <string.h> #include <glib/gi18n.h> -#include <e-shell-content.h> -#include <e-shell-module.h> -#include <e-shell-sidebar.h> -#include <e-shell-taskbar.h> -#include <e-shell-window.h> -#include <e-shell-window-actions.h> +#include "e-util/e-util.h" + +#include "e-shell-content.h" +#include "e-shell-module.h" +#include "e-shell-sidebar.h" +#include "e-shell-taskbar.h" +#include "e-shell-window.h" +#include "e-shell-window-actions.h" #define E_SHELL_VIEW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -41,8 +43,10 @@ struct _EShellViewPrivate { gchar *title; gchar *view_id; gint page_num; + guint merge_id; GtkAction *action; + GtkSizeGroup *size_group; GtkWidget *shell_content; GtkWidget *shell_sidebar; GtkWidget *shell_taskbar; @@ -61,7 +65,8 @@ enum { }; enum { - CHANGED, + TOGGLED, + UPDATE_ACTIONS, LAST_SIGNAL }; @@ -105,6 +110,12 @@ shell_view_init_view_collection (EShellViewClass *shell_view_class) } static void +shell_view_emit_toggled (EShellView *shell_view) +{ + g_signal_emit (shell_view, signals[TOGGLED], 0); +} + +static void shell_view_set_action (EShellView *shell_view, GtkAction *action) { @@ -117,6 +128,10 @@ shell_view_set_action (EShellView *shell_view, g_object_get (action, "label", &label, NULL); e_shell_view_set_title (shell_view, label); g_free (label); + + g_signal_connect_swapped ( + action, "toggled", + G_CALLBACK (shell_view_emit_toggled), shell_view); } static void @@ -252,6 +267,11 @@ shell_view_dispose (GObject *object) priv->shell_window = NULL; } + if (priv->size_group != NULL) { + g_object_unref (priv->size_group); + priv->size_group = NULL; + } + if (priv->shell_content != NULL) { g_object_unref (priv->shell_content); priv->shell_content = NULL; @@ -311,6 +331,28 @@ shell_view_constructed (GObject *object) } static void +shell_view_toggled (EShellView *shell_view) +{ + EShellViewPrivate *priv = shell_view->priv; + EShellViewClass *shell_view_class; + EShellWindow *shell_window; + GtkUIManager *ui_manager; + const gchar *basename; + + shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + ui_manager = e_shell_window_get_ui_manager (shell_window); + basename = shell_view_class->ui_definition; + + if (e_shell_view_is_active (shell_view)) + priv->merge_id = e_load_ui_definition (ui_manager, basename); + else + gtk_ui_manager_remove_ui (ui_manager, priv->merge_id); + + gtk_ui_manager_ensure_update (ui_manager); +} + +static void shell_view_class_init (EShellViewClass *class) { GObjectClass *object_class; @@ -330,6 +372,8 @@ shell_view_class_init (EShellViewClass *class) class->new_shell_sidebar = e_shell_sidebar_new; class->new_shell_taskbar = e_shell_taskbar_new; + class->toggled = shell_view_toggled; + g_object_class_install_property ( object_class, PROP_ACTION, @@ -418,11 +462,20 @@ shell_view_class_init (EShellViewClass *class) NULL, G_PARAM_READWRITE)); - signals[CHANGED] = g_signal_new ( - "changed", + signals[TOGGLED] = g_signal_new ( + "toggled", G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EShellViewClass, changed), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EShellViewClass, toggled), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[UPDATE_ACTIONS] = g_signal_new ( + "update-actions", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EShellViewClass, update_actions), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -432,7 +485,12 @@ static void shell_view_init (EShellView *shell_view, EShellViewClass *shell_view_class) { + GtkSizeGroup *size_group; + + size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); + shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view); + shell_view->priv->size_group = size_group; if (shell_view_class->view_collection == NULL) shell_view_init_view_collection (shell_view_class); @@ -579,6 +637,14 @@ e_shell_view_get_page_num (EShellView *shell_view) return shell_view->priv->page_num; } +GtkSizeGroup * +e_shell_view_get_size_group (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return shell_view->priv->size_group; +} + EShellContent * e_shell_view_get_shell_content (EShellView *shell_view) { @@ -604,9 +670,49 @@ e_shell_view_get_shell_taskbar (EShellView *shell_view) } void -e_shell_view_changed (EShellView *shell_view) +e_shell_view_update_actions (EShellView *shell_view) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + g_signal_emit (shell_view, signals[UPDATE_ACTIONS], 0); +} + +/** + * e_shell_view_show_popup_menu: + * @shell_view: an #EShellView + * @widget_path: path in the UI definition + * @event: a #GdkEventButton + * + * Displays a context-sensitive (or "popup") menu that is described in + * the UI definition loaded into @shell_view<!-- -->'s user interface + * manager. The menu will be shown at the current mouse cursor position. + * + * The #EShellView::update-actions signal is emitted just prior to + * showing the menu to give @shell_view and any plugins that extend + * @shell_view a chance to update the menu's actions. + **/ +void +e_shell_view_show_popup_menu (EShellView *shell_view, + const gchar *widget_path, + GdkEventButton *event) { + EShellWindow *shell_window; + GtkWidget *menu; + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_signal_emit (shell_view, signals[CHANGED], 0); + e_shell_view_update_actions (shell_view); + + shell_window = e_shell_view_get_shell_window (shell_view); + menu = e_shell_window_get_managed_widget (shell_window, widget_path); + g_return_if_fail (GTK_IS_MENU (menu)); + + if (event != NULL) + gtk_menu_popup ( + GTK_MENU (menu), NULL, NULL, NULL, NULL, + event->button, event->time); + else + gtk_menu_popup ( + GTK_MENU (menu), NULL, NULL, NULL, NULL, + 0, gtk_get_current_event_time ()); } diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 5f12840c12..7998326329 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -68,6 +68,9 @@ struct _EShellViewClass { const gchar *label; const gchar *icon_name; + /* Base name of the UI definition file. */ + const gchar *ui_definition; + /* Path to the search entry popup menu. */ const gchar *search_options; @@ -84,7 +87,8 @@ struct _EShellViewClass { GtkWidget * (*new_shell_taskbar) (EShellView *shell_view); /* Signals */ - void (*changed) (EShellView *shell_view); + void (*toggled) (EShellView *shell_view); + void (*update_actions) (EShellView *shell_view); }; GType e_shell_view_get_type (void); @@ -100,11 +104,15 @@ gboolean e_shell_view_is_active (EShellView *shell_view); void e_shell_view_add_activity (EShellView *shell_view, EActivity *activity); gint e_shell_view_get_page_num (EShellView *shell_view); +GtkSizeGroup * e_shell_view_get_size_group (EShellView *shell_view); EShellContent * e_shell_view_get_shell_content (EShellView *shell_view); EShellSidebar * e_shell_view_get_shell_sidebar (EShellView *shell_view); EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view); EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view); -void e_shell_view_changed (EShellView *shell_view); +void e_shell_view_update_actions (EShellView *shell_view); +void e_shell_view_show_popup_menu (EShellView *shell_view, + const gchar *widget_path, + GdkEventButton *event); G_END_DECLS diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index c03e60eecf..28920a7eb7 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -926,7 +926,7 @@ action_search_options_cb (GtkAction *action, shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); widget_path = shell_view_class->search_options; - e_shell_window_show_popup_menu (shell_window, widget_path, NULL); + e_shell_view_show_popup_menu (shell_view, widget_path, NULL); } static void @@ -1727,6 +1727,7 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) gtk_action_group_add_action_with_accel ( action_group, GTK_ACTION (action), accelerator); + g_debug ("Adding action '%s'", action_name); e_shell_switcher_add_action (switcher, GTK_ACTION (action)); gtk_ui_manager_add_ui ( diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 79cdeb94a8..6836e07fa8 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -432,11 +432,6 @@ e_shell_window_switch_to_view (EShellWindow *shell_window, e_shell_window_update_new_menu (shell_window); e_shell_window_update_view_menu (shell_window); e_shell_window_update_search_menu (shell_window); - - /* Notify all loaded views. */ - list = g_hash_table_get_values (shell_window->priv->loaded_views); - g_list_foreach (list, (GFunc) e_shell_view_changed, NULL); - g_list_free (list); } void diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index a316fd7680..e6aa0b09fd 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -648,38 +648,6 @@ e_shell_window_set_safe_mode (EShellWindow *shell_window, } /** - * e_shell_window_show_popup_menu: - * @shell_window: an #EShellWindow - * @widget_path: path in the UI definition - * @event: a #GdkEventButton - * - * Displays a context-sensitive (or "popup") menu that is described in - * the UI definition loaded into @shell_window<!-- -->'s user interface - * manager. The menu will be shown at the current mouse cursor position. - **/ -void -e_shell_window_show_popup_menu (EShellWindow *shell_window, - const gchar *widget_path, - GdkEventButton *event) -{ - GtkWidget *menu; - - g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); - - menu = e_shell_window_get_managed_widget (shell_window, widget_path); - g_return_if_fail (GTK_IS_MENU (menu)); - - if (event != NULL) - gtk_menu_popup ( - GTK_MENU (menu), NULL, NULL, NULL, NULL, - event->button, event->time); - else - gtk_menu_popup ( - GTK_MENU (menu), NULL, NULL, NULL, NULL, - 0, gtk_get_current_event_time ()); -} - -/** * e_shell_window_register_new_item_actions: * @shell_window: an #EShellWindow * @module_name: name of an #EShellModule diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index caf403319b..8ad69a7e65 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -80,9 +80,6 @@ void e_shell_window_set_active_view (EShellWindow *shell_window, gboolean e_shell_window_get_safe_mode (EShellWindow *shell_window); void e_shell_window_set_safe_mode (EShellWindow *shell_window, gboolean safe_mode); -void e_shell_window_show_popup_menu (EShellWindow *shell_window, - const gchar *widget_path, - GdkEventButton *event); /* These should be called from the shell module's window_created() handler. */ diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c index b0f38007c6..7701849cc2 100644 --- a/shell/test/e-test-shell-view.c +++ b/shell/test/e-test-shell-view.c @@ -35,14 +35,16 @@ GType e_test_shell_view_type = 0; static gpointer parent_class; static void -test_shell_view_changed (EShellView *shell_view) +test_shell_view_toggled (EShellView *shell_view) { +#if 0 gboolean is_active; const gchar *active; is_active = e_shell_view_is_active (shell_view); active = is_active ? "active" : "inactive"; g_debug ("%s (now %s)", G_STRFUNC, active); +#endif } static void @@ -113,7 +115,7 @@ test_shell_view_class_init (ETestShellViewClass *class, shell_view_class->label = "Test"; shell_view_class->icon_name = "face-monkey"; shell_view_class->type_module = type_module; - shell_view_class->changed = test_shell_view_changed; + shell_view_class->toggled = test_shell_view_toggled; } static void |