aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog24
-rw-r--r--shell/e-shortcuts-view-model.c3
-rw-r--r--shell/e-shortcuts-view.c126
-rw-r--r--shell/e-shortcuts.c13
4 files changed, 147 insertions, 19 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index c401a3e5d5..25e998633b 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,27 @@
+2000-09-26 Ettore Perazzoli <ettore@helixcode.com>
+
+ * e-shortcuts.c (e_shortcuts_get_group_title): Cast the data
+ pointer, not the node pointer.
+ (e_shortcuts_add_group): If @group_num is -1, emit the effective
+ group number with the "new_group" signal instead of -1, which is
+ going to confuse the signal handler.
+ (e_shortcuts_add_shortcut): Likewise with the shortcut.
+
+ * e-shortcuts-view-model.c (shortcuts_new_group_cb): We are @data,
+ not @shortcuts.
+ (class_init): Install the `::destroy' handler.
+
+ * e-shortcuts-view.c (e_shortcuts_view_construct): Set
+ `priv->shortcuts'.
+ (remove_shortcut_cb): Don't remove the item both on the data and
+ the model.
+ (toggle_small_icons_cb): Removed some crufty checks.
+ (toggle_large_icons_cb): Likewise.
+ (show_new_group_dialog): New, implementation for the "Create new
+ shortcut group" dialog.
+ (destroy_group_cb): Callback for the "Destroy this group" item.
+ (create_new_group): Callback for the "Create new group" item.
+
2000-09-25 Ettore Perazzoli <ettore@helixcode.com>
* e-shortcuts-view.c (item_selected): Renamed from
diff --git a/shell/e-shortcuts-view-model.c b/shell/e-shortcuts-view-model.c
index c37e45092c..384144508b 100644
--- a/shell/e-shortcuts-view-model.c
+++ b/shell/e-shortcuts-view-model.c
@@ -145,7 +145,7 @@ shortcuts_new_group_cb (EShortcuts *shortcuts,
EShortcutsViewModelPrivate *priv;
const char *title;
- shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (shortcuts);
+ shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
priv = shortcuts_view_model->priv;
title = e_shortcuts_get_group_title (priv->shortcuts, group_num);
@@ -229,6 +229,7 @@ class_init (EShortcutsViewModelClass *klass)
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = impl_destroy;
parent_class = gtk_type_class (e_shortcut_model_get_type ());
}
diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c
index 014be21beb..105d96b496 100644
--- a/shell/e-shortcuts-view.c
+++ b/shell/e-shortcuts-view.c
@@ -109,6 +109,54 @@ icon_callback (EShortcutBar *shortcut_bar,
}
+static void
+show_new_group_dialog (EShortcutsView *view)
+{
+ GtkWidget *dialog;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *box;
+ const char *group_name;
+ int button_num;
+
+ dialog = gnome_dialog_new (_("Create new shortcut group"),
+ GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL);
+
+ label = gtk_label_new (_("Group name:"));
+ gtk_widget_show (label);
+
+ entry = gtk_entry_new ();
+ gtk_widget_show (entry);
+
+ box = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
+ gtk_widget_show (box);
+
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 0);
+
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), box, FALSE, TRUE, 0);
+
+ gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))));
+ gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
+
+ gtk_widget_grab_focus (entry);
+ gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE (entry));
+
+ gtk_widget_show (dialog);
+
+ button_num = gnome_dialog_run (GNOME_DIALOG (dialog));
+ if (button_num == -1)
+ return;
+ if (button_num != 0) {
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+ group_name = gtk_entry_get_text (GTK_ENTRY (entry));
+ e_shortcuts_add_group (view->priv->shortcuts, -1, group_name);
+}
+
+
/* Shortcut bar right-click menu. */
struct _RightClickMenuData {
@@ -123,13 +171,11 @@ toggle_large_icons_cb (GtkWidget *widget,
{
RightClickMenuData *menu_data;
- g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (widget));
+ menu_data = (RightClickMenuData *) data;
- if (data == NULL)
+ if (menu_data == NULL)
return;
- menu_data = (RightClickMenuData *) data;
-
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
@@ -144,12 +190,9 @@ toggle_small_icons_cb (GtkWidget *widget,
{
RightClickMenuData *menu_data;
- g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (widget));
-
- if (data == NULL)
- return;
-
menu_data = (RightClickMenuData *) data;
+ if (menu_data == NULL)
+ return;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
@@ -159,11 +202,53 @@ toggle_small_icons_cb (GtkWidget *widget,
E_ICON_BAR_SMALL_ICONS);
}
+static void
+create_new_group_cb (GtkWidget *widget,
+ void *data)
+{
+ RightClickMenuData *menu_data;
+
+ menu_data = (RightClickMenuData *) data;
+
+ show_new_group_dialog (menu_data->shortcuts_view);
+}
+
+static void
+destroy_group_cb (GtkWidget *widget,
+ void *data)
+{
+ RightClickMenuData *menu_data;
+ EShortcuts *shortcuts;
+ EShortcutsView *shortcuts_view;
+ EShortcutsViewPrivate *priv;
+ GtkWidget *message_box;
+ char *question;
+
+ menu_data = (RightClickMenuData *) data;
+ shortcuts_view = menu_data->shortcuts_view;
+ priv = shortcuts_view->priv;
+ shortcuts = priv->shortcuts;
+
+ question = g_strdup_printf (_("Do you really want to remove group\n"
+ "`%s' from the shortcut bar?"),
+ e_shortcuts_get_group_title (shortcuts, menu_data->group_num));
+
+ message_box = gnome_message_box_new (question, GNOME_MESSAGE_BOX_QUESTION,
+ _("Remove"), _("Don't remove"), NULL);
+ gnome_dialog_set_parent (GNOME_DIALOG (message_box),
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shortcuts_view))));
+
+ if (gnome_dialog_run_and_close (GNOME_DIALOG (message_box)) != 0)
+ return;
+
+ e_shortcuts_remove_group (shortcuts, menu_data->group_num);
+}
+
static GnomeUIInfo icon_size_radio_group_uiinfo[] = {
- { GNOME_APP_UI_ITEM, N_("_Small icons"),
+ { 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"),
+ { GNOME_APP_UI_ITEM, N_("_Large Icons"),
N_("Show the shortcuts as large icons"), toggle_large_icons_cb, NULL,
NULL, 0, 0, 0, 0 },
@@ -172,6 +257,16 @@ static GnomeUIInfo icon_size_radio_group_uiinfo[] = {
static GnomeUIInfo right_click_menu_uiinfo[] = {
GNOMEUIINFO_RADIOLIST (icon_size_radio_group_uiinfo),
+
+ GNOMEUIINFO_SEPARATOR,
+
+ { GNOME_APP_UI_ITEM, N_("_New Group..."),
+ N_("Create a new shortcut group"), create_new_group_cb, NULL,
+ NULL, 0, 0, 0, 0 },
+ { GNOME_APP_UI_ITEM, N_("_Remove This Group..."),
+ N_("Remove this shortcut group"), destroy_group_cb, NULL,
+ NULL, 0, 0, 0, 0 },
+
GNOMEUIINFO_END
};
@@ -197,6 +292,9 @@ pop_up_right_click_menu_for_group (EShortcutsView *shortcuts_view,
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (icon_size_radio_group_uiinfo[1].widget),
TRUE);
+ if (group_num == 0)
+ gtk_widget_set_sensitive (right_click_menu_uiinfo[3].widget, FALSE);
+
gnome_popup_menu_do_popup_modal (popup_menu, NULL, NULL, event, menu_data);
g_free (menu_data);
@@ -247,11 +345,6 @@ remove_shortcut_cb (GtkWidget *widget,
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_model_remove_item (E_SHORTCUT_BAR (shortcuts_view)->model,
- menu_data->group_num,
- menu_data->item_num);
}
static GnomeUIInfo shortcut_right_click_menu_uiinfo[] = {
@@ -426,6 +519,7 @@ e_shortcuts_view_construct (EShortcutsView *shortcuts_view,
g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
priv = shortcuts_view->priv;
+ priv->shortcuts = shortcuts;
e_shortcut_bar_set_icon_callback (E_SHORTCUT_BAR (shortcuts_view), icon_callback,
shortcuts);
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 4befb87cb7..7f044dd129 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -697,6 +697,9 @@ e_shortcuts_add_shortcut (EShortcuts *shortcuts,
group = (ShortcutGroup *) p->data;
+ if (num == -1)
+ num = g_list_length (group->shortcuts);
+
group->shortcuts = g_list_insert (group->shortcuts, g_strdup (uri), num);
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[NEW_SHORTCUT], group_num, num);
@@ -748,6 +751,9 @@ e_shortcuts_add_group (EShortcuts *shortcuts,
group->title = g_strdup (group_name);
group->shortcuts = NULL;
+ if (group_num == -1)
+ group_num = g_list_length (priv->groups);
+
priv->groups = g_list_insert (priv->groups, group, group_num);
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[NEW_GROUP], group_num);
@@ -761,6 +767,7 @@ e_shortcuts_get_group_title (EShortcuts *shortcuts,
int group_num)
{
EShortcutsPrivate *priv;
+ GList *group_element;
const ShortcutGroup *group;
g_return_val_if_fail (shortcuts != NULL, NULL);
@@ -768,10 +775,12 @@ e_shortcuts_get_group_title (EShortcuts *shortcuts,
priv = shortcuts->priv;
- group = g_list_nth (priv->groups, group_num);
- if (group == NULL)
+ group_element = g_list_nth (priv->groups, group_num);
+ if (group_element == NULL)
return NULL;
+ group = (ShortcutGroup *) group_element->data;
+
return group->title;
}