Re: #58920: can't undo gtk_menu_item_right_justify()
- From: Owen Taylor <otaylor redhat com>
- To: ERDI Gergo <cactus cactus rulez org>
- Cc: GTK+ development list <gtk-devel-list redhat com>
- Subject: Re: #58920: can't undo gtk_menu_item_right_justify()
- Date: 26 Aug 2001 20:51:42 -0400
ERDI Gergo <cactus cactus rulez org> writes:
> Since I had the necesarry 5 minutes to implement this, here it is. OK to
> check in?
Here's an improved version of the patch with some style fixes, docs,
and a change so that set_right_justified on a menu item already
in a menu should work.
I have two qualms about this patch in general:
* This really should be a child-property on GtkMenuBar -
gtk_menu_bar_set_child_right_justified(), though that would
cause slightly substantial code breakage than this rename.
* Right-justification of Help menu items is considered a bad
UI idea (noted in the docs below), so perhaps we should
have simply deprcated gtk_menu_item_right_justify() and
left it at that.
But, unless anybody strongly agrees with either of the above, I'm
going to go ahead and commit this.
Regards,
Owen
Index: demos/gtk-demo/menus.c
===================================================================
RCS file: /cvs/gnome/gtk+/demos/gtk-demo/menus.c,v
retrieving revision 1.9
diff -u -r1.9 menus.c
--- demos/gtk-demo/menus.c 2001/08/23 23:30:38 1.9
+++ demos/gtk-demo/menus.c 2001/08/27 00:42:47
@@ -128,7 +128,7 @@
menuitem = gtk_menu_item_new_with_label ("bar");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, TRUE));
- gtk_menu_item_right_justify (GTK_MENU_ITEM (menuitem));
+ gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
gtk_widget_show (menuitem);
Index: docs/Changes-2.0.txt
===================================================================
RCS file: /cvs/gnome/gtk+/docs/Changes-2.0.txt,v
retrieving revision 1.27
diff -u -r1.27 Changes-2.0.txt
--- docs/Changes-2.0.txt 2001/08/25 03:15:24 1.27
+++ docs/Changes-2.0.txt 2001/08/27 00:42:47
@@ -443,6 +443,14 @@
- For NO_WINDOW widgets, if you create windows in your realize()
method, you must map then in map() and unmap them in unmap().
+* gtk_widget_set_default_style (), gtk_widget_push_style (),
+ and gtk_widget_pop_style () have been removed, since they
+ did not work properly with themes and there were better
+ alternatives for modifying the appearance of widgets.
+
+ You should generally use gtk_widget_modify_fg/bg/base/text/font
+ instead.
+
* gtk_image_new() now takes no arguments and creates an empty GtkImage
widget. To create a GtkImage widget from a GdkImage (the least
- common usage of GdkImage), use gtk_image_new_from_image.
\ No newline at end of file
+ common usage of GdkImage), use gtk_image_new_from_image.
Index: gtk/gtkitemfactory.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkitemfactory.c,v
retrieving revision 1.47
diff -u -r1.47 gtkitemfactory.c
--- gtk/gtkitemfactory.c 2001/08/04 12:48:16 1.47
+++ gtk/gtkitemfactory.c 2001/08/27 00:42:48
@@ -1288,7 +1288,7 @@
entry->path);
if (type_id == quark_type_last_branch)
- gtk_menu_item_right_justify (GTK_MENU_ITEM (widget));
+ gtk_menu_item_set_right_justified (GTK_MENU_ITEM (widget), TRUE);
parent = widget;
widget = gtk_widget_new (GTK_TYPE_MENU,
Index: gtk/gtkmenuitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenuitem.c,v
retrieving revision 1.55
diff -u -r1.55 gtkmenuitem.c
--- gtk/gtkmenuitem.c 2001/08/25 02:20:33 1.55
+++ gtk/gtkmenuitem.c 2001/08/27 00:42:48
@@ -817,12 +817,49 @@
*y = ty;
}
+/**
+ * gtk_menu_item_set_right_justified:
+ * @menu_item: a #GtkMenuItem.
+ * @right_justified: if %TRUE the menu item will appear at the
+ * far right if added to a menu bar.
+ *
+ * Sets whether the menu item appears justified at the right
+ * side of a menu bar. This was traditionally done for "Help" menu
+ * items, but is now considered a bad idea. (If the widget
+ * layout is reversed for a right-to-left language like Hebrew
+ * or Arabic, right-justified-menu-items appear at the left.)
+ **/
void
-gtk_menu_item_right_justify (GtkMenuItem *menuitem)
+gtk_menu_item_set_right_justified (GtkMenuItem *menu_item,
+ gboolean right_justified)
{
g_return_if_fail (GTK_IS_MENU_ITEM (menuitem));
- menuitem->right_justify = 1;
+ right_justified = right_justified != FALSE;
+
+ if (right_justified != menu_item->right_justified)
+ {
+ menuitem->right_justify = right_justified;
+ gtk_widget_queue_resize (GTK_MENU_ITEM (menu_item));
+ }
+}
+
+/**
+ * gtk_menu_item_get_right_justified:
+ * @menu_item: a #GtkMenuItem
+ *
+ * Gets whether the menu item appears justified at the right
+ * side of the menu bar.
+ *
+ * Return value: %TRUE if the menu item will appear at the
+ * far right if added to a menu bar.
+ **/
+gboolean
+gtk_menu_item_get_right_justified (GtkMenuItem *menu_item)
+{
+ g_return_val_if_fail (GTK_IS_MENU_ITEM (menuitem), FALSE);
+
+ return menuitem->right_justify;
}
Index: gtk/gtkmenuitem.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenuitem.h,v
retrieving revision 1.18
diff -u -r1.18 gtkmenuitem.h
--- gtk/gtkmenuitem.h 2001/08/25 02:20:33 1.18
+++ gtk/gtkmenuitem.h 2001/08/27 00:42:48
@@ -103,9 +103,13 @@
gint *requisition);
void gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
gint allocation);
-void gtk_menu_item_right_justify (GtkMenuItem *menu_item);
+void gtk_menu_item_set_right_justified (GtkMenuItem *menu_item,
+ gboolean right_justified);
+gboolean gtk_menu_item_get_right_justified (GtkMenuItem *menu_item);
-
+#ifndef GTK_DISABLE_DEPRECATED
+#define gtk_menu_item_right_justify(menu_item) gtk_menu_item_set_right_justified ((menu_item), TRUE)
+#endif /* GTK_DISABLE_DEPRECATED */
#ifdef __cplusplus
}
Index: tests/testgtk.c
===================================================================
RCS file: /cvs/gnome/gtk+/tests/testgtk.c,v
retrieving revision 1.273
diff -u -r1.273 testgtk.c
--- tests/testgtk.c 2001/08/26 22:23:28 1.273
+++ tests/testgtk.c 2001/08/27 00:42:51
@@ -2864,7 +2864,7 @@
menuitem = gtk_image_menu_item_new_with_label ("Help");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, 5, TRUE));
- gtk_menu_item_right_justify (GTK_MENU_ITEM (menuitem));
+ gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
gtk_widget_show (menuitem);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]