diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2000-06-01 08:56:00 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2000-06-01 08:56:00 +0800 |
commit | a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa (patch) | |
tree | 6372937cce97db28833b55e6ff2a9287a4ad9482 /shell/e-shortcuts-view.c | |
parent | 19150e7c7b614544188f93dbffd748a2846d2a1b (diff) | |
download | gsoc2013-evolution-a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa.tar gsoc2013-evolution-a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa.tar.gz gsoc2013-evolution-a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa.tar.bz2 gsoc2013-evolution-a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa.tar.lz gsoc2013-evolution-a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa.tar.xz gsoc2013-evolution-a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa.tar.zst gsoc2013-evolution-a718dec073135b0dac15e0f36e9a7ac6b9b9ddfa.zip |
Implemented right-click menus for the shell's shortcut bar (the user
can remove shortcuts now) and added status bar to the shell view.
Also, added an API call to EShortcutBar to get the view type for a
specified group.
svn path=/trunk/; revision=3318
Diffstat (limited to 'shell/e-shortcuts-view.c')
-rw-r--r-- | shell/e-shortcuts-view.c | 199 |
1 files changed, 195 insertions, 4 deletions
diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index 8e4bbea50c..e5184129f6 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -181,6 +181,182 @@ icon_callback (EShortcutBar *shortcut_bar, } +/* Shortcut bar right-click menu. */ + +struct _RightClickMenuData { + EShortcutsView *shortcuts_view; + int group_num; +}; +typedef struct _RightClickMenuData RightClickMenuData; + +static void +toggle_large_icons_cb (GtkWidget *widget, + void *data) +{ + RightClickMenuData *menu_data; + + g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (widget)); + + if (data == NULL) + return; + + menu_data = (RightClickMenuData *) data; + + if (! GTK_CHECK_MENU_ITEM (widget)->active) + return; + + e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), + menu_data->group_num, + E_ICON_BAR_LARGE_ICONS); +} + +static void +toggle_small_icons_cb (GtkWidget *widget, + void *data) +{ + RightClickMenuData *menu_data; + + g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (widget)); + + if (data == NULL) + return; + + menu_data = (RightClickMenuData *) data; + + if (! GTK_CHECK_MENU_ITEM (widget)->active) + return; + + e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), + menu_data->group_num, + E_ICON_BAR_SMALL_ICONS); +} + +static GnomeUIInfo icon_size_radio_group_uiinfo[] = { + { GNOME_APP_UI_ITEM, N_("_Small icons"), + N_("Show the shortcuts as small icons"), toggle_small_icons_cb, NULL, + NULL, 0, 0, 0, 0 }, + { GNOME_APP_UI_ITEM, N_("_Large icons"), + N_("Show the shortcuts as large icons"), toggle_large_icons_cb, NULL, + NULL, 0, 0, 0, 0 }, + + GNOMEUIINFO_END +}; + +static GnomeUIInfo right_click_menu_uiinfo[] = { + GNOMEUIINFO_RADIOLIST (icon_size_radio_group_uiinfo), + GNOMEUIINFO_END +}; + +static void +pop_up_right_click_menu_for_group (EShortcutsView *shortcuts_view, + GdkEventButton *event, + int group_num) +{ + RightClickMenuData *menu_data; + GtkWidget *popup_menu; + + menu_data = g_new (RightClickMenuData, 1); + menu_data->shortcuts_view = shortcuts_view; + menu_data->group_num = group_num; + + popup_menu = gnome_popup_menu_new (right_click_menu_uiinfo); + + if (e_shortcut_bar_get_view_type (E_SHORTCUT_BAR (shortcuts_view), group_num) + == E_ICON_BAR_SMALL_ICONS) + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (icon_size_radio_group_uiinfo[0].widget), + TRUE); + else + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (icon_size_radio_group_uiinfo[1].widget), + TRUE); + + gnome_popup_menu_do_popup_modal (popup_menu, NULL, NULL, event, menu_data); + + g_free (menu_data); + gtk_widget_destroy (popup_menu); +} + + +/* Shortcut right-click menu. */ + +struct _ShortcutRightClickMenuData { + EShortcutsView *shortcuts_view; + int group_num; + int item_num; +}; +typedef struct _ShortcutRightClickMenuData ShortcutRightClickMenuData; + +static void +activate_shortcut_cb (GtkWidget *widget, + void *data) +{ + ShortcutRightClickMenuData *menu_data; + EShortcutsView *shortcuts_view; + EShortcuts *shortcuts; + const char *uri; + + menu_data = (ShortcutRightClickMenuData *) data; + shortcuts_view = menu_data->shortcuts_view; + shortcuts = shortcuts_view->priv->shortcuts; + + uri = e_shortcuts_get_uri (shortcuts, menu_data->group_num, menu_data->item_num); + if (uri == NULL) + return; + + gtk_signal_emit (GTK_OBJECT (shortcuts_view), signals[ACTIVATE_SHORTCUT], + shortcuts, uri); +} + +static void +remove_shortcut_cb (GtkWidget *widget, + void *data) +{ + ShortcutRightClickMenuData *menu_data; + EShortcutsView *shortcuts_view; + EShortcuts *shortcuts; + + menu_data = (ShortcutRightClickMenuData *) data; + shortcuts_view = menu_data->shortcuts_view; + shortcuts = shortcuts_view->priv->shortcuts; + + e_shortcuts_remove_shortcut (shortcuts, menu_data->group_num, menu_data->item_num); + + /* FIXME not real model-view. */ + e_shortcut_bar_remove_item (E_SHORTCUT_BAR (shortcuts_view), + menu_data->group_num, menu_data->item_num); +} + +static GnomeUIInfo shortcut_right_click_menu_uiinfo[] = { + GNOMEUIINFO_ITEM (N_("Activate"), N_("Activate this shortcut"), + activate_shortcut_cb, NULL), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK (N_("Remove"), N_("Remove this shortcut from the shortcut bar"), + remove_shortcut_cb, GNOME_STOCK_MENU_CLOSE), + GNOMEUIINFO_END +}; + +static void +pop_up_right_click_menu_for_shortcut (EShortcutsView *shortcuts_view, + GdkEventButton *event, + int group_num, + int item_num) +{ + ShortcutRightClickMenuData *menu_data; + GtkWidget *popup_menu; + + menu_data = g_new (ShortcutRightClickMenuData, 1); + menu_data->shortcuts_view = shortcuts_view; + menu_data->group_num = group_num; + menu_data->item_num = item_num; + + popup_menu = gnome_popup_menu_new (shortcut_right_click_menu_uiinfo); + + gnome_popup_menu_do_popup_modal (popup_menu, NULL, NULL, event, menu_data); + + g_free (menu_data); + gtk_widget_destroy (popup_menu); +} + + /* GtkObject methods. */ static void @@ -207,17 +383,32 @@ selected_item (EShortcutBar *shortcut_bar, int item_num) { EShortcuts *shortcuts; + EShortcutsView *shortcuts_view; const char *uri; - shortcuts = E_SHORTCUTS_VIEW (shortcut_bar)->priv->shortcuts; + shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar); + shortcuts = shortcuts_view->priv->shortcuts; - uri = e_shortcuts_get_uri (shortcuts, group_num, item_num); + if (event->button.button == 3) { + if (item_num < 0) + pop_up_right_click_menu_for_group (shortcuts_view, &event->button, + group_num); + else + pop_up_right_click_menu_for_shortcut (shortcuts_view, &event->button, + group_num, item_num); + return; + } else if (event->button.button != 1) { + return; + } - /* Lame EShortcutBar. This can happen. */ + if (item_num < 0) + return; + + uri = e_shortcuts_get_uri (shortcuts, group_num, item_num); if (uri == NULL) return; - gtk_signal_emit (GTK_OBJECT (shortcut_bar), signals[ACTIVATE_SHORTCUT], + gtk_signal_emit (GTK_OBJECT (shortcuts_view), signals[ACTIVATE_SHORTCUT], shortcuts, uri); } |