Merge branch 'action-docs' into 'master'

Action docs

See merge request GNOME/gtk!1665
This commit is contained in:
Matthias Clasen 2020-04-11 15:12:22 +00:00
commit 9f5b04e65c
11 changed files with 243 additions and 48 deletions

View File

@ -515,6 +515,9 @@ gdk_key_event_get_consumed_modifiers
gdk_key_event_get_layout
gdk_key_event_get_level
gdk_key_event_is_modifier
GdkEventMatch
gdk_key_event_matches
gdk_key_event_get_match
gdk_focus_event_get_in
gdk_touch_event_get_emulating_pointer
gdk_crossing_event_get_mode
@ -537,11 +540,6 @@ gdk_events_get_angle
gdk_events_get_center
gdk_events_get_distance
<SUBSECTION>
GdkEventMatch
gdk_event_matches
gdk_event_get_match
<SUBSECTION Standard>
GDK_TYPE_EVENT
GDK_TYPE_EVENT_MASK
@ -657,8 +655,6 @@ gdk_toplevel_set_transient_for
gdk_toplevel_set_modal
gdk_toplevel_set_icon_list
gdk_toplevel_show_window_menu
gdk_toplevel_set_accept_focus
gdk_toplevel_set_focus_on_map
gdk_toplevel_set_decorated
gdk_toplevel_set_deletable
gdk_toplevel_supports_edge_constraints

View File

@ -561,10 +561,13 @@ gtk_color_editor_class_init (GtkColorEditorClass *class)
gtk_widget_class_bind_template_callback (widget_class, entry_focus_changed);
gtk_widget_class_bind_template_callback (widget_class, pick_color);
/**
* GtkColorEditor|color.edit:
* @component: the component to edit, "h", "sv" or "a"
*
* Opens the edit popup for one of the color components.
*/
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
}
static void

View File

@ -497,6 +497,11 @@ 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));
/**
* GtkColorSwatch|menu.popup:
*
* Opens the context menu.
*/
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, swatch_popup_menu);
gtk_widget_class_add_binding_action (widget_class,

View File

@ -1023,6 +1023,11 @@ gtk_label_class_init (GtkLabelClass *class)
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, label_props);
/**
* GtkLabel|menu.popup:
*
* Opens the context menu.
*/
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_label_popup_menu);
/*

View File

@ -228,9 +228,19 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LINK_BUTTON_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("button"));
/**
* GtkLinkButton|clipboard.copy:
*
* Copies the url to the clipboard.
*/
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
gtk_link_button_activate_clipboard_copy);
/**
* GtkLinkButton|menu.popup:
*
* Opens the context menu.
*/
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_link_button_popup_menu);
gtk_widget_class_add_binding_action (widget_class,

View File

@ -1304,6 +1304,11 @@ gtk_notebook_class_init (GtkNotebookClass *class)
G_TYPE_FROM_CLASS (gobject_class),
_gtk_marshal_OBJECT__OBJECTv);
/**
* GtkNotebook|menu.popup:
*
* Opens the context menu.
*/
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_notebook_popup_menu);
gtk_widget_class_add_binding_signal (widget_class,

View File

@ -2330,12 +2330,53 @@ gtk_places_view_class_init (GtkPlacesViewClass *klass)
gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
gtk_widget_class_bind_template_callback (widget_class, on_recent_servers_listbox_row_activated);
/**
* GtkPlacesView|location.open:
*
* Opens the location in the current window.
*/
gtk_widget_class_install_action (widget_class, "location.open", NULL, open_cb);
/**
* GtkPlacesView|location.open-tab:
*
* Opens the location in a new tab.
*/
gtk_widget_class_install_action (widget_class, "location.open-tab", NULL, open_cb);
/**
* GtkPlacesView|location.open-window:
*
* Opens the location in a new window.
*/
gtk_widget_class_install_action (widget_class, "location.open-window", NULL, open_cb);
/**
* GtkPlacesView|location.mount:
*
* Mount the location.
*/
gtk_widget_class_install_action (widget_class, "location.mount", NULL, mount_cb);
/**
* GtkPlacesView|location.connect:
*
* Connect the location.
*/
gtk_widget_class_install_action (widget_class, "location.connect", NULL, mount_cb);
/**
* GtkPlacesView|location.unmount:
*
* Unmount the location.
*/
gtk_widget_class_install_action (widget_class, "location.unmount", NULL, unmount_cb);
/**
* GtkPlacesView|location.disconnect:
*
* Disconnect the location.
*/
gtk_widget_class_install_action (widget_class, "location.disconnect", NULL, unmount_cb);
gtk_widget_class_set_css_name (widget_class, I_("placesview"));

View File

@ -1194,9 +1194,82 @@ gtk_text_class_init (GtkTextClass *class)
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
/*
* Actions
*/
/**
* GtkText|clipboard.cut:
*
* Copies the contents to the clipboard and deletes it from the widget.
*/
gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
gtk_text_activate_clipboard_cut);
/**
* GtkText|clipboard.copy:
*
* Copies the contents to the clipboard.
*/
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
gtk_text_activate_clipboard_copy);
/**
* GtkText|clipboard.copy:
*
* Inserts the contents of the clipboard into the widget.
*/
gtk_widget_class_install_action (widget_class, "clipboard.paste", NULL,
gtk_text_activate_clipboard_paste);
/**
* GtkText|selection.delete:
*
* Deletes the current selection.
*/
gtk_widget_class_install_action (widget_class, "selection.delete", NULL,
gtk_text_activate_selection_delete);
/**
* GtkText|selection.select-all:
*
* Selects all of the widgets content.
*/
gtk_widget_class_install_action (widget_class, "selection.select-all", NULL,
gtk_text_activate_selection_select_all);
/**
* GtkText|misc.insert-emoji:
*
* Opens the Emoji chooser.
*/
gtk_widget_class_install_action (widget_class, "misc.insert-emoji", NULL,
gtk_text_activate_misc_insert_emoji);
gtk_widget_class_install_property_action (widget_class,
"misc.toggle-visibility",
"visibility");
/**
* GtkText|text.undo:
*
* Undoes the last change to the contents.
*/
gtk_widget_class_install_action (widget_class, "text.undo", NULL, gtk_text_real_undo);
/**
* GtkText|text.redo:
*
* Redoes the last change to the contents.
*/
gtk_widget_class_install_action (widget_class, "text.redo", NULL, gtk_text_real_redo);
/**
* GtkText|menu.popup:
*
* Opens the context menu.
*/
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_text_popup_menu);
/*
@ -1411,22 +1484,6 @@ gtk_text_class_init (GtkTextClass *class)
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("text"));
gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
gtk_text_activate_clipboard_cut);
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
gtk_text_activate_clipboard_copy);
gtk_widget_class_install_action (widget_class, "clipboard.paste", NULL,
gtk_text_activate_clipboard_paste);
gtk_widget_class_install_action (widget_class, "selection.delete", NULL,
gtk_text_activate_selection_delete);
gtk_widget_class_install_action (widget_class, "selection.select-all", NULL,
gtk_text_activate_selection_select_all);
gtk_widget_class_install_action (widget_class, "misc.insert-emoji", NULL,
gtk_text_activate_misc_insert_emoji);
gtk_widget_class_install_property_action (widget_class,
"misc.toggle-visibility",
"visibility");
}
static void

View File

@ -1464,8 +1464,77 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
NULL,
G_TYPE_NONE, 0);
/*
* Actions
*/
/**
* GtkTextView|clipboard.cut:
*
* Copies the contents to the clipboard and deletes it from the widget.
*/
gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
gtk_text_view_activate_clipboard_cut);
/**
* GtkTextView|clipboard.copy:
*
* Copies the contents to the clipboard.
*/
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
gtk_text_view_activate_clipboard_copy);
/**
* GtkTextView|clipboard.paste:
*
* Inserts the contents of the clipboard into the widget.
*/
gtk_widget_class_install_action (widget_class, "clipboard.paste", NULL,
gtk_text_view_activate_clipboard_paste);
/**
* GtkTextView|selection.delete:
*
* Deletes the current selection.
*/
gtk_widget_class_install_action (widget_class, "selection.delete", NULL,
gtk_text_view_activate_selection_delete);
/**
* GtkTextView|selection.select-all:
*
* Selects all of the widgets content.
*/
gtk_widget_class_install_action (widget_class, "selection.select-all", NULL,
gtk_text_view_activate_selection_select_all);
/**
* GtkTextView|misc.insert-emoji:
*
* Opens the Emoji chooser.
*/
gtk_widget_class_install_action (widget_class, "misc.insert-emoji", NULL,
gtk_text_view_activate_misc_insert_emoji);
/**
* GtkTextView|text.undo:
*
* Undoes the last change to the contents.
*/
gtk_widget_class_install_action (widget_class, "text.undo", NULL, gtk_text_view_real_undo);
/**
* GtkTextView|text.redo:
*
* Redoes the last change to the contents.
*/
gtk_widget_class_install_action (widget_class, "text.redo", NULL, gtk_text_view_real_redo);
/**
* GtkTextView|menu.popup:
*
* Opens the context menu.
*/
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_text_view_popup_menu);
/*
@ -1755,19 +1824,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
quark_text_selection_data = g_quark_from_static_string ("gtk-text-view-text-selection-data");
quark_gtk_signal = g_quark_from_static_string ("gtk-signal");
quark_text_view_child = g_quark_from_static_string ("gtk-text-view-child");
gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
gtk_text_view_activate_clipboard_cut);
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
gtk_text_view_activate_clipboard_copy);
gtk_widget_class_install_action (widget_class, "clipboard.paste", NULL,
gtk_text_view_activate_clipboard_paste);
gtk_widget_class_install_action (widget_class, "selection.delete", NULL,
gtk_text_view_activate_selection_delete);
gtk_widget_class_install_action (widget_class, "selection.select-all", NULL,
gtk_text_view_activate_selection_select_all);
gtk_widget_class_install_action (widget_class, "misc.insert-emoji", NULL,
gtk_text_view_activate_misc_insert_emoji);
}
static void

View File

@ -1057,6 +1057,11 @@ gtk_window_class_init (GtkWindowClass *klass)
* Key bindings
*/
/**
* GtkWindow|default.activate:
*
* Activate the default widget.
*/
gtk_widget_class_install_action (widget_class, "default.activate", NULL,
gtk_window_activate_default_activate);

View File

@ -347,7 +347,8 @@ static void
test_introspection (void)
{
GtkWidgetClass *class = g_type_class_ref (GTK_TYPE_TEXT);
guint i;
guint i, j;
guint found;
GType owner;
const char *name;
const GVariantType *params;
@ -370,21 +371,32 @@ test_introspection (void)
{ GTK_TYPE_TEXT, "text.undo", NULL, NULL },
};
i = 0;
j = 0;
found = 0;
while (gtk_widget_class_query_action (class,
i,
j,
&owner,
&name,
&params,
&property))
{
g_assert (expected[i].owner == owner);
g_assert_cmpstr (expected[i].name, ==, name);
g_assert_cmpstr (expected[i].params, ==, params ? g_variant_type_peek_string (params) : NULL);
g_assert_cmpstr (expected[i].property, ==, property);
i++;
for (i = 0; i < G_N_ELEMENTS (expected); i++)
{
if (strcmp (expected[i].name, name) == 0)
{
found++;
g_assert (expected[i].owner == owner);
g_assert_cmpstr (expected[i].name, ==, name);
g_assert_cmpstr (expected[i].params, ==, params ? g_variant_type_peek_string (params) : NULL);
g_assert_cmpstr (expected[i].property, ==, property);
break;
}
}
if (i == G_N_ELEMENTS (expected))
g_error ("Unexpected GtkText action: %s", name);
j++;
}
g_assert (i == G_N_ELEMENTS (expected));
g_assert (found == G_N_ELEMENTS (expected));
g_type_class_unref (class);
}