2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* 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>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
2008-06-17 14:11:26 +00:00
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2008-06-17 14:11:26 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
#include <stdlib.h>
|
2008-06-17 14:11:26 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gdk/gdkkeysyms.h"
|
2008-06-17 14:11:26 +00:00
|
|
|
|
|
|
|
#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu */
|
|
|
|
|
2006-06-29 09:18:07 +00:00
|
|
|
#include "gtkinputdialog.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtkbutton.h"
|
1997-12-18 02:17:14 +00:00
|
|
|
#include "gtkentry.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtkhbox.h"
|
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtkmain.h"
|
2001-11-17 23:28:51 +00:00
|
|
|
#include "gtkmarshalers.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtkmenu.h"
|
|
|
|
#include "gtkmenuitem.h"
|
1997-12-18 02:17:14 +00:00
|
|
|
#include "gtknotebook.h"
|
2008-06-17 14:11:26 +00:00
|
|
|
#include "gtkoptionmenu.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtkscrolledwindow.h"
|
2002-02-08 17:35:06 +00:00
|
|
|
#include "gtkstock.h"
|
1997-12-18 02:17:14 +00:00
|
|
|
#include "gtktable.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtkvbox.h"
|
|
|
|
|
1998-12-14 17:39:58 +00:00
|
|
|
#include "gtkintl.h"
|
2005-03-20 07:01:23 +00:00
|
|
|
#include "gtkalias.h"
|
1998-12-14 17:39:58 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
typedef struct _GtkInputDialogPrivate GtkInputDialogPrivate;
|
|
|
|
typedef struct _GtkInputKeyInfo GtkInputKeyInfo;
|
|
|
|
|
|
|
|
struct _GtkInputDialogPrivate
|
|
|
|
{
|
|
|
|
GtkWidget *device_menu;
|
|
|
|
GtkWidget *device_optionmenu;
|
|
|
|
GtkWidget *no_devices_label;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkInputKeyInfo
|
|
|
|
{
|
1997-12-18 02:17:14 +00:00
|
|
|
gint index;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkInputDialog *inputd;
|
2002-11-12 21:54:16 +00:00
|
|
|
};
|
1997-12-18 02:17:14 +00:00
|
|
|
|
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
|
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
#define KEYS_LIST_WIDTH 200
|
|
|
|
#define KEYS_LIST_HEIGHT 175
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
/* Forward declarations */
|
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
static void gtk_input_dialog_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous_screen);
|
2000-07-03 19:00:23 +00:00
|
|
|
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);
|
2002-11-12 21:54:16 +00:00
|
|
|
static gboolean gtk_input_dialog_key_press (GtkWidget *widget,
|
2000-07-03 19:00:23 +00:00
|
|
|
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
|
|
|
|
1998-03-09 15:16:28 +00:00
|
|
|
static guint input_dialog_signals[LAST_SIGNAL] = { 0 };
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2006-05-14 04:25:34 +00:00
|
|
|
G_DEFINE_TYPE (GtkInputDialog, gtk_input_dialog, GTK_TYPE_DIALOG)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2004-08-09 16:59:53 +00:00
|
|
|
static GtkInputDialogPrivate *
|
2002-12-14 02:41:30 +00:00
|
|
|
gtk_input_dialog_get_private (GtkInputDialog *input_dialog)
|
2002-11-12 21:54:16 +00:00
|
|
|
{
|
2005-11-28 14:23:17 +00:00
|
|
|
return G_TYPE_INSTANCE_GET_PRIVATE (input_dialog,
|
|
|
|
GTK_TYPE_INPUT_DIALOG,
|
|
|
|
GtkInputDialogPrivate);
|
2002-11-12 21:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkInputDialog *
|
|
|
|
input_dialog_from_widget (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
|
|
if (GTK_IS_MENU_ITEM (widget))
|
|
|
|
{
|
|
|
|
GtkMenu *menu = GTK_MENU (widget->parent);
|
|
|
|
widget = gtk_menu_get_attach_widget (menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (widget);
|
|
|
|
return GTK_INPUT_DIALOG (toplevel);
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
static void
|
|
|
|
gtk_input_dialog_class_init (GtkInputDialogClass *klass)
|
|
|
|
{
|
2005-11-28 14:23:17 +00:00
|
|
|
GObjectClass *object_class = (GObjectClass *) klass;
|
2002-11-12 21:54:16 +00:00
|
|
|
GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
|
|
|
|
|
|
|
|
widget_class->screen_changed = gtk_input_dialog_screen_changed;
|
|
|
|
|
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] =
|
2008-08-11 12:54:57 +00:00
|
|
|
g_signal_new (I_("enable-device"),
|
2002-10-11 22:57:11 +00:00
|
|
|
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] =
|
2008-08-11 12:54:57 +00:00
|
|
|
g_signal_new (I_("disable-device"),
|
2002-10-11 22:57:11 +00:00
|
|
|
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);
|
2005-11-28 14:23:17 +00:00
|
|
|
|
|
|
|
g_type_class_add_private (object_class, sizeof (GtkInputDialogPrivate));
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_input_dialog_init (GtkInputDialog *inputd)
|
|
|
|
{
|
2002-11-12 21:54:16 +00:00
|
|
|
GtkInputDialogPrivate *private = gtk_input_dialog_get_private (inputd);
|
2006-03-10 21:37:43 +00:00
|
|
|
GtkDialog *dialog = GTK_DIALOG (inputd);
|
1997-11-24 22:37:52 +00:00
|
|
|
GtkWidget *util_box;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *mapping_menu;
|
|
|
|
GtkWidget *menuitem;
|
1997-12-18 02:17:14 +00:00
|
|
|
GtkWidget *notebook;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-01-18 00:10:23 +00:00
|
|
|
gtk_widget_push_composite_child ();
|
|
|
|
|
1998-12-14 17:39:58 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (inputd), _("Input"));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_dialog_set_has_separator (dialog, FALSE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
|
|
|
gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
|
|
|
|
gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
|
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
/* main vbox */
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
private->main_vbox = gtk_vbox_new (FALSE, 12);
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (private->main_vbox), 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (inputd)->vbox), private->main_vbox,
|
|
|
|
TRUE, TRUE, 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2003-11-12 20:01:26 +00:00
|
|
|
private->no_devices_label = gtk_label_new (_("No extended input devices"));
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (private->main_vbox), 5);
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (inputd)->vbox),
|
|
|
|
private->no_devices_label,
|
|
|
|
TRUE, TRUE, 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
/* menu for selecting device */
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
private->device_menu = gtk_menu_new ();
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
util_box = gtk_hbox_new (FALSE, 12);
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (private->main_vbox), util_box, FALSE, FALSE, 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Device:"));
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), label, FALSE, FALSE, 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
private->device_optionmenu = gtk_option_menu_new ();
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), private->device_optionmenu);
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), private->device_optionmenu, TRUE, TRUE, 0);
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_widget_show (private->device_optionmenu);
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (private->device_optionmenu), private->device_menu);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_widget_show (label);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
/* Device options */
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
/* mapping mode option menu */
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
mapping_menu = gtk_menu_new ();
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
menuitem = gtk_menu_item_new_with_label(_("Disabled"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
|
|
|
|
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
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
menuitem = gtk_menu_item_new_with_label(_("Screen"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
|
|
|
|
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
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
menuitem = gtk_menu_item_new_with_label(_("Window"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
|
|
|
|
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
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Mode:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), label, FALSE, FALSE, 0);
|
2002-11-12 21:54:16 +00:00
|
|
|
|
|
|
|
inputd->mode_optionmenu = gtk_option_menu_new ();
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), inputd->mode_optionmenu);
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), inputd->mode_optionmenu, FALSE, FALSE, 0);
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_widget_show (inputd->mode_optionmenu);
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (inputd->mode_optionmenu), mapping_menu);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_widget_show(label);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_widget_show (util_box);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
/* Notebook */
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
notebook = gtk_notebook_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (private->main_vbox), notebook, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (notebook);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
/* The axis listbox */
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
label = gtk_label_new (_("Axes"));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
inputd->axis_listbox = gtk_scrolled_window_new (NULL, NULL);
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (inputd->axis_listbox), 12);
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(inputd->axis_listbox),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
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
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_widget_show (inputd->axis_listbox);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2004-10-28 15:00:05 +00:00
|
|
|
inputd->axis_list = NULL;
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
/* Keys listbox */
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
label = gtk_label_new (_("Keys"));
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
inputd->keys_listbox = gtk_scrolled_window_new (NULL, NULL);
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (inputd->keys_listbox), 12);
|
2002-11-12 21:54:16 +00:00
|
|
|
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);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
gtk_widget_show (inputd->keys_listbox);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2004-10-28 15:00:05 +00:00
|
|
|
inputd->keys_list = NULL;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-02-08 17:35:06 +00:00
|
|
|
inputd->save_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
|
2010-03-02 06:58:05 +00:00
|
|
|
gtk_widget_set_can_default (inputd->save_button, TRUE);
|
1997-11-24 22:37:52 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(inputd)->action_area),
|
|
|
|
inputd->save_button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (inputd->save_button);
|
|
|
|
|
2002-02-08 17:35:06 +00:00
|
|
|
inputd->close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
|
2010-03-02 06:58:05 +00:00
|
|
|
gtk_widget_set_can_default (inputd->close_button, TRUE);
|
1997-11-24 22:37:52 +00:00
|
|
|
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);
|
|
|
|
|
2002-01-18 00:10:23 +00:00
|
|
|
gtk_widget_pop_composite_child ();
|
2002-11-12 21:54:16 +00:00
|
|
|
|
|
|
|
gtk_input_dialog_screen_changed (GTK_WIDGET (inputd), NULL);
|
2006-03-10 21:37:43 +00:00
|
|
|
|
|
|
|
_gtk_dialog_set_ignore_separator (dialog, TRUE);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
static void
|
|
|
|
gtk_input_dialog_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous_screen)
|
|
|
|
{
|
|
|
|
GtkInputDialog *inputd = GTK_INPUT_DIALOG (widget);
|
|
|
|
GtkInputDialogPrivate *private = gtk_input_dialog_get_private (inputd);
|
|
|
|
|
|
|
|
GList *device_info = NULL;
|
|
|
|
GdkDevice *core_pointer = NULL;
|
|
|
|
GList *tmp_list;
|
|
|
|
|
|
|
|
if (gtk_widget_has_screen (widget))
|
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
device_info = gdk_display_list_devices (display);
|
|
|
|
core_pointer = gdk_display_get_core_pointer (display);
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
inputd->current_device = NULL;
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (private->device_menu),
|
|
|
|
(GtkCallback)gtk_widget_destroy, NULL);
|
|
|
|
|
|
|
|
if (g_list_length(device_info) <= 1) /* only core device */
|
|
|
|
{
|
|
|
|
gtk_widget_hide (private->main_vbox);
|
|
|
|
gtk_widget_show (private->no_devices_label);
|
|
|
|
gtk_widget_set_sensitive(inputd->save_button, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_show (private->main_vbox);
|
|
|
|
gtk_widget_hide (private->no_devices_label);
|
|
|
|
gtk_widget_set_sensitive(inputd->save_button, TRUE);
|
|
|
|
|
|
|
|
for (tmp_list = device_info; tmp_list; tmp_list = tmp_list->next)
|
|
|
|
{
|
|
|
|
GdkDevice *info = tmp_list->data;
|
|
|
|
if (info != core_pointer)
|
|
|
|
{
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (info->name);
|
|
|
|
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (private->device_menu),
|
|
|
|
menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (gtk_input_dialog_set_device),
|
|
|
|
info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_input_dialog_set_device (widget, device_info->data);
|
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (private->device_optionmenu), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
GtkWidget*
|
|
|
|
gtk_input_dialog_new (void)
|
|
|
|
{
|
|
|
|
GtkInputDialog *inputd;
|
|
|
|
|
2002-10-11 22:57:11 +00:00
|
|
|
inputd = g_object_new (GTK_TYPE_INPUT_DIALOG, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
return GTK_WIDGET (inputd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-11 22:57:11 +00:00
|
|
|
gtk_input_dialog_set_device (GtkWidget *w,
|
|
|
|
gpointer data)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkDevice *device = data;
|
2002-11-12 21:54:16 +00:00
|
|
|
GtkInputDialog *inputd = input_dialog_from_widget (w);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
inputd->current_device = device;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-10-11 22:57:11 +00:00
|
|
|
gtk_input_dialog_fill_axes (inputd, device);
|
|
|
|
gtk_input_dialog_fill_keys (inputd, device);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-10-11 22:57:11 +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
|
2000-07-03 19:00:23 +00:00
|
|
|
gtk_input_dialog_set_mapping_mode (GtkWidget *w,
|
|
|
|
gpointer data)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-11-12 21:54:16 +00:00
|
|
|
GtkInputDialog *inputd = input_dialog_from_widget (w);
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkDevice *info = inputd->current_device;
|
2006-04-11 16:26:26 +00:00
|
|
|
GdkInputMode old_mode;
|
1998-05-13 00:24:57 +00:00
|
|
|
GdkInputMode mode = GPOINTER_TO_INT (data);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
if (!info)
|
|
|
|
return;
|
2006-04-11 16:26:26 +00:00
|
|
|
|
|
|
|
old_mode = info->mode;
|
2002-11-12 21:54:16 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
if (mode != old_mode)
|
|
|
|
{
|
2002-11-12 21:54:16 +00:00
|
|
|
if (gdk_device_set_mode (info, mode))
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
if (mode == GDK_MODE_DISABLED)
|
2002-10-11 22:57:11 +00:00
|
|
|
g_signal_emit (inputd,
|
|
|
|
input_dialog_signals[DISABLE_DEVICE],
|
|
|
|
0,
|
|
|
|
info);
|
1997-11-24 22:37:52 +00:00
|
|
|
else
|
2002-10-11 22:57:11 +00:00
|
|
|
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
|
2002-10-11 22:57:11 +00:00
|
|
|
gtk_input_dialog_set_axis (GtkWidget *w,
|
|
|
|
gpointer data)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
1998-05-13 00:24:57 +00:00
|
|
|
GdkAxisUse use = GPOINTER_TO_INT(data) & 0xFFFF;
|
1997-11-24 22:37:52 +00:00
|
|
|
GdkAxisUse old_use;
|
|
|
|
GdkAxisUse *new_axes;
|
2002-11-12 21:54:16 +00:00
|
|
|
GtkInputDialog *inputd = input_dialog_from_widget (w);
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkDevice *info = inputd->current_device;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1998-05-13 00:24:57 +00:00
|
|
|
gint axis = (GPOINTER_TO_INT(data) >> 16) - 1;
|
1997-11-24 22:37:52 +00:00
|
|
|
gint old_axis;
|
|
|
|
int i;
|
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
if (!info)
|
|
|
|
return;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
new_axes = g_new (GdkAxisUse, info->num_axes);
|
|
|
|
old_axis = -1;
|
|
|
|
for (i=0;i<info->num_axes;i++)
|
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
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)
|
2000-07-03 19:00:23 +00:00
|
|
|
old_use = info->axes[axis].use;
|
1997-11-24 22:37:52 +00:00
|
|
|
else
|
|
|
|
old_use = GDK_AXIS_IGNORE;
|
|
|
|
|
2006-10-08 05:07:55 +00:00
|
|
|
if (axis == old_axis) {
|
|
|
|
g_free (new_axes);
|
1997-11-24 22:37:52 +00:00
|
|
|
return;
|
2006-10-08 05:07:55 +00:00
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
/* 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)
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_axis_use (info, axis, use);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
if (old_axis != -1)
|
2000-07-03 19:00:23 +00:00
|
|
|
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
|
2000-07-03 19:00:23 +00:00
|
|
|
gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDevice *info)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2005-03-01 06:25:55 +00:00
|
|
|
static const char *const axis_use_strings[GDK_AXIS_LAST] =
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
"",
|
2006-03-10 21:37:43 +00:00
|
|
|
N_("_X:"),
|
|
|
|
N_("_Y:"),
|
|
|
|
N_("_Pressure:"),
|
|
|
|
N_("X _tilt:"),
|
|
|
|
N_("Y t_ilt:"),
|
|
|
|
N_("_Wheel:")
|
1997-11-24 22:37:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int i,j;
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *option_menu;
|
|
|
|
GtkWidget *label;
|
2006-03-10 21:37:43 +00:00
|
|
|
GtkWidget *viewport;
|
2007-04-26 06:23:36 +00:00
|
|
|
GtkWidget *old_child;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
1997-12-18 02:17:14 +00:00
|
|
|
inputd->axis_list = gtk_table_new (GDK_AXIS_LAST, 2, 0);
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (inputd->axis_list), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (inputd->axis_list), 12);
|
|
|
|
|
|
|
|
viewport = gtk_viewport_new (NULL, NULL);
|
2007-04-26 06:23:36 +00:00
|
|
|
old_child = gtk_bin_get_child (GTK_BIN (inputd->axis_listbox));
|
|
|
|
if (old_child != NULL)
|
|
|
|
gtk_widget_destroy (old_child);
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (inputd->axis_listbox), viewport);
|
|
|
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
|
|
|
|
gtk_widget_show (viewport);
|
|
|
|
gtk_container_add (GTK_CONTAINER (viewport), 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,
|
1998-02-13 05:26:33 +00:00
|
|
|
&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 */
|
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_(axis_use_strings[i]));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_table_attach (GTK_TABLE (inputd->axis_list), label, 0, 1, i, i+1,
|
2006-03-10 21:37:43 +00:00
|
|
|
GTK_FILL, 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)
|
1998-12-14 17:39:58 +00:00
|
|
|
menu_item = gtk_menu_item_new_with_label (_("none"));
|
1997-11-24 22:37:52 +00:00
|
|
|
else
|
|
|
|
{
|
2002-12-15 01:49:01 +00:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%d", j+1);
|
1997-11-24 22:37:52 +00:00
|
|
|
menu_item = gtk_menu_item_new_with_label (buffer);
|
|
|
|
}
|
2002-10-11 22:57:11 +00:00
|
|
|
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 ();
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu);
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_table_attach (GTK_TABLE (inputd->axis_list), option_menu,
|
2006-03-10 21:37:43 +00:00
|
|
|
1, 2, i, i+1, GTK_EXPAND | GTK_FILL, 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++)
|
2000-07-03 19:00:23 +00:00
|
|
|
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);
|
1997-12-18 02:17:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_input_dialog_clear_key (GtkWidget *widget, GtkInputKeyInfo *key)
|
|
|
|
{
|
2002-11-12 21:54:16 +00:00
|
|
|
if (!key->inputd->current_device)
|
|
|
|
return;
|
|
|
|
|
1998-12-14 17:39:58 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY(key->entry), _("(disabled)"));
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_key (key->inputd->current_device, key->index, 0, 0);
|
1997-12-18 02:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_input_dialog_set_key (GtkInputKeyInfo *key,
|
|
|
|
guint keyval, GdkModifierType modifiers)
|
|
|
|
{
|
|
|
|
GString *str;
|
|
|
|
gchar chars[2];
|
|
|
|
|
|
|
|
if (keyval)
|
|
|
|
{
|
2003-05-27 21:21:00 +00:00
|
|
|
str = g_string_new (NULL);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
|
|
|
if (modifiers & GDK_SHIFT_MASK)
|
2001-07-19 18:58:53 +00:00
|
|
|
g_string_append (str, "Shift+");
|
1997-12-18 02:17:14 +00:00
|
|
|
if (modifiers & GDK_CONTROL_MASK)
|
2001-07-19 18:58:53 +00:00
|
|
|
g_string_append (str, "Ctrl+");
|
1997-12-18 02:17:14 +00:00
|
|
|
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
|
1998-12-14 17:39:58 +00:00
|
|
|
g_string_append (str, _("(unknown)"));
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY(key->entry), str->str);
|
|
|
|
|
|
|
|
g_string_free (str, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-12-14 17:39:58 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY(key->entry), _("(disabled)"));
|
1997-12-18 02:17:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-12 21:54:16 +00:00
|
|
|
static gboolean
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_input_dialog_key_press (GtkWidget *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
GtkInputKeyInfo *key)
|
|
|
|
{
|
2002-11-12 21:54:16 +00:00
|
|
|
if (!key->inputd->current_device)
|
|
|
|
return FALSE;
|
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_input_dialog_set_key (key, event->keyval, event->state & 0xFF);
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_key (key->inputd->current_device, key->index,
|
|
|
|
event->keyval, event->state & 0xFF);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2008-08-11 12:54:57 +00:00
|
|
|
g_signal_stop_emission_by_name (widget, "key-press-event");
|
1997-12-18 02:17:14 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_input_dialog_destroy_key (GtkWidget *widget, GtkInputKeyInfo *key)
|
|
|
|
{
|
|
|
|
g_free (key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-03 19:00:23 +00:00
|
|
|
gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDevice *info)
|
1997-12-18 02:17:14 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *button;
|
2006-03-10 21:37:43 +00:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *viewport;
|
2007-04-26 06:23:36 +00:00
|
|
|
GtkWidget *old_child;
|
1997-12-18 02:17:14 +00:00
|
|
|
|
1998-05-03 22:41:32 +00:00
|
|
|
char buffer[32];
|
1997-12-18 02:17:14 +00:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
inputd->keys_list = gtk_table_new (info->num_keys, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (inputd->keys_list), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (inputd->keys_list), 12);
|
|
|
|
|
|
|
|
viewport = gtk_viewport_new (NULL, NULL);
|
2007-04-26 06:23:36 +00:00
|
|
|
old_child = gtk_bin_get_child (GTK_BIN (inputd->keys_listbox));
|
|
|
|
if (old_child != NULL)
|
|
|
|
gtk_widget_destroy (old_child);
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (inputd->keys_listbox), viewport);
|
|
|
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
|
|
|
|
gtk_widget_show (viewport);
|
|
|
|
gtk_container_add (GTK_CONTAINER (viewport), inputd->keys_list);
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_widget_show (inputd->keys_list);
|
|
|
|
|
|
|
|
gtk_widget_realize (inputd->keys_list);
|
|
|
|
gdk_window_set_background (inputd->keys_list->window,
|
1998-02-13 05:26:33 +00:00
|
|
|
&inputd->keys_list->style->base[GTK_STATE_NORMAL]);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
|
|
|
for (i=0;i<info->num_keys;i++)
|
|
|
|
{
|
|
|
|
GtkInputKeyInfo *key = g_new (GtkInputKeyInfo, 1);
|
|
|
|
key->index = i;
|
|
|
|
key->inputd = inputd;
|
|
|
|
|
|
|
|
/* create the label */
|
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "_%d:", i+1);
|
|
|
|
label = gtk_label_new_with_mnemonic (buffer);
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_table_attach (GTK_TABLE (inputd->keys_list), label, 0, 1, i, i+1,
|
2006-03-10 21:37:43 +00:00
|
|
|
GTK_FILL, 0, 2, 2);
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the entry */
|
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_table_attach (GTK_TABLE (inputd->keys_list), hbox, 1, 2, i, i+1,
|
|
|
|
GTK_EXPAND | GTK_FILL, 0, 2, 2);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
key->entry = gtk_entry_new ();
|
2006-03-10 21:37:43 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), key->entry);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), key->entry, TRUE, TRUE, 0);
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_widget_show (key->entry);
|
|
|
|
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (key->entry, "key-press-event",
|
2002-10-11 22:57:11 +00:00
|
|
|
G_CALLBACK (gtk_input_dialog_key_press), key);
|
|
|
|
g_signal_connect (key->entry, "destroy",
|
|
|
|
G_CALLBACK (gtk_input_dialog_destroy_key), key);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
|
|
|
/* and clear button */
|
|
|
|
|
2006-03-10 21:37:43 +00:00
|
|
|
button = gtk_button_new_with_mnemonic (_("Cl_ear"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2002-10-11 22:57:11 +00:00
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (gtk_input_dialog_clear_key), key);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
gtk_input_dialog_set_key (key, info->keys[i].keyval,
|
|
|
|
info->keys[i].modifiers);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-20 07:01:23 +00:00
|
|
|
|
|
|
|
#define __GTK_INPUTDIALOG_C__
|
|
|
|
#include "gtkaliasdef.c"
|