[gtk/shortcuts-rebased-again: 154/171] Remove popup-menu signal
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/shortcuts-rebased-again: 154/171] Remove popup-menu signal
- Date: Mon, 24 Jun 2019 23:17:26 +0000 (UTC)
commit 3a139453c4c197606cb16856f023c9b59f65dd44
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jun 23 17:51:01 2019 +0000
Remove popup-menu signal
We decided not to have generic context menu api,
so this binding is a bit out of place too. Replace
it by bindings in the individual widgets that
have context menus.
gtk/gtkcolorswatch.c | 15 +++++++++++----
gtk/gtklabel.c | 21 +++++++++++++++------
gtk/gtklinkbutton.c | 24 +++++++++++++++++-------
gtk/gtknotebook.c | 17 ++++++++++++++---
gtk/gtktext.c | 17 ++++++++++++++---
gtk/gtktextview.c | 18 ++++++++++++++----
gtk/gtktoolbar.c | 17 ++++++++++++++---
gtk/gtkwidget.c | 36 ------------------------------------
gtk/gtkwidget.h | 5 -----
9 files changed, 99 insertions(+), 71 deletions(-)
---
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index d17093fe9a..ba88da40b7 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -422,10 +422,10 @@ gtk_color_swatch_measure (GtkWidget *widget,
*natural = MAX (*natural, min);
}
-
-
static gboolean
-swatch_popup_menu (GtkWidget *widget)
+gtk_color_swatch_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data)
{
do_popup (GTK_COLOR_SWATCH (widget));
return TRUE;
@@ -551,7 +551,6 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
widget_class->drag_begin = swatch_drag_begin;
widget_class->drag_data_get = swatch_drag_data_get;
widget_class->drag_data_received = swatch_drag_data_received;
- widget_class->popup_menu = swatch_popup_menu;
widget_class->size_allocate = swatch_size_allocate;
widget_class->state_flags_changed = swatch_state_flags_changed;
@@ -565,6 +564,14 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
g_param_spec_boolean ("has-menu", P_("Has Menu"), P_("Whether the swatch should offer customization"),
TRUE, GTK_PARAM_READWRITE));
+ /* Context menu */
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ gtk_color_swatch_popup_menu, NULL);
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_Menu, 0,
+ gtk_color_swatch_popup_menu, NULL);
+
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COLOR_SWATCH_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("colorswatch"));
}
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 16268b0d8e..61483807e2 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -484,7 +484,9 @@ static void gtk_label_recalculate (GtkLabel *label);
static void gtk_label_root (GtkWidget *widget);
static void gtk_label_map (GtkWidget *widget);
static void gtk_label_unmap (GtkWidget *widget);
-static gboolean gtk_label_popup_menu (GtkWidget *widget);
+static gboolean gtk_label_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data);
static void gtk_label_do_popup (GtkLabel *label,
double x,
double y);
@@ -654,7 +656,6 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->map = gtk_label_map;
widget_class->unmap = gtk_label_unmap;
widget_class->mnemonic_activate = gtk_label_mnemonic_activate;
- widget_class->popup_menu = gtk_label_popup_menu;
widget_class->drag_data_get = gtk_label_drag_data_get;
widget_class->grab_focus = gtk_label_grab_focus;
widget_class->focus = gtk_label_focus;
@@ -1137,6 +1138,14 @@ gtk_label_class_init (GtkLabelClass *class)
"activate-current-link",
NULL);
+ /* Context menu */
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ gtk_label_popup_menu, NULL);
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_Menu, 0,
+ gtk_label_popup_menu, NULL);
+
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LABEL_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("label"));
@@ -6133,11 +6142,11 @@ gtk_label_do_popup (GtkLabel *label,
}
static gboolean
-gtk_label_popup_menu (GtkWidget *widget)
+gtk_label_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data)
{
- GtkLabel *label = GTK_LABEL (widget);
-
- gtk_label_do_popup (label, -1, -1);
+ gtk_label_do_popup (GTK_LABEL (widget), -1, -1);
return TRUE;
}
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index bbf19a08c7..125b5dc6c7 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -123,7 +123,9 @@ static void gtk_link_button_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec);
static void gtk_link_button_clicked (GtkButton *button);
-static gboolean gtk_link_button_popup_menu (GtkWidget *widget);
+static gboolean gtk_link_button_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data);
static void gtk_link_button_drag_data_get_cb (GtkWidget *widget,
GdkDrag *drag,
GtkSelectionData *selection,
@@ -173,8 +175,6 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
gobject_class->get_property = gtk_link_button_get_property;
gobject_class->finalize = gtk_link_button_finalize;
- widget_class->popup_menu = gtk_link_button_popup_menu;
-
button_class->clicked = gtk_link_button_clicked;
klass->activate_link = gtk_link_button_activate_link;
@@ -229,11 +229,19 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
_gtk_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
- gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LINK_BUTTON_ACCESSIBLE);
- gtk_widget_class_set_css_name (widget_class, I_("button"));
-
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
gtk_link_button_activate_clipboard_copy);
+
+ /* Context menu */
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ gtk_link_button_popup_menu, NULL);
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_Menu, 0,
+ gtk_link_button_popup_menu, NULL);
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LINK_BUTTON_ACCESSIBLE);
+ gtk_widget_class_set_css_name (widget_class, I_("button"));
}
static GMenuModel *
@@ -443,7 +451,9 @@ gtk_link_button_clicked (GtkButton *button)
}
static gboolean
-gtk_link_button_popup_menu (GtkWidget *widget)
+gtk_link_button_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data)
{
gtk_link_button_do_popup (GTK_LINK_BUTTON (widget), -1, -1);
return TRUE;
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 648da727f2..0fb75973dd 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -692,7 +692,9 @@ static void gtk_notebook_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline);
-static gboolean gtk_notebook_popup_menu (GtkWidget *widget);
+static gboolean gtk_notebook_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data);
static void gtk_notebook_motion (GtkEventController *controller,
double x,
double y,
@@ -977,7 +979,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
widget_class->unmap = gtk_notebook_unmap;
widget_class->measure = gtk_notebook_measure;
widget_class->size_allocate = gtk_notebook_size_allocate;
- widget_class->popup_menu = gtk_notebook_popup_menu;
widget_class->grab_notify = gtk_notebook_grab_notify;
widget_class->state_flags_changed = gtk_notebook_state_flags_changed;
widget_class->focus = gtk_notebook_focus;
@@ -1309,6 +1310,14 @@ gtk_notebook_class_init (GtkNotebookClass *class)
add_tab_bindings (widget_class, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
+ /* Context menu */
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ gtk_notebook_popup_menu, NULL);
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_Menu, 0,
+ gtk_notebook_popup_menu, NULL);
+
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_NOTEBOOK_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("notebook"));
}
@@ -2596,7 +2605,9 @@ gtk_notebook_gesture_pressed (GtkGestureClick *gesture,
static gboolean
-gtk_notebook_popup_menu (GtkWidget *widget)
+gtk_notebook_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer data)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 08eb55287b..eb6ec683be 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -375,7 +375,9 @@ static void gtk_text_set_alignment (GtkText *self,
/* Default signal handlers
*/
static GMenuModel *gtk_text_get_menu_model (GtkText *self);
-static gboolean gtk_text_popup_menu (GtkWidget *widget);
+static gboolean gtk_text_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data);
static void gtk_text_move_cursor (GtkText *self,
GtkMovementStep step,
int count,
@@ -700,7 +702,6 @@ gtk_text_class_init (GtkTextClass *class)
widget_class->state_flags_changed = gtk_text_state_flags_changed;
widget_class->root = gtk_text_root;
widget_class->mnemonic_activate = gtk_text_mnemonic_activate;
- widget_class->popup_menu = gtk_text_popup_menu;
widget_class->drag_drop = gtk_text_drag_drop;
widget_class->drag_motion = gtk_text_drag_motion;
widget_class->drag_leave = gtk_text_drag_leave;
@@ -1231,6 +1232,14 @@ gtk_text_class_init (GtkTextClass *class)
"misc.insert-emoji",
NULL);
+ /* Context menu */
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ gtk_text_popup_menu, NULL);
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_Menu, 0,
+ gtk_text_popup_menu, NULL);
+
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("text"));
}
@@ -5655,7 +5664,9 @@ gtk_text_mnemonic_activate (GtkWidget *widget,
}
static gboolean
-gtk_text_popup_menu (GtkWidget *widget)
+gtk_text_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data)
{
gtk_text_do_popup (GTK_TEXT (widget), -1, -1);
return TRUE;
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index dae878fb79..2e7be3cf9d 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -441,7 +441,9 @@ static void gtk_text_view_drag_data_received (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data);
-static gboolean gtk_text_view_popup_menu (GtkWidget *widget);
+static gboolean gtk_text_view_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer data);
static void gtk_text_view_move_cursor (GtkTextView *text_view,
GtkMovementStep step,
gint count,
@@ -725,8 +727,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->drag_drop = gtk_text_view_drag_drop;
widget_class->drag_data_received = gtk_text_view_drag_data_received;
- widget_class->popup_menu = gtk_text_view_popup_menu;
-
container_class->add = gtk_text_view_add;
container_class->remove = gtk_text_view_remove;
container_class->forall = gtk_text_view_forall;
@@ -1628,6 +1628,14 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
"move-focus",
"(i)", GTK_DIR_TAB_BACKWARD);
+ /* Context menu */
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ gtk_text_view_popup_menu, NULL);
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_Menu, 0,
+ gtk_text_view_popup_menu, NULL);
+
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_VIEW_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("textview"));
@@ -8780,7 +8788,9 @@ gtk_text_view_do_popup (GtkTextView *text_view,
}
static gboolean
-gtk_text_view_popup_menu (GtkWidget *widget)
+gtk_text_view_popup_menu (GtkWidget *widget,
+ GVariant *args,
+ gpointer data)
{
gtk_text_view_do_popup (GTK_TEXT_VIEW (widget), NULL);
return TRUE;
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index eb31c630d4..6170d44a98 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -234,7 +234,9 @@ static void gtk_toolbar_arrow_button_press (GtkGesture *gesture
GtkToolbar *toolbar);
static void gtk_toolbar_arrow_button_clicked (GtkWidget *button,
GtkToolbar *toolbar);
-static gboolean gtk_toolbar_popup_menu (GtkWidget *toolbar);
+static gboolean gtk_toolbar_popup_menu (GtkWidget *toolbar,
+ GVariant *args,
+ gpointer data);
static void gtk_toolbar_reconfigured (GtkToolbar *toolbar);
static void gtk_toolbar_measure (GtkWidget *widget,
@@ -387,7 +389,6 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
widget_class->root = gtk_toolbar_root;
widget_class->unroot = gtk_toolbar_unroot;
- widget_class->popup_menu = gtk_toolbar_popup_menu;
container_class->add = gtk_toolbar_add;
container_class->remove = gtk_toolbar_remove;
@@ -524,6 +525,14 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
add_ctrl_tab_bindings (widget_class, 0, GTK_DIR_TAB_FORWARD);
add_ctrl_tab_bindings (widget_class, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
+ /* Context menu */
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ gtk_toolbar_popup_menu, NULL);
+ gtk_widget_class_add_binding (widget_class,
+ GDK_KEY_Menu, 0,
+ gtk_toolbar_popup_menu, NULL);
+
gtk_widget_class_set_css_name (widget_class, I_("toolbar"));
}
@@ -2234,7 +2243,9 @@ gtk_toolbar_pressed_cb (GtkGestureClick *gesture,
}
static gboolean
-gtk_toolbar_popup_menu (GtkWidget *toolbar)
+gtk_toolbar_popup_menu (GtkWidget *toolbar,
+ GVariant *args,
+ gpointer data)
{
gboolean return_value;
/* This function is the handler for the "popup menu" keybinding,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4b8a406a90..33f0288967 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -533,7 +533,6 @@ enum {
DRAG_DROP,
DRAG_DATA_GET,
DRAG_DATA_RECEIVED,
- POPUP_MENU,
ACCEL_CLOSURES_CHANGED,
DISPLAY_CHANGED,
CAN_ACTIVATE_ACCEL,
@@ -2091,32 +2090,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_TYPE_FROM_CLASS (klass),
_gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECTv);
- /**
- * GtkWidget::popup-menu:
- * @widget: the object which received the signal
- *
- * This signal gets emitted whenever a widget should pop up a context
- * menu. This usually happens through the standard key binding mechanism;
- * by pressing a certain key while a widget is focused, the user can cause
- * the widget to pop up a menu. For example, the #GtkEntry widget creates
- * a menu with clipboard commands. See the
- * [Popup Menu Migration Checklist][checklist-popup-menu]
- * for an example of how to use this signal.
- *
- * Returns: %TRUE if a menu was activated
- */
- widget_signals[POPUP_MENU] =
- g_signal_new (I_("popup-menu"),
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GtkWidgetClass, popup_menu),
- _gtk_boolean_handled_accumulator, NULL,
- _gtk_marshal_BOOLEAN__VOID,
- G_TYPE_BOOLEAN, 0);
- g_signal_set_va_marshaller (widget_signals[POPUP_MENU],
- G_TYPE_FROM_CLASS (klass),
- _gtk_marshal_BOOLEAN__VOIDv);
-
/**
* GtkWidget::accel-closures-changed:
* @widget: the object which received the signal.
@@ -2158,15 +2131,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_TYPE_FROM_CLASS (klass),
_gtk_marshal_BOOLEAN__UINTv);
- gtk_widget_class_add_binding_signal (klass,
- GDK_KEY_F10, GDK_SHIFT_MASK,
- "popup-menu",
- NULL);
- gtk_widget_class_add_binding_signal (klass,
- GDK_KEY_Menu, 0,
- "popup-menu",
- NULL);
-
gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE);
gtk_widget_class_set_css_name (klass, I_("widget"));
}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 8651001b0f..d264b47176 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -207,8 +207,6 @@ struct _GtkWidget
* dragged data has been received.
* @drag_failed: Signal emitted on the drag source when a drag has
* failed.
- * @popup_menu: Signal emitted whenever a widget should pop up a
- * context menu.
* @get_accessible: Returns the accessible object that describes the
* widget to an assistive technology.
* @can_activate_accel: Signal allows applications and derived widgets
@@ -307,9 +305,6 @@ struct _GtkWidgetClass
GdkDrag *drag,
GtkDragResult result);
- /* Signals used only for keybindings */
- gboolean (* popup_menu) (GtkWidget *widget);
-
/* accessibility support
*/
AtkObject * (* get_accessible) (GtkWidget *widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]