summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-03-15 22:25:09 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-03-18 23:00:51 -0400
commit908d996b4f0cbfbda3cc8141c64aaf711db78d60 (patch)
tree00b038c9d326e14eb7f9b184f9649586bb0cc27d /gtk
parent4e263b4042b273f26602fa65b3398af7ab56e86f (diff)
downloadgtk+-908d996b4f0cbfbda3cc8141c64aaf711db78d60.tar.gz
Use an action for the context menu keybinding
The ::popup-menu signal is going away.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcolorswatch.c21
-rw-r--r--gtk/gtklabel.c23
-rw-r--r--gtk/gtklinkbutton.c24
-rw-r--r--gtk/gtknotebook.c30
-rw-r--r--gtk/gtktext.c22
-rw-r--r--gtk/gtktextview.c23
6 files changed, 104 insertions, 39 deletions
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index ca6ab4d54f..f68003cc69 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -348,13 +348,12 @@ gtk_color_swatch_measure (GtkWidget *widget,
*natural = MAX (*natural, min);
}
-
-
-static gboolean
-swatch_popup_menu (GtkWidget *widget)
+static void
+swatch_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters)
{
do_popup (GTK_COLOR_SWATCH (widget));
- return TRUE;
}
static void
@@ -480,7 +479,6 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
widget_class->measure = gtk_color_swatch_measure;
widget_class->snapshot = swatch_snapshot;
- widget_class->popup_menu = swatch_popup_menu;
widget_class->size_allocate = swatch_size_allocate;
widget_class->state_flags_changed = swatch_state_flags_changed;
@@ -497,6 +495,17 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
g_param_spec_boolean ("can-drop", P_("Can Drop"), P_("Whether the swatch should accept drops"),
FALSE, GTK_PARAM_READWRITE));
+ gtk_widget_class_install_action (widget_class, "menu.popup", NULL, swatch_popup_menu);
+
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ "menu.popup",
+ NULL);
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_Menu, 0,
+ "menu.popup",
+ 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 049927ef2c..b1f12d12e7 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -480,7 +480,9 @@ static void gtk_label_set_markup_internal (GtkLabel *label,
static void gtk_label_recalculate (GtkLabel *label);
static void gtk_label_root (GtkWidget *widget);
static void gtk_label_unroot (GtkWidget *widget);
-static gboolean gtk_label_popup_menu (GtkWidget *widget);
+static void gtk_label_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters);
static void gtk_label_do_popup (GtkLabel *label,
double x,
double y);
@@ -645,7 +647,6 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->root = gtk_label_root;
widget_class->unroot = gtk_label_unroot;
widget_class->mnemonic_activate = gtk_label_mnemonic_activate;
- widget_class->popup_menu = gtk_label_popup_menu;
widget_class->grab_focus = gtk_label_grab_focus;
widget_class->focus = gtk_label_focus;
widget_class->get_request_mode = gtk_label_get_request_mode;
@@ -1022,10 +1023,21 @@ gtk_label_class_init (GtkLabelClass *class)
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, label_props);
+ gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_label_popup_menu);
+
/*
* Key bindings
*/
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ "menu.popup",
+ NULL);
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_Menu, 0,
+ "menu.popup",
+ NULL);
+
/* Moving the insertion point */
add_move_binding (widget_class, GDK_KEY_Right, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
@@ -6059,13 +6071,14 @@ gtk_label_do_popup (GtkLabel *label,
gtk_popover_popup (GTK_POPOVER (priv->popup_menu));
}
-static gboolean
-gtk_label_popup_menu (GtkWidget *widget)
+static void
+gtk_label_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters)
{
GtkLabel *label = GTK_LABEL (widget);
gtk_label_do_popup (label, -1, -1);
- return TRUE;
}
static void
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index d64c3f3a83..96831ec083 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 void gtk_link_button_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters);
static gboolean gtk_link_button_query_tooltip_cb (GtkWidget *widget,
gint x,
gint y,
@@ -169,8 +171,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;
@@ -230,6 +230,17 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
gtk_link_button_activate_clipboard_copy);
+
+ gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_link_button_popup_menu);
+
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ "menu.popup",
+ NULL);
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_Menu, 0,
+ "menu.popup",
+ NULL);
}
static GMenuModel *
@@ -503,11 +514,12 @@ gtk_link_button_clicked (GtkButton *button)
g_signal_emit (button, link_signals[ACTIVATE_LINK], 0, &retval);
}
-static gboolean
-gtk_link_button_popup_menu (GtkWidget *widget)
+static void
+gtk_link_button_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters)
{
gtk_link_button_do_popup (GTK_LINK_BUTTON (widget), -1, -1);
- return TRUE;
}
/**
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 1c2a095a6f..a625013109 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -772,7 +772,9 @@ static void gtk_notebook_dispose (GObject *object);
/*** GtkWidget Methods ***/
static void gtk_notebook_destroy (GtkWidget *widget);
static void gtk_notebook_unmap (GtkWidget *widget);
-static gboolean gtk_notebook_popup_menu (GtkWidget *widget);
+static void gtk_notebook_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters);
static void gtk_notebook_motion (GtkEventController *controller,
double x,
double y,
@@ -1046,7 +1048,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
widget_class->destroy = gtk_notebook_destroy;
widget_class->unmap = gtk_notebook_unmap;
- 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->direction_changed = gtk_notebook_direction_changed;
@@ -1310,6 +1311,8 @@ gtk_notebook_class_init (GtkNotebookClass *class)
G_TYPE_FROM_CLASS (gobject_class),
_gtk_marshal_OBJECT__OBJECTv);
+ gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_notebook_popup_menu);
+
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_space, 0,
"select-page",
@@ -1336,6 +1339,15 @@ gtk_notebook_class_init (GtkNotebookClass *class)
"focus-tab",
"(i)", GTK_NOTEBOOK_TAB_LAST);
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ "menu.popup",
+ NULL);
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_Menu, 0,
+ "menu.popup",
+ NULL);
+
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_Page_Up, GDK_CONTROL_MASK,
"change-current-page",
@@ -2599,20 +2611,16 @@ gtk_notebook_gesture_pressed (GtkGestureClick *gesture,
}
}
-
-static gboolean
-gtk_notebook_popup_menu (GtkWidget *widget)
+static void
+gtk_notebook_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
if (priv->menu)
- {
- gtk_popover_popup (GTK_POPOVER (priv->menu));
- return TRUE;
- }
-
- return FALSE;
+ gtk_popover_popup (GTK_POPOVER (priv->menu));
}
static void
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 013ac5c1da..70a5d5276c 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -381,7 +381,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 void gtk_text_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters);
static void gtk_text_move_cursor (GtkText *self,
GtkMovementStep step,
int count,
@@ -721,7 +723,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;
class->move_cursor = gtk_text_move_cursor;
class->insert_at_cursor = gtk_text_insert_at_cursor;
@@ -1189,11 +1190,21 @@ gtk_text_class_init (GtkTextClass *class)
gtk_widget_class_install_action (widget_class, "text.undo", NULL, gtk_text_real_undo);
gtk_widget_class_install_action (widget_class, "text.redo", NULL, gtk_text_real_redo);
+ gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_text_popup_menu);
/*
* Key bindings
*/
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ "menu.popup",
+ NULL);
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_Menu, 0,
+ "menu.popup",
+ NULL);
+
/* Moving the insertion point */
add_move_binding (widget_class, GDK_KEY_Right, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
@@ -5925,11 +5936,12 @@ gtk_text_mnemonic_activate (GtkWidget *widget,
return GDK_EVENT_STOP;
}
-static gboolean
-gtk_text_popup_menu (GtkWidget *widget)
+static void
+gtk_text_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters)
{
gtk_text_do_popup (GTK_TEXT (widget), -1, -1);
- return TRUE;
}
static void
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index e87b0d11df..793e97a8b8 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -434,7 +434,9 @@ static gboolean gtk_text_view_drag_drop (GtkDropTarget *dest,
double y,
GtkTextView *text_view);
-static gboolean gtk_text_view_popup_menu (GtkWidget *widget);
+static void gtk_text_view_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters);
static void gtk_text_view_move_cursor (GtkTextView *text_view,
GtkMovementStep step,
gint count,
@@ -818,8 +820,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->snapshot = gtk_text_view_snapshot;
widget_class->focus = gtk_text_view_focus;
- 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;
@@ -1462,11 +1462,21 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
gtk_widget_class_install_action (widget_class, "text.undo", NULL, gtk_text_view_real_undo);
gtk_widget_class_install_action (widget_class, "text.redo", NULL, gtk_text_view_real_redo);
+ gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_text_view_popup_menu);
/*
* Key bindings
*/
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_F10, GDK_SHIFT_MASK,
+ "menu.popup",
+ NULL);
+ gtk_widget_class_add_binding_action (widget_class,
+ GDK_KEY_Menu, 0,
+ "menu.popup",
+ NULL);
+
/* Moving the insertion point */
add_move_binding (widget_class, GDK_KEY_Right, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
@@ -8692,11 +8702,12 @@ gtk_text_view_do_popup (GtkTextView *text_view,
gdk_event_unref (trigger_event);
}
-static gboolean
-gtk_text_view_popup_menu (GtkWidget *widget)
+static void
+gtk_text_view_popup_menu (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameters)
{
gtk_text_view_do_popup (GTK_TEXT_VIEW (widget), NULL);
- return TRUE;
}
static void