! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
[PATCH] respect layout when setting mode/orientation
Status:
RESOLVED: MOVED
Product:
Xfce4-datetime-plugin
Component:
General

Comments

Description j.witteveen 2013-10-12 00:13:16 CEST
Created attachment 5180 
respect layout when setting orientation

datetime_set_mode / datetime_set_orientation (datetime.c:594) reorder the children of the GTK box, but in a fixed order. This makes it impossible to use the "Time, then date" layout.

The attached patch moves the orientation-setting out of datetime_create_widget (so that we have time to read the configuration settings) and respects the layout.
Comment 1 j.witteveen 2013-10-12 00:39:32 CEST
Comment on attachment 5180 
respect layout when setting orientation

>diff --git a/panel-plugin/datetime.c b/panel-plugin/datetime.c
>index 181c273..c75ca64 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(datetime->plugin);
>+#ifdef HAS_PANEL_49
>+  datetime_set_mode(datetime->plugin, orientation, datetime);

'datetime->plugin' can be replaced by just 'plugin'.

>+#else
>+  datetime_set_orientation(datetime->plugin, orientation, datetime);

'datetime->plugin' can be replaced by just 'plugin'.

>+#endif
>+
>   /* set date and time labels */
>   datetime_update(datetime);
>
Comment 2 j.witteveen 2013-10-13 18:29:23 CEST
Created attachment 5182 
respect layout when setting mode/orientation
Comment 3 Landry Breuil editbugs 2014-11-23 21:45:11 CET
Mass-reassign all bugs from florian@ to goodies-dev@, thanks for the maintenance work! (and sorry for the bugmail spam..)
Comment 4 Steve Dodier-Lazaro editbugs 2015-02-08 17:59:58 CET
This bug was fixed on Git using a subset of the proposed patch (the switch part)

j.witteveen: if you still experience an issue, please could you explain why the orientation should be created outside the widget?

Thanks,
Comment 5 j.witteveen 2015-02-20 12:05:55 CET
I don't see any changes in git[1] that incorporate any of my patch? My patch was against 0.6.2. On my vertical deskbar panel, I need my patch in order to use the "Time, then date" layout directly when the panel first loads.

[1] http://git.xfce.org/panel-plugins/xfce4-datetime-plugin/
Comment 6 Steve Dodier-Lazaro editbugs 2015-02-21 05:41:47 CET
Hm, I actually expected the second part should be for first-time loading, but I couldn't trigger a bug when I reloaded my panel.

Looking at git head, I see that the switch part is applied, and the other part was added at the end of datetime_create_widget?
Comment 7 j.witteveen 2015-03-09 12:47:13 CET
I don't see anything applied in git and the bug is still present.

Even though I have opted for "Time, then date", when the panel first loads, it displays the date before the time. My panel is in vertical deskbar mode.
Comment 8 Git Bot editbugs 2020-05-23 01:22:09 CEST
-- GitLab Migration Automatic Message --

This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/panel-plugins/xfce4-datetime-plugin/-/issues/8.

Please create an account or use an existing account on one of our supported OAuth providers. 

If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests

Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev

Bug #10400

Reported by:
j.witteveen
Reported on: 2013-10-12
Last modified on: 2020-05-23

People

Assignee:
Xfce-Goodies Maintainers
CC List:
1 user

Version

Version:
unspecified

Attachments

Additional information