[gedit] commands-view: port to TeplLanguageChooserDialog



commit ffedbc882cf98df5159af5db0b91548f0c353d86
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Nov 6 07:20:50 2020 +0100

    commands-view: port to TeplLanguageChooserDialog

 gedit/gedit-commands-view.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/gedit/gedit-commands-view.c b/gedit/gedit-commands-view.c
index 369bc93b0..71785b78f 100644
--- a/gedit/gedit-commands-view.c
+++ b/gedit/gedit-commands-view.c
@@ -21,16 +21,11 @@
  */
 
 #include "config.h"
-
 #include "gedit-commands.h"
 #include "gedit-commands-private.h"
-
-#include <gtk/gtk.h>
-
+#include <tepl/tepl.h>
 #include "gedit-debug.h"
 #include "gedit-window.h"
-#include "gedit-highlight-mode-dialog.h"
-#include "gedit-highlight-mode-selector.h"
 
 void
 _gedit_cmd_view_focus_active (GSimpleAction *action,
@@ -126,9 +121,9 @@ _gedit_cmd_view_leave_fullscreen_mode (GSimpleAction *action,
 }
 
 static void
-language_selected_cb (GeditHighlightModeSelector *selector,
-                     GtkSourceLanguage          *language,
-                     GeditWindow                *window)
+language_activated_cb (TeplLanguageChooserDialog *dialog,
+                      GtkSourceLanguage         *language,
+                      GeditWindow               *window)
 {
        GeditDocument *active_document;
 
@@ -137,6 +132,16 @@ language_selected_cb (GeditHighlightModeSelector *selector,
        {
                gedit_document_set_language (active_document, language);
        }
+
+       gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+language_chooser_dialog_response_after_cb (TeplLanguageChooserDialog *dialog,
+                                          gint                       response_id,
+                                          gpointer                   user_data)
+{
+       gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
 void
@@ -145,12 +150,10 @@ _gedit_cmd_view_highlight_mode (GSimpleAction *action,
                                 gpointer       user_data)
 {
        GeditWindow *window = GEDIT_WINDOW (user_data);
-       GeditHighlightModeDialog *dialog;
-       GeditHighlightModeSelector *selector;
+       TeplLanguageChooserDialog *dialog;
        GeditDocument *active_document;
 
-       dialog = GEDIT_HIGHLIGHT_MODE_DIALOG (gedit_highlight_mode_dialog_new (GTK_WINDOW (window)));
-       selector = gedit_highlight_mode_dialog_get_selector (dialog);
+       dialog = tepl_language_chooser_dialog_new (GTK_WINDOW (window));
 
        active_document = gedit_window_get_active_document (window);
        if (active_document != NULL)
@@ -158,15 +161,20 @@ _gedit_cmd_view_highlight_mode (GSimpleAction *action,
                GtkSourceLanguage *language;
 
                language = gedit_document_get_language (active_document);
-               gedit_highlight_mode_selector_select_language (selector, language);
+               tepl_language_chooser_select_language (TEPL_LANGUAGE_CHOOSER (dialog), language);
        }
 
-       g_signal_connect_object (selector,
-                                "language-selected",
-                                G_CALLBACK (language_selected_cb),
+       g_signal_connect_object (dialog,
+                                "language-activated",
+                                G_CALLBACK (language_activated_cb),
                                 window,
                                 0);
 
+       g_signal_connect_after (dialog,
+                               "response",
+                               G_CALLBACK (language_chooser_dialog_response_after_cb),
+                               NULL);
+
        gtk_widget_show (GTK_WIDGET (dialog));
 }
 


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