Re: patch #59456, #59456-2, #64977 -- menu stuff
- From: Kristian Rietveld <kristian planet nl>
- To: Owen Taylor <otaylor redhat com>
- Cc: GTK Development list <gtk-devel-list gnome org>
- Subject: Re: patch #59456, #59456-2, #64977 -- menu stuff
- Date: 28 Nov 2001 23:39:56 +0100
On Wed, 2001-11-28 at 20:45, Owen Taylor wrote:
>
> Kristian Rietveld <kristian planet nl> writes:
>
> > Hi all,
> >
> > This patch implements some GtkMenu stuff, which makes the menu work
> > somewhat saner. ChangeLog has been appended, patch has been attached.
>
> Looks good, with a few comments below.
>
Okay, new try.
regards,
Kris
Wed Nov 28 23:37:12 2001 Kristian Rietveld <kristian planet nl>
* gtk/gtkmenu.c (gtk_menu_motion_notify): add checks for
empty menu items to behave like insensitive items (#59456)
* gtk/gtkmenuitem.c (gtk_real_menu_item_activate_item): select
next item if the first item in the menu is a tear off item
(#59456-2, suggestion by Matthias Clasen)
* gtk/gtkmenushell.c (gtk_menu_shell_button_press),
(gtk_menu_shell_button_release), (gtk_menu_shell_entry_notify),
(gtk_menu_shell_leave_notify),
(gtk_real_menu_shell_move_current),
(gtk_real_menu_shell_activate_current): add check, so empty
menu items behave like insensitive items (#59456)
* gtk/gtkmenuitem.[ch]: add _gtk_menu_item_is_selectable to make
the checks more readable ...
* gtk/gtkmenushell.c (gtk_menu_shell_button_press),
(gtk_menu_shell_button_release): causes the menu to dropdown if
the
caption is clicked again (#64977)
Index: gtkmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenu.c,v
retrieving revision 1.76
diff -u -r1.76 gtkmenu.c
--- gtkmenu.c 2001/11/20 23:43:02 1.76
+++ gtkmenu.c 2001/11/28 22:29:15
@@ -1716,7 +1716,8 @@
* which may be different from 'widget'.
*/
menu_item = gtk_get_event_widget ((GdkEvent*) event);
- if (!menu_item || !GTK_IS_MENU_ITEM (menu_item) || !GTK_WIDGET_IS_SENSITIVE (menu_item) ||
+ if (!menu_item || !GTK_IS_MENU_ITEM (menu_item) ||
+ !_gtk_menu_item_is_selectable (menu_item) ||
!GTK_IS_MENU (menu_item->parent))
return FALSE;
Index: gtkmenuitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenuitem.c,v
retrieving revision 1.62
diff -u -r1.62 gtkmenuitem.c
--- gtkmenuitem.c 2001/11/17 23:28:50 1.62
+++ gtkmenuitem.c 2001/11/28 22:29:16
@@ -31,6 +31,8 @@
#include "gtkmenu.h"
#include "gtkmenubar.h"
#include "gtkmenuitem.h"
+#include "gtktearoffmenuitem.h"
+#include "gtkseparatormenuitem.h"
#include "gtksignal.h"
@@ -757,7 +759,13 @@
submenu = GTK_MENU_SHELL (menu_item->submenu);
if (submenu->children)
- gtk_menu_shell_select_item (submenu, submenu->children->data);
+ {
+ if (submenu->children->next &&
+ GTK_IS_TEAROFF_MENU_ITEM (submenu->children->data))
+ gtk_menu_shell_select_item (submenu, submenu->children->next->data);
+ else
+ gtk_menu_shell_select_item (submenu, submenu->children->data);
+ }
}
}
}
@@ -1102,4 +1110,17 @@
if (bin->child)
callback (bin->child, callback_data);
+}
+
+gboolean
+_gtk_menu_item_is_selectable (GtkWidget *menu_item)
+{
+ if ((!GTK_BIN (menu_item)->child &&
+ G_OBJECT_TYPE (menu_item) == GTK_TYPE_MENU_ITEM) ||
+ GTK_IS_SEPARATOR_MENU_ITEM (menu_item) ||
+ !GTK_WIDGET_IS_SENSITIVE (menu_item) ||
+ !GTK_WIDGET_VISIBLE (menu_item))
+ return FALSE;
+
+ return TRUE;
}
Index: gtkmenuitem.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenuitem.h,v
retrieving revision 1.22
diff -u -r1.22 gtkmenuitem.h
--- gtkmenuitem.h 2001/11/16 15:20:27 1.22
+++ gtkmenuitem.h 2001/11/28 22:29:16
@@ -110,10 +110,12 @@
void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,
const gchar *accel_path);
+/* private */
void _gtk_menu_item_refresh_accel_path (GtkMenuItem *menu_item,
const gchar *prefix,
GtkAccelGroup *accel_group,
gboolean group_changed);
+gboolean _gtk_menu_item_is_selectable (GtkWidget *menu_item);
#ifndef GTK_DISABLE_DEPRECATED
#define gtk_menu_item_right_justify(menu_item) gtk_menu_item_set_right_justified ((menu_item), TRUE)
Index: gtkmenushell.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenushell.c,v
retrieving revision 1.49
diff -u -r1.49 gtkmenushell.c
--- gtkmenushell.c 2001/11/24 21:05:10 1.49
+++ gtkmenushell.c 2001/11/28 22:29:17
@@ -29,7 +29,6 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkmenuitem.h"
-#include "gtktearoffmenuitem.h" /* FIXME */
#include "gtkmenushell.h"
#include "gtksignal.h"
#include "gtkwindow.h"
@@ -411,12 +410,17 @@
menu_item = gtk_menu_shell_get_item (menu_shell, (GdkEvent *)event);
- if (menu_item &&
- GTK_WIDGET_IS_SENSITIVE (menu_item))
+ if (menu_item && _gtk_menu_item_is_selectable (menu_item))
{
if ((menu_item->parent == widget) &&
(menu_item != menu_shell->active_menu_item))
- gtk_menu_shell_select_item (menu_shell, menu_item);
+ {
+ if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement == GTK_TOP_BOTTOM)
+ g_object_set_data (G_OBJECT (menu_shell),
+ "gtk-menushell-just-activated",
+ GUINT_TO_POINTER (1));
+ gtk_menu_shell_select_item (menu_shell, menu_item);
+ }
}
}
else
@@ -452,16 +456,30 @@
if (menu_shell->parent_menu_shell)
return gtk_widget_event (menu_shell->parent_menu_shell, (GdkEvent*) event);
}
-
+
menu_shell->button = 0;
menu_item = gtk_menu_shell_get_item (menu_shell, (GdkEvent*) event);
deactivate = TRUE;
+ if (menu_item
+ && GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement == GTK_TOP_BOTTOM)
+ {
+ if (g_object_get_data (G_OBJECT (menu_shell), "gtk-menushell-just-activated"))
+ {
+ g_object_set_data (G_OBJECT (menu_shell), "gtk-menushell-just-activated", NULL);
+ }
+ else
+ {
+ gtk_menu_shell_deactivate (menu_shell);
+ return TRUE;
+ }
+ }
+
if ((event->time - menu_shell->activate_time) > MENU_SHELL_TIMEOUT)
{
if (menu_item && (menu_shell->active_menu_item == menu_item) &&
- GTK_WIDGET_IS_SENSITIVE (menu_item))
+ _gtk_menu_item_is_selectable (menu_item))
{
if (GTK_MENU_ITEM (menu_item)->submenu == NULL)
{
@@ -469,7 +487,7 @@
return TRUE;
}
}
- else if (menu_item && !GTK_WIDGET_IS_SENSITIVE (menu_item))
+ else if (menu_item && !_gtk_menu_item_is_selectable (menu_item))
deactivate = FALSE;
else if (menu_shell->parent_menu_shell)
{
@@ -562,7 +580,9 @@
{
menu_item = gtk_get_event_widget ((GdkEvent*) event);
- if (!menu_item || !GTK_WIDGET_IS_SENSITIVE (menu_item))
+ if (!menu_item ||
+ (GTK_IS_MENU_ITEM (menu_item) &&
+ !_gtk_menu_item_is_selectable (menu_item)))
return TRUE;
if ((menu_item->parent == widget) &&
@@ -614,7 +634,7 @@
return TRUE;
}
- if (!GTK_WIDGET_IS_SENSITIVE (menu_item))
+ if (!_gtk_menu_item_is_selectable (event_widget))
return TRUE;
if ((menu_shell->active_menu_item == event_widget) &&
@@ -785,7 +805,7 @@
GtkWidget *menu_item)
{
gtk_menu_shell_deselect (menu_shell);
-
+
menu_shell->active_menu_item = menu_item;
_gtk_menu_item_set_placement (GTK_MENU_ITEM (menu_shell->active_menu_item),
GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement);
@@ -874,9 +894,7 @@
{
node = node->next;
while (node != start_node &&
- (!node ||
- !GTK_WIDGET_IS_SENSITIVE (node->data) ||
- !GTK_WIDGET_VISIBLE (node->data) ))
+ (!node || !_gtk_menu_item_is_selectable (node->data)))
{
if (!node)
node = menu_shell->children;
@@ -888,9 +906,7 @@
{
node = node->prev;
while (node != start_node &&
- (!node ||
- !GTK_WIDGET_IS_SENSITIVE (node->data) ||
- !GTK_WIDGET_VISIBLE (node->data) ))
+ (!node || !_gtk_menu_item_is_selectable (node->data)))
{
if (!node)
node = g_list_last (menu_shell->children);
@@ -949,7 +965,7 @@
case GTK_MENU_DIR_CHILD:
if (menu_shell->active_menu_item &&
- GTK_BIN (menu_shell->active_menu_item)->child &&
+ _gtk_menu_item_is_selectable (menu_shell->active_menu_item) &&
GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu)
{
menu_shell = GTK_MENU_SHELL (GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu);
@@ -995,7 +1011,7 @@
gboolean force_hide)
{
if (menu_shell->active_menu_item &&
- GTK_WIDGET_IS_SENSITIVE (menu_shell->active_menu_item) &&
+ _gtk_menu_item_is_selectable (menu_shell->active_menu_item) &&
GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL)
{
gtk_menu_shell_activate_item (menu_shell,
@@ -1014,4 +1030,3 @@
gtk_menu_shell_deactivate (menu_shell);
gtk_signal_emit (GTK_OBJECT (menu_shell), menu_shell_signals[SELECTION_DONE]);
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]