summaryrefslogtreecommitdiff
path: root/gtk/gtktoolbutton.c
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2009-07-13 19:13:59 +0200
committerMurray Cumming <murrayc@murrayc.com>2009-07-13 19:13:59 +0200
commitdad6e7343c1fbdbbe2a6ca765aabcf8b887933c9 (patch)
tree1f2565ca69346eccdac3580e16c75a717995e869 /gtk/gtktoolbutton.c
parent8a294b8bb75236c52519dcb39794bedad15498df (diff)
downloadgtk+-dad6e7343c1fbdbbe2a6ca765aabcf8b887933c9.tar.gz
ToolShell: Add ellipsize, text-orientation, text-alignment and size-group.
* gtk/gtktoolshell.c: Added vfuncs to get/set ellipsize, text-orientation, text-alignment and size-group plus getter/setters to invoke these vfuncs. * gtk/gtktoolitem.[h|c]: Added getters and setters to get/set these from the parent GtkToolShell. This is in the style of the existing "properties". * gtk/gtktoolbutton.c: Updated to use the extra properties. * docs/reference/gtk/gtk-sections.txt * gtk/gtk.symbols: Updated to mention the new functions. These new "properties" are used by GtkToolPalette.
Diffstat (limited to 'gtk/gtktoolbutton.c')
-rw-r--r--gtk/gtktoolbutton.c73
1 files changed, 65 insertions, 8 deletions
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c
index 89231ea3ac..c9e63f6a68 100644
--- a/gtk/gtktoolbutton.c
+++ b/gtk/gtktoolbutton.c
@@ -96,7 +96,9 @@ struct _GtkToolButtonPrivate
gchar *label_text;
GtkWidget *label_widget;
GtkWidget *icon_widget;
-
+
+ GtkSizeGroup *text_size_group;
+
guint use_underline : 1;
guint contents_invalid : 1;
};
@@ -318,6 +320,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
GtkIconSize icon_size;
GtkWidget *box = NULL;
guint icon_spacing;
+ GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL;
+ GtkSizeGroup *size_group = NULL;
button->priv->contents_invalid = FALSE;
@@ -355,7 +359,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
if (style == GTK_TOOLBAR_BOTH_HORIZ &&
(gtk_tool_item_get_is_important (GTK_TOOL_ITEM (button)) ||
- gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL))
+ gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL ||
+ gtk_tool_item_get_text_orientation (GTK_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL))
{
need_label = TRUE;
}
@@ -415,6 +420,28 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gtk_widget_show (label);
}
+
+ gtk_label_set_ellipsize (GTK_LABEL (label),
+ gtk_tool_item_get_ellipsize_mode (GTK_TOOL_ITEM (button)));
+ text_orientation = gtk_tool_item_get_text_orientation (GTK_TOOL_ITEM (button));
+ if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ gtk_label_set_angle (GTK_LABEL (label), 0);
+ gtk_misc_set_alignment (GTK_MISC (label),
+ gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)),
+ 0.5);
+ }
+ else
+ {
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE);
+ if (gtk_widget_get_direction (GTK_WIDGET (tool_item)) == GTK_TEXT_DIR_RTL)
+ gtk_label_set_angle (GTK_LABEL (label), -90);
+ else
+ gtk_label_set_angle (GTK_LABEL (label), 90);
+ gtk_misc_set_alignment (GTK_MISC (label),
+ 0.5,
+ 1 - gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)));
+ }
}
icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button));
@@ -442,6 +469,22 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
icon = gtk_image_new_from_icon_name (button->priv->icon_name, icon_size);
gtk_widget_show (icon);
}
+
+ if (icon && text_orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_misc_set_alignment (GTK_MISC (icon),
+ 1.0 - gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)),
+ 0.5);
+ else if (icon)
+ gtk_misc_set_alignment (GTK_MISC (icon),
+ 0.5,
+ gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)));
+
+ if (icon)
+ {
+ size_group = gtk_tool_item_get_text_size_group (GTK_TOOL_ITEM (button));
+ if (size_group != NULL)
+ gtk_size_group_add_widget (size_group, icon);
+ }
}
switch (style)
@@ -452,7 +495,10 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
break;
case GTK_TOOLBAR_BOTH:
- box = gtk_vbox_new (FALSE, icon_spacing);
+ if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
+ box = gtk_vbox_new (FALSE, icon_spacing);
+ else
+ box = gtk_hbox_new (FALSE, icon_spacing);
if (icon)
gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (box), label, FALSE, TRUE, 0);
@@ -460,11 +506,22 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
break;
case GTK_TOOLBAR_BOTH_HORIZ:
- box = gtk_hbox_new (FALSE, icon_spacing);
- if (icon)
- gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
- if (label)
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ box = gtk_hbox_new (FALSE, icon_spacing);
+ if (icon)
+ gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
+ if (label)
+ gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
+ }
+ else
+ {
+ box = gtk_vbox_new (FALSE, icon_spacing);
+ if (icon)
+ gtk_box_pack_end (GTK_BOX (box), icon, label ? FALSE : TRUE, TRUE, 0);
+ if (label)
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ }
gtk_container_add (GTK_CONTAINER (button->priv->button), box);
break;