keybindings work
- From: Havoc Pennington <hp redhat com>
- To: gtk-devel-list gnome org
- Subject: keybindings work
- Date: 19 Apr 2001 14:21:04 -0400
Hi,
Here's a patch that makes all the easy-to-change keybindings into
binding sets, and adds numeric keypad support as appropriate.
We have assorted hard-to-fix keybindings in file selector, GtkCombo,
and places like that; will poke some of these soon, will probably
leave deprecated junk like GtkText alone though.
Also, I think for some global keys (drag-and-drop cancel key - Escape
by default - and F10 for menu bar focus, are two examples) will
probably make those keys a GtkSetting, unless someone has a better
idea.
Havoc
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.1907
diff -u -u -r1.1907 ChangeLog
--- ChangeLog 2001/04/18 22:21:42 1.1907
+++ ChangeLog 2001/04/19 17:59:07
@@ -1,3 +1,38 @@
+2001-04-19 Havoc Pennington <hp redhat com>
+
+ * gtk/gtknotebook.c: remove key press handler, replace with
+ binding set, add numeric keypad support
+
+ * gtk/gtktextview.c (gtk_text_view_class_init): accept KP_Delete
+
+ * gtk/gtktext.c (gtk_text_key_press): add a bunch of KP keysyms
+
+ * gtk/gtkentry.c (gtk_entry_class_init): accept GDK_KP_Delete in
+ addition to plain Delete
+
+ * gtk/gtktextview.c (gtk_text_view_key_press_event): accept
+ GDK_KP_Enter in addition to GDK_Return
+
+ * gtk/gtkfontsel.c (gtk_font_selection_size_key_press): connect to
+ activate on entry instead of key press
+ (gtk_font_selection_on_clist_key_press): get
+ rid of this signal handler, not needed with new font sel.
+
+ * gtk/gtkfilesel.c (gtk_file_selection_key_press): remove a
+ no-longer-needed emit_stop_by_name(), just return TRUE
+
+ * gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.c: remove keybindings
+ cruft, this widget is no longer focusable.
+
+ * gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkvscale.c,
+ gtk/gtkhscale.c: Get rid of trough_keys virtual function, add
+ move_slider action signal, add binding set for vscale/hscale, in
+ the process support numeric keypad
+
+ * gtk/gtkentry.c (gtk_entry_class_init): Add keypad bindings;
+ make GDK_Return and GDK_KP_Enter activate the entry via
+ binding set, instead of hardcoded.
+
2001-04-18 Havoc Pennington <hp redhat com>
* gtk/gtkwindow.c (gtk_window_class_init): add signals and binding
Index: docs/reference/gtk/tmpl/gtknotebook.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/tmpl/gtknotebook.sgml,v
retrieving revision 1.7
diff -u -u -r1.7 gtknotebook.sgml
--- docs/reference/gtk/tmpl/gtknotebook.sgml 2001/01/09 16:41:17 1.7
+++ docs/reference/gtk/tmpl/gtknotebook.sgml 2001/04/19 17:59:07
@@ -336,6 +336,22 @@
@tab_vborder:
+<!-- ##### SIGNAL GtkNotebook::focus-tab ##### -->
+<para>
+
+</para>
+
+ notebook: the object which received the signal.
+ arg1:
+
+<!-- ##### SIGNAL GtkNotebook::select-page ##### -->
+<para>
+
+</para>
+
+ notebook: the object which received the signal.
+ arg1:
+
<!-- ##### SIGNAL GtkNotebook::switch-page ##### -->
<para>
Emitted when the user or a function changes the current page.
Index: docs/reference/gtk/tmpl/gtkrange.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/tmpl/gtkrange.sgml,v
retrieving revision 1.5
diff -u -u -r1.5 gtkrange.sgml
--- docs/reference/gtk/tmpl/gtkrange.sgml 2001/03/23 22:21:05 1.5
+++ docs/reference/gtk/tmpl/gtkrange.sgml 2001/04/19 17:59:07
@@ -65,6 +65,15 @@
@setting:
+<!-- ##### SIGNAL GtkRange::move-slider ##### -->
+<para>
+
+</para>
+
+ range: the object which received the signal.
+ arg1:
+ arg2:
+
<!-- ##### ARG GtkRange:update-policy ##### -->
<para>
Index: gtk/gtkentry.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkentry.c,v
retrieving revision 1.124
diff -u -u -r1.124 gtkentry.c
--- gtk/gtkentry.c 2001/04/18 20:16:37 1.124
+++ gtk/gtkentry.c 2001/04/19 17:59:07
@@ -552,6 +552,12 @@
add_move_binding (binding_set, GDK_Left, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
+ add_move_binding (binding_set, GDK_KP_Right, 0,
+ GTK_MOVEMENT_VISUAL_POSITIONS, 1);
+
+ add_move_binding (binding_set, GDK_KP_Left, 0,
+ GTK_MOVEMENT_VISUAL_POSITIONS, -1);
+
add_move_binding (binding_set, GDK_f, GDK_CONTROL_MASK,
GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
@@ -563,6 +569,12 @@
add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
GTK_MOVEMENT_WORDS, -1);
+
+ add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_WORDS, 1);
+
+ add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_WORDS, -1);
add_move_binding (binding_set, GDK_a, GDK_CONTROL_MASK,
GTK_MOVEMENT_PARAGRAPH_ENDS, -1);
@@ -581,6 +593,12 @@
add_move_binding (binding_set, GDK_End, 0,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
+
+ add_move_binding (binding_set, GDK_KP_Home, 0,
+ GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
+
+ add_move_binding (binding_set, GDK_KP_End, 0,
+ GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
add_move_binding (binding_set, GDK_Home, GDK_CONTROL_MASK,
GTK_MOVEMENT_BUFFER_ENDS, -1);
@@ -588,12 +606,31 @@
add_move_binding (binding_set, GDK_End, GDK_CONTROL_MASK,
GTK_MOVEMENT_BUFFER_ENDS, 1);
+ add_move_binding (binding_set, GDK_KP_Home, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_BUFFER_ENDS, -1);
+
+ add_move_binding (binding_set, GDK_KP_End, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_BUFFER_ENDS, 1);
+
+ /* Activate */
+
+ gtk_binding_entry_add_signal (binding_set, GDK_Return, 0,
+ "activate", 0);
+
+ gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0,
+ "activate", 0);
+
/* Deleting text */
gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0,
"delete_from_cursor", 2,
GTK_TYPE_ENUM, GTK_DELETE_CHARS,
GTK_TYPE_INT, 1);
+ gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0,
+ "delete_from_cursor", 2,
+ GTK_TYPE_ENUM, GTK_DELETE_CHARS,
+ GTK_TYPE_INT, 1);
+
gtk_binding_entry_add_signal (binding_set, GDK_d, GDK_CONTROL_MASK,
"delete_from_cursor", 2,
GTK_TYPE_ENUM, GTK_DELETE_CHARS,
@@ -609,6 +646,11 @@
GTK_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
GTK_TYPE_INT, 1);
+ gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_CONTROL_MASK,
+ "delete_from_cursor", 2,
+ GTK_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
+ GTK_TYPE_INT, 1);
+
gtk_binding_entry_add_signal (binding_set, GDK_d, GDK_MOD1_MASK,
"delete_from_cursor", 2,
GTK_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
@@ -1463,11 +1505,6 @@
/* Activate key bindings
*/
return TRUE;
- else if (event->keyval == GDK_Return)
- {
- gtk_widget_activate (widget);
- return TRUE;
- }
return FALSE;
}
Index: gtk/gtkfilesel.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilesel.c,v
retrieving revision 1.78
diff -u -u -r1.78 gtkfilesel.c
--- gtk/gtkfilesel.c 2001/03/31 19:33:47 1.78
+++ gtk/gtkfilesel.c 2001/04/19 17:59:07
@@ -1424,8 +1424,6 @@
g_free (text);
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
-
return TRUE;
}
Index: gtk/gtkfontsel.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfontsel.c,v
retrieving revision 1.47
diff -u -u -r1.47 gtkfontsel.c
--- gtk/gtkfontsel.c 2001/03/24 06:10:39 1.47
+++ gtk/gtkfontsel.c 2001/04/19 17:59:07
@@ -86,13 +86,6 @@
gint column,
GdkEventButton *bevent,
gpointer data);
-static gint gtk_font_selection_on_clist_key_press (GtkWidget *clist,
- GdkEventKey *event,
- GtkFontSelection *fs);
-static gboolean gtk_font_selection_select_next (GtkFontSelection *fs,
- GtkWidget *clist,
- gint step);
-
static void gtk_font_selection_show_available_fonts (GtkFontSelection *fs);
static void gtk_font_selection_show_available_styles (GtkFontSelection *fs);
@@ -106,8 +99,7 @@
static void gtk_font_selection_select_best_size (GtkFontSelection *fs);
static void gtk_font_selection_show_available_sizes (GtkFontSelection *fs);
-static gint gtk_font_selection_size_key_press (GtkWidget *w,
- GdkEventKey *event,
+static void gtk_font_selection_size_activate (GtkWidget *w,
gpointer data);
static void gtk_font_selection_select_size (GtkWidget *w,
gint row,
@@ -206,8 +198,8 @@
gtk_widget_show (fontsel->size_entry);
gtk_table_attach (GTK_TABLE (table), fontsel->size_entry, 2, 3, 1, 2,
GTK_FILL, 0, 0, 0);
- gtk_signal_connect (GTK_OBJECT (fontsel->size_entry), "key_press_event",
- (GtkSignalFunc) gtk_font_selection_size_key_press,
+ gtk_signal_connect (GTK_OBJECT (fontsel->size_entry), "activate",
+ (GtkSignalFunc) gtk_font_selection_size_activate,
fontsel);
fontsel->font_label = gtk_label_new_with_mnemonic (_("_Family:"));
@@ -285,9 +277,6 @@
GTK_SIGNAL_FUNC(gtk_font_selection_select_font),
fontsel);
GTK_WIDGET_SET_FLAGS (fontsel->font_clist, GTK_CAN_FOCUS);
- gtk_signal_connect (GTK_OBJECT (fontsel->font_clist), "key_press_event",
- GTK_SIGNAL_FUNC(gtk_font_selection_on_clist_key_press),
- fontsel);
gtk_signal_connect_after (GTK_OBJECT (fontsel->font_clist), "expose_event",
GTK_SIGNAL_FUNC(gtk_font_selection_expose_list),
fontsel);
@@ -298,10 +287,6 @@
GTK_SIGNAL_FUNC(gtk_font_selection_select_style),
fontsel);
GTK_WIDGET_SET_FLAGS (fontsel->font_style_clist, GTK_CAN_FOCUS);
- gtk_signal_connect (GTK_OBJECT (fontsel->font_style_clist),
- "key_press_event",
- GTK_SIGNAL_FUNC(gtk_font_selection_on_clist_key_press),
- fontsel);
gtk_font_selection_show_available_sizes (fontsel);
@@ -309,9 +294,6 @@
GTK_SIGNAL_FUNC(gtk_font_selection_select_size),
fontsel);
GTK_WIDGET_SET_FLAGS (fontsel->size_clist, GTK_CAN_FOCUS);
- gtk_signal_connect (GTK_OBJECT (fontsel->size_clist), "key_press_event",
- GTK_SIGNAL_FUNC(gtk_font_selection_on_clist_key_press),
- fontsel);
/* create the text entry widget */
text_frame = gtk_frame_new (_("Preview:"));
@@ -480,59 +462,6 @@
pango_font_map_free_families (families, n_families);
}
-static gint
-gtk_font_selection_on_clist_key_press (GtkWidget *clist,
- GdkEventKey *event,
- GtkFontSelection *fontsel)
-{
-#ifdef FONTSEL_DEBUG
- g_message("In on_clist_key_press\n");
-#endif
- if (event->keyval == GDK_Up)
- return gtk_font_selection_select_next (fontsel, clist, -1);
- else if (event->keyval == GDK_Down)
- return gtk_font_selection_select_next (fontsel, clist, 1);
- else
- return FALSE;
-}
-
-
-static gboolean
-gtk_font_selection_select_next (GtkFontSelection *fontsel,
- GtkWidget *clist,
- gint step)
-{
- GList *selection;
- gint current_row, row;
-
- selection = GTK_CLIST(clist)->selection;
- if (!selection)
- return FALSE;
- current_row = GPOINTER_TO_INT (selection->data);
-
- /* Stop the normal clist key handler from being run. */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (clist), "key_press_event");
-
- for (row = current_row + step;
- row >= 0 && row < GTK_CLIST(clist)->rows;
- row += step)
- {
- /* If this is the style clist, make sure that the item is not a charset
- entry. */
- if (clist == fontsel->font_style_clist)
- if (GPOINTER_TO_INT (gtk_clist_get_row_data(GTK_CLIST(clist), row)) == -1)
- continue;
-
- /* Now we've found the row to select. */
- if (gtk_clist_row_is_visible(GTK_CLIST(clist), row)
- != GTK_VISIBILITY_FULL)
- gtk_clist_moveto(GTK_CLIST(clist), row, -1, (step < 0) ? 0 : 1, 0);
- gtk_clist_select_row(GTK_CLIST(clist), row, 0);
- break;
- }
- return TRUE;
-}
-
static int
compare_font_descriptions (const PangoFontDescription *a, const PangoFontDescription *b)
{
@@ -702,31 +631,24 @@
/* If the user hits return in the font size entry, we change to the new font
size. */
-static gint
-gtk_font_selection_size_key_press (GtkWidget *w,
- GdkEventKey *event,
- gpointer data)
+static void
+gtk_font_selection_size_activate (GtkWidget *w,
+ gpointer data)
{
GtkFontSelection *fontsel;
gint new_size;
gchar *text;
fontsel = GTK_FONT_SELECTION (data);
+
+ text = gtk_entry_get_text (GTK_ENTRY (fontsel->size_entry));
+ new_size = atoi (text) * PANGO_SCALE;
- if (event->keyval == GDK_Return)
+ if (fontsel->font_desc->size != new_size)
{
- text = gtk_entry_get_text (GTK_ENTRY (fontsel->size_entry));
- new_size = atoi (text) * PANGO_SCALE;
-
- if (fontsel->font_desc->size != new_size)
- {
- fontsel->font_desc->size = new_size;
- gtk_font_selection_load_font (fontsel);
- }
- return TRUE;
+ fontsel->font_desc->size = new_size;
+ gtk_font_selection_load_font (fontsel);
}
-
- return FALSE;
}
/* This is called when a size is selected in the list. */
Index: gtk/gtkhscale.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkhscale.c,v
retrieving revision 1.31
diff -u -u -r1.31 gtkhscale.c
--- gtk/gtkhscale.c 2001/04/02 15:51:25 1.31
+++ gtk/gtkhscale.c 2001/04/19 17:59:07
@@ -29,6 +29,7 @@
#include "gtksignal.h"
#include "gdk/gdkkeysyms.h"
#include "gtkintl.h"
+#include "gtkbindings.h"
#define SCALE_CLASS(w) GTK_SCALE_GET_CLASS (w)
#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
@@ -65,10 +66,7 @@
gint *h);
static void gtk_hscale_draw_slider (GtkRange *range);
static void gtk_hscale_draw_value (GtkScale *scale);
-static gboolean gtk_hscale_trough_keys (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos);
+
static void gtk_hscale_clear_background (GtkRange *range);
@@ -97,6 +95,12 @@
return hscale_type;
}
+#define add_slider_binding(binding_set, keyval, mask, scroll, trough) \
+ gtk_binding_entry_add_signal (binding_set, keyval, mask, \
+ "move_slider", 2, \
+ GTK_TYPE_SCROLL_TYPE, scroll, \
+ GTK_TYPE_TROUGH_TYPE, trough)
+
static void
gtk_hscale_class_init (GtkHScaleClass *class)
{
@@ -105,7 +109,8 @@
GtkWidgetClass *widget_class;
GtkRangeClass *range_class;
GtkScaleClass *scale_class;
-
+ GtkBindingSet *binding_set;
+
gobject_class = (GObjectClass*) class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
@@ -123,7 +128,6 @@
range_class->trough_click = _gtk_range_default_htrough_click;
range_class->motion = _gtk_range_default_hmotion;
range_class->draw_slider = gtk_hscale_draw_slider;
- range_class->trough_keys = gtk_hscale_trough_keys;
range_class->clear_background = gtk_hscale_clear_background;
scale_class->draw_value = gtk_hscale_draw_value;
@@ -135,7 +139,45 @@
_("The GtkAdjustment that determines the values to use for this HScale."),
GTK_TYPE_ADJUSTMENT,
G_PARAM_READWRITE));
+ binding_set = gtk_binding_set_by_class (object_class);
+
+ add_slider_binding (binding_set, GDK_Left, 0,
+ GTK_SCROLL_STEP_LEFT, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_LEFT, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Left, 0,
+ GTK_SCROLL_STEP_LEFT, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_LEFT, GTK_TROUGH_NONE);
+
+
+ add_slider_binding (binding_set, GDK_Right, 0,
+ GTK_SCROLL_STEP_RIGHT, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_RIGHT, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Right, 0,
+ GTK_SCROLL_STEP_RIGHT, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_RIGHT, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Home, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_START);
+ add_slider_binding (binding_set, GDK_KP_Home, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_START);
+
+
+ add_slider_binding (binding_set, GDK_End, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_END);
+
+ add_slider_binding (binding_set, GDK_KP_End, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_END);
}
static void
@@ -554,39 +596,4 @@
g_object_unref (G_OBJECT (layout));
}
-}
-
-static gboolean
-gtk_hscale_trough_keys (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos)
-{
- gint return_val = FALSE;
- switch (key->keyval)
- {
- case GDK_Left:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *scroll = GTK_SCROLL_PAGE_LEFT;
- else
- *scroll = GTK_SCROLL_STEP_LEFT;
- break;
- case GDK_Right:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *scroll = GTK_SCROLL_PAGE_RIGHT;
- else
- *scroll = GTK_SCROLL_STEP_RIGHT;
- break;
- case GDK_Home:
- return_val = TRUE;
- *pos = GTK_TROUGH_START;
- break;
- case GDK_End:
- return_val = TRUE;
- *pos = GTK_TROUGH_END;
- break;
- }
- return return_val;
}
Index: gtk/gtkhscrollbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkhscrollbar.c,v
retrieving revision 1.24
diff -u -u -r1.24 gtkhscrollbar.c
--- gtk/gtkhscrollbar.c 2001/04/02 15:51:26 1.24
+++ gtk/gtkhscrollbar.c 2001/04/19 17:59:07
@@ -58,10 +58,6 @@
static void gtk_hscrollbar_draw_step_back (GtkRange *range);
static void gtk_hscrollbar_slider_update (GtkRange *range);
static void gtk_hscrollbar_calc_slider_size (GtkHScrollbar *hscrollbar);
-static gboolean gtk_hscrollbar_trough_keys (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos);
GtkType
gtk_hscrollbar_get_type (void)
@@ -112,7 +108,6 @@
range_class->draw_step_back = gtk_hscrollbar_draw_step_back;
range_class->slider_update = gtk_hscrollbar_slider_update;
range_class->trough_click = _gtk_range_default_htrough_click;
- range_class->trough_keys = gtk_hscrollbar_trough_keys;
range_class->motion = _gtk_range_default_hmotion;
g_object_class_install_property (gobject_class,
@@ -463,39 +458,4 @@
gdk_window_invalidate_rect (range->slider, NULL, FALSE);
}
}
-}
-
-static gboolean
-gtk_hscrollbar_trough_keys(GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos)
-{
- gint return_val = FALSE;
- switch (key->keyval)
- {
- case GDK_Left:
- return_val = TRUE;
- *scroll = GTK_SCROLL_STEP_BACKWARD;
- break;
- case GDK_Right:
- return_val = TRUE;
- *scroll = GTK_SCROLL_STEP_FORWARD;
- break;
- case GDK_Home:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *scroll = GTK_SCROLL_PAGE_BACKWARD;
- else
- *pos = GTK_TROUGH_START;
- break;
- case GDK_End:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *scroll = GTK_SCROLL_PAGE_FORWARD;
- else
- *pos = GTK_TROUGH_END;
- break;
- }
- return return_val;
}
Index: gtk/gtkmarshal.list
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmarshal.list,v
retrieving revision 1.30
diff -u -u -r1.30 gtkmarshal.list
--- gtk/gtkmarshal.list 2001/04/02 23:38:53 1.30
+++ gtk/gtkmarshal.list 2001/04/19 17:59:07
@@ -48,6 +48,7 @@
VOID:BOXED,UINT,FLAGS
VOID:BOXED,UINT,UINT
VOID:ENUM
+VOID:ENUM,ENUM
VOID:ENUM,FLOAT
VOID:ENUM,FLOAT,BOOL
VOID:ENUM,INT
Index: gtk/gtknotebook.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.c,v
retrieving revision 1.86
diff -u -u -r1.86 gtknotebook.c
--- gtk/gtknotebook.c 2001/04/01 07:32:39 1.86
+++ gtk/gtknotebook.c 2001/04/19 17:59:07
@@ -33,6 +33,7 @@
#include <gdk/gdkkeysyms.h>
#include <stdio.h>
#include "gtkintl.h"
+#include "gtkbindings.h"
#define TAB_OVERLAP 2
@@ -46,6 +47,8 @@
enum {
SWITCH_PAGE,
+ FOCUS_TAB,
+ SELECT_PAGE,
LAST_SIGNAL
};
@@ -111,6 +114,11 @@
static void gtk_notebook_class_init (GtkNotebookClass *klass);
static void gtk_notebook_init (GtkNotebook *notebook);
+static void gtk_notebook_select_page (GtkNotebook *notebook,
+ gboolean move_focus);
+static void gtk_notebook_focus_tab (GtkNotebook *notebook,
+ GtkNotebookTab type);
+
/*** GtkObject Methods ***/
static void gtk_notebook_destroy (GtkObject *object);
static void gtk_notebook_set_arg (GtkObject *object,
@@ -141,8 +149,6 @@
GdkEventCrossing *event);
static gint gtk_notebook_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
-static gint gtk_notebook_key_press (GtkWidget *widget,
- GdkEventKey *event);
static gint gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_notebook_draw_focus (GtkWidget *widget);
@@ -274,7 +280,8 @@
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
-
+ GtkBindingSet *binding_set;
+
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
container_class = (GtkContainerClass*) class;
@@ -297,7 +304,6 @@
widget_class->enter_notify_event = gtk_notebook_enter_notify;
widget_class->leave_notify_event = gtk_notebook_leave_notify;
widget_class->motion_notify_event = gtk_notebook_motion_notify;
- widget_class->key_press_event = gtk_notebook_key_press;
widget_class->focus_in_event = gtk_notebook_focus_in;
widget_class->style_set = gtk_notebook_style_set;
@@ -312,6 +318,9 @@
class->switch_page = gtk_notebook_real_switch_page;
+ class->focus_tab = gtk_notebook_focus_tab;
+ class->select_page = gtk_notebook_select_page;
+
gtk_object_add_arg_type ("GtkNotebook::page", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PAGE);
gtk_object_add_arg_type ("GtkNotebook::tab_pos", GTK_TYPE_POSITION_TYPE, GTK_ARG_READWRITE, ARG_TAB_POS);
gtk_object_add_arg_type ("GtkNotebook::tab_border", GTK_TYPE_UINT, GTK_ARG_WRITABLE, ARG_TAB_BORDER);
@@ -338,6 +347,60 @@
GTK_TYPE_NONE, 2,
GTK_TYPE_POINTER,
GTK_TYPE_UINT);
+
+ notebook_signals[FOCUS_TAB] =
+ g_signal_newc ("focus_tab",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkNotebookClass, focus_tab),
+ NULL, NULL,
+ gtk_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_NOTEBOOK_TAB);
+
+ notebook_signals[SELECT_PAGE] =
+ g_signal_newc ("select_page",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkNotebookClass, select_page),
+ NULL, NULL,
+ gtk_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1,
+ G_TYPE_BOOLEAN);
+
+ binding_set = gtk_binding_set_by_class (object_class);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_Return, 0,
+ "select_page", 1,
+ G_TYPE_BOOLEAN, TRUE);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KP_Enter, 0,
+ "select_page", 1,
+ G_TYPE_BOOLEAN, TRUE);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_space, 0,
+ "select_page", 1,
+ G_TYPE_BOOLEAN, FALSE);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_Home, 0,
+ "focus_tab", 1,
+ GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_FIRST);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KP_Home, 0,
+ "focus_tab", 1,
+ GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_FIRST);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_End, 0,
+ "focus_tab", 1,
+ GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_LAST);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KP_End, 0,
+ "focus_tab", 1,
+ GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_LAST);
}
static void
@@ -368,6 +431,34 @@
notebook->have_visible_child = FALSE;
}
+static void
+gtk_notebook_select_page (GtkNotebook *notebook,
+ gboolean move_focus)
+{
+ gtk_notebook_page_select (notebook, move_focus);
+}
+
+static void
+gtk_notebook_focus_tab (GtkNotebook *notebook,
+ GtkNotebookTab type)
+{
+ GList *list;
+
+ switch (type)
+ {
+ case GTK_NOTEBOOK_TAB_FIRST:
+ list = gtk_notebook_search_page (notebook, NULL, STEP_NEXT, TRUE);
+ if (list)
+ gtk_notebook_switch_focus_tab (notebook, list);
+ break;
+ case GTK_NOTEBOOK_TAB_LAST:
+ list = gtk_notebook_search_page (notebook, NULL, STEP_PREV, TRUE);
+ if (list)
+ gtk_notebook_switch_focus_tab (notebook, list);
+ break;
+ }
+}
+
/**
* gtk_notebook_new:
*
@@ -509,7 +600,6 @@
* gtk_notebook_enter_notify
* gtk_notebook_leave_notify
* gtk_notebook_motion_notify
- * gtk_notebook_key_press
* gtk_notebook_focus_in
* gtk_notebook_focus_out
* gtk_notebook_draw_focus
@@ -1226,45 +1316,6 @@
gtk_notebook_redraw_arrows (notebook);
}
- return FALSE;
-}
-
-static gint
-gtk_notebook_key_press (GtkWidget *widget,
- GdkEventKey *event)
-{
- GtkNotebook *notebook;
- GList *list;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- notebook = GTK_NOTEBOOK (widget);
-
- if (!notebook->children || !notebook->show_tabs)
- return FALSE;
-
- switch (event->keyval)
- {
- case GDK_Home:
- list = gtk_notebook_search_page (notebook, NULL, STEP_NEXT, TRUE);
- if (list)
- gtk_notebook_switch_focus_tab (notebook, list);
- return TRUE;
- case GDK_End:
- list = gtk_notebook_search_page (notebook, NULL, STEP_PREV, TRUE);
- if (list)
- gtk_notebook_switch_focus_tab (notebook, list);
- return TRUE;
- case GDK_Return:
- gtk_notebook_page_select (GTK_NOTEBOOK (widget), TRUE);
- return TRUE;
- case GDK_space:
- gtk_notebook_page_select (GTK_NOTEBOOK (widget), FALSE);
- return TRUE;
- }
-
return FALSE;
}
Index: gtk/gtknotebook.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.h,v
retrieving revision 1.23
diff -u -u -r1.23 gtknotebook.h
--- gtk/gtknotebook.h 2000/12/11 17:47:24 1.23
+++ gtk/gtknotebook.h 2001/04/19 17:59:07
@@ -45,6 +45,12 @@
#define GTK_NOTEBOOK_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_NOTEBOOK, GtkNotebookClass))
+typedef enum
+{
+ GTK_NOTEBOOK_TAB_FIRST,
+ GTK_NOTEBOOK_TAB_LAST
+} GtkNotebookTab;
+
typedef struct _GtkNotebook GtkNotebook;
typedef struct _GtkNotebookClass GtkNotebookClass;
typedef struct _GtkNotebookPage GtkNotebookPage;
@@ -86,6 +92,14 @@
void (* switch_page) (GtkNotebook *notebook,
GtkNotebookPage *page,
guint page_num);
+
+ /* Action signals for keybindings */
+ void (* select_page) (GtkNotebook *notebook,
+ gboolean move_focus);
+
+ void (* focus_tab) (GtkNotebook *notebook,
+ GtkNotebookTab type);
+
};
/***********************************************************
Index: gtk/gtkrange.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkrange.c,v
retrieving revision 1.50
diff -u -u -r1.50 gtkrange.c
--- gtk/gtkrange.c 2001/04/02 15:51:26 1.50
+++ gtk/gtkrange.c 2001/04/19 17:59:07
@@ -43,6 +43,11 @@
PROP_UPDATE_POLICY
};
+enum {
+ MOVE_SLIDER,
+ LAST_SIGNAL
+};
+
static void gtk_range_class_init (GtkRangeClass *klass);
static void gtk_range_init (GtkRange *range);
static void gtk_range_set_property (GObject *object,
@@ -63,8 +68,6 @@
GdkEventButton *event);
static gint gtk_range_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
-static gint gtk_range_key_press (GtkWidget *widget,
- GdkEventKey *event);
static gint gtk_range_enter_notify (GtkWidget *widget,
GdkEventCrossing *event);
static gint gtk_range_leave_notify (GtkWidget *widget,
@@ -74,6 +77,10 @@
static void gtk_range_style_set (GtkWidget *widget,
GtkStyle *previous_style);
+static void gtk_range_move_slider (GtkRange *range,
+ GtkScrollType scroll,
+ GtkTroughType trough);
+
static void gtk_real_range_draw_trough (GtkRange *range);
static void gtk_real_range_draw_slider (GtkRange *range);
static gint gtk_real_range_timer (GtkRange *range);
@@ -96,6 +103,7 @@
gint *bottom);
static GtkWidgetClass *parent_class = NULL;
+static guint signals[LAST_SIGNAL];
GtkType
@@ -146,16 +154,18 @@
widget_class->button_release_event = gtk_range_button_release;
widget_class->motion_notify_event = gtk_range_motion_notify;
widget_class->scroll_event = gtk_range_scroll_event;
- widget_class->key_press_event = gtk_range_key_press;
widget_class->enter_notify_event = gtk_range_enter_notify;
widget_class->leave_notify_event = gtk_range_leave_notify;
widget_class->style_set = gtk_range_style_set;
-
+
class->min_slider_size = 7;
class->trough = 1;
class->slider = 2;
class->step_forw = 3;
class->step_back = 4;
+
+ class->move_slider = gtk_range_move_slider;
+
class->draw_background = NULL;
class->clear_background = NULL;
class->draw_trough = gtk_real_range_draw_trough;
@@ -163,10 +173,21 @@
class->draw_step_forw = NULL;
class->draw_step_back = NULL;
class->trough_click = NULL;
- class->trough_keys = NULL;
class->motion = NULL;
class->timer = gtk_real_range_timer;
+ signals[MOVE_SLIDER] =
+ g_signal_newc ("move_slider",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkRangeClass, move_slider),
+ NULL, NULL,
+ gtk_marshal_VOID__ENUM_ENUM,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_SCROLL_TYPE,
+ GTK_TYPE_TROUGH_TYPE);
+
+
g_object_class_install_property (gobject_class,
PROP_UPDATE_POLICY,
g_param_spec_enum ("update_policy",
@@ -1137,94 +1158,78 @@
return TRUE;
}
-
-static gint
-gtk_range_key_press (GtkWidget *widget,
- GdkEventKey *event)
-{
- GtkRange *range;
- gint return_val;
- GtkScrollType scroll = GTK_SCROLL_NONE;
- GtkTroughType pos = GTK_TROUGH_NONE;
-
- g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- range = GTK_RANGE (widget);
- return_val = FALSE;
-
- if (RANGE_CLASS (range)->trough_keys)
- return_val = (* RANGE_CLASS (range)->trough_keys) (range, event, &scroll, &pos);
-
- if (return_val)
- {
- if (scroll != GTK_SCROLL_NONE)
- {
- range->scroll_type = scroll;
- gtk_range_scroll (range, -1);
- if (range->old_value != range->adjustment->value)
- {
- gtk_signal_emit_by_name (GTK_OBJECT (range->adjustment), "value_changed");
- switch (range->scroll_type)
- {
- case GTK_SCROLL_STEP_LEFT:
- if (should_invert (range, TRUE))
- _gtk_range_draw_step_forw (range);
- else
- _gtk_range_draw_step_back (range);
- break;
+static void
+gtk_range_move_slider (GtkRange *range,
+ GtkScrollType scroll,
+ GtkTroughType pos)
+{
+ if (scroll != GTK_SCROLL_NONE)
+ {
+ range->scroll_type = scroll;
+
+ gtk_range_scroll (range, -1);
+ if (range->old_value != range->adjustment->value)
+ {
+ gtk_signal_emit_by_name (GTK_OBJECT (range->adjustment), "value_changed");
+ switch (range->scroll_type)
+ {
+ case GTK_SCROLL_STEP_LEFT:
+ if (should_invert (range, TRUE))
+ _gtk_range_draw_step_forw (range);
+ else
+ _gtk_range_draw_step_back (range);
+ break;
- case GTK_SCROLL_STEP_UP:
- if (should_invert (range, FALSE))
- _gtk_range_draw_step_forw (range);
- else
- _gtk_range_draw_step_back (range);
- break;
-
- case GTK_SCROLL_STEP_RIGHT:
- if (should_invert (range, TRUE))
- _gtk_range_draw_step_back (range);
- else
- _gtk_range_draw_step_forw (range);
- break;
+ case GTK_SCROLL_STEP_UP:
+ if (should_invert (range, FALSE))
+ _gtk_range_draw_step_forw (range);
+ else
+ _gtk_range_draw_step_back (range);
+ break;
+
+ case GTK_SCROLL_STEP_RIGHT:
+ if (should_invert (range, TRUE))
+ _gtk_range_draw_step_back (range);
+ else
+ _gtk_range_draw_step_forw (range);
+ break;
- case GTK_SCROLL_STEP_DOWN:
- if (should_invert (range, FALSE))
- _gtk_range_draw_step_back (range);
- else
- _gtk_range_draw_step_forw (range);
- break;
+ case GTK_SCROLL_STEP_DOWN:
+ if (should_invert (range, FALSE))
+ _gtk_range_draw_step_back (range);
+ else
+ _gtk_range_draw_step_forw (range);
+ break;
- case GTK_SCROLL_STEP_BACKWARD:
- _gtk_range_draw_step_back (range);
- break;
+ case GTK_SCROLL_STEP_BACKWARD:
+ _gtk_range_draw_step_back (range);
+ break;
- case GTK_SCROLL_STEP_FORWARD:
- _gtk_range_draw_step_forw (range);
- break;
- }
- }
- }
- if (pos != GTK_TROUGH_NONE)
- {
- if (pos == GTK_TROUGH_START)
- range->adjustment->value = range->adjustment->lower;
- else if (pos == GTK_TROUGH_END)
- range->adjustment->value =
- range->adjustment->upper - range->adjustment->page_size;
-
- if (range->old_value != range->adjustment->value)
- {
- gtk_signal_emit_by_name (GTK_OBJECT (range->adjustment),
- "value_changed");
+ case GTK_SCROLL_STEP_FORWARD:
+ _gtk_range_draw_step_forw (range);
+ break;
+ }
+ }
+ }
- _gtk_range_slider_update (range);
- _gtk_range_clear_background (range);
- }
- }
+ if (pos != GTK_TROUGH_NONE)
+ {
+ if (pos == GTK_TROUGH_START)
+ range->adjustment->value = range->adjustment->lower;
+ else if (pos == GTK_TROUGH_END)
+ range->adjustment->value =
+ range->adjustment->upper - range->adjustment->page_size;
+
+ if (range->old_value != range->adjustment->value)
+ {
+ gtk_signal_emit_by_name (GTK_OBJECT (range->adjustment),
+ "value_changed");
+
+ _gtk_range_slider_update (range);
+ _gtk_range_clear_background (range);
+ }
}
- return return_val;
}
static gint
Index: gtk/gtkrange.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkrange.h,v
retrieving revision 1.17
diff -u -u -r1.17 gtkrange.h
--- gtk/gtkrange.h 2001/04/02 15:51:26 1.17
+++ gtk/gtkrange.h 2001/04/19 17:59:07
@@ -92,6 +92,12 @@
guint8 step_forw;
guint8 step_back;
+ /* action signals for keybindings */
+ void (* move_slider) (GtkRange *range,
+ GtkScrollType scroll,
+ GtkTroughType trough);
+
+ /* Completely broken virtual functions, please ignore */
void (* draw_background) (GtkRange *range);
void (* clear_background) (GtkRange *range);
void (* draw_trough) (GtkRange *range);
@@ -103,10 +109,6 @@
gint x,
gint y,
gdouble *jump_perc);
- gboolean (* trough_keys) (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *trough);
void (* motion) (GtkRange *range,
gint xdelta,
gint ydelta);
Index: gtk/gtktext.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktext.c,v
retrieving revision 1.100
diff -u -u -r1.100 gtktext.c
--- gtk/gtktext.c 2001/04/18 20:16:38 1.100
+++ gtk/gtktext.c 2001/04/19 17:59:07
@@ -1970,29 +1970,37 @@
switch (event->keyval)
{
+ case GDK_KP_Home:
case GDK_Home:
if (event->state & GDK_CONTROL_MASK)
move_cursor_buffer_ver (text, -1);
else
gtk_text_move_beginning_of_line (text);
break;
+ case GDK_KP_End:
case GDK_End:
if (event->state & GDK_CONTROL_MASK)
move_cursor_buffer_ver (text, +1);
else
gtk_text_move_end_of_line (text);
break;
+ case GDK_KP_Page_Up:
case GDK_Page_Up: move_cursor_page_ver (text, -1); break;
+ case GDK_KP_Page_Down:
case GDK_Page_Down: move_cursor_page_ver (text, +1); break;
/* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */
+ case GDK_KP_Up:
case GDK_Up: move_cursor_ver (text, -1); break;
+ case GDK_KP_Down:
case GDK_Down: move_cursor_ver (text, +1); break;
+ case GDK_KP_Left:
case GDK_Left:
if (event->state & GDK_CONTROL_MASK)
gtk_text_move_backward_word (text);
else
move_cursor_hor (text, -1);
break;
+ case GDK_KP_Right:
case GDK_Right:
if (event->state & GDK_CONTROL_MASK)
gtk_text_move_forward_word (text);
@@ -2025,6 +2033,7 @@
}
break;
case GDK_Delete:
+ case GDK_KP_Delete:
if (event->state & GDK_CONTROL_MASK)
gtk_text_delete_forward_word (text);
else if (event->state & GDK_SHIFT_MASK)
@@ -2036,9 +2045,11 @@
gtk_text_delete_forward_character (text);
break;
case GDK_Tab:
+ case GDK_ISO_Left_Tab:
position = text->point.index;
gtk_editable_insert_text (GTK_EDITABLE (old_editable), "\t", 1, &position);
break;
+ case GDK_KP_Enter:
case GDK_Return:
if (event->state & GDK_CONTROL_MASK)
gtk_signal_emit_by_name (GTK_OBJECT (text), "activate");
Index: gtk/gtktextview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextview.c,v
retrieving revision 1.80
diff -u -u -r1.80 gtktextview.c
--- gtk/gtktextview.c 2001/04/18 18:09:18 1.80
+++ gtk/gtktextview.c 2001/04/19 17:59:07
@@ -683,6 +683,11 @@
GTK_TYPE_ENUM, GTK_DELETE_CHARS,
GTK_TYPE_INT, 1);
+ gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0,
+ "delete_from_cursor", 2,
+ GTK_TYPE_ENUM, GTK_DELETE_CHARS,
+ GTK_TYPE_INT, 1);
+
gtk_binding_entry_add_signal (binding_set, GDK_d, GDK_CONTROL_MASK,
"delete_from_cursor", 2,
GTK_TYPE_ENUM, GTK_DELETE_CHARS,
@@ -698,6 +703,11 @@
GTK_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
GTK_TYPE_INT, 1);
+ gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_CONTROL_MASK,
+ "delete_from_cursor", 2,
+ GTK_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
+ GTK_TYPE_INT, 1);
+
gtk_binding_entry_add_signal (binding_set, GDK_d, GDK_MOD1_MASK,
"delete_from_cursor", 2,
GTK_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
@@ -2951,7 +2961,8 @@
else if (GTK_WIDGET_CLASS (parent_class)->key_press_event &&
GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event))
retval = TRUE;
- else if (event->keyval == GDK_Return)
+ else if (event->keyval == GDK_Return ||
+ event->keyval == GDK_KP_Enter)
{
gtk_text_buffer_insert_interactive_at_cursor (get_buffer (text_view), "\n", 1,
text_view->editable);
Index: gtk/gtkvscale.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkvscale.c,v
retrieving revision 1.30
diff -u -u -r1.30 gtkvscale.c
--- gtk/gtkvscale.c 2001/04/02 15:51:27 1.30
+++ gtk/gtkvscale.c 2001/04/19 17:59:07
@@ -29,6 +29,7 @@
#include "gtksignal.h"
#include "gdk/gdkkeysyms.h"
#include "gtkintl.h"
+#include "gtkbindings.h"
#define SCALE_CLASS(w) GTK_SCALE_GET_CLASS (w)
@@ -66,10 +67,6 @@
gint *h);
static void gtk_vscale_draw_slider (GtkRange *range);
static void gtk_vscale_draw_value (GtkScale *scale);
-static gboolean gtk_vscale_trough_keys (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos);
static void gtk_vscale_clear_background (GtkRange *range);
GtkType
@@ -97,6 +94,12 @@
return vscale_type;
}
+#define add_slider_binding(binding_set, keyval, mask, scroll, trough) \
+ gtk_binding_entry_add_signal (binding_set, keyval, mask, \
+ "move_slider", 2, \
+ GTK_TYPE_SCROLL_TYPE, scroll, \
+ GTK_TYPE_TROUGH_TYPE, trough)
+
static void
gtk_vscale_class_init (GtkVScaleClass *class)
{
@@ -105,6 +108,7 @@
GtkWidgetClass *widget_class;
GtkRangeClass *range_class;
GtkScaleClass *scale_class;
+ GtkBindingSet *binding_set;
object_class = (GtkObjectClass*) class;
gobject_class = G_OBJECT_CLASS (class);
@@ -123,7 +127,6 @@
range_class->trough_click = _gtk_range_default_vtrough_click;
range_class->motion = _gtk_range_default_vmotion;
range_class->draw_slider = gtk_vscale_draw_slider;
- range_class->trough_keys = gtk_vscale_trough_keys;
range_class->clear_background = gtk_vscale_clear_background;
scale_class->draw_value = gtk_vscale_draw_value;
@@ -135,6 +138,58 @@
_("The GtkAdjustment that determines the values to use for this VScale."),
GTK_TYPE_ADJUSTMENT,
G_PARAM_READWRITE));
+
+ binding_set = gtk_binding_set_by_class (object_class);
+
+ add_slider_binding (binding_set, GDK_Up, 0,
+ GTK_SCROLL_STEP_UP, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Up, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_UP, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Up, 0,
+ GTK_SCROLL_STEP_UP, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Up, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_UP, GTK_TROUGH_NONE);
+
+
+ add_slider_binding (binding_set, GDK_Down, 0,
+ GTK_SCROLL_STEP_DOWN, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Down, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_DOWN, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Down, 0,
+ GTK_SCROLL_STEP_DOWN, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Down, GDK_CONTROL_MASK,
+ GTK_SCROLL_PAGE_DOWN, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Page_Up, 0,
+ GTK_SCROLL_PAGE_BACKWARD, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Page_Up, 0,
+ GTK_SCROLL_PAGE_BACKWARD, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Page_Down, 0,
+ GTK_SCROLL_PAGE_FORWARD, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_KP_Page_Down, 0,
+ GTK_SCROLL_PAGE_FORWARD, GTK_TROUGH_NONE);
+
+ add_slider_binding (binding_set, GDK_Home, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_START);
+
+ add_slider_binding (binding_set, GDK_KP_Home, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_START);
+
+
+ add_slider_binding (binding_set, GDK_End, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_END);
+
+ add_slider_binding (binding_set, GDK_KP_End, 0,
+ GTK_SCROLL_NONE, GTK_TROUGH_END);
}
static void
@@ -551,47 +606,4 @@
g_object_unref (G_OBJECT (layout));
}
-}
-
-static gboolean
-gtk_vscale_trough_keys (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos)
-{
- gint return_val = FALSE;
- switch (key->keyval)
- {
- case GDK_Up:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *scroll = GTK_SCROLL_PAGE_UP;
- else
- *scroll = GTK_SCROLL_STEP_UP;
- break;
- case GDK_Down:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *scroll = GTK_SCROLL_PAGE_DOWN;
- else
- *scroll = GTK_SCROLL_STEP_DOWN;
- break;
- case GDK_Page_Up:
- return_val = TRUE;
- *scroll = GTK_SCROLL_PAGE_BACKWARD;
- break;
- case GDK_Page_Down:
- return_val = TRUE;
- *scroll = GTK_SCROLL_PAGE_FORWARD;
- break;
- case GDK_Home:
- return_val = TRUE;
- *pos = GTK_TROUGH_START;
- break;
- case GDK_End:
- return_val = TRUE;
- *pos = GTK_TROUGH_END;
- break;
- }
- return return_val;
}
Index: gtk/gtkvscrollbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkvscrollbar.c,v
retrieving revision 1.25
diff -u -u -r1.25 gtkvscrollbar.c
--- gtk/gtkvscrollbar.c 2001/04/02 15:51:27 1.25
+++ gtk/gtkvscrollbar.c 2001/04/19 17:59:07
@@ -58,10 +58,6 @@
static void gtk_vscrollbar_draw_step_back (GtkRange *range);
static void gtk_vscrollbar_slider_update (GtkRange *range);
static void gtk_vscrollbar_calc_slider_size (GtkVScrollbar *vscrollbar);
-static gboolean gtk_vscrollbar_trough_keys (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos);
GtkType
gtk_vscrollbar_get_type (void)
@@ -110,7 +106,6 @@
range_class->draw_step_back = gtk_vscrollbar_draw_step_back;
range_class->slider_update = gtk_vscrollbar_slider_update;
range_class->trough_click = _gtk_range_default_vtrough_click;
- range_class->trough_keys = gtk_vscrollbar_trough_keys;
range_class->motion = _gtk_range_default_vmotion;
g_object_class_install_property (gobject_class,
@@ -459,39 +454,4 @@
gdk_window_invalidate_rect (range->slider, NULL, FALSE);
}
}
-}
-
-static gboolean
-gtk_vscrollbar_trough_keys (GtkRange *range,
- GdkEventKey *key,
- GtkScrollType *scroll,
- GtkTroughType *pos)
-{
- gint return_val = FALSE;
- switch (key->keyval)
- {
- case GDK_Up:
- return_val = TRUE;
- *scroll = GTK_SCROLL_STEP_UP;
- break;
- case GDK_Down:
- return_val = TRUE;
- *scroll = GTK_SCROLL_STEP_DOWN;
- break;
- case GDK_Page_Up:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *pos = GTK_TROUGH_START;
- else
- *scroll = GTK_SCROLL_PAGE_BACKWARD;
- break;
- case GDK_Page_Down:
- return_val = TRUE;
- if (key->state & GDK_CONTROL_MASK)
- *pos = GTK_TROUGH_END;
- else
- *scroll = GTK_SCROLL_PAGE_FORWARD;
- break;
- }
- return return_val;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]