[George <jirka 5z com>] [jirka 5z com: new version of the default patch]
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list redhat com
- Subject: [George <jirka@5z.com>] [jirka@5z.com: new version of the default patch]
- Date: 21 Jan 1999 13:13:13 -0500
Date: Thu, 21 Jan 1999 02:02:39 -0800
From: George <jirka@5z.com>
To: otaylor@redhat.com, gnome-hackers@nuclecu.unam.mx,
gtk-devel-list@redhat.com
Subject: new version of the default patch
ok here's an updated version of the patch adressing the ugly if statement
issue and has the migration of the HAS_DEFAULT flag ... and adds gtkplug
fix for defaults ... it seems to work fine for me
[Owen: I sent it to you as well, if it doesn't make it to the
gtk-devel-list for some reason again, can you forward it??]
George
--
------------------------------------------------------------------------------
George Lebl <jirka@5z.com> http://www.5z.com/jirka/
------------------------------------------------------------------------------
The following implements RSA in perl and is illegal to export from the US:
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="def2.patch"
? allocation.y
Index: gtkbutton.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkbutton.c,v
retrieving revision 1.37
diff -u -r1.37 gtkbutton.c
--- gtkbutton.c 1999/01/14 06:04:32 1.37
+++ gtkbutton.c 1999/01/21 09:41:46
@@ -205,7 +205,7 @@
static void
gtk_button_init (GtkButton *button)
{
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS | GTK_RECEIVES_DEFAULT);
GTK_WIDGET_UNSET_FLAGS (button, GTK_NO_WINDOW);
button->child = NULL;
@@ -540,6 +540,7 @@
gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
if (GTK_WIDGET_HAS_DEFAULT (widget) &&
+ GTK_WIDGET_CAN_DEFAULT (widget) &&
GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL)
{
gtk_paint_box (widget->style, widget->window,
Index: gtkcheckbutton.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcheckbutton.c,v
retrieving revision 1.17
diff -u -r1.17 gtkcheckbutton.c
--- gtkcheckbutton.c 1999/01/15 16:00:13 1.17
+++ gtkcheckbutton.c 1999/01/21 09:41:47
@@ -95,6 +95,7 @@
gtk_check_button_init (GtkCheckButton *check_button)
{
GTK_WIDGET_SET_FLAGS (check_button, GTK_NO_WINDOW);
+ GTK_WIDGET_UNSET_FLAGS (check_button, GTK_RECEIVES_DEFAULT);
GTK_TOGGLE_BUTTON (check_button)->draw_indicator = TRUE;
}
Index: gtkoptionmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkoptionmenu.c,v
retrieving revision 1.22
diff -u -r1.22 gtkoptionmenu.c
--- gtkoptionmenu.c 1998/12/22 20:55:30 1.22
+++ gtkoptionmenu.c 1999/01/21 09:41:47
@@ -131,7 +131,7 @@
gtk_option_menu_init (GtkOptionMenu *option_menu)
{
GTK_WIDGET_SET_FLAGS (option_menu, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (option_menu, GTK_CAN_DEFAULT);
+ GTK_WIDGET_UNSET_FLAGS (option_menu, GTK_CAN_DEFAULT | GTK_RECEIVES_DEFAULT);
option_menu->menu = NULL;
option_menu->menu_item = NULL;
Index: gtkplug.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkplug.c,v
retrieving revision 1.3
diff -u -r1.3 gtkplug.c
--- gtkplug.c 1998/11/30 19:06:30 1.3
+++ gtkplug.c 1999/01/21 09:41:47
@@ -204,7 +204,9 @@
break;
case GDK_Return:
case GDK_KP_Enter:
- if (window->default_widget)
+ if (window->default_widget &&
+ (!window->focus_widget ||
+ !GTK_WIDGET_RECEIVES_DEFAULT (window->focus_widget)))
{
gtk_widget_activate (window->default_widget);
return_val = TRUE;
Index: gtkradiobutton.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkradiobutton.c,v
retrieving revision 1.17
diff -u -r1.17 gtkradiobutton.c
--- gtkradiobutton.c 1999/01/12 15:12:09 1.17
+++ gtkradiobutton.c 1999/01/21 09:41:47
@@ -99,6 +99,7 @@
gtk_radio_button_init (GtkRadioButton *radio_button)
{
GTK_WIDGET_SET_FLAGS (radio_button, GTK_NO_WINDOW);
+ GTK_WIDGET_UNSET_FLAGS (radio_button, GTK_RECEIVES_DEFAULT);
radio_button->group = g_slist_prepend (NULL, radio_button);
}
Index: gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.135
diff -u -r1.135 gtkwidget.c
--- gtkwidget.c 1999/01/17 23:12:16 1.135
+++ gtkwidget.c 1999/01/21 09:41:47
@@ -107,6 +107,7 @@
ARG_HAS_FOCUS,
ARG_CAN_DEFAULT,
ARG_HAS_DEFAULT,
+ ARG_RECEIVES_DEFAULT,
ARG_COMPOSITE_CHILD,
ARG_STYLE,
ARG_EVENTS,
@@ -276,6 +277,7 @@
gtk_object_add_arg_type ("GtkWidget::has_focus", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HAS_FOCUS);
gtk_object_add_arg_type ("GtkWidget::can_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CAN_DEFAULT);
gtk_object_add_arg_type ("GtkWidget::has_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HAS_DEFAULT);
+ gtk_object_add_arg_type ("GtkWidget::receives_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_RECEIVES_DEFAULT);
gtk_object_add_arg_type ("GtkWidget::composite_child", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_COMPOSITE_CHILD);
gtk_object_add_arg_type ("GtkWidget::style", GTK_TYPE_STYLE, GTK_ARG_READWRITE, ARG_STYLE);
gtk_object_add_arg_type ("GtkWidget::events", GTK_TYPE_GDK_EVENT_MASK, GTK_ARG_READWRITE, ARG_EVENTS);
@@ -838,6 +840,12 @@
if (GTK_VALUE_BOOL (*arg))
gtk_widget_grab_default (widget);
break;
+ case ARG_RECEIVES_DEFAULT:
+ if (GTK_VALUE_BOOL (*arg))
+ GTK_WIDGET_SET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+ break;
case ARG_COMPOSITE_CHILD:
if (GTK_VALUE_BOOL(*arg))
GTK_WIDGET_SET_FLAGS (widget, GTK_COMPOSITE_CHILD);
@@ -939,6 +947,9 @@
break;
case ARG_HAS_DEFAULT:
GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_HAS_DEFAULT (widget) != FALSE);
+ break;
+ case ARG_RECEIVES_DEFAULT:
+ GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_RECEIVES_DEFAULT (widget) != FALSE);
break;
case ARG_COMPOSITE_CHILD:
GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE);
Index: gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.57
diff -u -r1.57 gtkwidget.h
--- gtkwidget.h 1999/01/17 23:12:18 1.57
+++ gtkwidget.h 1999/01/21 09:41:48
@@ -51,7 +51,8 @@
GTK_RC_STYLE = 1 << 16,
GTK_COMPOSITE_CHILD = 1 << 17,
GTK_NO_REPARENT = 1 << 18,
- GTK_APP_PAINTABLE = 1 << 19
+ GTK_APP_PAINTABLE = 1 << 19,
+ GTK_RECEIVES_DEFAULT = 1 << 20
} GtkWidgetFlags;
/* Macro for casting a pointer to a GtkWidget or GtkWidgetClass pointer.
@@ -90,6 +91,7 @@
#define GTK_WIDGET_RC_STYLE(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_RC_STYLE) != 0)
#define GTK_WIDGET_COMPOSITE_CHILD(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_COMPOSITE_CHILD) != 0)
#define GTK_WIDGET_APP_PAINTABLE(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_APP_PAINTABLE) != 0)
+#define GTK_WIDGET_RECEIVES_DEFAULT(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_RECEIVES_DEFAULT) != 0)
/* Macros for setting and clearing widget flags.
*/
Index: gtkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.c,v
retrieving revision 1.65
diff -u -r1.65 gtkwindow.c
--- gtkwindow.c 1999/01/11 12:22:51 1.65
+++ gtkwindow.c 1999/01/21 09:41:48
@@ -1033,7 +1033,9 @@
break;
case GDK_Return:
case GDK_KP_Enter:
- if (window->default_widget)
+ if (window->default_widget &&
+ (!window->focus_widget ||
+ !GTK_WIDGET_RECEIVES_DEFAULT (window->focus_widget)))
{
gtk_widget_activate (window->default_widget);
handled = TRUE;
@@ -1494,16 +1496,31 @@
GtkWidget *focus)
{
GdkEventFocus event;
+ gboolean def_flags = 0;
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
-
+
+ if (window->default_widget)
+ def_flags = GTK_WIDGET_HAS_DEFAULT (window->default_widget);
+
if (window->focus_widget)
{
event.type = GDK_FOCUS_CHANGE;
event.window = window->focus_widget->window;
event.in = FALSE;
+ if (GTK_WIDGET_HAS_DEFAULT (window->focus_widget) &&
+ window->focus_widget != window->default_widget)
+ {
+ GTK_WIDGET_UNSET_FLAGS (window->focus_widget, GTK_HAS_DEFAULT);
+ /* if any widget had the default set there should be
+ a default_widget, but might not so this is a sanity
+ check */
+ if (window->default_widget)
+ GTK_WIDGET_SET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+ }
+
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
}
@@ -1514,9 +1531,31 @@
event.type = GDK_FOCUS_CHANGE;
event.window = window->focus_widget->window;
event.in = TRUE;
+
+ if (window->default_widget)
+ {
+ if (GTK_WIDGET_RECEIVES_DEFAULT (window->focus_widget) &&
+ window->focus_widget != window->default_widget)
+ {
+ GTK_WIDGET_SET_FLAGS (window->focus_widget, GTK_HAS_DEFAULT);
+ GTK_WIDGET_UNSET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+ }
+ else
+ {
+ GTK_WIDGET_SET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+ }
+ }
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
}
+ else if (window->default_widget)
+ {
+ GTK_WIDGET_SET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+ }
+
+ if (window->default_widget &&
+ def_flags != GTK_WIDGET_FLAGS (window->default_widget))
+ gtk_widget_queue_draw (window->default_widget);
}
static void
--6c2NcOVqGQ03X4Wi--
------- End of forwarded message -------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]