gnumeric r17251 - in trunk: . src
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17251 - in trunk: . src
- Date: Sun, 29 Mar 2009 16:35:24 +0000 (UTC)
Author: mortenw
Date: Sun Mar 29 16:35:23 2009
New Revision: 17251
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17251&view=rev
Log:
2009-03-29 Morten Welinder <terra gnome org>
* src/wbc-gtk.c (sheet_menu_label_run): Simplify and add sorted
sheet menu too.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/src/wbc-gtk.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sun Mar 29 16:35:23 2009
@@ -7,6 +7,7 @@
* Improve XIRR a bit.
* Fix Applix loading crash. [#577145]
* Fix Lotus loading crash. [#577156]
+ * Add sorted sheet list to tab menu.
--------------------------------------------------------------------------
Gnumeric 1.9.5
Modified: trunk/src/wbc-gtk.c
==============================================================================
--- trunk/src/wbc-gtk.c (original)
+++ trunk/src/wbc-gtk.c Sun Mar 29 16:35:23 2009
@@ -446,69 +446,90 @@
static void cb_sheets_add (SheetControlGUI *scg) { wbcg_append_sheet (NULL, scg->wbcg); }
static void cb_sheets_clone (SheetControlGUI *scg) { wbcg_clone_sheet (NULL, scg->wbcg); }
static void cb_sheets_rename (SheetControlGUI *scg) { editable_label_start_editing (EDITABLE_LABEL(scg->label)); }
+
+static gint
+cb_by_scg_sheet_name (gconstpointer a_, gconstpointer b_)
+{
+ const SheetControlGUI *a = a_;
+ const SheetControlGUI *b = b_;
+ Sheet *sa = scg_sheet (a);
+ Sheet *sb = scg_sheet (b);
+
+ return g_utf8_collate (sa->name_unquoted, sb->name_unquoted);
+}
+
+
static void
sheet_menu_label_run (SheetControlGUI *scg, GdkEventButton *event)
{
- struct {
+ struct SheetTabMenu {
char const *text;
void (*function) (SheetControlGUI *scg);
gboolean req_multiple_sheets;
+ int submenu;
} const sheet_label_context_actions [] = {
- { N_("Manage sheets..."), &cb_sheets_manage, FALSE},
- { NULL, NULL, 0},
- { N_("Insert"), &cb_sheets_insert, FALSE },
- { N_("Append"), &cb_sheets_add, FALSE },
- { N_("Duplicate"), &cb_sheets_clone, FALSE },
- { N_("Remove"), &scg_delete_sheet_if_possible, TRUE },
- { N_("Rename"), &cb_sheets_rename, FALSE }
+ { N_("Manage sheets..."), &cb_sheets_manage, FALSE, 0},
+ { NULL, NULL, FALSE, 0 },
+ { N_("Insert"), &cb_sheets_insert, FALSE, 0 },
+ { N_("Append"), &cb_sheets_add, FALSE, 0 },
+ { N_("Duplicate"), &cb_sheets_clone, FALSE, 0 },
+ { N_("Remove"), &scg_delete_sheet_if_possible, TRUE, 0 },
+ { N_("Rename"), &cb_sheets_rename, FALSE, 0 },
+ { N_("Select"), NULL, FALSE, 1 },
+ { N_("Select (sorted)"), NULL, FALSE, 2 }
};
- unsigned int i;
+ unsigned int ui;
GtkWidget *item, *menu = gtk_menu_new ();
- gboolean has_multiple = gnm_notebook_get_n_visible (scg->wbcg->bnotebook) > 1;
-
- for (i = 0; i < G_N_ELEMENTS (sheet_label_context_actions); i++){
- char const *text = sheet_label_context_actions[i].text;
- gboolean req_multiple_sheets = sheet_label_context_actions [i].req_multiple_sheets;
- gboolean inactive =
- (req_multiple_sheets && !has_multiple) ||
- wbc_gtk_get_guru (scg_wbcg (scg)) != NULL;
-
- if (text != NULL) {
- item = gtk_menu_item_new_with_label (_(text));
- g_signal_connect_swapped (G_OBJECT (item), "activate",
- G_CALLBACK (sheet_label_context_actions [i].function), scg);
- } else
- item = gtk_separator_menu_item_new ();
-
- gtk_widget_set_sensitive (item, !inactive);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- }
+ GtkWidget *guru = wbc_gtk_get_guru (scg_wbcg (scg));
+ unsigned int N_visible, pass;
+ GtkWidget *submenus[2 + 1];
+ GSList *scgs = get_all_scgs (scg->wbcg);
- if (1) {
- GSList *l, *scgs = get_all_scgs (scg->wbcg);
- GtkWidget *submenu = gtk_menu_new ();
-
- item = gtk_menu_item_new_with_label (_("Select"));
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
+ for (pass = 1; pass <= 2; pass++) {
+ GSList *l;
+ submenus[pass] = gtk_menu_new ();
+ N_visible = 0;
for (l = scgs; l; l = l->next) {
SheetControlGUI *scg1 = l->data;
Sheet *sheet = scg_sheet (scg1);
if (!sheet_is_visible (sheet))
continue;
+ N_visible++;
+
item = gtk_menu_item_new_with_label (sheet->name_unquoted);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (cb_show_sheet), scg1);
- gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (submenus[pass]), item);
gtk_widget_show (item);
}
- g_slist_free (scgs);
+ scgs = g_slist_sort (scgs, cb_by_scg_sheet_name);
+ }
+ g_slist_free (scgs);
+
+ for (ui = 0; ui < G_N_ELEMENTS (sheet_label_context_actions); ui++) {
+ const struct SheetTabMenu *it =
+ sheet_label_context_actions + ui;
+ gboolean inactive =
+ (it->req_multiple_sheets && N_visible <= 1) ||
+ (!it->submenu && guru != NULL);
+
+ item = it->text
+ ? gtk_menu_item_new_with_label (_(it->text))
+ : gtk_separator_menu_item_new ();
+ if (it->function)
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (it->function), scg);
+ if (it->submenu)
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (item),
+ submenus[it->submenu]);
+
+ gtk_widget_set_sensitive (item, !inactive);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
}
gnumeric_popup_menu (GTK_MENU (menu), event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]