GtkPathBar: don't use a GtkAlignment

This commit is contained in:
Matthias Clasen 2011-06-07 12:59:11 -04:00
parent 02285b232c
commit 4962545ef3

View File

@ -25,7 +25,6 @@
#include <string.h> #include <string.h>
#include "gtktogglebutton.h" #include "gtktogglebutton.h"
#include "gtkalignment.h"
#include "gtkarrow.h" #include "gtkarrow.h"
#include "gtkdnd.h" #include "gtkdnd.h"
#include "gtkimage.h" #include "gtkimage.h"
@ -1392,7 +1391,7 @@ get_dir_name (ButtonData *button_data)
* or not the contents are bold * or not the contents are bold
*/ */
static void static void
set_label_size_request (GtkWidget *alignment, set_label_size_request (GtkWidget *widget,
ButtonData *button_data) ButtonData *button_data)
{ {
const gchar *dir_name = get_dir_name (button_data); const gchar *dir_name = get_dir_name (button_data);
@ -1408,7 +1407,7 @@ set_label_size_request (GtkWidget *alignment,
pango_layout_get_pixel_size (layout, &bold_width, &bold_height); pango_layout_get_pixel_size (layout, &bold_width, &bold_height);
gtk_widget_set_size_request (alignment, gtk_widget_set_size_request (widget,
MAX (width, bold_width), MAX (width, bold_width),
MAX (height, bold_height)); MAX (height, bold_height));
g_object_unref (layout); g_object_unref (layout);
@ -1497,7 +1496,6 @@ make_directory_button (GtkPathBar *path_bar,
{ {
AtkObject *atk_obj; AtkObject *atk_obj;
GtkWidget *child = NULL; GtkWidget *child = NULL;
GtkWidget *label_alignment = NULL;
ButtonData *button_data; ButtonData *button_data;
file_is_hidden = !! file_is_hidden; file_is_hidden = !! file_is_hidden;
@ -1521,19 +1519,15 @@ make_directory_button (GtkPathBar *path_bar,
case DESKTOP_BUTTON: case DESKTOP_BUTTON:
button_data->image = gtk_image_new (); button_data->image = gtk_image_new ();
button_data->label = gtk_label_new (NULL); button_data->label = gtk_label_new (NULL);
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_box_new (GTK_ORIENTATION_HORIZONTAL, 2); child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0); 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); gtk_box_pack_start (GTK_BOX (child), button_data->label, FALSE, FALSE, 0);
break; break;
case NORMAL_BUTTON: case NORMAL_BUTTON:
default: default:
button_data->label = gtk_label_new (NULL); button_data->label = gtk_label_new (NULL);
gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_END); gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_END);
label_alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); child = button_data->label;
gtk_container_add (GTK_CONTAINER (label_alignment), button_data->label);
child = label_alignment;
button_data->image = NULL; button_data->image = NULL;
} }
@ -1541,14 +1535,12 @@ make_directory_button (GtkPathBar *path_bar,
button_data->file = g_object_ref (file); button_data->file = g_object_ref (file);
button_data->file_is_hidden = file_is_hidden; button_data->file_is_hidden = file_is_hidden;
/* 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 * The following function ensures that the alignment will always
* request the same size whether the button's text is bold or not. * request the same size whether the button's text is bold or not.
*/ */
if (label_alignment) if (button_data->label)
set_label_size_request (label_alignment, button_data); set_label_size_request (button_data->label, button_data);
gtk_container_add (GTK_CONTAINER (button_data->button), child); gtk_container_add (GTK_CONTAINER (button_data->button), child);
gtk_widget_show_all (button_data->button); gtk_widget_show_all (button_data->button);