diff options
author | Tomas Bzatek <[email protected]> | 2020-07-16 18:08:33 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-07-23 13:33:30 +0200 |
commit | 45b9287ca6d550c1cc3245abab342bd06765e6e7 (patch) | |
tree | 9712cf711af75801043e7fd115a88d70d30f722f | |
parent | 7c82385341a1b5db43a4bf5cef81e133d07618e2 (diff) | |
download | mate-panel-45b9287ca6d550c1cc3245abab342bd06765e6e7.tar.bz2 mate-panel-45b9287ca6d550c1cc3245abab342bd06765e6e7.tar.xz |
panel-toplevel: Refactor panel_toplevel_update_hide_buttons_size()
No real leak here except of the unnecessary gtk_css_provider_new() call,
refactored for readability and to conform to the code style.
-rw-r--r-- | mate-panel/panel-toplevel.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c index 985ade8e..dd4c5abc 100644 --- a/mate-panel/panel-toplevel.c +++ b/mate-panel/panel-toplevel.c @@ -1266,31 +1266,23 @@ static void panel_toplevel_update_buttons_showing(PanelToplevel* toplevel) } /* force set hide button size on panel size < 30px */ -static void panel_toplevel_update_hide_buttons_size(GtkWidget* button, int panel_size) +static void panel_toplevel_update_hide_buttons_size (GtkWidget *button, int panel_size) { + GtkCssProvider *css_provider; + GtkStyleContext *context; + GtkWidget *arrow; + GtkSettings *settings; + gchar *gtk_theme_name = NULL; - static GtkCssProvider *css_provider = NULL; - GtkStyleContext *context = NULL; - - context = gtk_widget_get_style_context(button); - gtk_style_context_add_class(context, "panel-button"); - - if (css_provider == NULL) - css_provider = gtk_css_provider_new (); - - /* get arrow image */ - GtkWidget *arrow = NULL; - arrow = gtk_bin_get_child (GTK_BIN (button)); + context = gtk_widget_get_style_context (button); + gtk_style_context_add_class (context, "panel-button"); /* get defaults from theme */ - GtkSettings * settings = NULL; settings = gtk_settings_get_default (); - gchar *gtk_theme_name = NULL; g_object_get (settings, "gtk-theme-name", >k_theme_name, NULL); css_provider = gtk_css_provider_get_named (gtk_theme_name, NULL); g_free (gtk_theme_name); - /* set custom css by adding our custom code to the default theme css * * NOTE that contriary to the documentation: @@ -1307,9 +1299,11 @@ static void panel_toplevel_update_hide_buttons_size(GtkWidget* button, int panel gtk_css_provider_load_from_data (css_provider, ".panel-button {min-height: 13px; min-width: 13px; padding: 0px;}", -1, NULL); } - gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + /* get arrow image */ + arrow = gtk_bin_get_child (GTK_BIN (button)); + /* set image size */ if (panel_size < 20) { gtk_image_set_pixel_size (GTK_IMAGE (arrow), 12); @@ -1320,7 +1314,6 @@ static void panel_toplevel_update_hide_buttons_size(GtkWidget* button, int panel } else { gtk_image_set_pixel_size (GTK_IMAGE (arrow), 24); } - } static void panel_toplevel_update_hide_buttons(PanelToplevel* toplevel) |