From 49a3bba0c1fef5239ece89383c4fda43fc85e3e9 Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Sun, 13 Oct 2013 18:23:45 +0200 Subject: [PATCH] Respect layout when setting mode The "Time, then date" layout needs to be respected when changing the mode of the panel. This means we can only set the mode once we know the preferences for the plugin, hence we read them before setting the mode. --- panel-plugin/datetime.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/panel-plugin/datetime.c b/panel-plugin/datetime.c index 181c273..f879c81 100644 --- a/panel-plugin/datetime.c +++ b/panel-plugin/datetime.c @@ -605,16 +605,24 @@ static void datetime_set_orientation(XfcePanelPlugin *plugin, GtkOrientation ori xfce_hvbox_set_orientation(XFCE_HVBOX(datetime->box), GTK_ORIENTATION_HORIZONTAL); gtk_label_set_angle(GTK_LABEL(datetime->time_label), -90); gtk_label_set_angle(GTK_LABEL(datetime->date_label), -90); - gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->time_label, 0); - gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->date_label, 1); } else { xfce_hvbox_set_orientation(XFCE_HVBOX(datetime->box), GTK_ORIENTATION_VERTICAL); gtk_label_set_angle(GTK_LABEL(datetime->time_label), 0); gtk_label_set_angle(GTK_LABEL(datetime->date_label), 0); - gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->date_label, 0); - gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->time_label, 1); + } + /* set order based on layout-selection */ + switch(datetime->layout) + { + case LAYOUT_TIME_DATE: + gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->time_label, 0); + gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->date_label, 1); + break; + + default: + gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->time_label, 1); + gtk_box_reorder_child(GTK_BOX(datetime->box), datetime->date_label, 0); } } @@ -623,9 +631,6 @@ static void datetime_set_orientation(XfcePanelPlugin *plugin, GtkOrientation ori */ static void datetime_create_widget(t_datetime * datetime) { - GtkOrientation orientation; - orientation = xfce_panel_plugin_get_orientation(datetime->plugin); - /* create button */ datetime->button = xfce_create_panel_toggle_button(); gtk_widget_show(datetime->button); @@ -651,13 +656,6 @@ static void datetime_create_widget(t_datetime * datetime) /* connect widget signals to functions */ g_signal_connect(datetime->button, "button-press-event", G_CALLBACK(datetime_clicked), datetime); - - /* set orientation according to the panel orientation */ -#ifdef HAS_PANEL_49 - datetime_set_mode(datetime->plugin, orientation, datetime); -#else - datetime_set_orientation(datetime->plugin, orientation, datetime); -#endif } /* @@ -666,6 +664,7 @@ static void datetime_create_widget(t_datetime * datetime) static t_datetime * datetime_new(XfcePanelPlugin *plugin) { t_datetime * datetime; + GtkOrientation orientation; DBG("Starting datetime panel plugin"); @@ -681,6 +680,14 @@ static t_datetime * datetime_new(XfcePanelPlugin *plugin) /* load settings (default values if non-av) */ datetime_read_rc_file(plugin, datetime); + /* set orientation according to the panel orientation */ + orientation = xfce_panel_plugin_get_orientation(plugin); +#ifdef HAS_PANEL_49 + datetime_set_mode(plugin, orientation, datetime); +#else + datetime_set_orientation(plugin, orientation, datetime); +#endif + /* set date and time labels */ datetime_update(datetime); -- 1.8.4