summaryrefslogtreecommitdiff
path: root/gtk/gtkwindow.c
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-06-07 06:48:56 +0000
committerTim Janik <timj@src.gnome.org>1998-06-07 06:48:56 +0000
commita391196ba51da34253593712e8bf4552c04f19e5 (patch)
tree50c2edfc5d066467f3c33c1f82c89dd9923c44c4 /gtk/gtkwindow.c
parentf522f36dd1c484b133ba6b04027667aa9144ad04 (diff)
downloadgtk+-a391196ba51da34253593712e8bf4552c04f19e5.tar.gz
fixed an assertment.
Sat Jun 6 06:01:24 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_emitv): fixed an assertment. * gtk/makeenums.awk: a script to generate the GtkEnumValue arrays from, this should eventually be done by gentypeinfo.el somewhen. * gtk/gtkenumvalues.c: new generated file to hold GtkEnumValue arrays. * gtk/gtktypeutils.h: new function gtk_enum_values() to retrive all the enum values of an enum type. * gtk/gtk.defs: * gtk/gtkcurve.h: * gtk/gtkobject.h: * gtk/gtkprivate.h: * gtk/gtkwidget.h: * gtk/gtkenums.h: brought enum/flags definitions in sync, added a few more enum definitions for bindings and pattern matching. * some more macro and GtkType fixups in various places. * gdk/gdktypes.h (enum): added a new value GDK_AFTER_MASK, which is used as a key-release modifier for the binding system. Fri Jun 5 06:06:06 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenu.h (struct _GtkMenu): removed GList*children, since it was a stale list pointer that is already present in GtkMenuShell. * gtk/gtkmenushell.h (struct _GtkMenuShellClass): added a signal GtkMenuShell::selection_done which is emitted after the menu shell poped down again and all possible menu items have been activated. Thu Jun 4 02:20:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_menu_shell_button_release): flush the x-queue before activation of the menuitem, so the menu is actually taken off the screen prior to any menu item activation. * gtk/gtkctree.c (gtk_ctree_get_row_data): allow function invokation for NULL nodes. * gtk/gtkwidget.h: * gtk/gtkwidget.c: new function gtk_widget_stop_accelerator to stop the emission of the "add-accelerator" signal on a widget. this is usefull to prevent accelerator installation on certain widgets. * gtk/gtknotebook.c (gtk_notebook_menu_item_create): keep the menu labels left justified, by setting their alignment. stop accelerator installation for the menu items, since we use dynamic menus. Wed Jun 3 06:41:22 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenufactory.c: adaptions to use the new accel groups. people should *really* use GtkItemFactory. this is only for preserving source compatibility where possible, use of GtkMenuFactory is deprecated as of now. * gtk/gtkobject.h (gtk_object_class_add_user_signal): new function to create user signals of type GTK_RUN_NO_RECURSE. don't know why i missed this possibility when i added gtk_object_class_add_user_signal in late january. * gtk/gtkmain.c (gtk_init): ignore subsequent function calls. Sun May 31 07:31:09 1998 Tim Janik <timj@gtk.org> * gtk/gtkaccelgroup.h: * gtk/gtkaccelgroup.c: new implementation of the accelerator concept. * gtk/gtkaccellabel.h: * gtk/gtkaccellabel.c: new widget derived from GtkLabel whitch features display of the accelerators associated with a certain widget. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: new widget, item factory with automatic rc parsing and accelerator handling. * gtk/gtkmenu.c (gtk_menu_reposition): new function to care for positioning a menu. (gtk_menu_map): removed the allocation code. (gtk_menu_size_allocate): care for redrawing of children and resize our widget->window correctly. (gtk_menu_key_press): feature the new accelerator groups. * gtk/gtkmenuitem.c (gtk_menu_item_size_allocate): reposition the submenu if neccessary. * gtk/gtkmenuitem.c: * gtk/gtkcheckmenuitem.c: * gtk/gtkradiomenuitem.c: use GtkAccelLabel in the *_new_with_label() function variants. * gdk/gdk.c: (gdk_keyval_from_name): (gdk_keyval_name): new functions for keyval<->key-name associations. (gdk_keyval_to_upper): (gdk_keyval_to_lower): (gdk_keyval_is_upper): (gdk_keyval_is_lower): new functions to check/translate keyvalues with regards to their cases. Wed May 27 00:48:10 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_class_path): new function to calculate a widget's class path. (gtk_widget_path): new function to calculate a widget's name path. * gtk/gtkrc.c: newly introduced GtkPatternSpec structures to speed up pattern matching, features reversed pattern matches.
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r--gtk/gtkwindow.c117
1 files changed, 40 insertions, 77 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c618097d03..0af3fe0b79 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -25,6 +25,7 @@
#include "gtkrc.h"
#include "gtksignal.h"
#include "gtkwindow.h"
+#include "gtkbindings.h"
enum {
MOVE_RESIZE,
@@ -107,9 +108,6 @@ static void gtk_real_window_set_focus (GtkWindow *window,
static gint gtk_window_move_resize (GtkWidget *widget);
static void gtk_window_set_hints (GtkWidget *widget,
GtkRequisition *requisition);
-static gint gtk_window_check_accelerator (GtkWindow *window,
- gint key,
- guint mods);
static void gtk_window_read_rcfiles (GtkWidget *widget,
GdkEventClient *event);
@@ -220,7 +218,6 @@ gtk_window_init (GtkWindow *window)
window->wmclass_name = g_strdup (gdk_progname);
window->wmclass_class = g_strdup (gdk_progclass);
window->type = GTK_WINDOW_TOPLEVEL;
- window->accelerator_tables = NULL;
window->focus_widget = NULL;
window->default_widget = NULL;
window->resize_count = 0;
@@ -397,38 +394,25 @@ gtk_window_set_policy (GtkWindow *window,
}
void
-gtk_window_add_accelerator_table (GtkWindow *window,
- GtkAcceleratorTable *table)
+gtk_window_add_accel_group (GtkWindow *window,
+ GtkAccelGroup *accel_group)
{
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (table != NULL);
+ g_return_if_fail (accel_group != NULL);
- gtk_accelerator_table_ref (table);
- window->accelerator_tables = g_list_prepend (window->accelerator_tables,
- table);
+ gtk_accel_group_attach (accel_group, GTK_OBJECT (window));
}
void
-gtk_window_remove_accelerator_table (GtkWindow *window,
- GtkAcceleratorTable *table)
+gtk_window_remove_accel_group (GtkWindow *window,
+ GtkAccelGroup *accel_group)
{
- GList *list;
-
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (table != NULL);
+ g_return_if_fail (accel_group != NULL);
- for (list = window->accelerator_tables; list; list = list->next)
- {
- if (list->data == table)
- {
- gtk_accelerator_table_unref (table);
- window->accelerator_tables = g_list_remove_link (window->accelerator_tables, list);
- g_list_free_1 (list);
- break;
- }
- }
+ gtk_accel_group_detach (accel_group, GTK_OBJECT (window));
}
void
@@ -507,18 +491,11 @@ gtk_window_marshal_signal_2 (GtkObject *object,
static void
gtk_window_destroy (GtkObject *object)
{
- GList *list;
-
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_WINDOW (object));
gtk_container_unregister_toplevel (GTK_CONTAINER (object));
- for (list = GTK_WINDOW (object)->accelerator_tables; list; list = list->next)
- gtk_accelerator_table_unref (list->data);
- g_list_free (GTK_WINDOW (object)->accelerator_tables);
- GTK_WINDOW (object)->accelerator_tables = NULL;
-
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -765,7 +742,7 @@ gtk_window_key_press_event (GtkWidget *widget,
{
GtkWindow *window;
GtkDirectionType direction = 0;
- gint return_val;
+ gboolean handled;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
@@ -773,14 +750,21 @@ gtk_window_key_press_event (GtkWidget *widget,
window = GTK_WINDOW (widget);
- return_val = FALSE;
+ handled = FALSE;
+
if (window->focus_widget)
- return_val = gtk_widget_event (window->focus_widget, (GdkEvent*) event);
+ {
+ handled = gtk_widget_event (window->focus_widget, (GdkEvent*) event);
- if (!return_val && gtk_window_check_accelerator (window, event->keyval, event->state))
- return_val = TRUE;
+ if (!handled)
+ handled = gtk_bindings_activate (GTK_OBJECT (window->focus_widget),
+ event->keyval, event->state);
+ }
+
+ if (!handled)
+ handled = gtk_accel_groups_activate (GTK_OBJECT (window), event->keyval, event->state);
- if (!return_val)
+ if (!handled)
{
switch (event->keyval)
{
@@ -788,7 +772,7 @@ gtk_window_key_press_event (GtkWidget *widget,
if (window->focus_widget)
{
gtk_widget_activate (window->focus_widget);
- return_val = TRUE;
+ handled = TRUE;
}
break;
case GDK_Return:
@@ -796,12 +780,12 @@ gtk_window_key_press_event (GtkWidget *widget,
if (window->default_widget)
{
gtk_widget_activate (window->default_widget);
- return_val = TRUE;
+ handled = TRUE;
}
else if (window->focus_widget)
{
gtk_widget_activate (window->focus_widget);
- return_val = TRUE;
+ handled = TRUE;
}
break;
case GDK_Up:
@@ -840,12 +824,12 @@ gtk_window_key_press_event (GtkWidget *widget,
if (!GTK_CONTAINER (window)->focus_child)
gtk_window_set_focus (GTK_WINDOW (widget), NULL);
else
- return_val = TRUE;
+ handled = TRUE;
break;
}
}
- return return_val;
+ return handled;
}
static gint
@@ -853,18 +837,24 @@ gtk_window_key_release_event (GtkWidget *widget,
GdkEventKey *event)
{
GtkWindow *window;
- gint return_val;
-
+ gint handled;
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
window = GTK_WINDOW (widget);
- return_val = FALSE;
+ handled = FALSE;
if (window->focus_widget)
- return_val = gtk_widget_event (window->focus_widget, (GdkEvent*) event);
-
- return return_val;
+ {
+ handled = gtk_widget_event (window->focus_widget, (GdkEvent*) event);
+
+ if (!handled)
+ handled = gtk_bindings_activate (GTK_OBJECT (window->focus_widget),
+ event->keyval, event->state | GDK_AFTER_MASK);
+ }
+
+ return handled;
}
static gint
@@ -1320,30 +1310,3 @@ gtk_window_set_hints (GtkWidget *widget,
}
}
}
-
-static gint
-gtk_window_check_accelerator (GtkWindow *window,
- gint key,
- guint mods)
-{
- GtkAcceleratorTable *table;
- GList *tmp;
-
- if ((key >= 0x20) && (key <= 0xFF))
- {
- tmp = window->accelerator_tables;
- while (tmp)
- {
- table = tmp->data;
- tmp = tmp->next;
-
- if (gtk_accelerator_table_check (table, key, mods))
- return TRUE;
- }
-
- if (gtk_accelerator_table_check (NULL, key, mods))
- return TRUE;
- }
-
- return FALSE;
-}