summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-06-28 17:01:54 +0200
committerraveit65 <[email protected]>2016-07-14 16:15:12 +0200
commit6247be1f934beaf7f5e523dd476df538385d9ae0 (patch)
treec70f81efe2b6cc6311f6fe30c055f5f504c2e48d /src
parentf3331893add1aca7fe85e1f3803000d17fec0c63 (diff)
downloadcaja-6247be1f934beaf7f5e523dd476df538385d9ae0.tar.bz2
caja-6247be1f934beaf7f5e523dd476df538385d9ae0.tar.xz
GTK+-3 pathbar: refresh label size request every time it changes
Or we might end up with buttons having the wrong size if a folder on the pathbar changes name. https://bugzilla.gnome.org/show_bug.cgi?id=671865 taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-6&id=7358824778
Diffstat (limited to 'src')
-rw-r--r--src/caja-pathbar.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c
index 1d2fac48..bdd78004 100644
--- a/src/caja-pathbar.c
+++ b/src/caja-pathbar.c
@@ -90,6 +90,7 @@ struct _ButtonData
GtkWidget *image;
GtkWidget *label;
+ GtkWidget *alignment;
guint ignore_changes : 1;
guint file_is_hidden : 1;
guint fake_root : 1;
@@ -1572,8 +1573,7 @@ get_dir_name (ButtonData *button_data)
*/
#if GTK_CHECK_VERSION(3,0,0)
static void
-set_label_size_request (GtkWidget *alignment,
- ButtonData *button_data)
+set_label_size_request (ButtonData *button_data)
{
const gchar *dir_name = get_dir_name (button_data);
PangoLayout *layout;
@@ -1589,7 +1589,7 @@ set_label_size_request (GtkWidget *alignment,
pango_layout_get_pixel_size (layout, &bold_width, &bold_height);
- gtk_widget_set_size_request (alignment,
+ gtk_widget_set_size_request (button_data->alignment,
MAX (width, bold_width),
MAX (height, bold_height));
@@ -1646,6 +1646,17 @@ caja_path_bar_update_button_appearance (ButtonData *button_data)
}
}
+#if GTK_CHECK_VERSION(3,0,0)
+ /* FIXME: Maybe we dont need this alignment at all and we can
+ * use GtkMisc aligments or even GtkWidget:halign/valign center.
+ *
+ * The following function ensures that the alignment will always
+ * request the same size whether the button's text is bold or not.
+ */
+ set_label_size_request (button_data);
+#endif
+
+
if (button_data->image != NULL)
{
if (button_data->custom_icon)
@@ -2007,13 +2018,17 @@ make_directory_button (CajaPathBar *path_bar,
{
GFile *path;
GtkWidget *child;
+#if !GTK_CHECK_VERSION(3,0,0)
GtkWidget *label_alignment;
+#endif
ButtonData *button_data;
path = caja_file_get_location (file);
child = NULL;
+#if !GTK_CHECK_VERSION(3,0,0)
label_alignment = NULL;
+#endif
file_is_hidden = !! file_is_hidden;
/* Is it a special button? */
@@ -2043,20 +2058,36 @@ make_directory_button (CajaPathBar *path_bar,
case MOUNT_BUTTON:
case DEFAULT_LOCATION_BUTTON:
button_data->label = gtk_label_new (NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+ button_data->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_container_add (GTK_CONTAINER (button_data->alignment), button_data->label);
+ child = gtk_hbox_new (FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (child), button_data->alignment, FALSE, FALSE, 0);
+#else
label_alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_container_add (GTK_CONTAINER (label_alignment), button_data->label);
child = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (child), label_alignment, FALSE, FALSE, 0);
+#endif
break;
case NORMAL_BUTTON:
default:
button_data->label = gtk_label_new (NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+ button_data->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_container_add (GTK_CONTAINER (button_data->alignment), button_data->label);
+ child = gtk_hbox_new (FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (child), button_data->alignment, FALSE, FALSE, 0);
+#else
label_alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_container_add (GTK_CONTAINER (label_alignment), button_data->label);
child = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (child), label_alignment, FALSE, FALSE, 0);
+#endif
button_data->is_base_dir = base_dir;
}
@@ -2093,18 +2124,6 @@ make_directory_button (CajaPathBar *path_bar,
button_data->file_is_hidden = file_is_hidden;
-#if GTK_CHECK_VERSION(3,0,0)
- /* FIXME: Maybe we dont need this alignment at all and we can
- * use GtkMisc aligments or even GtkWidget:halign/valign center.
- *
- * The following function ensures that the alignment will always
- * request the same size whether the button's text is bold or not.
- */
- if (label_alignment) {
- set_label_size_request (label_alignment, button_data);
- }
-#endif
-
gtk_container_add (GTK_CONTAINER (button_data->button), child);
gtk_widget_show_all (button_data->button);