[gtk+] GtkToolButton: Drop use of GtkMisc
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkToolButton: Drop use of GtkMisc
- Date: Sat, 24 May 2014 04:48:49 +0000 (UTC)
commit 1008e1541450a17d3a140cd50f086c4df167ec49
Author: Matthias Clasen <mclasen redhat com>
Date: Thu May 22 22:54:18 2014 -0400
GtkToolButton: Drop use of GtkMisc
Use h/valign instead of x/yalign.
https://bugzilla.gnome.org/show_bug.cgi?id=730613
gtk/gtktoolbutton.c | 64 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 43 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c
index bd218bb..5c2b73f 100644
--- a/gtk/gtktoolbutton.c
+++ b/gtk/gtktoolbutton.c
@@ -488,25 +488,33 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
text_orientation = gtk_tool_item_get_text_orientation (GTK_TOOL_ITEM (button));
if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
{
+ gfloat align;
+
gtk_label_set_angle (GTK_LABEL (label), 0);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_misc_set_alignment (GTK_MISC (label),
- gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)),
- 0.5);
-G_GNUC_END_IGNORE_DEPRECATIONS
+ align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
+ if (align < 0.4)
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ else if (align > 0.6)
+ gtk_widget_set_halign (label, GTK_ALIGN_END);
+ else
+ gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
}
else
{
+ gfloat align;
+
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);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_misc_set_alignment (GTK_MISC (label),
- 0.5,
- 1 - gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)));
-G_GNUC_END_IGNORE_DEPRECATIONS
+ align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
+ if (align < 0.4)
+ gtk_widget_set_valign (label, GTK_ALIGN_END);
+ else if (align > 0.6)
+ gtk_widget_set_valign (label, GTK_ALIGN_START);
+ else
+ gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
}
}
}
@@ -547,19 +555,33 @@ G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_show (icon);
}
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- if (GTK_IS_MISC (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 (GTK_IS_MISC (icon))
- gtk_misc_set_alignment (GTK_MISC (icon),
- 0.5,
- gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button)));
-G_GNUC_END_IGNORE_DEPRECATIONS
-
if (icon)
{
+ if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ gfloat align;
+
+ align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
+ if (align > 0.6)
+ gtk_widget_set_halign (icon, GTK_ALIGN_START);
+ else if (align < 0.4)
+ gtk_widget_set_halign (icon, GTK_ALIGN_END);
+ else
+ gtk_widget_set_halign (icon, GTK_ALIGN_CENTER);
+ }
+ else
+ {
+ gfloat align;
+
+ align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
+ if (align > 0.6)
+ gtk_widget_set_valign (icon, GTK_ALIGN_END);
+ else if (align < 0.4)
+ gtk_widget_set_valign (icon, GTK_ALIGN_START);
+ else
+ gtk_widget_set_valign (icon, GTK_ALIGN_CENTER);
+ }
+
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]