#58920: can't undo gtk_menu_item_right_justify()



Since I had the necesarry 5 minutes to implement this, here it is. OK to
check in?
(please note: the patch in Bugzilla doesn't include the changes to
gtk-demo)

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2211
diff -u -u -r1.2211 ChangeLog
--- ChangeLog	2001/08/25 03:15:25	1.2211
+++ ChangeLog	2001/08/25 14:59:43
@@ -1,3 +1,11 @@
+2001-08-25  ERDI Gergo  <cactus cactus rulez org>
+
+	* gtk/gtkmenuitem.c (gtk_menu_item_set_justification): fix for
+	(#58920)
+	(gtk_menu_item_get_justification): a getter to go with the setter
+
+	* gtk/gtkenums.h: new enumeration for menu item justifications
+
 Fri Aug 24 23:09:05 2001  Owen Taylor  <otaylor redhat com>
 
 	* gtk/gtkimage.[ch] docs/Changes-2.0.txt: Break compatibility 
Index: demos/gtk-demo/menus.c
===================================================================
RCS file: /cvs/gnome/gtk+/demos/gtk-demo/menus.c,v
retrieving revision 1.9
diff -u -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/25 14:59:44
@@ -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_justification (GTK_MENU_ITEM (menuitem), GTK_MENU_ITEM_JUSTIFY_RIGHT);
       gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
       gtk_widget_show (menuitem);
       
Index: gtk/gtkenums.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkenums.h,v
retrieving revision 1.43
diff -u -u -r1.43 gtkenums.h
--- gtk/gtkenums.h	2001/07/22 20:09:00	1.43
+++ gtk/gtkenums.h	2001/08/25 14:59:45
@@ -182,6 +182,13 @@
   GTK_MENU_DIR_PREV
 } GtkMenuDirectionType;
 
+/* Menu item text alignment */
+typedef enum
+{
+  GTK_MENU_ITEM_JUSTIFY_LEFT,
+  GTK_MENU_ITEM_JUSTIFY_RIGHT,
+} GtkMenuItemJustification;
+
 typedef enum
 {
   GTK_PIXELS,
Index: gtk/gtkitemfactory.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkitemfactory.c,v
retrieving revision 1.47
diff -u -u -r1.47 gtkitemfactory.c
--- gtk/gtkitemfactory.c	2001/08/04 12:48:16	1.47
+++ gtk/gtkitemfactory.c	2001/08/25 14:59:46
@@ -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_justification (GTK_MENU_ITEM (widget), GTK_MENU_ITEM_JUSTIFY_RIGHT);
       
       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 -u -r1.55 gtkmenuitem.c
--- gtk/gtkmenuitem.c	2001/08/25 02:20:33	1.55
+++ gtk/gtkmenuitem.c	2001/08/25 14:59:47
@@ -818,11 +818,21 @@
 }
 
 void
-gtk_menu_item_right_justify (GtkMenuItem *menuitem)
+gtk_menu_item_set_justification (GtkMenuItem              *menuitem,
+				 GtkMenuItemJustification  justification)
 {
   g_return_if_fail (GTK_IS_MENU_ITEM (menuitem));
 
-  menuitem->right_justify = 1;
+  menuitem->right_justify = (justification == GTK_MENU_ITEM_JUSTIFY_RIGHT);
+}
+
+GtkMenuItemJustification
+gtk_menu_item_get_justification (GtkMenuItem              *menuitem)
+{
+  g_return_if_fail (GTK_IS_MENU_ITEM (menuitem));
+
+  return menuitem->right_justify ?
+      GTK_MENU_ITEM_JUSTIFY_RIGHT : GTK_MENU_ITEM_JUSTIFY_LEFT;
 }
 
 
Index: gtk/gtkmenuitem.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenuitem.h,v
retrieving revision 1.18
diff -u -u -r1.18 gtkmenuitem.h
--- gtk/gtkmenuitem.h	2001/08/25 02:20:33	1.18
+++ gtk/gtkmenuitem.h	2001/08/25 14:59:47
@@ -86,26 +86,26 @@
 };
 
 
-GtkType	   gtk_menu_item_get_type	      (void) G_GNUC_CONST;
-GtkWidget* gtk_menu_item_new                  (void);
-GtkWidget* gtk_menu_item_new_with_label       (const gchar         *label);
-GtkWidget* gtk_menu_item_new_with_mnemonic    (const gchar         *label);
-void       gtk_menu_item_set_submenu          (GtkMenuItem         *menu_item,
-					       GtkWidget           *submenu);
-GtkWidget* gtk_menu_item_get_submenu          (GtkMenuItem         *menu_item);
-void       gtk_menu_item_remove_submenu       (GtkMenuItem         *menu_item);
-void       gtk_menu_item_set_placement        (GtkMenuItem         *menu_item,
-					       GtkSubmenuPlacement  placement);
-void       gtk_menu_item_select               (GtkMenuItem         *menu_item);
-void       gtk_menu_item_deselect             (GtkMenuItem         *menu_item);
-void       gtk_menu_item_activate             (GtkMenuItem         *menu_item);
-void       gtk_menu_item_toggle_size_request  (GtkMenuItem         *menu_item,
-					       gint                *requisition);
-void       gtk_menu_item_toggle_size_allocate (GtkMenuItem         *menu_item,
-					       gint                 allocation);
-void       gtk_menu_item_right_justify        (GtkMenuItem         *menu_item);
-
-
+GtkType	                 gtk_menu_item_get_type	            (void) G_GNUC_CONST;
+GtkWidget*               gtk_menu_item_new                  (void);
+GtkWidget*               gtk_menu_item_new_with_label       (const gchar              *label);
+GtkWidget*               gtk_menu_item_new_with_mnemonic    (const gchar              *label);
+void                     gtk_menu_item_set_submenu          (GtkMenuItem              *menu_item,
+							     GtkWidget                *submenu);
+GtkWidget*               gtk_menu_item_get_submenu          (GtkMenuItem              *menu_item);
+void                     gtk_menu_item_remove_submenu       (GtkMenuItem              *menu_item);
+void                     gtk_menu_item_set_placement        (GtkMenuItem              *menu_item,
+							     GtkSubmenuPlacement       placement);
+void                     gtk_menu_item_select               (GtkMenuItem              *menu_item);
+void                     gtk_menu_item_deselect             (GtkMenuItem              *menu_item);
+void                     gtk_menu_item_activate             (GtkMenuItem              *menu_item);
+void                     gtk_menu_item_toggle_size_request  (GtkMenuItem              *menu_item,
+							     gint                     *requisition);
+void                     gtk_menu_item_toggle_size_allocate (GtkMenuItem              *menu_item,
+							     gint                      allocation);
+void                     gtk_menu_item_set_justification    (GtkMenuItem              *menu_item,
+							     GtkMenuItemJustification  justification);
+GtkMenuItemJustification gtk_menu_item_get_justification    (GtkMenuItem              *menu_item);
 
 #ifdef __cplusplus
 }

-- 
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
One Tequila... Two Tequila... Three Tequila... Floor





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]