summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2004-04-13 20:56:50 +0000
committerJonathan Blandford <jrb@src.gnome.org>2004-04-13 20:56:50 +0000
commit1d87e028a844c865c29e0ff53c8823d4f2a0f486 (patch)
tree4d16ca1be7780cea108817810c8a414b2b2c49e0
parent157943b584fc9251f10154a630acc056ae73af82 (diff)
downloadgtk+-1d87e028a844c865c29e0ff53c8823d4f2a0f486.tar.gz
patch from Owen to make the buttons sized by a bold label. This makes the
Tue Apr 13 16:19:23 2004 Jonathan Blandford <jrb@redhat.com> * gtk/gtkpathbar.c (make_directory_button): patch from Owen to make the buttons sized by a bold label. This makes the text 'swim' a little, but stops the buttons from resizign, #137210
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.pre-2-106
-rw-r--r--ChangeLog.pre-2-46
-rw-r--r--ChangeLog.pre-2-66
-rw-r--r--ChangeLog.pre-2-86
-rw-r--r--gtk/gtkpathbar.c66
6 files changed, 86 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 26ee54d8d5..a3ca497414 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Apr 13 16:19:23 2004 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkpathbar.c (make_directory_button): patch from Owen to
+ make the buttons sized by a bold label. This makes the text
+ 'swim' a little, but stops the buttons from resizign, #137210
+
2004-04-13 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkuimanager.c (get_child_node): Don't crash if a node
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 26ee54d8d5..a3ca497414 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,9 @@
+Tue Apr 13 16:19:23 2004 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkpathbar.c (make_directory_button): patch from Owen to
+ make the buttons sized by a bold label. This makes the text
+ 'swim' a little, but stops the buttons from resizign, #137210
+
2004-04-13 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkuimanager.c (get_child_node): Don't crash if a node
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 26ee54d8d5..a3ca497414 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,9 @@
+Tue Apr 13 16:19:23 2004 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkpathbar.c (make_directory_button): patch from Owen to
+ make the buttons sized by a bold label. This makes the text
+ 'swim' a little, but stops the buttons from resizign, #137210
+
2004-04-13 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkuimanager.c (get_child_node): Don't crash if a node
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 26ee54d8d5..a3ca497414 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,9 @@
+Tue Apr 13 16:19:23 2004 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkpathbar.c (make_directory_button): patch from Owen to
+ make the buttons sized by a bold label. This makes the text
+ 'swim' a little, but stops the buttons from resizign, #137210
+
2004-04-13 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkuimanager.c (get_child_node): Don't crash if a node
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 26ee54d8d5..a3ca497414 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,9 @@
+Tue Apr 13 16:19:23 2004 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkpathbar.c (make_directory_button): patch from Owen to
+ make the buttons sized by a bold label. This makes the text
+ 'swim' a little, but stops the buttons from resizign, #137210
+
2004-04-13 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkuimanager.c (get_child_node): Don't crash if a node
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index c2139c13c1..f8aad8ad8d 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -21,6 +21,7 @@
#include <string.h>
#include "gtkpathbar.h"
#include "gtktogglebutton.h"
+#include "gtkalignment.h"
#include "gtkarrow.h"
#include "gtkimage.h"
#include "gtkintl.h"
@@ -834,19 +835,50 @@ button_data_free (ButtonData *button_data)
g_free (button_data);
}
+static const char *
+get_dir_name (ButtonData *button_data)
+{
+ if (button_data->type == HOME_BUTTON)
+ return _("Home");
+ else if (button_data->type == DESKTOP_BUTTON)
+ return _("Desktop");
+ else
+ return button_data->dir_name;
+
+}
+
+/* We always want to request the same size for the label, whether
+ * or not the contents are bold
+ */
+static void
+label_size_request_cb (GtkWidget *widget,
+ GtkRequisition *requisition,
+ ButtonData *button_data)
+{
+ const gchar *dir_name = get_dir_name (button_data);
+ PangoLayout *layout = gtk_widget_create_pango_layout (button_data->label, dir_name);
+ gint bold_width, bold_height;
+ gchar *markup;
+
+ pango_layout_get_pixel_size (layout, &requisition->width, &requisition->height);
+
+ markup = g_markup_printf_escaped ("<b>%s</b>", dir_name);
+ pango_layout_set_markup (layout, markup, -1);
+ g_free (markup);
+
+ pango_layout_get_pixel_size (layout, &bold_width, &bold_height);
+ requisition->width = MAX (requisition->width, bold_width);
+ requisition->height = MAX (requisition->height, bold_height);
+
+ g_object_unref (layout);
+}
+
static void
gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
ButtonData *button_data,
gboolean current_dir)
{
- const gchar *dir_name;
-
- if (button_data->type == HOME_BUTTON)
- dir_name = _("Home");
- else if (button_data->type == DESKTOP_BUTTON)
- dir_name = _("Desktop");
- else
- dir_name = button_data->dir_name;
+ const gchar *dir_name = get_dir_name (button_data);
if (button_data->label != NULL)
{
@@ -901,6 +933,7 @@ make_directory_button (GtkPathBar *path_bar,
gboolean file_is_hidden)
{
GtkWidget *child = NULL;
+ GtkWidget *label_alignment = NULL;
ButtonData *button_data;
/* Is it a special button? */
@@ -920,17 +953,30 @@ make_directory_button (GtkPathBar *path_bar,
case DESKTOP_BUTTON:
button_data->image = gtk_image_new ();
button_data->label = gtk_label_new (NULL);
+ label_alignment = gtk_alignment_new (0.5, 0.5, 0., 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), button_data->label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (child), label_alignment, FALSE, FALSE, 0);
break;
case NORMAL_BUTTON:
default:
button_data->label = gtk_label_new (NULL);
- child = button_data->label;
+ label_alignment = gtk_alignment_new (0.5, 0.5, 0., 0.);
+ gtk_container_add (GTK_CONTAINER (label_alignment), button_data->label);
+ child = label_alignment;
+ gtk_box_pack_start (GTK_BOX (child), label_alignment, FALSE, FALSE, 0);
button_data->image = NULL;
}
+ /* label_alignment is created because we can't override size-request
+ * on label itself and still have the contents of the label centered
+ * properly in the label's requisition
+ */
+ if (label_alignment)
+ g_signal_connect (label_alignment, "size-request",
+ G_CALLBACK (label_size_request_cb), button_data);
+
button_data->dir_name = g_strdup (dir_name);
button_data->path = gtk_file_path_new_dup (gtk_file_path_get_string (path));
button_data->file_is_hidden = file_is_hidden;