summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtktextview.c55
-rw-r--r--gtk/gtktextview.h7
-rw-r--r--gtk/gtkwidget.c95
-rw-r--r--gtk/gtkwidget.h69
-rw-r--r--gtk/gtkwindow.c28
-rw-r--r--gtk/gtkwindow.h11
6 files changed, 100 insertions, 165 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index a41a2479bc..30dce18e2d 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -308,8 +308,6 @@ static void gtk_text_view_draw_focus (GtkWidget *widget,
cairo_t *cr);
static gboolean gtk_text_view_focus (GtkWidget *widget,
GtkDirectionType direction);
-static void gtk_text_view_move_focus (GtkWidget *widget,
- GtkDirectionType direction_type);
static void gtk_text_view_select_all (GtkWidget *widget,
gboolean select);
@@ -379,8 +377,7 @@ static void gtk_text_view_copy_clipboard (GtkTextView *text_view);
static void gtk_text_view_paste_clipboard (GtkTextView *text_view);
static void gtk_text_view_toggle_overwrite (GtkTextView *text_view);
static void gtk_text_view_toggle_cursor_visible (GtkTextView *text_view);
-static void gtk_text_view_compat_move_focus(GtkTextView *text_view,
- GtkDirectionType direction_type);
+
static void gtk_text_view_unselect (GtkTextView *text_view);
static void gtk_text_view_validate_onscreen (GtkTextView *text_view);
@@ -593,14 +590,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->motion_notify_event = gtk_text_view_motion_event;
widget_class->draw = gtk_text_view_draw;
widget_class->focus = gtk_text_view_focus;
-
- /* need to override the base class function via override_class_handler,
- * because the signal slot is not available in GtkWidgetCLass
- */
- g_signal_override_class_handler ("move-focus",
- GTK_TYPE_TEXT_VIEW,
- G_CALLBACK (gtk_text_view_move_focus));
-
widget_class->drag_begin = gtk_text_view_drag_begin;
widget_class->drag_end = gtk_text_view_drag_end;
widget_class->drag_data_get = gtk_text_view_drag_data_get;
@@ -626,7 +615,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
klass->copy_clipboard = gtk_text_view_copy_clipboard;
klass->paste_clipboard = gtk_text_view_paste_clipboard;
klass->toggle_overwrite = gtk_text_view_toggle_overwrite;
- klass->move_focus = gtk_text_view_compat_move_focus;
klass->set_scroll_adjustments = gtk_text_view_set_scroll_adjustments;
/*
@@ -4932,17 +4920,6 @@ gtk_text_view_focus (GtkWidget *widget,
}
}
-static void
-gtk_text_view_move_focus (GtkWidget *widget,
- GtkDirectionType direction_type)
-{
- GtkTextView *text_view = GTK_TEXT_VIEW (widget);
-
- if (GTK_TEXT_VIEW_GET_CLASS (text_view)->move_focus)
- GTK_TEXT_VIEW_GET_CLASS (text_view)->move_focus (text_view,
- direction_type);
-}
-
/*
* Container
*/
@@ -6149,36 +6126,6 @@ gtk_text_view_get_accepts_tab (GtkTextView *text_view)
return text_view->priv->accepts_tab;
}
-static void
-gtk_text_view_compat_move_focus (GtkTextView *text_view,
- GtkDirectionType direction_type)
-{
- GSignalInvocationHint *hint = g_signal_get_invocation_hint (text_view);
-
- /* as of GTK+ 2.12, the "move-focus" signal has been moved to GtkWidget,
- * the evil code below makes sure that both emitting the signal and
- * calling the virtual function directly continue to work as expetcted
- */
-
- if (hint->signal_id == g_signal_lookup ("move-focus", GTK_TYPE_WIDGET))
- {
- /* if this is a signal emission, chain up */
-
- gboolean retval;
-
- g_signal_chain_from_overridden_handler (text_view,
- direction_type, &retval);
- }
- else
- {
- /* otherwise emit the signal, since somebody called the virtual
- * function directly
- */
-
- g_signal_emit_by_name (text_view, "move-focus", direction_type);
- }
-}
-
/*
* Selections
*/
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index 703b0d4d7d..21760303ba 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -106,13 +106,6 @@ struct _GtkTextViewClass
/* overwrite */
void (* toggle_overwrite) (GtkTextView *text_view);
- /* as of GTK+ 2.12 the "move-focus" signal has been moved to GtkWidget,
- * so this is merley a virtual function now. Overriding it in subclasses
- * continues to work though.
- */
- void (* move_focus) (GtkTextView *text_view,
- GtkDirectionType direction);
-
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 98429e1b45..474f55a265 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -337,6 +337,7 @@ enum {
GRAB_FOCUS,
FOCUS,
MOVE_FOCUS,
+ KEYNAV_FAILED,
EVENT,
EVENT_AFTER,
BUTTON_PRESS_EVENT,
@@ -363,6 +364,12 @@ enum {
SELECTION_RECEIVED,
PROXIMITY_IN_EVENT,
PROXIMITY_OUT_EVENT,
+ CLIENT_EVENT,
+ NO_EXPOSE_EVENT,
+ VISIBILITY_NOTIFY_EVENT,
+ WINDOW_STATE_EVENT,
+ DAMAGE_EVENT,
+ GRAB_BROKEN_EVENT,
DRAG_BEGIN,
DRAG_END,
DRAG_DATA_DELETE,
@@ -371,21 +378,14 @@ enum {
DRAG_DROP,
DRAG_DATA_GET,
DRAG_DATA_RECEIVED,
- CLIENT_EVENT,
- NO_EXPOSE_EVENT,
- VISIBILITY_NOTIFY_EVENT,
- WINDOW_STATE_EVENT,
POPUP_MENU,
SHOW_HELP,
ACCEL_CLOSURES_CHANGED,
SCREEN_CHANGED,
CAN_ACTIVATE_ACCEL,
- GRAB_BROKEN,
COMPOSITED_CHANGED,
QUERY_TOOLTIP,
- KEYNAV_FAILED,
DRAG_FAILED,
- DAMAGE_EVENT,
LAST_SIGNAL
};
@@ -768,6 +768,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
klass->grab_focus = gtk_widget_real_grab_focus;
klass->focus = gtk_widget_real_focus;
+ klass->move_focus = gtk_widget_real_move_focus;
+ klass->keynav_failed = gtk_widget_real_keynav_failed;
klass->event = NULL;
klass->button_press_event = NULL;
klass->button_release_event = NULL;
@@ -1594,15 +1596,39 @@ gtk_widget_class_init (GtkWidgetClass *klass)
* @direction:
*/
widget_signals[MOVE_FOCUS] =
- g_signal_new_class_handler (I_("move-focus"),
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_CALLBACK (gtk_widget_real_move_focus),
- NULL, NULL,
- _gtk_marshal_VOID__ENUM,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_DIRECTION_TYPE);
+ g_signal_new (I_("move-focus"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkWidgetClass, move_focus),
+ NULL, NULL,
+ _gtk_marshal_VOID__ENUM,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_DIRECTION_TYPE);
+
+ /**
+ * GtkWidget::keynav-failed:
+ * @widget: the object which received the signal
+ * @direction: the direction of movement
+ *
+ * Gets emitted if keyboard navigation fails.
+ * See gtk_widget_keynav_failed() for details.
+ *
+ * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
+ * if the emitting widget should try to handle the keyboard
+ * navigation attempt in its parent container(s).
+ *
+ * Since: 2.12
+ **/
+ widget_signals[KEYNAV_FAILED] =
+ g_signal_new (I_("keynav-failed"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkWidgetClass, keynav_failed),
+ _gtk_boolean_handled_accumulator, NULL,
+ _gtk_marshal_BOOLEAN__ENUM,
+ G_TYPE_BOOLEAN, 1,
+ GTK_TYPE_DIRECTION_TYPE);
/**
* GtkWidget::event:
@@ -1778,30 +1804,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_TYPE_NONE, 0);
/**
- * GtkWidget::keynav-failed:
- * @widget: the object which received the signal
- * @direction: the direction of movement
- *
- * Gets emitted if keyboard navigation fails.
- * See gtk_widget_keynav_failed() for details.
- *
- * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
- * if the emitting widget should try to handle the keyboard
- * navigation attempt in its parent container(s).
- *
- * Since: 2.12
- **/
- widget_signals[KEYNAV_FAILED] =
- g_signal_new_class_handler (I_("keynav-failed"),
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_CALLBACK (gtk_widget_real_keynav_failed),
- _gtk_boolean_handled_accumulator, NULL,
- _gtk_marshal_BOOLEAN__ENUM,
- G_TYPE_BOOLEAN, 1,
- GTK_TYPE_DIRECTION_TYPE);
-
- /**
* GtkWidget::delete-event:
* @widget: the object which received the signal
* @event: the event which triggered this signal
@@ -2729,7 +2731,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
g_signal_new (I_("damage-event"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- 0,
+ G_STRUCT_OFFSET (GtkWidgetClass, damage_event),
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
@@ -2752,7 +2754,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
*
* Since: 2.8
*/
- widget_signals[GRAB_BROKEN] =
+ widget_signals[GRAB_BROKEN_EVENT] =
g_signal_new (I_("grab-broken-event"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -5809,7 +5811,7 @@ gtk_widget_event_internal (GtkWidget *widget,
signal_num = VISIBILITY_NOTIFY_EVENT;
break;
case GDK_GRAB_BROKEN:
- signal_num = GRAB_BROKEN;
+ signal_num = GRAB_BROKEN_EVENT;
break;
case GDK_DAMAGE:
signal_num = DAMAGE_EVENT;
@@ -6296,11 +6298,10 @@ gtk_widget_real_move_focus (GtkWidget *widget,
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_IS_WINDOW (toplevel) &&
- GTK_WINDOW_GET_CLASS (toplevel)->move_focus)
+ if (widget != toplevel && GTK_IS_WINDOW (toplevel))
{
- GTK_WINDOW_GET_CLASS (toplevel)->move_focus (GTK_WINDOW (toplevel),
- direction);
+ g_signal_emit (toplevel, widget_signals[MOVE_FOCUS], 0,
+ direction);
}
}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 0d8859111d..c7faeece8f 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -168,7 +168,7 @@ struct _GtkWidgetClass
GInitiallyUnownedClass parent_class;
/*< public >*/
-
+
guint activate_signal;
guint set_scroll_adjustments_signal;
@@ -207,7 +207,7 @@ struct _GtkWidgetClass
GParamSpec *pspec);
gboolean (* draw) (GtkWidget *widget,
cairo_t *cr);
-
+
/* size requests */
GtkSizeRequestMode (* get_request_mode) (GtkWidget *widget);
@@ -227,14 +227,20 @@ struct _GtkWidgetClass
gint *natural_height);
/* Mnemonics */
- gboolean (* mnemonic_activate) (GtkWidget *widget,
- gboolean group_cycling);
-
+ gboolean (* mnemonic_activate) (GtkWidget *widget,
+ gboolean group_cycling);
+
/* explicit focus */
- void (* grab_focus) (GtkWidget *widget);
- gboolean (* focus) (GtkWidget *widget,
- GtkDirectionType direction);
-
+ void (* grab_focus) (GtkWidget *widget);
+ gboolean (* focus) (GtkWidget *widget,
+ GtkDirectionType direction);
+
+ /* keyboard navigation */
+ void (* move_focus) (GtkWidget *widget,
+ GtkDirectionType direction);
+ gboolean (* keynav_failed) (GtkWidget *widget,
+ GtkDirectionType direction);
+
/* events */
gboolean (* event) (GtkWidget *widget,
GdkEvent *event);
@@ -288,31 +294,35 @@ struct _GtkWidgetClass
GdkEventAny *event);
gboolean (* window_state_event) (GtkWidget *widget,
GdkEventWindowState *event);
-
+ gboolean (* damage_event) (GtkWidget *widget,
+ GdkEventExpose *event);
+ gboolean (* grab_broken_event) (GtkWidget *widget,
+ GdkEventGrabBroken *event);
+
/* selection */
- void (* selection_get) (GtkWidget *widget,
+ void (* selection_get) (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time_);
- void (* selection_received) (GtkWidget *widget,
+ void (* selection_received) (GtkWidget *widget,
GtkSelectionData *selection_data,
guint time_);
/* Source side drag signals */
- void (* drag_begin) (GtkWidget *widget,
+ void (* drag_begin) (GtkWidget *widget,
GdkDragContext *context);
- void (* drag_end) (GtkWidget *widget,
+ void (* drag_end) (GtkWidget *widget,
GdkDragContext *context);
- void (* drag_data_get) (GtkWidget *widget,
+ void (* drag_data_get) (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time_);
- void (* drag_data_delete) (GtkWidget *widget,
+ void (* drag_data_delete) (GtkWidget *widget,
GdkDragContext *context);
/* Target side drag signals */
- void (* drag_leave) (GtkWidget *widget,
+ void (* drag_leave) (GtkWidget *widget,
GdkDragContext *context,
guint time_);
gboolean (* drag_motion) (GtkWidget *widget,
@@ -325,7 +335,7 @@ struct _GtkWidgetClass
gint x,
gint y,
guint time_);
- void (* drag_data_received) (GtkWidget *widget,
+ void (* drag_data_received) (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
@@ -343,19 +353,16 @@ struct _GtkWidgetClass
*/
gboolean (* show_help) (GtkWidget *widget,
GtkWidgetHelpType help_type);
-
- /* accessibility support
+
+ /* accessibility support
*/
- AtkObject* (*get_accessible) (GtkWidget *widget);
+ AtkObject * (* get_accessible) (GtkWidget *widget);
- void (*screen_changed) (GtkWidget *widget,
- GdkScreen *previous_screen);
- gboolean (*can_activate_accel) (GtkWidget *widget,
- guint signal_id);
+ void (* screen_changed) (GtkWidget *widget,
+ GdkScreen *previous_screen);
+ gboolean (* can_activate_accel) (GtkWidget *widget,
+ guint signal_id);
- /* Sent when a grab is broken. */
- gboolean (*grab_broken_event) (GtkWidget *widget,
- GdkEventGrabBroken *event);
void (* composited_changed) (GtkWidget *widget);
@@ -365,7 +372,6 @@ struct _GtkWidgetClass
gboolean keyboard_tooltip,
GtkTooltip *tooltip);
- /*< public >*/
void (* compute_expand) (GtkWidget *widget,
gboolean *hexpand_p,
gboolean *vexpand_p);
@@ -380,11 +386,6 @@ struct _GtkWidgetClass
/*< private >*/
- /* Signals without a C default handler class slot:
- * gboolean (*damage_event) (GtkWidget *widget,
- * GdkEventExpose *event);
- */
-
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7db0793e5d..08202a29b6 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -354,6 +354,8 @@ static gboolean gtk_window_state_event (GtkWidget *widget,
static void gtk_window_check_resize (GtkContainer *container);
static gint gtk_window_focus (GtkWidget *widget,
GtkDirectionType direction);
+static void gtk_window_move_focus (GtkWidget *widget,
+ GtkDirectionType dir);
static void gtk_window_real_set_focus (GtkWindow *window,
GtkWidget *focus);
static void gtk_window_direction_changed (GtkWidget *widget,
@@ -363,8 +365,6 @@ static void gtk_window_state_changed (GtkWidget *widget,
static void gtk_window_real_activate_default (GtkWindow *window);
static void gtk_window_real_activate_focus (GtkWindow *window);
-static void gtk_window_move_focus (GtkWindow *window,
- GtkDirectionType dir);
static void gtk_window_keys_changed (GtkWindow *window);
static gint gtk_window_draw (GtkWidget *widget,
cairo_t *cr);
@@ -587,6 +587,7 @@ gtk_window_class_init (GtkWindowClass *klass)
widget_class->focus_out_event = gtk_window_focus_out_event;
widget_class->client_event = gtk_window_client_event;
widget_class->focus = gtk_window_focus;
+ widget_class->move_focus = gtk_window_move_focus;
widget_class->draw = gtk_window_draw;
widget_class->get_preferred_width = gtk_window_get_preferred_width;
widget_class->get_preferred_height = gtk_window_get_preferred_height;
@@ -602,7 +603,6 @@ gtk_window_class_init (GtkWindowClass *klass)
klass->activate_default = gtk_window_real_activate_default;
klass->activate_focus = gtk_window_real_activate_focus;
- klass->move_focus = gtk_window_move_focus;
klass->keys_changed = gtk_window_keys_changed;
g_type_class_add_private (gobject_class, sizeof (GtkWindowPrivate));
@@ -4690,7 +4690,7 @@ gtk_window_show (GtkWidget *widget)
/* Try to make sure that we have some focused widget
*/
if (!priv->focus_widget && !GTK_IS_PLUG (window))
- gtk_window_move_focus (window, GTK_DIR_TAB_FORWARD);
+ gtk_window_move_focus (widget, GTK_DIR_TAB_FORWARD);
if (priv->modal)
gtk_grab_add (widget);
@@ -5883,16 +5883,6 @@ gtk_window_real_activate_focus (GtkWindow *window)
gtk_window_activate_focus (window);
}
-static void
-gtk_window_move_focus (GtkWindow *window,
- GtkDirectionType dir)
-{
- gtk_widget_child_focus (GTK_WIDGET (window), dir);
-
- if (!gtk_container_get_focus_child (GTK_CONTAINER (window)))
- gtk_window_set_focus (window, NULL);
-}
-
static gint
gtk_window_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
@@ -6120,6 +6110,16 @@ gtk_window_focus (GtkWidget *widget,
}
static void
+gtk_window_move_focus (GtkWidget *widget,
+ GtkDirectionType dir)
+{
+ gtk_widget_child_focus (widget, dir);
+
+ if (! gtk_container_get_focus_child (GTK_CONTAINER (widget)))
+ gtk_window_set_focus (GTK_WINDOW (widget), NULL);
+}
+
+static void
gtk_window_real_set_focus (GtkWindow *window,
GtkWidget *focus)
{
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 29e729e90f..57d1f81476 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -75,15 +75,8 @@ struct _GtkWindowClass
void (* activate_focus) (GtkWindow *window);
void (* activate_default) (GtkWindow *window);
- /* as of GTK+ 2.12 the "move-focus" signal has been moved to GtkWidget,
- * so this is merley a virtual function now. Overriding it in subclasses
- * continues to work though.
- */
- void (* move_focus) (GtkWindow *window,
- GtkDirectionType direction);
-
- void (*keys_changed) (GtkWindow *window);
-
+ void (* keys_changed) (GtkWindow *window);
+
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);