@@ -246,6 +246,51 @@ static void panel_toplevel_calculate_animation_end_geometry(PanelToplevel *tople
246246static void panel_toplevel_update_monitor (PanelToplevel * toplevel );
247247static void panel_toplevel_set_monitor_internal (PanelToplevel * toplevel , int monitor , gboolean force_resize );
248248
249+ static void
250+ update_style_classes (PanelToplevel * toplevel )
251+ {
252+ GtkStyleContext * context ;
253+
254+ context = gtk_widget_get_style_context (GTK_WIDGET (toplevel ));
255+
256+ /*ensure the panel BG can always be themed*/
257+ /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
258+ gtk_style_context_add_class (context ,"gnome-panel-menu-bar" );
259+ gtk_style_context_add_class (context ,"mate-panel-menu-bar" );
260+
261+ gtk_style_context_remove_class (context , GTK_STYLE_CLASS_HORIZONTAL );
262+ gtk_style_context_remove_class (context , GTK_STYLE_CLASS_VERTICAL );
263+ gtk_style_context_remove_class (context , GTK_STYLE_CLASS_RIGHT );
264+ gtk_style_context_remove_class (context , GTK_STYLE_CLASS_LEFT );
265+ gtk_style_context_remove_class (context , GTK_STYLE_CLASS_TOP );
266+ gtk_style_context_remove_class (context , GTK_STYLE_CLASS_BOTTOM );
267+
268+ switch (toplevel -> priv -> orientation ) {
269+ case PANEL_ORIENTATION_TOP :
270+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_HORIZONTAL );
271+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_TOP );
272+ break ;
273+
274+ case PANEL_ORIENTATION_LEFT :
275+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_VERTICAL );
276+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_LEFT );
277+ break ;
278+
279+ case PANEL_ORIENTATION_BOTTOM :
280+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_HORIZONTAL );
281+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_BOTTOM );
282+ break ;
283+
284+ case PANEL_ORIENTATION_RIGHT :
285+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_VERTICAL );
286+ gtk_style_context_add_class (context , GTK_STYLE_CLASS_RIGHT );
287+ break ;
288+
289+ default :
290+ g_assert_not_reached ();
291+ break ;
292+ }
293+ }
249294
250295GSList * panel_toplevel_list_toplevels (void )
251296{
@@ -4806,12 +4851,7 @@ panel_toplevel_init (PanelToplevel *toplevel)
48064851 (PanelBackgroundChangedNotify ) background_changed ,
48074852 toplevel );
48084853
4809- /*ensure the panel BG can always be themed*/
4810- /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
4811- GtkStyleContext * context ;
4812- context = gtk_widget_get_style_context (GTK_WIDGET (toplevel ));
4813- gtk_style_context_add_class (context ,"gnome-panel-menu-bar" );
4814- gtk_style_context_add_class (context ,"mate-panel-menu-bar" );
4854+ update_style_classes (toplevel );
48154855}
48164856
48174857PanelWidget *
@@ -5020,15 +5060,8 @@ panel_toplevel_set_orientation (PanelToplevel *toplevel,
50205060 }
50215061
50225062 toplevel -> priv -> orientation = orientation ;
5063+ update_style_classes (toplevel );
50235064
5024- GtkStyleContext * context = gtk_widget_get_style_context (GTK_WIDGET (toplevel ));
5025- if (orientation & PANEL_HORIZONTAL_MASK ) {
5026- gtk_style_context_add_class (context , GTK_STYLE_CLASS_HORIZONTAL );
5027- gtk_style_context_remove_class (context , GTK_STYLE_CLASS_VERTICAL );
5028- } else {
5029- gtk_style_context_add_class (context , GTK_STYLE_CLASS_VERTICAL );
5030- gtk_style_context_remove_class (context , GTK_STYLE_CLASS_HORIZONTAL );
5031- }
50325065 gtk_widget_reset_style (GTK_WIDGET (toplevel ));
50335066
50345067 panel_toplevel_update_hide_buttons (toplevel );
0 commit comments