summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <[email protected]>2018-01-20 23:06:10 +0200
committerraveit65 <[email protected]>2018-06-29 21:35:12 +0200
commit2c8de940026ce9a933dedc378a17d7c5e42bbb74 (patch)
treea9a4380872f9b18b1806738f9978f42115dea2e6
parent35552077755088cb79cdd061eb7f318d6db5544a (diff)
downloadmate-panel-2c8de940026ce9a933dedc378a17d7c5e42bbb74.tar.bz2
mate-panel-2c8de940026ce9a933dedc378a17d7c5e42bbb74.tar.xz
panel-toplevel: add position css class
origin commit: https://gitlab.gnome.org/GNOME/gnome-panel/commit/6015418
-rw-r--r--mate-panel/panel-toplevel.c61
1 files changed, 47 insertions, 14 deletions
diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c
index d3fd0dcd..d9456f22 100644
--- a/mate-panel/panel-toplevel.c
+++ b/mate-panel/panel-toplevel.c
@@ -246,6 +246,51 @@ static void panel_toplevel_calculate_animation_end_geometry(PanelToplevel *tople
static void panel_toplevel_update_monitor(PanelToplevel* toplevel);
static void panel_toplevel_set_monitor_internal(PanelToplevel* toplevel, int monitor, gboolean force_resize);
+static void
+update_style_classes (PanelToplevel *toplevel)
+{
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (toplevel));
+
+ /*ensure the panel BG can always be themed*/
+ /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
+ gtk_style_context_add_class(context,"gnome-panel-menu-bar");
+ gtk_style_context_add_class(context,"mate-panel-menu-bar");
+
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
+
+ switch (toplevel->priv->orientation) {
+ case PANEL_ORIENTATION_TOP:
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ break;
+
+ case PANEL_ORIENTATION_LEFT:
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ break;
+
+ case PANEL_ORIENTATION_BOTTOM:
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ break;
+
+ case PANEL_ORIENTATION_RIGHT:
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
GSList* panel_toplevel_list_toplevels(void)
{
@@ -4806,12 +4851,7 @@ panel_toplevel_init (PanelToplevel *toplevel)
(PanelBackgroundChangedNotify) background_changed,
toplevel);
- /*ensure the panel BG can always be themed*/
- /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
- GtkStyleContext *context;
- context = gtk_widget_get_style_context (GTK_WIDGET (toplevel));
- gtk_style_context_add_class(context,"gnome-panel-menu-bar");
- gtk_style_context_add_class(context,"mate-panel-menu-bar");
+ update_style_classes (toplevel);
}
PanelWidget *
@@ -5020,15 +5060,8 @@ panel_toplevel_set_orientation (PanelToplevel *toplevel,
}
toplevel->priv->orientation = orientation;
+ update_style_classes (toplevel);
- GtkStyleContext* context = gtk_widget_get_style_context (GTK_WIDGET (toplevel));
- if (orientation & PANEL_HORIZONTAL_MASK) {
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
- } else {
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
- }
gtk_widget_reset_style (GTK_WIDGET (toplevel));
panel_toplevel_update_hide_buttons (toplevel);