GNOME Bugzilla – Bug 318377
Date/Time shouldn't always be vertically aligned on side panels
Last modified: 2015-03-24 13:00:56 UTC
The Date/Time applet shows the text vertically if placed on a vertical panel, or on a drawer. This is appearantly a new feature, but it just makes it harder to read. While I appreciate the ability to display it this way on narrow panels, I would like to see the option to display it the normal horizontal way. At the very least, the date/time should not be vertical if the panel is wide enough to show it properly horizontally.
Horizontal time (no date, just time) fitted just nice on a 48 pixel vertical panel on a widescreen, (bottom right under a Weather applet - also horizontal). Now (2.12.1, I think) time is vertical. The Weather applet is still horizontal and the overall effect loses some consistency. It would be nice, say, to be able to choose aspect - maybe the same could apply to other applets, too. Getting off-topic but with the increasing use of wide screens, vertical panels may increase in popularity, as they seem to maximise screen "real estate", i.e. you can make them wide and still leave "more" screen than on a 4:3. Because of this, such issues as the above may well take on greater importance than in the past.
Good point. Will try to do this for 2.14.
*** Bug 327113 has been marked as a duplicate of this bug. ***
Created attachment 62558 [details] [review] Take panel-width into account when deciding whether to rotate clock I'm very new to (programming with) pango and gtk, and my C is quite rusty, so review and comments are very welcome.
Comment on attachment 62558 [details] [review] Take panel-width into account when deciding whether to rotate clock Thanks for working on this. First comment: please use the -p option of diff when making a diff ;-) >--- gnome-panel-2.12.3/applets/clock/clock.c 2006-02-06 17:52:53.000000000 +0100 >+++ fixed/gnome-panel-2.12.3/applets/clock/clock.c 2006-04-01 19:56:58.984729329 +0200 >@@ -144,6 +144,8 @@ > guint timeout; > PanelAppletOrient orient; > int size; >+ int width; >+ int height; You're using spaces instead of tabs here (and in some other places). > int fixed_width; > int fixed_height; >@@ -178,6 +180,8 @@ > GtkWidget *window, > GtkWidget *button); > >+static void update_orient (ClockData *cd); >+ > static void > unfix_size (ClockData *cd) > { >@@ -286,6 +290,34 @@ > return PANGO_PIXELS (ascent + descent) + 2 * (focus_width + focus_pad + thickness); > } > >+static int >+calculate_minimum_width (GtkWidget *widget, >+ PanelAppletOrient orientation, >+ const gchar *text) >+{ >+ PangoContext *context; >+ PangoLayout *layout; >+ int width, height; >+ int focus_width = 0; >+ int focus_pad = 0; >+ >+ context = gtk_widget_get_pango_context (widget); >+ >+ layout = pango_layout_new (context); >+ pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT); >+ pango_layout_set_text (layout, text, -1); >+ pango_layout_get_pixel_size (layout, &width, &height); You're leaking the layout here, I guess. >+ gtk_widget_style_get (widget, >+ "focus-line-width", &focus_width, >+ "focus-padding", &focus_pad, >+ NULL); >+ >+ width += 2*(focus_width+focus_pad+widget->style->xthickness); >+ >+ return width; >+} If we're using this function, we don't really need calculate_minimum_height() too since we can get the height here too. You should probably merge both functions. > static gboolean > use_two_line_format (ClockData *cd) > { >@@ -1665,16 +1697,10 @@ > > cd->orient = panel_applet_get_orient (PANEL_APPLET (cd->applet)); > >- /* Initialize label orientation */ >- if (cd->orient == PANEL_APPLET_ORIENT_LEFT) >- gtk_label_set_angle (GTK_LABEL (cd->clockw), 270); >- else if (cd->orient == PANEL_APPLET_ORIENT_RIGHT) >- gtk_label_set_angle (GTK_LABEL (cd->clockw), 90); >- else >- gtk_label_set_angle (GTK_LABEL (cd->clockw), 0); >- > cd->size = panel_applet_get_size (PANEL_APPLET (cd->applet)); > >+ update_orient(cd); >+ > g_signal_connect (G_OBJECT(clock), "destroy", > G_CALLBACK (destroy_clock), > cd); >@@ -1684,24 +1710,36 @@ > > /* Refresh the clock so that it paints its first state */ > refresh_clock_timeout(cd); >+ /* Also update the orientation, now that the clock has gotten it's correct content: */ >+ update_orient(cd); > } > >-/* this is when the panel orientation changes */ >+static void update_orient (ClockData *cd) >+{ >+ const gchar *text; >+ int min_width; >+ >+ text=gtk_label_get_text (GTK_LABEL (cd->clockw)); >+ min_width=calculate_minimum_width(cd->applet, cd->orient, text); > >+ if (cd->orient == PANEL_APPLET_ORIENT_LEFT && min_width>cd->width) >+ gtk_label_set_angle (GTK_LABEL (cd->clockw), 270); >+ else if (cd->orient == PANEL_APPLET_ORIENT_RIGHT && min_width>cd->width) >+ gtk_label_set_angle (GTK_LABEL (cd->clockw), 90); >+ else >+ gtk_label_set_angle (GTK_LABEL (cd->clockw), 0); >+} This should probably be called when the user changes a setting: adding the date change the width, eg. >+/* this is when the panel orientation changes */ No need to add a comment here. > static void > applet_change_orient (PanelApplet *applet, > PanelAppletOrient orient, > ClockData *cd) > { > cd->orient = orient; >+ >+ update_orient(cd); > >- if (cd->orient == PANEL_APPLET_ORIENT_LEFT) >- gtk_label_set_angle (GTK_LABEL (cd->clockw), 270); >- else if (cd->orient == PANEL_APPLET_ORIENT_RIGHT) >- gtk_label_set_angle (GTK_LABEL (cd->clockw), 90); >- else >- gtk_label_set_angle (GTK_LABEL (cd->clockw), 0); >- > unfix_size (cd); > update_clock (cd); > update_popup (cd); >@@ -1744,12 +1782,18 @@ > > /* this is when the panel size changes */ > static void >-applet_change_pixel_size (PanelApplet *applet, >- gint size, >- ClockData *cd) >+applet_change_pixel_size (PanelApplet *applet, >+ GtkAllocation *allocation, >+ ClockData *cd) > { >- cd->size = size; >+ if (cd->width == allocation->width && cd->height == allocation->height) return; > >+ cd->width = allocation->width; >+ cd->height = allocation->height; >+ cd->size = panel_applet_get_size (applet); >+ >+ update_orient(cd); >+ > unfix_size (cd); > update_timeformat (cd); > update_clock (cd); >@@ -2294,7 +2338,7 @@ > > /* similiar to the above in semantics*/ > g_signal_connect (G_OBJECT (cd->applet), >- "change_size", >+ "size_allocate", > G_CALLBACK (applet_change_pixel_size), > cd); > I didn't test the patch, but it mostly looks good! If you can just update the patch to fix the minor issues, it'll be great.
Thank you for the comments. -p: never heard of that option; will do. spaces/tabs: my editor automatically converts tabs to spaces, yes. Please note that clock.c sometimes uses tabs, sometimes spaces. "leaking the layout": I don't know what that means in this context. How do I check if it does? I found the use of pango_layout_new() in accessx_status_applet_get_glyph_pixbuf() ingnome-applets-2.12.3/accessx-status/applet.c - I can see that gnome-applets/gnome-applets-2.12.3/libkbdraw/keyboard-drawing.c does free layout, so I'll add the two lines from there. calculate_minimum_height: I don't care to understand what that function is used for (it is not related to the problem I have with the applet), so I haven't taken time to change it. Basically I have tried to fix the problem without changing other things, as I do not have any idea of how those things work nor what the plans for rewriting/structuring/cleaning up clock.c is. Adding a comment: I did not add that comment - that is a diff artefact (look a few lines up, and you will see diff "removing" the original occurrence of that comment).
Created attachment 62615 [details] [review] Updated patch * Run diff with -p. * M-x tabify my changes * g_object_unref layout * Call update_orient () from update_clock ()
Ubuntu bug about that: https://launchpad.net/products/gnome-panel/+bug/42575
I would really like to see this feature added. I find that rotated text for something that is supposed to be glanced at quickly is almost useless to me.
I can only join Andy Balaam in his request about the clock. Another vote for this bug.
*** Bug 340832 has been marked as a duplicate of this bug. ***
*** Bug 339390 has been marked as a duplicate of this bug. ***
Created attachment 67974 [details] [review] Updated patch for 2.14.1 I have updated the patch to apply to 2.14.1 (the previous patch was for 2.12.3).
The updated patch is ok with me. ALT Linux's Sisyphus repository has gained a well-behaved clock applet :) But I should note that, e.g. battery applet has the same problem. Its layout on wide vertical panels looks at least weird. The text is always vertical, even when it is not needed. Is it a separate bug? Should we work out a common ground for a text orientation solution, or solve this problem individually for each applet?
Thanks! I committed a slightly modified version that fixes some minor bugs (when resizing the panel). Alexey: we're working on a new applet library which should automatically handle this.
Thanks for the good news, looking forward to see it in action.