diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2015-10-29 10:14:57 -0200 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2015-10-30 11:35:43 -0200 |
commit | 50c6a11b050c97f5a3f901340ffb6628c84af6c9 (patch) | |
tree | 905354ceea7d427014c8be0a4b9c8082085a8ca5 /gtk | |
parent | 84380b345d93b2a7d5ca6c78e565d3d6ec4ad3e1 (diff) | |
download | gtk+-50c6a11b050c97f5a3f901340ffb6628c84af6c9.tar.gz |
placesview: vertically align path labels
The current situation is somewhat sad, with the path
label totally misaligned throughout the rows.
This is fixed by using a size group for the path labels,
so they all have the same allocated size (with the max
of 15 chars). Also, instead of hiding the eject button,
set it child-invisible, so it is hidden and yet it's size
is allocated by GtkBox.
https://bugzilla.gnome.org/show_bug.cgi?id=757303
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkplacesview.c | 6 | ||||
-rw-r--r-- | gtk/gtkplacesviewrow.c | 18 | ||||
-rw-r--r-- | gtk/gtkplacesviewrowprivate.h | 4 | ||||
-rw-r--r-- | gtk/ui/gtkplacesviewrow.ui | 4 |
4 files changed, 29 insertions, 3 deletions
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c index 7c70e98085..77dd938d92 100644 --- a/gtk/gtkplacesview.c +++ b/gtk/gtkplacesview.c @@ -72,6 +72,8 @@ struct _GtkPlacesViewPrivate GtkWidget *network_placeholder; GtkWidget *network_placeholder_label; + GtkSizeGroup *path_size_group; + GtkEntryCompletion *address_entry_completion; GtkListStore *completion_store; @@ -406,6 +408,7 @@ gtk_places_view_finalize (GObject *object) g_clear_object (&priv->volume_monitor); g_clear_object (&priv->cancellable); g_clear_object (&priv->networks_fetching_cancellable); + g_clear_object (&priv->path_size_group); G_OBJECT_CLASS (gtk_places_view_parent_class)->finalize (object); } @@ -674,6 +677,8 @@ insert_row (GtkPlacesView *view, G_CALLBACK (on_eject_button_clicked), row); + gtk_places_view_row_set_path_size_group (GTK_PLACES_VIEW_ROW (row), priv->path_size_group); + gtk_container_add (GTK_CONTAINER (priv->listbox), row); } @@ -2254,6 +2259,7 @@ gtk_places_view_init (GtkPlacesView *self) priv->volume_monitor = g_volume_monitor_get (); priv->open_flags = GTK_PLACES_OPEN_NORMAL; + priv->path_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); gtk_widget_init_template (GTK_WIDGET (self)); } diff --git a/gtk/gtkplacesviewrow.c b/gtk/gtkplacesviewrow.c index 8c1d1cb127..3466053e4f 100644 --- a/gtk/gtkplacesviewrow.c +++ b/gtk/gtkplacesviewrow.c @@ -150,7 +150,15 @@ gtk_places_view_row_set_property (GObject *object, case PROP_MOUNT: g_set_object (&self->mount, g_value_get_object (value)); - gtk_widget_set_visible (GTK_WIDGET (self->eject_button), self->mount != NULL); + + /* + * When we hide the eject button, no size is allocated for it. Since + * we want to have alignment between rows, it needs an empty space + * when the eject button is not available. So, call then + * gtk_widget_set_child_visible(), which makes the button allocate the + * size but it stays hidden when needed. + */ + gtk_widget_set_child_visible (GTK_WIDGET (self->eject_button), self->mount != NULL); break; case PROP_FILE: @@ -323,3 +331,11 @@ gtk_places_view_row_set_is_network (GtkPlacesViewRow *row, gtk_widget_set_tooltip_text (GTK_WIDGET (row->eject_button), is_network ? _("Disconnect") : _("Unmount")); } } + +void +gtk_places_view_row_set_path_size_group (GtkPlacesViewRow *row, + GtkSizeGroup *group) +{ + if (group) + gtk_size_group_add_widget (group, GTK_WIDGET (row->path_label)); +} diff --git a/gtk/gtkplacesviewrowprivate.h b/gtk/gtkplacesviewrowprivate.h index 3c46d5d9a5..2d5da7e5fb 100644 --- a/gtk/gtkplacesviewrowprivate.h +++ b/gtk/gtkplacesviewrowprivate.h @@ -24,6 +24,7 @@ #endif #include "gtkwidget.h" +#include "gtksizegroup.h" #include "gtklistbox.h" G_BEGIN_DECLS @@ -53,6 +54,9 @@ gboolean gtk_places_view_row_get_is_network (GtkPlacesViewR void gtk_places_view_row_set_is_network (GtkPlacesViewRow *row, gboolean is_network); +void gtk_places_view_row_set_path_size_group (GtkPlacesViewRow *row, + GtkSizeGroup *group); + G_END_DECLS #endif /* GTK_PLACES_VIEW_ROW_H */ diff --git a/gtk/ui/gtkplacesviewrow.ui b/gtk/ui/gtkplacesviewrow.ui index 2d06d0d872..9ace5b9300 100644 --- a/gtk/ui/gtkplacesviewrow.ui +++ b/gtk/ui/gtkplacesviewrow.ui @@ -40,8 +40,7 @@ <property name="visible">1</property> <property name="justify">right</property> <property name="ellipsize">middle</property> - <property name="xalign">1</property> - <property name="width_chars">15</property> + <property name="xalign">0</property> <property name="max_width_chars">15</property> <style> <class name="dim-label"/> @@ -53,6 +52,7 @@ </child> <child> <object class="GtkButton" id="eject_button"> + <property name="visible">True</property> <property name="halign">end</property> <property name="valign">center</property> <property name="tooltip-text" translatable="yes">Unmount</property> |