[gedit/wip/tabs] Use a template for gedit notebook and add a documents menu



commit 4c7705eb9d766ed4fe245fcbf2cb15531766a568
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Jun 24 17:16:01 2013 +0200

    Use a template for gedit notebook and add a documents menu

 gedit/gedit-marshal.list     |    1 +
 gedit/gedit-notebook.c       |  148 +++++++++++++++++++-
 gedit/gedit-notebook.h       |    2 +
 gedit/gedit-notebook.ui      |   23 +++
 gedit/gedit-ui.xml           |    5 +-
 gedit/gedit-window-private.h |    4 -
 gedit/gedit-window.c         |  307 ------------------------------------------
 gedit/gedit.gresource.xml    |    1 +
 8 files changed, 170 insertions(+), 321 deletions(-)
---
diff --git a/gedit/gedit-marshal.list b/gedit/gedit-marshal.list
index d646838..9762ba2 100644
--- a/gedit/gedit-marshal.list
+++ b/gedit/gedit-marshal.list
@@ -1,5 +1,6 @@
 BOOLEAN:NONE
 BOOLEAN:OBJECT
+BOOLEAN:INT
 VOID:BOOLEAN
 VOID:BOOLEAN,POINTER
 VOID:BOXED,BOXED
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index d65b29a..4e852ab 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -50,6 +50,7 @@
 #include "gedit-enum-types.h"
 #include "gedit-settings.h"
 #include "gedit-marshal.h"
+#include "gedit-utils.h"
 
 #define GEDIT_NOTEBOOK_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_NOTEBOOK, 
GeditNotebookPrivate))
 
@@ -59,6 +60,9 @@ struct _GeditNotebookPrivate
 {
        GSettings     *ui_settings;
 
+       GtkWidget     *documents_button;
+       GMenu         *documents_menu;
+
        GList         *focused_pages;
 
        GeditNotebookShowTabsModeType show_tabs_mode;
@@ -81,6 +85,7 @@ enum
 {
        TAB_CLOSE_REQUEST,
        SHOW_POPUP_MENU,
+       CHANGE_TO_PAGE,
        LAST_SIGNAL
 };
 
@@ -161,9 +166,10 @@ gedit_notebook_set_property (GObject      *object,
 static void
 gedit_notebook_dispose (GObject *object)
 {
-       GeditNotebook *notebook = GEDIT_NOTEBOOK (object);
+       GeditNotebookPrivate *priv = GEDIT_NOTEBOOK (object)->priv;
 
-       g_clear_object (&notebook->priv->ui_settings);
+       g_clear_object (&priv->ui_settings);
+       g_clear_object (&priv->documents_menu);
 
        G_OBJECT_CLASS (gedit_notebook_parent_class)->dispose (object);
 }
@@ -427,11 +433,17 @@ gedit_notebook_page_removed (GtkNotebook *notebook,
 
        num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
 
-       /* If there is no tabs, calling this is pointless */
        if (num_pages > 0)
        {
+               /* If there is no tabs, calling this is pointless */
                update_tabs_visibility (nb, FALSE);
        }
+       else
+       {
+               /* Unset the menu model from the button to make it insensitive */
+               gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (nb->priv->documents_button),
+                                               NULL);
+       }
 }
 
 static void
@@ -455,6 +467,12 @@ gedit_notebook_page_added (GtkNotebook *notebook,
                          nb);
 
        update_tabs_visibility (GEDIT_NOTEBOOK (notebook), FALSE);
+
+       if (!gtk_menu_button_get_menu_model (GTK_MENU_BUTTON (nb->priv->documents_button)))
+       {
+               gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (nb->priv->documents_button),
+                                               G_MENU_MODEL (nb->priv->documents_menu));
+       }
 }
 
 static void
@@ -477,21 +495,42 @@ gedit_notebook_remove (GtkContainer *container,
        nb->priv->ignore_focused_page_update = FALSE;
 }
 
+static gboolean
+gedit_notebook_change_to_page (GeditNotebook *notebook,
+                               gint           page_num)
+{
+       gint n_pages;
+
+       n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+
+       if (page_num > n_pages - 1)
+       {
+               return FALSE;
+       }
+
+       gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
+                                      page_num);
+
+       return TRUE;
+}
+
 static void
 gedit_notebook_class_init (GeditNotebookClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
        GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
        GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+       GtkBindingSet *binding_set;
+       gint i;
 
        object_class->dispose = gedit_notebook_dispose;
        object_class->finalize = gedit_notebook_finalize;
        object_class->get_property = gedit_notebook_get_property;
        object_class->set_property = gedit_notebook_set_property;
 
-       gtkwidget_class->grab_focus = gedit_notebook_grab_focus;
-       gtkwidget_class->button_press_event = gedit_notebook_button_press;
+       widget_class->grab_focus = gedit_notebook_grab_focus;
+       widget_class->button_press_event = gedit_notebook_button_press;
 
        notebook_class->change_current_page = gedit_notebook_change_current_page;
        notebook_class->switch_page = gedit_notebook_switch_page;
@@ -500,6 +539,8 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
 
        container_class->remove = gedit_notebook_remove;
 
+       klass->change_to_page = gedit_notebook_change_to_page;
+
        g_object_class_install_property (object_class, PROP_SHOW_TABS_MODE,
                                         g_param_spec_enum ("show-tabs-mode",
                                                            "Show Tabs Mode",
@@ -530,6 +571,29 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
                              2,
                              GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
                              GEDIT_TYPE_TAB);
+       signals[CHANGE_TO_PAGE] =
+               g_signal_new ("change-to-page",
+                             G_TYPE_FROM_CLASS (object_class),
+                             G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                             G_STRUCT_OFFSET (GeditNotebookClass, change_to_page),
+                             NULL, NULL,
+                             gedit_marshal_BOOLEAN__INT,
+                             G_TYPE_BOOLEAN, 1,
+                             G_TYPE_INT);
+
+       binding_set = gtk_binding_set_by_class (klass);
+       for (i = 1; i < 10; i++)
+       {
+               gtk_binding_entry_add_signal (binding_set,
+                                             GDK_KEY_0 + i, GDK_MOD1_MASK,
+                                             "change-to-page", 1,
+                                             G_TYPE_INT, i - 1);
+       }
+
+       /* Bind class to template */
+       gtk_widget_class_set_template_from_resource (widget_class,
+                                                    "/org/gnome/gedit/ui/gedit-notebook.ui");
+       gtk_widget_class_bind_child (widget_class, GeditNotebookPrivate, documents_button);
 
        g_type_class_add_private (object_class, sizeof (GeditNotebookPrivate));
 }
@@ -547,16 +611,83 @@ gedit_notebook_new (void)
        return GTK_WIDGET (g_object_new (GEDIT_TYPE_NOTEBOOK, NULL));
 }
 
+static gboolean
+populate_menu (GeditNotebook *notebook)
+{
+       GeditNotebookPrivate *priv = notebook->priv;
+       GList *l, *children;
+       gint i;
+
+       children = gtk_container_get_children (GTK_CONTAINER (notebook));
+       for (l = children, i = 0; l != NULL; l = g_list_next (l), i++)
+       {
+               GeditTab *tab = GEDIT_TAB (l->data);
+               GMenuItem *item;
+               gchar *tab_name;
+               gchar *name;
+
+               tab_name = _gedit_tab_get_name (GEDIT_TAB (tab));
+               name = gedit_utils_escape_underscores (tab_name, -1);
+               g_free (tab_name);
+
+               item = g_menu_item_new (name, NULL);
+               g_free (name);
+
+               g_menu_item_set_action_and_target (item, "notebook.page", "i", i);
+
+               if (i < 9)
+               {
+                       g_menu_item_set_attribute_value (item, "accel", g_variant_new_printf ("<Alt>%d", i + 
1));
+               }
+
+               g_menu_append_item (priv->documents_menu, item);
+       }
+
+       g_list_free (children);
+
+       return G_SOURCE_REMOVE;
+}
+
+static void
+on_documents_button_toggled (GtkToggleButton *button,
+                             GeditNotebook   *notebook)
+{
+       g_idle_add ((GSourceFunc)populate_menu, notebook);
+}
+
+static void
+on_documents_button_toggled_after (GtkToggleButton *button,
+                                   GeditNotebook   *notebook)
+{
+       GeditNotebookPrivate *priv = notebook->priv;
+
+       g_menu_remove_all (priv->documents_menu);
+}
+
 static void
 gedit_notebook_init (GeditNotebook *notebook)
 {
        GeditNotebookPrivate *priv;
+       GSimpleActionGroup *action_group;
+       GPropertyAction *action;
 
        notebook->priv = GEDIT_NOTEBOOK_GET_PRIVATE (notebook);
        priv = notebook->priv;
 
+       gtk_widget_init_template (GTK_WIDGET (notebook));
+
        priv->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui");
 
+       priv->documents_menu = g_menu_new ();
+       action_group = g_simple_action_group_new ();
+       action = g_property_action_new ("page", notebook, "page");
+       g_simple_action_group_insert (action_group, G_ACTION (action));
+       gtk_widget_insert_action_group (GTK_WIDGET (notebook),
+                                       "notebook",
+                                       G_ACTION_GROUP (action_group));
+       g_object_unref (action);
+       g_object_unref (action_group);
+
        priv->show_tabs_mode = GEDIT_NOTEBOOK_SHOW_TABS_ALWAYS;
        priv->close_buttons_sensitive = TRUE;
 
@@ -572,6 +703,11 @@ gedit_notebook_init (GeditNotebook *notebook)
                         notebook,
                         "show-tabs-mode",
                         G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+       g_signal_connect (priv->documents_button, "toggled",
+                         G_CALLBACK (on_documents_button_toggled), notebook);
+       g_signal_connect_after (priv->documents_button, "toggled",
+                               G_CALLBACK (on_documents_button_toggled_after), notebook);
 }
 
 static GtkWidget *
diff --git a/gedit/gedit-notebook.h b/gedit/gedit-notebook.h
index f081abb..60d2ecc 100644
--- a/gedit/gedit-notebook.h
+++ b/gedit/gedit-notebook.h
@@ -92,6 +92,8 @@ struct _GeditNotebookClass
        void    (* show_popup_menu)     (GeditNotebook *notebook,
                                         GdkEvent      *event,
                                         GeditTab      *tab);
+       gboolean(* change_to_page)      (GeditNotebook *notebook,
+                                        gint           page_num);
 };
 
 /*
diff --git a/gedit/gedit-notebook.ui b/gedit/gedit-notebook.ui
new file mode 100644
index 0000000..746bcbe
--- /dev/null
+++ b/gedit/gedit-notebook.ui
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="GeditNotebook" parent="GtkNotebook">
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <property name="has_focus">False</property>
+    <property name="is_focus">False</property>
+    <child type="action-end">
+      <object class="GtkMenuButton" id="documents_button">
+        <property name="visible">True</property>
+        <property name="relief">none</property>
+        <child>
+          <object class="GtkImage" id="documents_image">
+            <property name="visible">True</property>
+            <property name="icon_size">1</property>
+            <property name="icon_name">view-more-symbolic</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/gedit/gedit-ui.xml b/gedit/gedit-ui.xml
index a0ee907..18d669e 100644
--- a/gedit/gedit-ui.xml
+++ b/gedit/gedit-ui.xml
@@ -137,13 +137,10 @@
       <placeholder name="DocumentsOps_2" />
       <separator/>
       <placeholder name="DocumentsOps_3" />
-      <menuitem action="DocumentsPreviousDocument" />      
+      <menuitem action="DocumentsPreviousDocument" />
       <menuitem action="DocumentsNextDocument" />
       <separator/>
       <menuitem action="DocumentsMoveToNewWindow"/>
-      <placeholder name="DocumentsListPlaceholder">
-      <separator/>
-      </placeholder>
     </menu>
 
     <menu name="HelpMenu" action="Help">
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index ccd2bdf..23bc323 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -88,8 +88,6 @@ struct _GeditWindowPrivate
        GtkActionGroup *close_action_group;
        GtkActionGroup *quit_action_group;
        GtkActionGroup *panels_action_group;
-       GtkActionGroup *documents_list_action_group;
-       guint           documents_list_menu_ui_id;
        GtkWidget      *toolbar;
        GtkWidget      *menubar;
 
@@ -98,8 +96,6 @@ struct _GeditWindowPrivate
        guint           recents_menu_ui_id;
        gulong          recents_handler_id;
 
-       guint           update_documents_list_menu_id;
-
        gint            num_tabs_with_error;
 
        gint            width;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 71331e6..7e8eb3e 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -243,12 +243,6 @@ gedit_window_dispose (GObject *object)
                window->priv->recents_handler_id = 0;
        }
 
-       if (window->priv->update_documents_list_menu_id != 0)
-       {
-               g_source_remove (window->priv->update_documents_list_menu_id);
-               window->priv->update_documents_list_menu_id = 0;
-       }
-
        g_clear_object (&window->priv->manager);
        g_clear_object (&window->priv->message_bus);
        g_clear_object (&window->priv->window_group);
@@ -1326,13 +1320,6 @@ create_menu_bar_and_toolbar (GeditWindow *window,
                                                             window);
        update_recent_files_menu (window);
 
-       /* list of open documents menu */
-       action_group = gtk_action_group_new ("DocumentsListActions");
-       gtk_action_group_set_translation_domain (action_group, NULL);
-       window->priv->documents_list_action_group = action_group;
-       gtk_ui_manager_insert_action_group (manager, action_group, 0);
-       g_object_unref (action_group);
-
        window->priv->menubar = gtk_ui_manager_get_widget (manager, "/MenuBar");
        gtk_box_pack_start (GTK_BOX (main_box),
                            window->priv->menubar,
@@ -1372,244 +1359,6 @@ create_menu_bar_and_toolbar (GeditWindow *window,
                                window);
 }
 
-static void
-documents_list_menu_activate (GtkToggleAction *action,
-                             GeditWindow     *window)
-{
-       gint n;
-
-       if (gtk_toggle_action_get_active (action) == FALSE)
-               return;
-
-       n = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
-       gedit_multi_notebook_set_current_page (window->priv->multi_notebook, n);
-}
-
-static gchar *
-get_menu_tip_for_tab (GeditTab *tab)
-{
-       GeditDocument *doc;
-       gchar *uri;
-       gchar *ruri;
-       gchar *tip;
-
-       doc = gedit_tab_get_document (tab);
-
-       uri = gedit_document_get_uri_for_display (doc);
-       ruri = gedit_utils_replace_home_dir_with_tilde (uri);
-       g_free (uri);
-
-       /* Translators: %s is a URI */
-       tip =  g_strdup_printf (_("Activate '%s'"), ruri);
-       g_free (ruri);
-
-       return tip;
-}
-
-static gboolean
-update_documents_list_menu_idle (GeditWindow *window)
-{
-       GeditWindowPrivate *p = window->priv;
-       GList *actions, *l;
-       gint n_notebooks, n_nb, n, i;
-       guint id;
-       GSList *group = NULL;
-
-       gedit_debug (DEBUG_WINDOW);
-
-       g_return_val_if_fail (p->documents_list_action_group != NULL, FALSE);
-
-       if (p->documents_list_menu_ui_id != 0)
-       {
-               gtk_ui_manager_remove_ui (p->manager,
-                                         p->documents_list_menu_ui_id);
-       }
-
-       actions = gtk_action_group_list_actions (p->documents_list_action_group);
-       for (l = actions; l != NULL; l = l->next)
-       {
-               g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
-                                                     G_CALLBACK (documents_list_menu_activate),
-                                                     window);
-               gtk_action_group_remove_action (p->documents_list_action_group,
-                                               GTK_ACTION (l->data));
-       }
-       g_list_free (actions);
-
-       n = gedit_multi_notebook_get_n_tabs (p->multi_notebook);
-
-       id = (n > 0) ? gtk_ui_manager_new_merge_id (p->manager) : 0;
-
-       n_notebooks = gedit_multi_notebook_get_n_notebooks (p->multi_notebook);
-
-       i = 0;
-       n_nb = 0;
-       while (n_nb < n_notebooks)
-       {
-               GeditNotebook *notebook = gedit_multi_notebook_get_nth_notebook (p->multi_notebook, n_nb);
-               gint j;
-
-               n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
-
-               for (j = 0; j < n; j++, i++)
-               {
-                       GtkWidget *tab;
-                       GtkRadioAction *action;
-                       gchar *action_name;
-                       gchar *tab_name;
-                       gchar *name;
-                       gchar *tip;
-                       gboolean active_notebook;
-
-                       tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), j);
-
-                       active_notebook = notebook == gedit_multi_notebook_get_active_notebook 
(p->multi_notebook);
-
-                       /* NOTE: the action is associated to the position of the tab in
-                        * the notebook not to the tab itself! This is needed to work
-                        * around the gtk+ bug #170727: gtk leaves around the accels
-                        * of the action. Since the accel depends on the tab position
-                        * the problem is worked around, action with the same name always
-                        * get the same accel.
-                        */
-                       if (active_notebook)
-                       {
-                               action_name = g_strdup_printf ("Active_Tab_%d", i);
-                       }
-                       else
-                       {
-                               action_name = g_strdup_printf ("Inactive_Tab_%d", i);
-                       }
-                       tab_name = _gedit_tab_get_name (GEDIT_TAB (tab));
-                       name = gedit_utils_escape_underscores (tab_name, -1);
-                       tip =  get_menu_tip_for_tab (GEDIT_TAB (tab));
-
-                       action = gtk_radio_action_new (action_name,
-                                                      name,
-                                                      tip,
-                                                      NULL,
-                                                      i);
-
-                       if (group != NULL)
-                               gtk_radio_action_set_group (action, group);
-
-                       /* note that group changes each time we add an action, so it must be updated */
-                       group = gtk_radio_action_get_group (action);
-
-                       /* alt + 1, 2, 3... 0 to switch to the first ten tabs */
-                       if (active_notebook)
-                       {
-                               gchar *accel;
-                               gchar const *mod;
-
-#ifndef OS_OSX
-                               mod = "alt";
-#else
-                               mod = "meta";
-#endif
-
-                               accel = (j < 10) ? g_strdup_printf ("<%s>%d", mod, (j + 1) % 10) : NULL;
-
-                               gtk_action_group_add_action_with_accel (p->documents_list_action_group,
-                                                                       GTK_ACTION (action),
-                                                                       accel);
-                               g_free (accel);
-                       }
-                       else
-                       {
-                               gtk_action_group_add_action (p->documents_list_action_group,
-                                                            GTK_ACTION (action));
-                       }
-
-                       g_signal_connect (action,
-                                         "activate",
-                                         G_CALLBACK (documents_list_menu_activate),
-                                         window);
-
-                       gtk_ui_manager_add_ui (p->manager,
-                                              id,
-                                              "/MenuBar/DocumentsMenu/DocumentsListPlaceholder",
-                                              action_name, action_name,
-                                              GTK_UI_MANAGER_MENUITEM,
-                                              FALSE);
-
-                       if (GEDIT_TAB (tab) == gedit_window_get_active_tab (window))
-                               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
-                       g_object_unref (action);
-
-                       g_free (action_name);
-                       g_free (tab_name);
-                       g_free (name);
-                       g_free (tip);
-               }
-
-               n_nb++;
-       }
-
-       p->documents_list_menu_ui_id = id;
-
-       window->priv->update_documents_list_menu_id = 0;
-
-       return FALSE;
-}
-
-static void
-update_documents_list_menu (GeditWindow *window)
-{
-       /* Do the real update in an idle so that we consolidate
-        * multiple updates when loading or closing many docs */
-       if (window->priv->update_documents_list_menu_id == 0)
-       {
-               window->priv->update_documents_list_menu_id =
-                       gdk_threads_add_idle ((GSourceFunc) update_documents_list_menu_idle,
-                                             window);
-       }
-}
-
-static void
-activate_documents_list_item (GeditWindow *window,
-                             GeditTab    *tab)
-{
-       GtkAction *action;
-       gchar *action_name;
-       gint page_num;
-       GeditNotebook *active_notebook;
-       gboolean is_active;
-
-       active_notebook = gedit_multi_notebook_get_active_notebook (window->priv->multi_notebook);
-       page_num = gtk_notebook_page_num (GTK_NOTEBOOK (active_notebook),
-                                         GTK_WIDGET (tab));
-
-       is_active = (page_num != -1);
-
-       page_num = gedit_multi_notebook_get_page_num (window->priv->multi_notebook,
-                                                     tab);
-
-       /* get the action name related with the page number */
-       if (is_active)
-       {
-               action_name = g_strdup_printf ("Active_Tab_%d", page_num);
-       }
-       else
-       {
-               action_name = g_strdup_printf ("Inactive_Tab_%d", page_num);
-       }
-       action = gtk_action_group_get_action (window->priv->documents_list_action_group,
-                                             action_name);
-
-       /* sometimes the action doesn't exist yet, and the proper action
-        * is set active during the documents list menu creation
-        * CHECK: would it be nicer if active_tab was a property and we monitored the notify signal?
-        */
-       if (action != NULL)
-       {
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-       }
-
-       g_free (action_name);
-}
-
 /* Returns TRUE if status bar is visible */
 static gboolean
 set_statusbar_style (GeditWindow *window,
@@ -2279,9 +2028,6 @@ tab_switched (GeditMultiNotebook *mnb,
        set_title (window);
        set_sensitivity_according_to_tab (window, new_tab);
 
-       /* activate the right item in the documents menu */
-       activate_documents_list_item (window, new_tab);
-
        g_signal_emit (G_OBJECT (window),
                       signals[ACTIVE_TAB_CHANGED],
                       0,
@@ -2517,11 +2263,7 @@ sync_name (GeditTab    *tab,
           GeditWindow *window)
 {
        GtkAction *action;
-       gchar *action_name;
        GeditDocument *doc;
-       gint page_num;
-       GeditNotebook *active_notebook;
-       gboolean is_active;
 
        if (tab == gedit_window_get_active_tab (window))
        {
@@ -2534,49 +2276,6 @@ sync_name (GeditTab    *tab,
                                          !gedit_document_is_untitled (doc));
        }
 
-       /* sync the item in the documents list menu */
-
-       active_notebook = gedit_multi_notebook_get_active_notebook (window->priv->multi_notebook);
-       page_num = gtk_notebook_page_num (GTK_NOTEBOOK (active_notebook),
-                                         GTK_WIDGET (tab));
-
-       is_active = (page_num != -1);
-
-       page_num = gedit_multi_notebook_get_page_num (window->priv->multi_notebook,
-                                                     tab);
-
-       /* get the action name related with the page number */
-       if (is_active)
-       {
-               action_name = g_strdup_printf ("Active_Tab_%d", page_num);
-       }
-       else
-       {
-               action_name = g_strdup_printf ("Inactive_Tab_%d", page_num);
-       }
-       action = gtk_action_group_get_action (window->priv->documents_list_action_group,
-                                             action_name);
-       g_free (action_name);
-
-       /* action may be NULL if the idle has not populated the menu yet */
-       if (action != NULL)
-       {
-               gchar *tab_name;
-               gchar *escaped_name;
-               gchar *tip;
-
-               tab_name = _gedit_tab_get_name (tab);
-               escaped_name = gedit_utils_escape_underscores (tab_name, -1);
-               tip =  get_menu_tip_for_tab (tab);
-
-               g_object_set (action, "label", escaped_name, NULL);
-               g_object_set (action, "tooltip", tip, NULL);
-
-               g_free (tab_name);
-               g_free (escaped_name);
-               g_free (tip);
-       }
-
        peas_extension_set_foreach (window->priv->extensions,
                                    (PeasExtensionSetForeachFunc) extension_update_state,
                                    window);
@@ -3127,8 +2826,6 @@ on_tab_added (GeditMultiNotebook *multi,
                          G_CALLBACK (editable_changed),
                          window);
 
-       update_documents_list_menu (window);
-
        update_window_state (window);
        update_can_close (window);
 
@@ -3239,7 +2936,6 @@ on_tab_removed (GeditMultiNotebook *multi,
                    gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 0) ||
                    num_tabs == 0)
                {
-                       update_documents_list_menu (window);
                        update_next_prev_doc_sensitivity_per_window (window);
                        update_sensitivity_according_to_open_tabs (window,
                                                                   num_notebooks,
@@ -3267,7 +2963,6 @@ on_page_reordered (GeditMultiNotebook *multi,
                    gint                page_num,
                    GeditWindow        *window)
 {
-       update_documents_list_menu (window);
        update_next_prev_doc_sensitivity_per_window (window);
 
        g_signal_emit (G_OBJECT (window), signals[TABS_REORDERED], 0);
@@ -3329,7 +3024,6 @@ on_notebook_changed (GeditMultiNotebook *mnb,
                     GParamSpec         *pspec,
                     GeditWindow        *window)
 {
-       update_documents_list_menu (window);
        update_sensitivity_according_to_open_tabs (window,
                                                   gedit_multi_notebook_get_n_notebooks (mnb),
                                                   gedit_multi_notebook_get_n_tabs (mnb));
@@ -3340,7 +3034,6 @@ on_notebook_removed (GeditMultiNotebook *mnb,
                     GeditNotebook      *notebook,
                     GeditWindow        *window)
 {
-       update_documents_list_menu (window);
        update_sensitivity_according_to_open_tabs (window,
                                                   gedit_multi_notebook_get_n_notebooks (mnb),
                                                   gedit_multi_notebook_get_n_tabs (mnb));
diff --git a/gedit/gedit.gresource.xml b/gedit/gedit.gresource.xml
index e277680..a620f82 100644
--- a/gedit/gedit.gresource.xml
+++ b/gedit/gedit.gresource.xml
@@ -13,5 +13,6 @@
     <file preprocess="xml-stripblanks">gedit-status-menu-button.ui</file>
     <file preprocess="xml-stripblanks">gedit-view-frame.ui</file>
     <file preprocess="xml-stripblanks">gedit-highlight-mode-dialog.ui</file>
+    <file preprocess="xml-stripblanks">gedit-notebook.ui</file>
   </gresource>
 </gresources>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]