[gedit/wip/redesign] Remove highlight mode submenu



commit 933ce513b70cf742dd37e59609ad95da3a18c56d
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon May 6 20:10:07 2013 +0200

    Remove highlight mode submenu
    
    This should be a dialog

 gedit/gedit-ui.h             |   20 +--
 gedit/gedit-window-private.h |    4 -
 gedit/gedit-window.c         |  463 ++++--------------------------------------
 3 files changed, 46 insertions(+), 441 deletions(-)
---
diff --git a/gedit/gedit-ui.h b/gedit/gedit-ui.h
index 2380971..b1ce8ef 100644
--- a/gedit/gedit-ui.h
+++ b/gedit/gedit-ui.h
@@ -37,23 +37,6 @@
 
 G_BEGIN_DECLS
 
-static const GtkActionEntry gedit_always_sensitive_menu_entries[] =
-{
-       /* Toplevel */
-       { "File", NULL, N_("_File") },
-       { "Edit", NULL, N_("_Edit") },
-       { "View", NULL, N_("_View") },
-       { "Search", NULL, N_("_Search") },
-       { "Tools", NULL, N_("_Tools") },
-       { "Help", NULL, N_("_Help") },
-};
-
-static const GtkActionEntry gedit_menu_entries[] =
-{
-       /* View menu */
-       { "ViewHighlightMode", NULL, N_("_Highlight Mode") },
-};
-
 static GActionEntry win_entries[] = {
        { "open", _gedit_cmd_file_open },
        { "new_tab", _gedit_cmd_file_new },
@@ -84,7 +67,8 @@ static GActionEntry win_entries[] = {
        { "copy", _gedit_cmd_edit_copy },
        { "paste", _gedit_cmd_edit_paste },
        { "delete", _gedit_cmd_edit_delete },
-       { "select_all", _gedit_cmd_edit_select_all }
+       { "select_all", _gedit_cmd_edit_select_all },
+       { "hightlight_mode", NULL }
 };
 
 G_END_DECLS
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index c5a7f9e..49f07b2 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -84,12 +84,8 @@ struct _GeditWindowPrivate
 
        /* Menus & Toolbars */
        GtkUIManager   *manager;
-       GtkActionGroup *action_group;
-       GtkActionGroup *always_sensitive_action_group;
-       GtkActionGroup *languages_action_group;
        GtkActionGroup *documents_list_action_group;
        guint           documents_list_menu_ui_id;
-       GtkWidget      *menubar;
 
        GtkWidget      *headerbar;
        GtkWidget      *open_button;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 9223ef3..675e39d 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -568,8 +568,7 @@ set_sensitivity_according_to_tab (GeditWindow *window,
 {
        GeditDocument *doc;
        GeditView *view;
-       GtkAction *action;
-       GAction *gaction;
+       GAction *action;
        gboolean b;
        gboolean state_normal;
        gboolean editable;
@@ -598,36 +597,36 @@ set_sensitivity_according_to_tab (GeditWindow *window,
        clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
                                              GDK_SELECTION_CLIPBOARD);
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "save");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "save");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      (state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
                                      (state == GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
                                     !gedit_document_get_readonly (doc) &&
                                     !(lockdown & GEDIT_LOCKDOWN_SAVE_TO_DISK));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "save_as");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "save_as");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      (state == GEDIT_TAB_STATE_SAVING_ERROR) ||
                                      (state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
                                      (state == GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
                                     !(lockdown & GEDIT_LOCKDOWN_SAVE_TO_DISK));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "revert");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "revert");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      (state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION)) &&
                                     !gedit_document_is_untitled (doc));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "print");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "print");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                     (state == GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
                                     !(lockdown & GEDIT_LOCKDOWN_PRINTING));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "close");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "close");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state != GEDIT_TAB_STATE_CLOSING) &&
                                     (state != GEDIT_TAB_STATE_SAVING) &&
                                     (state != GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
@@ -635,29 +634,29 @@ set_sensitivity_according_to_tab (GeditWindow *window,
                                     (state != GEDIT_TAB_STATE_PRINT_PREVIEWING) &&
                                     (state != GEDIT_TAB_STATE_SAVING_ERROR));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "undo");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "undo");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     state_normal &&
                                     gtk_source_buffer_can_undo (GTK_SOURCE_BUFFER (doc)));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "redo");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "redo");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     state_normal &&
                                     gtk_source_buffer_can_redo (GTK_SOURCE_BUFFER (doc)));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "cut");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "cut");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     state_normal &&
                                     editable &&
                                     gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "copy");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "copy");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) &&
                                     gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "paste");
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "paste");
        if (state_normal && editable)
        {
                set_paste_sensitivity_according_to_clipboard (window,
@@ -665,51 +664,50 @@ set_sensitivity_according_to_tab (GeditWindow *window,
        }
        else
        {
-               g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction), FALSE);
+               g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
        }
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "delete");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "delete");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     state_normal &&
                                     editable &&
                                     gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "find");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "find");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "replace");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "replace");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     state_normal &&
                                     editable);
 
        b = gedit_document_get_can_search_again (doc);
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "find_next");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "find_next");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "find_prev");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "find_prev");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "clear_highlight");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "clear_highlight");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
 
-       gaction = g_action_map_lookup_action (G_ACTION_MAP (window), "goto_line");
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction),
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "goto_line");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
                                     (state_normal ||
                                      state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
 
-       action = gtk_action_group_get_action (window->priv->action_group,
-                                             "ViewHighlightMode");
-       gtk_action_set_sensitive (action,
-                                 (state != GEDIT_TAB_STATE_CLOSING) &&
-                                 enable_syntax_highlighting);
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "hightlight_mode");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    (state != GEDIT_TAB_STATE_CLOSING) &&
+                                    enable_syntax_highlighting);
 
        update_next_prev_doc_sensitivity (window, tab);
 
@@ -718,302 +716,6 @@ set_sensitivity_according_to_tab (GeditWindow *window,
                                    window);
 }
 
-static void
-language_toggled (GtkToggleAction *action,
-                 GeditWindow     *window)
-{
-       GeditDocument *doc;
-       GtkSourceLanguage *lang;
-       const gchar *lang_id;
-
-       if (gtk_toggle_action_get_active (action) == FALSE)
-               return;
-
-       doc = gedit_window_get_active_document (window);
-       if (doc == NULL)
-               return;
-
-       lang_id = gtk_action_get_name (GTK_ACTION (action));
-
-       if (strcmp (lang_id, LANGUAGE_NONE) == 0)
-       {
-               /* Normal (no highlighting) */
-               lang = NULL;
-       }
-       else
-       {
-               lang = gtk_source_language_manager_get_language (
-                               gtk_source_language_manager_get_default (),
-                               lang_id);
-               if (lang == NULL)
-               {
-                       g_warning ("Could not get language %s\n", lang_id);
-               }
-       }
-
-       gedit_document_set_language (doc, lang);
-}
-
-static gchar *
-escape_section_name (const gchar *name)
-{
-       gchar *ret;
-
-       ret = g_markup_escape_text (name, -1);
-
-       /* Replace '/' with '-' to avoid problems in xml paths */
-       g_strdelimit (ret, "/", '-');
-
-       return ret;
-}
-
-static void
-create_language_menu_item (GtkSourceLanguage *lang,
-                          gint               index,
-                          guint              ui_id,
-                          GeditWindow       *window)
-{
-       GtkAction *section_action;
-       GtkRadioAction *action;
-       GtkAction *normal_action;
-       GSList *group;
-       const gchar *section;
-       gchar *escaped_section;
-       const gchar *lang_id;
-       const gchar *lang_name;
-       gchar *escaped_lang_name;
-       gchar *tip;
-       gchar *path;
-
-       section = gtk_source_language_get_section (lang);
-       escaped_section = escape_section_name (section);
-
-       /* check if the section submenu exists or create it */
-       section_action = gtk_action_group_get_action (window->priv->languages_action_group,
-                                                     escaped_section);
-
-       if (section_action == NULL)
-       {
-               gchar *section_name;
-
-               section_name = gedit_utils_escape_underscores (section, -1);
-
-               section_action = gtk_action_new (escaped_section,
-                                                section_name,
-                                                NULL,
-                                                NULL);
-
-               g_free (section_name);
-
-               gtk_action_group_add_action (window->priv->languages_action_group,
-                                            section_action);
-               g_object_unref (section_action);
-
-               gtk_ui_manager_add_ui (window->priv->manager,
-                                      ui_id,
-                                      "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder",
-                                      escaped_section,
-                                      escaped_section,
-                                      GTK_UI_MANAGER_MENU,
-                                      FALSE);
-       }
-
-       /* now add the language item to the section */
-       lang_name = gtk_source_language_get_name (lang);
-       lang_id = gtk_source_language_get_id (lang);
-
-       escaped_lang_name = gedit_utils_escape_underscores (lang_name, -1);
-
-       tip = g_strdup_printf (_("Use %s highlight mode"), lang_name);
-       path = g_strdup_printf ("/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder/%s",
-                               escaped_section);
-
-       action = gtk_radio_action_new (lang_id,
-                                      escaped_lang_name,
-                                      tip,
-                                      NULL,
-                                      index);
-
-       g_free (escaped_lang_name);
-
-       /* Action is added with a NULL accel to make the accel overridable */
-       gtk_action_group_add_action_with_accel (window->priv->languages_action_group,
-                                               GTK_ACTION (action),
-                                               NULL);
-       g_object_unref (action);
-
-       /* add the action to the same radio group of the "Normal" action */
-       normal_action = gtk_action_group_get_action (window->priv->languages_action_group,
-                                                    LANGUAGE_NONE);
-       group = gtk_radio_action_get_group (GTK_RADIO_ACTION (normal_action));
-       gtk_radio_action_set_group (action, group);
-
-       g_signal_connect (action,
-                         "activate",
-                         G_CALLBACK (language_toggled),
-                         window);
-
-       gtk_ui_manager_add_ui (window->priv->manager,
-                              ui_id,
-                              path,
-                              lang_id,
-                              lang_id,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
-
-       g_free (path);
-       g_free (tip);
-       g_free (escaped_section);
-}
-
-static gint
-language_compare (GtkSourceLanguage *lang1,
-                 GtkSourceLanguage *lang2)
-{
-       const gchar *section1, *section2, *name1, *name2;
-       gchar *tmp1, *tmp2;
-       gint ret;
-
-       section1 = gtk_source_language_get_section (lang1);
-       section2 = gtk_source_language_get_section (lang2);
-       name1 = gtk_source_language_get_name (lang1);
-       name2 = gtk_source_language_get_name (lang2);
-
-       /* we collate the concatenation so that they are
-        * sorted first by section and then by name */
-       tmp1 = g_strconcat (section1, "::", name1, NULL);
-       tmp2 = g_strconcat (section2, "::", name2, NULL);
-
-       ret = g_utf8_collate (tmp1, tmp2);
-
-       g_free(tmp1);
-       g_free(tmp2);
-
-       return ret;
-}
-
-static GSList *
-get_languages_sorted_by_section (GeditWindow *window)
-{
-       GtkSourceLanguageManager *lm;
-       const gchar * const *ids;
-       gint i;
-       GSList *languages = NULL;
-
-       lm = gtk_source_language_manager_get_default ();
-       ids = gtk_source_language_manager_get_language_ids (lm);
-
-       for (i = 0; ids[i] != NULL; i++)
-       {
-               GtkSourceLanguage *lang;
-
-               lang = gtk_source_language_manager_get_language (lm, ids[i]);
-
-               if (!gtk_source_language_get_hidden (lang))
-               {
-                       languages = g_slist_prepend (languages, lang);
-               }
-       }
-
-       return g_slist_sort (languages, (GCompareFunc)language_compare);
-}
-
-static void
-create_languages_menu (GeditWindow *window)
-{
-       GtkRadioAction *action_none;
-       GSList *languages;
-       GSList *l;
-       guint id;
-       gint i;
-
-       gedit_debug (DEBUG_WINDOW);
-
-       /* add the "Plain Text" item before all the others */
-
-       /* Translators: "Plain Text" means that no highlight mode is selected in the
-        * "View->Highlight Mode" submenu and so syntax highlighting is disabled */
-       action_none = gtk_radio_action_new (LANGUAGE_NONE, _("Plain Text"),
-                                           _("Disable syntax highlighting"),
-                                           NULL,
-                                           -1);
-
-       gtk_action_group_add_action (window->priv->languages_action_group,
-                                    GTK_ACTION (action_none));
-       g_object_unref (action_none);
-
-       g_signal_connect (action_none,
-                         "activate",
-                         G_CALLBACK (language_toggled),
-                         window);
-
-       id = gtk_ui_manager_new_merge_id (window->priv->manager);
-
-       gtk_ui_manager_add_ui (window->priv->manager,
-                              id,
-                              "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder",
-                              LANGUAGE_NONE,
-                              LANGUAGE_NONE,
-                              GTK_UI_MANAGER_MENUITEM,
-                              TRUE);
-
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_none), TRUE);
-
-       languages = get_languages_sorted_by_section (window);
-
-       for (l = languages, i = 0; l != NULL; l = l->next)
-       {
-               create_language_menu_item (l->data, i, id, window);
-       }
-
-       g_slist_free (languages);
-}
-
-static void
-update_languages_menu (GeditWindow *window)
-{
-       GeditDocument *doc;
-       GList *actions;
-       GList *l;
-       GtkAction *action;
-       GtkSourceLanguage *lang;
-       const gchar *lang_id;
-
-       doc = gedit_window_get_active_document (window);
-       if (doc == NULL)
-               return;
-
-       lang = gedit_document_get_language (doc);
-       if (lang != NULL)
-               lang_id = gtk_source_language_get_id (lang);
-       else
-               lang_id = LANGUAGE_NONE;
-
-       actions = gtk_action_group_list_actions (window->priv->languages_action_group);
-
-       /* prevent recursion */
-       for (l = actions; l != NULL; l = l->next)
-       {
-               g_signal_handlers_block_by_func (GTK_ACTION (l->data),
-                                                G_CALLBACK (language_toggled),
-                                                window);
-       }
-
-       action = gtk_action_group_get_action (window->priv->languages_action_group,
-                                             lang_id);
-
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
-       for (l = actions; l != NULL; l = l->next)
-       {
-               g_signal_handlers_unblock_by_func (GTK_ACTION (l->data),
-                                                  G_CALLBACK (language_toggled),
-                                                  window);
-       }
-
-       g_list_free (actions);
-}
-
 void
 _gedit_recent_add (GeditWindow *window,
                   GFile       *location,
@@ -1128,67 +830,11 @@ create_menu_bar_and_toolbar (GeditWindow *window)
 {
        GtkActionGroup *action_group;
        GtkUIManager *manager;
-       GError *error = NULL;
-
-       gedit_debug (DEBUG_WINDOW);
 
        manager = gtk_ui_manager_new ();
        window->priv->manager = manager;
 
-       gtk_window_add_accel_group (GTK_WINDOW (window),
-                                   gtk_ui_manager_get_accel_group (manager));
-
-       action_group = gtk_action_group_new ("GeditWindowAlwaysSensitiveActions");
-       gtk_action_group_set_translation_domain (action_group, NULL);
-       gtk_action_group_add_actions (action_group,
-                                     gedit_always_sensitive_menu_entries,
-                                     G_N_ELEMENTS (gedit_always_sensitive_menu_entries),
-                                     window);
-
-       gtk_ui_manager_insert_action_group (manager, action_group, 0);
-       g_object_unref (action_group);
-       window->priv->always_sensitive_action_group = action_group;
-
-       action_group = gtk_action_group_new ("GeditWindowActions");
-       gtk_action_group_set_translation_domain (action_group, NULL);
-       gtk_action_group_add_actions (action_group,
-                                     gedit_menu_entries,
-                                     G_N_ELEMENTS (gedit_menu_entries),
-                                     window);
-       gtk_ui_manager_insert_action_group (manager, action_group, 0);
-       g_object_unref (action_group);
-       window->priv->action_group = action_group;
-
-       gtk_ui_manager_add_ui_from_resource (manager,
-                                            "/org/gnome/gedit/ui/gedit-ui.xml",
-                                            &error);
-       if (error != NULL)
-       {
-               g_warning ("Could not add ui definition: %s", error->message);
-               g_error_free (error);
-               return;
-       }
-
-       if (!_gedit_app_has_app_menu (GEDIT_APP (g_application_get_default ())))
-       {
-               gtk_ui_manager_add_ui_from_resource (manager,
-                                                    "/org/gnome/gedit/ui/gedit-ui-fallback.xml",
-                                                    &error);
-               if (error != NULL)
-               {
-                       g_warning ("Could not add fallback ui definition: %s", error->message);
-                       g_error_free (error);
-                       return;
-               }
-       }
-
-       /* languages menu */
-       action_group = gtk_action_group_new ("LanguagesActions");
-       gtk_action_group_set_translation_domain (action_group, NULL);
-       window->priv->languages_action_group = action_group;
-       gtk_ui_manager_insert_action_group (manager, action_group, 0);
-       g_object_unref (action_group);
-       create_languages_menu (window);
+       gedit_debug (DEBUG_WINDOW);
 
        /* list of open documents menu */
        action_group = gtk_action_group_new ("DocumentsListActions");
@@ -1196,8 +842,6 @@ create_menu_bar_and_toolbar (GeditWindow *window)
        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");
 }
 
 static void
@@ -1960,6 +1604,10 @@ language_changed (GObject     *object,
                label = _("Plain Text");
 
        gtk_button_set_label (GTK_BUTTON (window->priv->language_combo), label);
+
+       peas_extension_set_foreach (window->priv->extensions,
+                                   (PeasExtensionSetForeachFunc) extension_update_state,
+                                   window);
 }
 
 static void
@@ -2058,9 +1706,6 @@ tab_switched (GeditMultiNotebook *mnb,
        /* activate the right item in the documents menu */
        activate_documents_list_item (window, new_tab);
 
-       /* update the syntax menu */
-       update_languages_menu (window);
-
        g_signal_emit (G_OBJECT (window),
                       signals[ACTIVE_TAB_CHANGED],
                       0,
@@ -2767,17 +2412,6 @@ selection_changed (GeditDocument *doc,
 }
 
 static void
-sync_languages_menu (GeditDocument *doc,
-                    GParamSpec    *pspec,
-                    GeditWindow   *window)
-{
-       update_languages_menu (window);
-       peas_extension_set_foreach (window->priv->extensions,
-                                   (PeasExtensionSetForeachFunc) extension_update_state,
-                                   window);
-}
-
-static void
 readonly_changed (GeditDocument *doc,
                  GParamSpec    *pspec,
                  GeditWindow   *window)
@@ -2934,10 +2568,6 @@ on_tab_added (GeditMultiNotebook *multi,
                          G_CALLBACK (selection_changed),
                          window);
        g_signal_connect (doc,
-                         "notify::language",
-                         G_CALLBACK (sync_languages_menu),
-                         window);
-       g_signal_connect (doc,
                          "notify::read-only",
                          G_CALLBACK (readonly_changed),
                          window);
@@ -3008,9 +2638,6 @@ on_tab_removed (GeditMultiNotebook *multi,
                                              G_CALLBACK (selection_changed),
                                              window);
        g_signal_handlers_disconnect_by_func (doc,
-                                             G_CALLBACK (sync_languages_menu),
-                                             window);
-       g_signal_handlers_disconnect_by_func (doc,
                                              G_CALLBACK (readonly_changed),
                                              window);
        g_signal_handlers_disconnect_by_func (view,
@@ -4290,8 +3917,6 @@ _gedit_window_unfullscreen (GeditWindow *window)
                                               (GtkCallback)show_notebook_tabs,
                                               window);
 
-       gtk_widget_show (window->priv->menubar);
-
        if (g_settings_get_boolean (window->priv->ui_settings, "statusbar-visible"))
        {
                gtk_widget_show (window->priv->statusbar);


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