[gedit] HighlightMode: small code improvements to gedit-window.c



commit 46e426f38fa43cf02710ff838443e2c67c38179e
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Oct 31 09:32:08 2020 +0100

    HighlightMode: small code improvements to gedit-window.c

 gedit/gedit-window.c | 48 ++++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index a5ab1ce37..f1fb046fb 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -766,30 +766,32 @@ update_actions_sensitivity (GeditWindow *window)
 }
 
 static void
-on_language_selector_shown (GeditHighlightModeSelector *sel,
-                            GeditWindow                *window)
+language_selector_show_cb (GeditHighlightModeSelector *selector,
+                          GeditWindow                *window)
 {
-       GeditDocument *doc;
+       GeditDocument *active_document;
 
-       doc = gedit_window_get_active_document (window);
-       if (doc)
+       active_document = gedit_window_get_active_document (window);
+       if (active_document != NULL)
        {
-               gedit_highlight_mode_selector_select_language (sel,
-                                                              gedit_document_get_language (doc));
+               GtkSourceLanguage *language;
+
+               language = gedit_document_get_language (active_document);
+               gedit_highlight_mode_selector_select_language (selector, language);
        }
 }
 
 static void
-on_language_selected (GeditHighlightModeSelector *sel,
-                      GtkSourceLanguage          *language,
-                      GeditWindow                *window)
+language_selected_cb (GeditHighlightModeSelector *selector,
+                     GtkSourceLanguage          *language,
+                     GeditWindow                *window)
 {
-       GeditDocument *doc;
+       GeditDocument *active_document;
 
-       doc = gedit_window_get_active_document (window);
-       if (doc)
+       active_document = gedit_window_get_active_document (window);
+       if (active_document != NULL)
        {
-               gedit_document_set_language (doc, language);
+               gedit_document_set_language (active_document, language);
        }
 
        gtk_widget_hide (GTK_WIDGET (window->priv->language_popover));
@@ -798,7 +800,7 @@ on_language_selected (GeditHighlightModeSelector *sel,
 static void
 setup_statusbar (GeditWindow *window)
 {
-       GeditHighlightModeSelector *sel;
+       GeditHighlightModeSelector *selector;
 
        gedit_debug (DEBUG_WINDOW);
 
@@ -828,18 +830,20 @@ setup_statusbar (GeditWindow *window)
        gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->priv->language_button),
                                     window->priv->language_popover);
 
-       sel = gedit_highlight_mode_selector_new ();
-       g_signal_connect (sel,
+       selector = gedit_highlight_mode_selector_new ();
+
+       g_signal_connect (selector,
                          "show",
-                         G_CALLBACK (on_language_selector_shown),
+                         G_CALLBACK (language_selector_show_cb),
                          window);
-       g_signal_connect (sel,
+
+       g_signal_connect (selector,
                          "language-selected",
-                         G_CALLBACK (on_language_selected),
+                         G_CALLBACK (language_selected_cb),
                          window);
 
-       gtk_container_add (GTK_CONTAINER (window->priv->language_popover), GTK_WIDGET (sel));
-       gtk_widget_show (GTK_WIDGET (sel));
+       gtk_container_add (GTK_CONTAINER (window->priv->language_popover), GTK_WIDGET (selector));
+       gtk_widget_show (GTK_WIDGET (selector));
 }
 
 static GeditWindow *


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