aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-shortcut.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/e-shell-shortcut.c')
-rw-r--r--shell/e-shell-shortcut.c208
1 files changed, 179 insertions, 29 deletions
diff --git a/shell/e-shell-shortcut.c b/shell/e-shell-shortcut.c
index 6e6aaf8260..a04171bdd2 100644
--- a/shell/e-shell-shortcut.c
+++ b/shell/e-shell-shortcut.c
@@ -17,28 +17,80 @@
#define LARGE_ICONS 2
static void
-set_large_icons (GtkMenu *menu, EShellView *eshell_view)
+set_large_icons (GtkMenuItem *menu_item, EShellView *eshell_view)
{
+ EShortcutGroup *sg = gtk_object_get_data (GTK_OBJECT (menu_item), "shortcut_group");
+
+ g_assert (sg != NULL);
+ e_shortcut_group_set_view_type (sg, E_ICON_BAR_LARGE_ICONS);
}
static void
-set_small_icons (GtkMenu *menu, EShellView *eshell_view)
+set_small_icons (GtkMenu *menu_item, EShellView *eshell_view)
{
+ EShortcutGroup *sg = gtk_object_get_data (GTK_OBJECT (menu_item), "shortcut_group");
+
+ g_assert (sg != NULL);
+ e_shortcut_group_set_view_type (sg, E_ICON_BAR_SMALL_ICONS);
}
static void
add_group (GtkMenu *menu, EShellView *eshell_view)
{
+ int group_num;
+ GtkWidget *entry;
+
+ group_num = e_shortcut_bar_model_add_group (eshell_view->eshell->shortcut_bar);
+
+ /*
+ * FIXME: Figure out why this does not quite work
+ */
+ entry = gtk_entry_new ();
+ gtk_widget_show (entry);
+
+ e_group_bar_set_group_button_label (
+ E_GROUP_BAR (eshell_view->shortcut_bar),
+ group_num,
+ entry);
}
static void
-remove_group (GtkMenu *menu, EShellView *eshell_view)
+remove_group (GtkMenuItem *menu_item, EShellView *eshell_view)
{
+ EShortcutGroup *sg = gtk_object_get_data (GTK_OBJECT (menu_item), "shortcut_group");
+
+ g_assert (sg != NULL);
+
+ e_shortcut_bar_model_remove_group (eshell_view->eshell->shortcut_bar, sg);
}
static void
-rename_group (GtkMenu *menu, EShellView *eshell_view)
+do_rename (GtkEntry *entry, EShortcutGroup *sg)
{
+ e_shortcut_group_rename (sg, gtk_entry_get_text (entry));
+}
+
+static void
+rename_group (GtkMenuItem *menu_item, EShellView *eshell_view)
+{
+ EShortcutGroup *sg = gtk_object_get_data (GTK_OBJECT (menu_item), "shortcut_group");
+ GtkWidget *entry;
+ int item;
+
+ g_assert (sg != NULL);
+
+ item = e_group_num_from_group_ptr (eshell_view->eshell->shortcut_bar, sg);
+ e_shortcut_group_rename (sg, "Dum de da");
+
+ return;
+
+ entry = gtk_entry_new ();
+ gtk_widget_show (entry);
+ gtk_widget_grab_focus (entry);
+
+ gtk_signal_connect (GTK_OBJECT (entry), "activate", GTK_SIGNAL_FUNC (do_rename), sg);
+
+ e_group_bar_set_group_button_label (E_GROUP_BAR (eshell_view->shortcut_bar), item, entry);
}
static void
@@ -72,19 +124,24 @@ shortcut_bar_show_standard_popup (EShellView *eshell_view, GdkEvent *event, ESho
menu = gtk_menu_new ();
for (i = 0; i < ELEMENTS (shortcut_menu); i++){
+ gboolean disable = FALSE;
+
if (shortcut_menu [i].flags & SMALL_ICONS)
- if (!shortcut_group->small_icons)
- continue;
+ if (shortcut_group->type != E_ICON_BAR_SMALL_ICONS)
+ disable = TRUE;
if (shortcut_menu [i].flags & LARGE_ICONS)
- if (shortcut_group->small_icons)
- continue;
+ if (shortcut_group->type != E_ICON_BAR_LARGE_ICONS)
+ disable = TRUE;
if (shortcut_menu [i].label == NULL){
menuitem = gtk_menu_item_new ();
gtk_widget_set_sensitive (menuitem, FALSE);
} else
menuitem = gtk_menu_item_new_with_label (_(shortcut_menu [i].label));
+
+ if (disable)
+ gtk_widget_set_sensitive (menuitem, FALSE);
gtk_widget_show (menuitem);
gtk_menu_append (GTK_MENU (menu), menuitem);
@@ -98,48 +155,141 @@ shortcut_bar_show_standard_popup (EShellView *eshell_view, GdkEvent *event, ESho
}
gtk_signal_connect (GTK_OBJECT (menu), "deactivate",
- GTK_SIGNAL_FUNC (gtk_object_destroy), NULL);
-
+ GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
+
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
event->button.button, event->button.time);
+
+ gtk_main ();
+
+ gtk_object_destroy (GTK_OBJECT (menu));
}
static void
-shortcut_bar_show_context_popup (EShellView *eshell_view, GdkEvent *event, EShortcutGroup *shortcut_group)
+shortcut_open (GtkMenuItem *menuitem, EShellView *eshell_view)
{
- printf ("Context popup\n");
}
-static EShortcut *
-shortcut_from_pos (EShellView *eshell_view, int group_num, int item_num, EShortcutGroup **group_result)
+static void
+shortcut_open_new_window (GtkMenuItem *menuitem, EShellView *eshell_view)
{
- EShell *eshell = eshell_view->eshell;
- EShortcutGroup *group;
- EShortcut *shortcut;
+}
+
+static void
+shortcut_remove (GtkMenuItem *menuitem, EShellView *eshell_view)
+{
+}
+
+static void
+shortcut_rename (GtkMenuItem *menuitem, EShellView *eshell_view)
+{
+ printf ("Implement: %s %s\n", __FILE__, __FUNCTION__);
+}
+
+static void
+shortcut_properties (GtkMenuItem *menuitem, EShellView *eshell_view)
+{
+ printf ("Implement: %s %s\n", __FILE__, __FUNCTION__);
+}
+
+#define NOT_IMPLEMENTED 1
+static struct {
+ char *label;
+ char *stock_id;
+ int flags;
+ GtkSignalFunc callback;
+} context_shortcut_menu [] = {
+ { N_("Open Folder"), GNOME_STOCK_MENU_OPEN, 0, GTK_SIGNAL_FUNC (shortcut_open) },
+ { N_("Open in New Window"), NULL, 0, GTK_SIGNAL_FUNC (shortcut_open_new_window) },
+ { N_("Advanced Find"), NULL, NOT_IMPLEMENTED, NULL },
+ { NULL, },
+ { N_("Remove From Shortcut Bar"), NULL, 0, GTK_SIGNAL_FUNC (shortcut_remove) },
+ { N_("Rename Shortcut"), NULL, 0, GTK_SIGNAL_FUNC (shortcut_rename) },
+ { NULL, },
+ { N_("Properties"), NULL, 0, GTK_SIGNAL_FUNC (shortcut_properties) },
+};
- if (item_num == -1)
- return NULL;
+static void
+shortcut_bar_show_context_popup (EShellView *eshell_view, GdkEvent *event, EShortcutGroup *shortcut_group)
+{
+ GtkWidget *menu, *menuitem;
+ int i;
+ gboolean disable;
- g_assert (group_num < eshell->shortcut_groups->len);
- group = g_array_index (eshell->shortcut_groups, EShortcutGroup *, group_num);
+ menu = gtk_menu_new ();
+
+ for (i = 0; i < ELEMENTS (context_shortcut_menu); i++){
+ disable = FALSE;
+
+ if (context_shortcut_menu [i].flags & NOT_IMPLEMENTED)
+ disable = TRUE;
+
+ if (context_shortcut_menu [i].label == NULL){
+ menuitem = gtk_menu_item_new ();
+ gtk_widget_set_sensitive (menuitem, FALSE);
+ } else {
+ GtkWidget *label;
+
+ if (context_shortcut_menu [i].stock_id){
+ GtkWidget *stock;
+
+ menuitem = gtk_pixmap_menu_item_new ();
+ stock = gnome_stock_pixmap_widget (
+ menu,
+ context_shortcut_menu [i].stock_id);
+ if (stock){
+ gtk_widget_show (stock);
+ gtk_pixmap_menu_item_set_pixmap (
+ GTK_PIXMAP_MENU_ITEM (menuitem), stock);
+ }
+ } else
+ menuitem = gtk_menu_item_new ();
+
+ label = gtk_label_new (_(context_shortcut_menu [i].label));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (menuitem), label);
+ }
+
+ if (disable)
+ gtk_widget_set_sensitive (menuitem, FALSE);
+
+ gtk_widget_show (menuitem);
+ gtk_menu_append (GTK_MENU (menu), menuitem);
- g_assert (item_num < group->shortcuts->len);
- shortcut = g_array_index (group->shortcuts, EShortcut *, item_num);
+ gtk_signal_connect (
+ GTK_OBJECT (menuitem), "activate",
+ context_shortcut_menu [i].callback, eshell_view);
+ gtk_object_set_data (
+ GTK_OBJECT (menuitem), "shortcut_group",
+ shortcut_group);
+ }
- *group_result = group;
+ gtk_signal_connect (GTK_OBJECT (menu), "deactivate",
+ GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ event->button.button, event->button.time);
+
+ gtk_main ();
- return shortcut;
+ gtk_object_destroy (GTK_OBJECT (menu));
}
void
-shortcut_bar_item_selected (EShortcutBar *shortcut_bar,
+shortcut_bar_item_selected (EShortcutBar *e_shortcut_bar,
GdkEvent *event, gint group_num, gint item_num,
EShellView *eshell_view)
{
EShortcut *shortcut;
EShortcutGroup *shortcut_group;
-
- shortcut = shortcut_from_pos (eshell_view, group_num, item_num, &shortcut_group);
+ EShortcutBarModel *shortcut_bar = eshell_view->eshell->shortcut_bar;
+
+ shortcut_group = e_shortcut_group_from_pos (shortcut_bar, group_num);
+ if (shortcut_group == NULL)
+ return;
+
+ shortcut = e_shortcut_from_pos (shortcut_group, item_num);
if (group_num == -1)
return;
@@ -153,7 +303,7 @@ shortcut_bar_item_selected (EShortcutBar *shortcut_bar,
eshell_view, event, shortcut_group);
else
shortcut_bar_show_context_popup (
- eshell_view, event, shortcut);
+ eshell_view, event, shortcut_group);
}
}