gtk2/gtk/gtkinputdialog.c

689 lines
20 KiB
C
Raw Normal View History

1997-11-24 22:37:52 +00:00
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
1997-11-24 22:37:52 +00:00
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
1997-11-24 22:37:52 +00:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
1997-11-24 22:37:52 +00:00
*/
/*
* gtkinputdialog.c
*
* Copyright 1997 Owen Taylor <owt1@cornell.edu>
*
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
1997-11-24 22:37:52 +00:00
#include <stdio.h>
#include <stdlib.h>
#include "gdk/gdkkeysyms.h"
#include "gtkbutton.h"
#include "gtkentry.h"
1997-11-24 22:37:52 +00:00
#include "gtkhbox.h"
#include "gtkhseparator.h"
#include "gtkinputdialog.h"
#include "gtklabel.h"
#include "gtklistitem.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
1997-11-24 22:37:52 +00:00
#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtknotebook.h"
1997-11-24 22:37:52 +00:00
#include "gtkoptionmenu.h"
#include "gtkscrolledwindow.h"
#include "gtkstock.h"
#include "gtktable.h"
1997-11-24 22:37:52 +00:00
#include "gtkvbox.h"
#include "gtkintl.h"
typedef struct {
gint index;
GtkWidget *entry;
GtkInputDialog *inputd;
} GtkInputKeyInfo;
1997-11-24 22:37:52 +00:00
enum
{
ENABLE_DEVICE,
DISABLE_DEVICE,
LAST_SIGNAL
};
#define AXIS_LIST_WIDTH 160
#define AXIS_LIST_HEIGHT 175
#define KEYS_LIST_WIDTH 200
#define KEYS_LIST_HEIGHT 175
#define GTK_INPUT_DIALOG_KEY "gtk-input-dialog-key"
1997-11-24 22:37:52 +00:00
/* Forward declarations */
static void gtk_input_dialog_class_init (GtkInputDialogClass *klass);
static void gtk_input_dialog_init (GtkInputDialog *inputd);
static void gtk_input_dialog_set_device (GtkWidget *widget,
gpointer data);
static void gtk_input_dialog_set_mapping_mode (GtkWidget *w,
gpointer data);
static void gtk_input_dialog_set_axis (GtkWidget *widget,
gpointer data);
static void gtk_input_dialog_fill_axes (GtkInputDialog *inputd,
GdkDevice *info);
static void gtk_input_dialog_set_key (GtkInputKeyInfo *key,
guint keyval,
GdkModifierType modifiers);
static gint gtk_input_dialog_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkInputKeyInfo *key);
static void gtk_input_dialog_clear_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_destroy_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd,
GdkDevice *info);
1997-11-24 22:37:52 +00:00
static GtkObjectClass *parent_class = NULL;
made the <widget>_signals[] arrays of type guint rather than gint. made Mon Mar 9 15:48:10 1998 Tim Janik <timj@gimp.org> * Signal signedness and naming corrections, plus GtkType fixes: * gtk/gtkadjustment.c: * gtk/gtkbutton.c: * gtk/gtkcheckmenuitem.c: * gtk/gtkclist.c: * gtk/gtkcolorsel.c: * gtk/gtkcontainer.c: * gtk/gtkcurve.c: * gtk/gtkdata.c: * gtk/gtkeditable.c: * gtk/gtkentry.c: * gtk/gtkhandlebox.c: * gtk/gtkinputdialog.c: * gtk/gtkitem.c: * gtk/gtklist.c: * gtk/gtkmenuitem.c: * gtk/gtkmenushell.c: * gtk/gtknotebook.c: * gtk/gtkstatusbar.c: * gtk/gtktoolbar.c: * gtk/gtktree.c: * gtk/gtktreeitem.c: * gtk/gtkwidget.c: * gtk/gtktogglebutton.c: * gtk/gtkwindow.c: made the <widget>_signals[] arrays of type guint rather than gint. * gtk/gtkwidget.c (gtk_widget_get_ancestor): made widget_type a GtkType. * gtk/gtkcombo.h: handler ids need to be of type guint (entry_change_id, list_change_id). * gtk/gtkaccelerator.c: changed signal_num to signal_id and typed it guint. * gtk/gtkmain.c: made gtk_ndebug_keys a guint. * gtk/gtkmenu.h: * gtk/gtkmenu.c: (gtk_menu_popup): made button a guint. (gtk_menu_set_active): made index a guint. * gtk/gtkmenuitem.h: * gtk/gtkmenuitem.c: made accelerator_signal a guint. * gtk/gtkoptionmenu.h: * gtk/gtkoptionmenu.c: (gtk_option_menu_set_history): made index a guint. * gtk/gtksignal.h: * gtk/gtksignal.c: * gtk/gtkobject.h: * gtk/gtkobject.c: changed a bunch of prototypes to take guints rather than gints. also made some conversions from guint to GtkType, left over from when the fundamental-types system was introduced. * gtk/gtkobject.h: * gtk/gtkobject.c: made object_data_id_index and obj_count guints. made *signals and nsignals guints in GtkObjectClass.
1998-03-09 15:16:28 +00:00
static guint input_dialog_signals[LAST_SIGNAL] = { 0 };
1997-11-24 22:37:52 +00:00
GType
configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on Sun May 3 13:38:22 1998 Owen Taylor <otaylor@gtk.org> * configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on the client and server side. (And, more importantly, check for the shape extension so we may include -lXext even when compiling with --disable-xshm) Don't set override_redirect on all shaped windows. It isn't necessary. * gdk/gdkwindow.c: Set ->colormap to NULL for root and foreign windows. Use this to check if we need to get the colormap from X. Fri May 1 22:32:47 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkbutton.c (gtk_button_paint): Draw the areas between the default and the button always in GTK_STATE_NORMAL. * gtk/gtkrange.c (gtk_range_style_set): Added a style_set callback. Fri May 1 16:40:57 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkpixmap.c (gdk_pixmap_colormap_create_from_xpmp[_d]): Fix a buffer overflow on pixmaps that claim to have more than 31 characters per pixel. (gdk_pixmap_read_string): Don't wrap around strings longer than half of address space ;-) * gtk/gtk[vh]ruler.c gtk/gtkinputdialog.c: Expand some buffers that were used for printing integers. * */* (almost): Style: All int foo () { ... } changed to int foo (void) { ... } ^^^^^^^ This is why some many files changed Even where there were proper prototypes elsewhere. * gdk/gxid.c (handle_claim_device): Some extra checks. It isn't safe against being fed bad X id's, but at least it should be safe against deleting all your files.
1998-05-03 22:41:32 +00:00
gtk_input_dialog_get_type (void)
1997-11-24 22:37:52 +00:00
{
static GType input_dialog_type = 0;
1997-11-24 22:37:52 +00:00
if (!input_dialog_type)
{
static const GTypeInfo input_dialog_info =
1997-11-24 22:37:52 +00:00
{
sizeof (GtkInputDialogClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_input_dialog_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkInputDialog),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_input_dialog_init,
1997-11-24 22:37:52 +00:00
};
input_dialog_type =
g_type_register_static (GTK_TYPE_DIALOG, "GtkInputDialog",
&input_dialog_info, 0);
1997-11-24 22:37:52 +00:00
}
return input_dialog_type;
}
static void
gtk_input_dialog_class_init (GtkInputDialogClass *klass)
{
parent_class = g_type_class_peek_parent (klass);
1997-11-24 22:37:52 +00:00
doh, this was broken beyond believe. Tue Dec 12 23:46:44 2000 Tim Janik <timj@gtk.org> * gtk/stock-icons/Makefile.am: doh, this was broken beyond believe. * gtk/gtkbox.c: change property types from (u)long to (u)int for ::position and ::padding. * gtk/gtkcontainer.c: make ::border_width an INT property. * gtk/gtkpacker.c: make ::position an INT property. * gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed): guard against NULL h/v scrollbars, since this is used at construction time. * gtk/gtkclist.[hc]: nuked gtk_clist_construct(), implemented internal gtk_clist_constructor(). * gtk/gtkctree.[hc]: nuked gtk_ctree_construct(), implemented gtk_ctree_constructor(). * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): property ::pulse_step should use ARG_PULSE_STEP, not ARG_FRACTION. * docs/reference/Makefile.am: fun stuff, disabled docs generation again, gtk-scan.c needs to introspec paramspecs, not GtkAgs. * gtk/gtkwidget.[hc]: removed gtk_widget_setv(), gtk_widget_getv(), gtk_widget_newv() and gtk_widget_get(). (gtk_widget_new): use g_object_new_valist(). (gtk_widget_set): use g_object_set_valist(). * gtk/gtkobject.[hc]: removed gtk_object_arg_get_info(), gtk_object_getv(), gtk_object_query_args(), gtk_object_newv(), gtk_object_class_add_signals(), gtk_object_class_user_signal_new(), gtk_object_class_user_signal_newv(), gtk_object_arg_set(), gtk_object_arg_get(), gtk_object_args_collect(), gtk_object_default_construct(), gtk_object_constructed(), GTK_CONSTRUCTED and GTK_OBJECT_CONSTRUCTED(). removed nsignals, signals and n_args members from GtkObjectClass. (gtk_object_new): use g_object_new_valist(). (gtk_object_set): use g_object_set_valist(). (gtk_object_get): use g_object_get_valist(). * gtk/gtkcompat.h: define gtk_object_default_construct(). * gtk/gtktypeutils.c (gtk_type_new): create constructed objects via g_object_new(). * gtk/*.c: removed gtk_object_class_add_signals() from class_init() fucntions, cleaned up method assignments (make sure your structures are setup properly before calling out). removed all GTK_CONSTRUCTED hacks ;)
2000-12-13 01:34:41 +00:00
klass->enable_device = NULL;
klass->disable_device = NULL;
1997-11-24 22:37:52 +00:00
input_dialog_signals[ENABLE_DEVICE] =
g_signal_new ("enable_device",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkInputDialogClass, enable_device),
NULL, NULL,
_gtk_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GDK_TYPE_DEVICE);
1997-11-24 22:37:52 +00:00
input_dialog_signals[DISABLE_DEVICE] =
g_signal_new ("disable_device",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkInputDialogClass, disable_device),
NULL, NULL,
_gtk_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GDK_TYPE_DEVICE);
1997-11-24 22:37:52 +00:00
}
static void
gtk_input_dialog_init (GtkInputDialog *inputd)
{
GtkWidget *vbox;
GtkWidget *util_box;
GtkWidget *label;
GtkWidget *device_menu;
GtkWidget *mapping_menu;
GtkWidget *menuitem;
GtkWidget *optionmenu;
GtkWidget *separator;
GtkWidget *notebook;
1997-11-24 22:37:52 +00:00
GList *tmp_list;
GList *device_info;
2002-01-18 00:10:23 +00:00
gtk_widget_push_composite_child ();
device_info = gdk_devices_list ();
1997-11-24 22:37:52 +00:00
/* shell and main vbox */
gtk_window_set_title (GTK_WINDOW (inputd), _("Input"));
1997-11-24 22:37:52 +00:00
vbox = gtk_vbox_new (FALSE, 4);
changed scrolled window inheritance, it inherits from GtkBin now. Sat Nov 28 03:13:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled window inheritance, it inherits from GtkBin now. * gtk/gtkbin.c (gtk_bin_unmap): removed superfluous check for visibility of child. (gtk_bin_draw): removed superfluous check for GTK_WIDGET_DRAWABLE(). added check so a child gets only drawn if it's visible. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed gtk_widget_draw_children(). * gtk/gtkstyle.h: * gtk/gtkstyle.c: rmoved gtk_reset_widget_shapes. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed crufty relict: gtk_widget_is_child(). added internal function gtk_widget_reset_shapes() from gtkstyle.c. * gtk/gtkrc.h: * gtk/gtkrc.c: (gtk_rc_find_pixmap_in_path): removed bogus gscanner argument, changed callers. * gtk/gtkmenufactory.c: GtkMenuFactory is deprecated for a long time, it will issue a warning now. * gtk/gtkcompat.h: new file to #define aliases for historic function names. * changed 8 function names for consistency and provided aliases to keep source compatibility in gtkcompat.h: (gtk_accel_label_get_accel_width): renamed from gtk_accel_label_accelerator_width (gtk_container_set_border_width): renamed from gtk_container_border_width (gtk_notebook_get_current_page): renamed from gtk_notebook_current_page (gtk_packer_configure): renamed from gtk_packer_set_child_packing (gtk_paned_set_gutter_size): renamed from gtk_paned_gutter_size (gtk_paned_set_handle_size): renamed from gtk_paned_handle_size (gtk_scale_get_value_width): renamed from gtk_scale_value_width (gtk_window_set_position): renamed from gtk_window_position * renamed a few recently added funtions for consistency: (gtk_notebook_get_tab_label): renamed from gtk_notebook_query_tab_label. (gtk_notebook_get_menu_label): renamed from gtk_notebook_query_menu_label. (gtk_progress_configure): renamed from gtk_progress_reconfigure.
1998-11-28 07:42:37 +00:00
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
1997-11-24 22:37:52 +00:00
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (inputd)->vbox), vbox, TRUE, TRUE, 0);
if (g_list_length(device_info) <= 1) /* only core device */
{
label = gtk_label_new (_("No input devices"));
1997-11-24 22:37:52 +00:00
gtk_container_add (GTK_CONTAINER (vbox), label);
gtk_widget_show (label);
}
else
{
/* menu for selecting device */
device_menu = gtk_menu_new ();
for (tmp_list = device_info; tmp_list; tmp_list = tmp_list->next) {
GdkDevice *info = (GdkDevice *)(tmp_list->data);
Make gdkx.h the only installed header from gdk/x11. All structures in Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com> Make gdkx.h the only installed header from gdk/x11. All structures in gdk/x11 are opaque. * gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h: Don't install gdk{drawable,pixmap,window}-x11.h. * gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c: Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11, GdkVisualClass into C files. * gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static. * gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c, gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c} Add public functions to replace previously exported direct structure access. gdk_x11_colormap_get_{xdisplay,xcolormap} gdk_x11_cursor_get_{xdisplay,xcursor}, gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual, gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage}, gdk_x11_gc_get_{xdisplay,ximage} * gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo, GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals. Fix a number of variables and functions that were exported "accidentally" from GDK. * gdk/**.[ch]: gdk => _gdk for gdk_visual_init, gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit, gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data, gdk_event_notify, gdk_queued_events, gdk_queued_tail, gdk_event_new, gdk_events_queue, gdk_events_unqueue, gdk_event_queue_find_first, gdk_event_queue_remove_link, gdk_event_queue_append, gdk_event_button_generate, gdk_debug_flags, gdk_default_filters, gdk_parent_root. * gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c, gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}: gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks, gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window, gdk_use_xshm, gdk_input_ignore_core. * gdk/x11/xsettings-common.h (xsettings_list_insert): Add #defines to namespace functions into the private _gdk_ namespace. * gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window () to replace gdk_parent_root exported variable. Adjust and deprecate GDK_ROOT_PARENT(). * demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix GDK_ROOT_PARENT usage, remove includes of port-specific headers. * gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for _gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core, gdk_input_devices, _gdk_input_windows, gdk_init_input_core. * gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c} docs/Changes-2.0.txt: Remove gdk_wm_protocols, gdk_wm_delete_window functions, gdk_wm_take_focus, use gdk_atom_intern() instead. * gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h} gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h} gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h} gtk/gtkselection.c Unexport gdk_selection_property, just use gdk_atom_intern ("GDK_SELECTION"). * gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}: Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type, GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate, GdkVisualprivate, gdk_x11_gc_flush. Make a number of public exports of variables into functions to increase encapsulation. * gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer, move to gdkinternals.h. Add gdk_device_get_core_pointer (). * gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code, gdk_error_warnings. * gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h} docs/Changes-2.0.txt: s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen() s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow() Add gdk_x11_get_default_xdisplay(). * gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class, Don't export gdk_progclass, move --class command line option and handling to common portion of GDK. Miscellaneous fixes: * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix g_return_val_if_fail that should have been g_return_if_fail. * gdk/gdkinternals.h gdk/gdkprivate.h: Move gdk_synthesize_window_state() to the semi-public gdkprivate.h. * gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded X11 dependency. * gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO: Remove unused gdk_key_repeat_disable/restore. * linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def: Remove unused gdk_null_window_warnings variable. * gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox; it can be retrieved from the repository; it is too far from functional to be worth having people check out; it would be easier to start from scratch, I suspect. * gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID(). * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. Add some space for future expansion to multihead. * gdk/gdkdrawable.h: Add four reserved function pointers for future expansion of GdkDrawableClass. * gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
if (info != gdk_device_get_core_pointer ())
1997-11-24 22:37:52 +00:00
{
menuitem = gtk_menu_item_new_with_label (info->name);
1997-11-24 22:37:52 +00:00
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_menu_shell_append (GTK_MENU_SHELL (device_menu), menuitem);
gtk_widget_show (menuitem);
g_object_set_data (G_OBJECT (menuitem), GTK_INPUT_DIALOG_KEY,
inputd);
g_signal_connect (menuitem, "activate",
G_CALLBACK (gtk_input_dialog_set_device),
info);
1997-11-24 22:37:52 +00:00
}
}
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), util_box, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic (_("_Device:"));
1997-11-24 22:37:52 +00:00
gtk_box_pack_start (GTK_BOX (util_box), label, FALSE, FALSE, 2);
optionmenu = gtk_option_menu_new ();
make this somewhat key-navigable 2001-03-23 Havoc Pennington <hp@pobox.com> * gtk/gtkhsv.c: make this somewhat key-navigable * gtk/gtkfontsel.c: mnemonics * gtk/gtkgamma.c: mnemonics * gtk/gtkcolorsel.c: add mnemonics to labels 2001-03-22 Havoc Pennington <hp@pobox.com> Applied big patch from Seth Lytle to fix event handler return values, slightly modified. * gtk/gtkcalendar.c (gtk_calendar_button_press): return TRUE if handled. (gtk_calendar_key_press): return TRUE for GDK_space triggers select_day * gtk/gtkclist.c (gtk_clist_button_press): return TRUE if handled (gtk_clist_button_release): return TRUE if handled * gtk/gtkcolorsel.c (mouse_release): (palette_activate): (palette_press): (palette_new): (mouse_press): (get_screen_color): fixed return type (void to gboolean), return TRUE, added GTK_SIGNAL_FUNC cast * gtk/gtkcombo.c (gtk_combo_popup_button_press): fixed return type (void to gboolean), and return TRUE (gtk_combo_button_release): changed return value to TRUE after gtk_grab_add on combo->popwin * gtk/gtkctree.c (gtk_ctree_button_press): return TRUE if triggers a collapse or expand * gtk/gtkcurve.c (gtk_curve_graph_events): return TRUE for button/motion * gtk/gtkdnd.c (gtk_drag_source_event_cb): return TRUE for button press/release and motion that trigger act * gtk/gtkentry.c (gtk_entry_button_release): return TRUE * gtk/gtkfontsel.c (gtk_font_selection_size_key_press): return TRUE for GDK_Return * gtk/gtklist.c (gtk_list_button_press): return TRUE mostly (gtk_list_button_release): return TRUE if selection * gtk/gtklistitem.c (gtk_list_item_button_press): return TRUE on press * gtk/gtkmenushell.c (gtk_menu_shell_button_press): (gtk_menu_shell_button_release): chain parent_menu_shell retval * gtk/gtknotebook.c (gtk_notebook_button_press): return FALSE if nothing triggered (gtk_notebook_button_release): return TRUE if we do anything * gtk/gtkspinbutton.c (gtk_spin_button_button_press): (gtk_spin_button_button_release): return TRUE or chained retval * gtk/gtktext.c (gtk_text_button_press): (gtk_text_button_release): return TRUE (gtk_text_key_press): remove redundant retval code * gtk/gtktreeitem.c (gtk_tree_item_button_press): return TRUE if button and sensitive (gtk_tree_item_subtree_button_click): changed type to gint, and return TRUE if sensitive * gtk/gtktooltips.c (gtk_tooltips_event_handler): deactivate implies return TRUE
2001-03-24 06:10:40 +00:00
gtk_label_set_mnemonic_widget (GTK_LABEL (label), optionmenu);
1997-11-24 22:37:52 +00:00
gtk_box_pack_start (GTK_BOX (util_box), optionmenu, TRUE, TRUE, 2);
gtk_widget_show (optionmenu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), device_menu);
gtk_widget_show (label);
/* Device options */
/* mapping mode option menu */
mapping_menu = gtk_menu_new ();
menuitem = gtk_menu_item_new_with_label(_("Disabled"));
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
g_object_set_data (G_OBJECT (menuitem), GTK_INPUT_DIALOG_KEY, inputd);
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_widget_show (menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (gtk_input_dialog_set_mapping_mode),
GINT_TO_POINTER (GDK_MODE_DISABLED));
1997-11-24 22:37:52 +00:00
menuitem = gtk_menu_item_new_with_label(_("Screen"));
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
g_object_set_data (G_OBJECT (menuitem), GTK_INPUT_DIALOG_KEY, inputd);
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_widget_show (menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (gtk_input_dialog_set_mapping_mode),
GINT_TO_POINTER (GDK_MODE_SCREEN));
1997-11-24 22:37:52 +00:00
menuitem = gtk_menu_item_new_with_label(_("Window"));
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
g_object_set_data (G_OBJECT (menuitem), GTK_INPUT_DIALOG_KEY, inputd);
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_widget_show (menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (gtk_input_dialog_set_mapping_mode),
GINT_TO_POINTER (GDK_MODE_WINDOW));
1997-11-24 22:37:52 +00:00
label = gtk_label_new_with_mnemonic (_("_Mode: "));
1997-11-24 22:37:52 +00:00
gtk_box_pack_start (GTK_BOX (util_box), label, FALSE, FALSE, 2);
inputd->mode_optionmenu = gtk_option_menu_new ();
make this somewhat key-navigable 2001-03-23 Havoc Pennington <hp@pobox.com> * gtk/gtkhsv.c: make this somewhat key-navigable * gtk/gtkfontsel.c: mnemonics * gtk/gtkgamma.c: mnemonics * gtk/gtkcolorsel.c: add mnemonics to labels 2001-03-22 Havoc Pennington <hp@pobox.com> Applied big patch from Seth Lytle to fix event handler return values, slightly modified. * gtk/gtkcalendar.c (gtk_calendar_button_press): return TRUE if handled. (gtk_calendar_key_press): return TRUE for GDK_space triggers select_day * gtk/gtkclist.c (gtk_clist_button_press): return TRUE if handled (gtk_clist_button_release): return TRUE if handled * gtk/gtkcolorsel.c (mouse_release): (palette_activate): (palette_press): (palette_new): (mouse_press): (get_screen_color): fixed return type (void to gboolean), return TRUE, added GTK_SIGNAL_FUNC cast * gtk/gtkcombo.c (gtk_combo_popup_button_press): fixed return type (void to gboolean), and return TRUE (gtk_combo_button_release): changed return value to TRUE after gtk_grab_add on combo->popwin * gtk/gtkctree.c (gtk_ctree_button_press): return TRUE if triggers a collapse or expand * gtk/gtkcurve.c (gtk_curve_graph_events): return TRUE for button/motion * gtk/gtkdnd.c (gtk_drag_source_event_cb): return TRUE for button press/release and motion that trigger act * gtk/gtkentry.c (gtk_entry_button_release): return TRUE * gtk/gtkfontsel.c (gtk_font_selection_size_key_press): return TRUE for GDK_Return * gtk/gtklist.c (gtk_list_button_press): return TRUE mostly (gtk_list_button_release): return TRUE if selection * gtk/gtklistitem.c (gtk_list_item_button_press): return TRUE on press * gtk/gtkmenushell.c (gtk_menu_shell_button_press): (gtk_menu_shell_button_release): chain parent_menu_shell retval * gtk/gtknotebook.c (gtk_notebook_button_press): return FALSE if nothing triggered (gtk_notebook_button_release): return TRUE if we do anything * gtk/gtkspinbutton.c (gtk_spin_button_button_press): (gtk_spin_button_button_release): return TRUE or chained retval * gtk/gtktext.c (gtk_text_button_press): (gtk_text_button_release): return TRUE (gtk_text_key_press): remove redundant retval code * gtk/gtktreeitem.c (gtk_tree_item_button_press): return TRUE if button and sensitive (gtk_tree_item_subtree_button_click): changed type to gint, and return TRUE if sensitive * gtk/gtktooltips.c (gtk_tooltips_event_handler): deactivate implies return TRUE
2001-03-24 06:10:40 +00:00
gtk_label_set_mnemonic_widget (GTK_LABEL (label), inputd->mode_optionmenu);
1997-11-24 22:37:52 +00:00
gtk_box_pack_start (GTK_BOX (util_box), inputd->mode_optionmenu, FALSE, FALSE, 2);
gtk_widget_show (inputd->mode_optionmenu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (inputd->mode_optionmenu), mapping_menu);
gtk_widget_show(label);
gtk_widget_show (util_box);
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX(vbox), util_box, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_widget_show (util_box);
separator = gtk_hseparator_new();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
gtk_widget_show (separator);
/* Notebook */
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
gtk_widget_show (notebook);
1997-11-24 22:37:52 +00:00
/* The axis listbox */
label = gtk_label_new_with_mnemonic (_("_Axes"));
1997-11-24 22:37:52 +00:00
inputd->axis_listbox = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(inputd->axis_listbox),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_set_size_request (inputd->axis_listbox,
AXIS_LIST_WIDTH, AXIS_LIST_HEIGHT);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
inputd->axis_listbox, label);
1997-11-24 22:37:52 +00:00
gtk_widget_show (inputd->axis_listbox);
inputd->axis_list = 0;
/* Keys listbox */
label = gtk_label_new_with_mnemonic (_("_Keys"));
inputd->keys_listbox = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_size_request (inputd->keys_listbox,
KEYS_LIST_WIDTH, KEYS_LIST_HEIGHT);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (inputd->keys_listbox),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
inputd->keys_listbox, label);
gtk_widget_show (inputd->keys_listbox);
inputd->keys_list = 0;
1997-11-24 22:37:52 +00:00
/* ...set_device expects to get input dialog from widget user data */
g_object_set_data (G_OBJECT (inputd), GTK_INPUT_DIALOG_KEY, inputd);
gtk_input_dialog_set_device (GTK_WIDGET(inputd), device_info->data);
1997-11-24 22:37:52 +00:00
}
1997-11-24 22:37:52 +00:00
/* We create the save button in any case, so that clients can
connect to it, without paying attention to whether it exits */
inputd->save_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
1997-11-24 22:37:52 +00:00
GTK_WIDGET_SET_FLAGS (inputd->save_button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(inputd)->action_area),
inputd->save_button, TRUE, TRUE, 0);
gtk_widget_show (inputd->save_button);
if (g_list_length(device_info) <= 1) /* only core device */
gtk_widget_set_sensitive(inputd->save_button, FALSE);
inputd->close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
1997-11-24 22:37:52 +00:00
GTK_WIDGET_SET_FLAGS (inputd->close_button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(inputd)->action_area),
inputd->close_button, TRUE, TRUE, 0);
gtk_widget_show (inputd->close_button);
gtk_widget_grab_default (inputd->close_button);
gtk_widget_show (vbox);
2002-01-18 00:10:23 +00:00
gtk_widget_pop_composite_child ();
1997-11-24 22:37:52 +00:00
}
GtkWidget*
gtk_input_dialog_new (void)
{
GtkInputDialog *inputd;
inputd = g_object_new (GTK_TYPE_INPUT_DIALOG, NULL);
1997-11-24 22:37:52 +00:00
return GTK_WIDGET (inputd);
}
static void
gtk_input_dialog_set_device (GtkWidget *w,
gpointer data)
1997-11-24 22:37:52 +00:00
{
GdkDevice *device = data;
GtkInputDialog *inputd =
GTK_INPUT_DIALOG (g_object_get_data (G_OBJECT (w), GTK_INPUT_DIALOG_KEY));
1997-11-24 22:37:52 +00:00
inputd->current_device = device;
1997-11-24 22:37:52 +00:00
gtk_input_dialog_fill_axes (inputd, device);
gtk_input_dialog_fill_keys (inputd, device);
1997-11-24 22:37:52 +00:00
gtk_option_menu_set_history (GTK_OPTION_MENU (inputd->mode_optionmenu),
device->mode);
1997-11-24 22:37:52 +00:00
}
static void
gtk_input_dialog_set_mapping_mode (GtkWidget *w,
gpointer data)
1997-11-24 22:37:52 +00:00
{
GtkInputDialog *inputd =
GTK_INPUT_DIALOG (g_object_get_data (G_OBJECT (w), GTK_INPUT_DIALOG_KEY));
GdkDevice *info = inputd->current_device;
1997-11-24 22:37:52 +00:00
GdkInputMode old_mode = info->mode;
GdkInputMode mode = GPOINTER_TO_INT (data);
1997-11-24 22:37:52 +00:00
if (mode != old_mode)
{
if (gdk_device_set_mode (inputd->current_device, mode))
1997-11-24 22:37:52 +00:00
{
if (mode == GDK_MODE_DISABLED)
g_signal_emit (inputd,
input_dialog_signals[DISABLE_DEVICE],
0,
info);
1997-11-24 22:37:52 +00:00
else
g_signal_emit (inputd,
input_dialog_signals[ENABLE_DEVICE],
0,
info);
1997-11-24 22:37:52 +00:00
}
else
gtk_option_menu_set_history (GTK_OPTION_MENU (inputd->mode_optionmenu),
old_mode);
/* FIXME: error dialog ? */
}
}
static void
gtk_input_dialog_set_axis (GtkWidget *w,
gpointer data)
1997-11-24 22:37:52 +00:00
{
GdkAxisUse use = GPOINTER_TO_INT(data) & 0xFFFF;
1997-11-24 22:37:52 +00:00
GdkAxisUse old_use;
GdkAxisUse *new_axes;
GtkInputDialog *inputd =
GTK_INPUT_DIALOG (g_object_get_data (G_OBJECT (w), GTK_INPUT_DIALOG_KEY));
GdkDevice *info = inputd->current_device;
1997-11-24 22:37:52 +00:00
gint axis = (GPOINTER_TO_INT(data) >> 16) - 1;
1997-11-24 22:37:52 +00:00
gint old_axis;
int i;
new_axes = g_new (GdkAxisUse, info->num_axes);
old_axis = -1;
for (i=0;i<info->num_axes;i++)
{
new_axes[i] = info->axes[i].use;
if (info->axes[i].use == use)
1997-11-24 22:37:52 +00:00
old_axis = i;
}
if (axis != -1)
old_use = info->axes[axis].use;
1997-11-24 22:37:52 +00:00
else
old_use = GDK_AXIS_IGNORE;
if (axis == old_axis)
return;
/* we must always have an x and a y axis */
if ((axis == -1 && (use == GDK_AXIS_X || use == GDK_AXIS_Y)) ||
(old_axis == -1 && (old_use == GDK_AXIS_X || old_use == GDK_AXIS_Y)))
{
gtk_option_menu_set_history (
GTK_OPTION_MENU (inputd->axis_items[use]),
old_axis + 1);
}
else
{
if (axis != -1)
gdk_device_set_axis_use (info, axis, use);
1997-11-24 22:37:52 +00:00
if (old_axis != -1)
gdk_device_set_axis_use (info, old_axis, old_use);
1997-11-24 22:37:52 +00:00
if (old_use != GDK_AXIS_IGNORE)
{
gtk_option_menu_set_history (
GTK_OPTION_MENU (inputd->axis_items[old_use]),
old_axis + 1);
}
}
g_free (new_axes);
}
static void
gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDevice *info)
1997-11-24 22:37:52 +00:00
{
static const char *axis_use_strings[GDK_AXIS_LAST] =
1997-11-24 22:37:52 +00:00
{
"",
N_("X"),
N_("Y"),
N_("Pressure"),
N_("X Tilt"),
N_("Y Tilt"),
N_("Wheel")
1997-11-24 22:37:52 +00:00
};
int i,j;
GtkWidget *menu;
GtkWidget *option_menu;
GtkWidget *label;
/* remove all the old items */
if (inputd->axis_list)
{
gtk_widget_hide (inputd->axis_list); /* suppress resizes (or get warnings) */
gtk_widget_destroy (inputd->axis_list);
}
inputd->axis_list = gtk_table_new (GDK_AXIS_LAST, 2, 0);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (inputd->axis_listbox),
inputd->axis_list);
1997-11-24 22:37:52 +00:00
gtk_widget_show (inputd->axis_list);
gtk_widget_realize (inputd->axis_list);
gdk_window_set_background (inputd->axis_list->window,
&inputd->axis_list->style->base[GTK_STATE_NORMAL]);
1997-11-24 22:37:52 +00:00
for (i=GDK_AXIS_X;i<GDK_AXIS_LAST;i++)
{
/* create the label */
label = gtk_label_new (_(axis_use_strings[i]));
gtk_table_attach (GTK_TABLE (inputd->axis_list), label, 0, 1, i, i+1,
0, 0, 2, 2);
1997-11-24 22:37:52 +00:00
/* and the use option menu */
menu = gtk_menu_new();
for (j = -1; j < info->num_axes; j++)
{
char buffer[16];
GtkWidget *menu_item;
if (j == -1)
menu_item = gtk_menu_item_new_with_label (_("none"));
1997-11-24 22:37:52 +00:00
else
{
sprintf (buffer,"%d",j+1);
menu_item = gtk_menu_item_new_with_label (buffer);
}
g_object_set_data (G_OBJECT (menu_item), GTK_INPUT_DIALOG_KEY,
inputd);
g_signal_connect (menu_item, "activate",
G_CALLBACK (gtk_input_dialog_set_axis),
GINT_TO_POINTER (0x10000 * (j + 1) + i));
1997-11-24 22:37:52 +00:00
gtk_widget_show (menu_item);
Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson <alexl@redhat.com> * docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc API changes. * gtk/gtkmenu.c: Add support for scrolling menus. Remove gtk_menu_append/prepend/insert, these have been moved to gtkcompat.h as #defines. * gtk/gtkcompat.h.in: Add compatibility #defines for gtk_menu_append/prepend/insert * gtk/gtkmenu.h: Add data needed for scrolling menus. GtkMenuPositionFunc gets an extra argument push_in. gtk_menu_append/prepend/insert removed. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu positioning behaviour to fit to scrolling menus. * gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse into menuitem->submeny. That is wrong, and broke torn off submenus of torn off menus, since they were unrealized when the first menu was unrealized. * gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and gtk_menu_shell_select_item() since these need to be overridden in GtkMenu. * gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu positioning behaviour to fit to scrolling menus. (gtk_option_menu_key_press, gtk_option_menu_button_press): Select the current item so that it is prelighted when the menu pops up. This is a workaround to the fact that the menu doesn't get the initial enter event (due to grabs). * gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c: s/gtk_menu_append/gtk_menu_shell_append/ * gtk/gtknotebook.c: s/gtk_menu_insert/gtk_menu_shell_insert/ * gtk/testgtk.c (create_menu, create_menus): Create the first menu with 50 items so that menu scrolling can be tested. Patch from Jonathan Blandford <jrb@redhat.com> * gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new system to handle size requests. First, we ask what the size of the toggle is. Then, when allocating the size, we allocate the toggle_size first. This way we can have multiple menu-item classes w/o needing a seperate class for each. * gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system. * gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system. * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_toggle_size_request): New function to handle the toggle size-request.
2000-11-08 17:34:52 +00:00
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
1997-11-24 22:37:52 +00:00
}
inputd->axis_items[i] = option_menu = gtk_option_menu_new ();
gtk_table_attach (GTK_TABLE (inputd->axis_list), option_menu,
1, 2, i, i+1, 0, 0, 2, 2);
1997-11-24 22:37:52 +00:00
gtk_widget_show (option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
for (j = 0; j < info->num_axes; j++)
if (info->axes[j].use == (GdkAxisUse) i)
1997-11-24 22:37:52 +00:00
{
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), j+1);
break;
}
gtk_widget_show (label);
}
}
static void
gtk_input_dialog_clear_key (GtkWidget *widget, GtkInputKeyInfo *key)
{
gtk_entry_set_text (GTK_ENTRY(key->entry), _("(disabled)"));
gdk_device_set_key (key->inputd->current_device, key->index, 0, 0);
}
static void
gtk_input_dialog_set_key (GtkInputKeyInfo *key,
guint keyval, GdkModifierType modifiers)
{
GString *str;
gchar chars[2];
if (keyval)
{
str = g_string_new("");
if (modifiers & GDK_SHIFT_MASK)
g_string_append (str, "Shift+");
if (modifiers & GDK_CONTROL_MASK)
g_string_append (str, "Ctrl+");
if (modifiers & GDK_MOD1_MASK)
g_string_append (str, "Alt+");
if ((keyval >= 0x20) && (keyval <= 0xFF))
{
chars[0] = keyval;
chars[1] = 0;
g_string_append (str, chars);
}
else
g_string_append (str, _("(unknown)"));
gtk_entry_set_text (GTK_ENTRY(key->entry), str->str);
g_string_free (str, TRUE);
}
else
{
gtk_entry_set_text (GTK_ENTRY(key->entry), _("(disabled)"));
}
}
static gint
gtk_input_dialog_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkInputKeyInfo *key)
{
gtk_input_dialog_set_key (key, event->keyval, event->state & 0xFF);
gdk_device_set_key (key->inputd->current_device, key->index,
event->keyval, event->state & 0xFF);
g_signal_stop_emission_by_name (widget, "key_press_event");
return TRUE;
}
static void
gtk_input_dialog_destroy_key (GtkWidget *widget, GtkInputKeyInfo *key)
{
g_free (key);
}
static void
gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDevice *info)
{
int i;
GtkWidget *label;
GtkWidget *button;
configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on Sun May 3 13:38:22 1998 Owen Taylor <otaylor@gtk.org> * configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on the client and server side. (And, more importantly, check for the shape extension so we may include -lXext even when compiling with --disable-xshm) Don't set override_redirect on all shaped windows. It isn't necessary. * gdk/gdkwindow.c: Set ->colormap to NULL for root and foreign windows. Use this to check if we need to get the colormap from X. Fri May 1 22:32:47 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkbutton.c (gtk_button_paint): Draw the areas between the default and the button always in GTK_STATE_NORMAL. * gtk/gtkrange.c (gtk_range_style_set): Added a style_set callback. Fri May 1 16:40:57 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkpixmap.c (gdk_pixmap_colormap_create_from_xpmp[_d]): Fix a buffer overflow on pixmaps that claim to have more than 31 characters per pixel. (gdk_pixmap_read_string): Don't wrap around strings longer than half of address space ;-) * gtk/gtk[vh]ruler.c gtk/gtkinputdialog.c: Expand some buffers that were used for printing integers. * */* (almost): Style: All int foo () { ... } changed to int foo (void) { ... } ^^^^^^^ This is why some many files changed Even where there were proper prototypes elsewhere. * gdk/gxid.c (handle_claim_device): Some extra checks. It isn't safe against being fed bad X id's, but at least it should be safe against deleting all your files.
1998-05-03 22:41:32 +00:00
char buffer[32];
/* remove all the old items */
if (inputd->keys_list)
{
gtk_widget_hide (inputd->keys_list); /* suppress resizes (or get warnings) */
gtk_widget_destroy (inputd->keys_list);
}
inputd->keys_list = gtk_table_new (info->num_keys, 3, FALSE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (inputd->keys_listbox),
inputd->keys_list);
gtk_widget_show (inputd->keys_list);
gtk_widget_realize (inputd->keys_list);
gdk_window_set_background (inputd->keys_list->window,
&inputd->keys_list->style->base[GTK_STATE_NORMAL]);
for (i=0;i<info->num_keys;i++)
{
GtkInputKeyInfo *key = g_new (GtkInputKeyInfo, 1);
key->index = i;
key->inputd = inputd;
/* create the label */
sprintf (buffer, "%d", i+1);
label = gtk_label_new (buffer);
gtk_table_attach (GTK_TABLE (inputd->keys_list), label, 0, 1, i, i+1,
0, 0, 2, 2);
gtk_widget_show (label);
/* the entry */
key->entry = gtk_entry_new ();
gtk_table_attach (GTK_TABLE (inputd->keys_list), key->entry, 1, 2, i, i+1,
GTK_EXPAND | GTK_FILL , 0, 2, 2);
gtk_widget_show (key->entry);
g_signal_connect (key->entry, "key_press_event",
G_CALLBACK (gtk_input_dialog_key_press), key);
g_signal_connect (key->entry, "destroy",
G_CALLBACK (gtk_input_dialog_destroy_key), key);
/* and clear button */
button = gtk_button_new_with_label (_("clear"));
gtk_table_attach (GTK_TABLE (inputd->keys_list), button, 2, 3, i, i+1,
0, 0, 2, 2);
gtk_widget_show (button);
g_signal_connect (button, "clicked",
G_CALLBACK (gtk_input_dialog_clear_key), key);
1997-11-24 22:37:52 +00:00
gtk_input_dialog_set_key (key, info->keys[i].keyval,
info->keys[i].modifiers);
1997-11-24 22:37:52 +00:00
}
}