diff options
| author | Matthias Clasen <mclasen@redhat.com> | 2020-09-15 11:04:54 +0000 |
|---|---|---|
| committer | Matthias Clasen <mclasen@redhat.com> | 2020-09-15 11:04:54 +0000 |
| commit | 9eb4eef48b4dfca6b80689d6ff995b66486b9260 (patch) | |
| tree | 73aacddb890de55d40246932379cea1cd802c503 | |
| parent | e69b623a2755626dd096d03a88558fcf4114d2e5 (diff) | |
| parent | 67c1600ac257cdac6430434852c42b671ead6ca2 (diff) | |
| download | gtk+-9eb4eef48b4dfca6b80689d6ff995b66486b9260.tar.gz | |
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master
See merge request GNOME/gtk!2582
| -rw-r--r-- | demos/gtk-demo/builder.c | 40 | ||||
| -rw-r--r-- | demos/gtk-demo/demo.ui | 19 | ||||
| -rw-r--r-- | demos/gtk-demo/dnd.c | 4 | ||||
| -rw-r--r-- | demos/gtk-demo/main.c | 10 | ||||
| -rw-r--r-- | demos/gtk-demo/main.ui | 5 | ||||
| -rw-r--r-- | gtk/gtkwidget.c | 36 |
6 files changed, 87 insertions, 27 deletions
diff --git a/demos/gtk-demo/builder.c b/demos/gtk-demo/builder.c index b6c3afbc09..db44bc17f9 100644 --- a/demos/gtk-demo/builder.c +++ b/demos/gtk-demo/builder.c @@ -1,6 +1,8 @@ /* Builder + * #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, toolbar * - * Demonstrates an interface loaded from a XML description. + * Demonstrates a traditional interface, loaded from a XML description, + * and shows how to connect actions to the menu items and toolbar buttons. */ #include <gtk/gtk.h> @@ -104,6 +106,7 @@ do_builder (GtkWidget *do_widget) GtkBuilder *builder; GtkWidget *about; GtkWidget *status; + GtkEventController *controller; builder = gtk_builder_new_from_resource ("/builder/demo.ui"); @@ -117,6 +120,41 @@ do_builder (GtkWidget *do_widget) window); gtk_widget_insert_action_group (window, "win", actions); + controller = gtk_shortcut_controller_new (); + gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller), + GTK_SHORTCUT_SCOPE_GLOBAL); + gtk_widget_add_controller (window, controller); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_n, GDK_CONTROL_MASK), + gtk_named_action_new ("win.new"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_o, GDK_CONTROL_MASK), + gtk_named_action_new ("win.open"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_s, GDK_CONTROL_MASK), + gtk_named_action_new ("win.save"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_s, GDK_CONTROL_MASK|GDK_SHIFT_MASK), + gtk_named_action_new ("win.save-as"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_q, GDK_CONTROL_MASK), + gtk_named_action_new ("win.quit"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_c, GDK_CONTROL_MASK), + gtk_named_action_new ("win.copy"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_x, GDK_CONTROL_MASK), + gtk_named_action_new ("win.cut"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_v, GDK_CONTROL_MASK), + gtk_named_action_new ("win.paste"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_F1, 0), + gtk_named_action_new ("win.help"))); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), + gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_F7, 0), + gtk_named_action_new ("win.about"))); + about = GTK_WIDGET (gtk_builder_get_object (builder, "aboutdialog1")); gtk_window_set_transient_for (GTK_WINDOW (about), GTK_WINDOW (window)); gtk_window_set_hide_on_close (GTK_WINDOW (about), TRUE); diff --git a/demos/gtk-demo/demo.ui b/demos/gtk-demo/demo.ui index c93d6d46b5..01847f8b92 100644 --- a/demos/gtk-demo/demo.ui +++ b/demos/gtk-demo/demo.ui @@ -29,29 +29,24 @@ <item> <attribute name="label" translatable="yes">_New</attribute> <attribute name="action">win.new</attribute> - <attribute name="accel"><Control>n</attribute> </item> <item> <attribute name="label" translatable="yes">_Open</attribute> <attribute name="action">win.open</attribute> - <attribute name="accel"><Control>o</attribute> </item> <item> <attribute name="label" translatable="yes">_Save</attribute> <attribute name="action">win.save</attribute> - <attribute name="accel"><Control>s</attribute> </item> <item> <attribute name="label" translatable="yes">Save _As</attribute> <attribute name="action">win.save-as</attribute> - <attribute name="accel"><Control>q</attribute> </item> </section> <section> <item> <attribute name="label" translatable="yes">_Quit</attribute> <attribute name="action">win.quit</attribute> - <attribute name="accel"><Control><Shift>s</attribute> </item> </section> </submenu> @@ -61,17 +56,14 @@ <item> <attribute name="label" translatable="yes">_Copy</attribute> <attribute name="action">win.copy</attribute> - <attribute name="accel"><Control>c</attribute> </item> <item> <attribute name="label" translatable="yes">_Cut</attribute> <attribute name="action">win.cut</attribute> - <attribute name="accel"><Control>x</attribute> </item> <item> <attribute name="label" translatable="yes">_Paste</attribute> <attribute name="action">win.paste</attribute> - <attribute name="accel"><Control>v</attribute> </item> </section> </submenu> @@ -81,12 +73,10 @@ <item> <attribute name="label" translatable="yes">_Help</attribute> <attribute name="action">win.help</attribute> - <attribute name="accel">F1</attribute> </item> <item> <attribute name="label" translatable="yes">_About</attribute> <attribute name="action">win.about</attribute> - <attribute name="accel">F7</attribute> </item> </section> </submenu> @@ -110,11 +100,15 @@ </child> <child> <object class="GtkBox" id="toolbar1"> + <style> + <class name="toolbar"/> + </style> <child> <object class="GtkButton"> <property name="label" translatable="yes">New</property> <property name="tooltip-text" translatable="yes">Create a new file</property> <property name="icon-name">document-new</property> + <property name="action-name">win.new</property> </object> </child> <child> @@ -122,6 +116,7 @@ <property name="label" translatable="yes">Open</property> <property name="tooltip-text" translatable="yes">Open a file</property> <property name="icon-name">document-open</property> + <property name="action-name">win.open</property> </object> </child> <child> @@ -129,6 +124,7 @@ <property name="label" translatable="yes">Save</property> <property name="tooltip-text" translatable="yes">Save a file</property> <property name="icon-name">document-save</property> + <property name="action-name">win.save</property> </object> </child> <child> @@ -139,6 +135,7 @@ <property name="label" translatable="yes">Copy</property> <property name="tooltip-text" translatable="yes">Copy selected object into the clipboard</property> <property name="icon-name">edit-copy</property> + <property name="action-name">win.copy</property> </object> </child> <child> @@ -146,6 +143,7 @@ <property name="label" translatable="yes">Cut</property> <property name="tooltip-text" translatable="yes">Cut selected object into the clipboard</property> <property name="icon-name">edit-cut</property> + <property name="action-name">win.cut</property> </object> </child> <child> @@ -153,6 +151,7 @@ <property name="label" translatable="yes">Paste</property> <property name="tooltip-text" translatable="yes">Paste object from the clipboard</property> <property name="icon-name">edit-paste</property> + <property name="action-name">win.paste</property> </object> </child> </object> diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c index 83e6e92359..2cdca577d9 100644 --- a/demos/gtk-demo/dnd.c +++ b/demos/gtk-demo/dnd.c @@ -1,8 +1,12 @@ /* Drag-and-Drop + * #Keywords: dnd, menu, popover, gesture * * This demo shows dragging colors and widgets. * The items in this demo can be moved, recolored * and rotated. + * + * The demo also has an example for creating a + * menu-like popover without using a menu model. */ #include <gtk/gtk.h> diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index 8cc809449a..db66928c88 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -341,12 +341,10 @@ display_text (const char *format, g_assert (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL)); textview = gtk_text_view_new (); - g_object_set (textview, - "left-margin", 20, - "right-margin", 20, - "top-margin", 20, - "bottom-margin", 20, - NULL); + gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20); + gtk_text_view_set_right_margin (GTK_TEXT_VIEW (textview), 20); + gtk_text_view_set_top_margin (GTK_TEXT_VIEW (textview), 20); + gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW (textview), 20); gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE); /* Make it a bit nicer for text. */ diff --git a/demos/gtk-demo/main.ui b/demos/gtk-demo/main.ui index acc789d0ff..b685b93ce8 100644 --- a/demos/gtk-demo/main.ui +++ b/demos/gtk-demo/main.ui @@ -106,8 +106,9 @@ <property name="right-margin">20</property> <property name="top-margin">20</property> <property name="bottom-margin">20</property> - <property name="pixels-above-lines">2</property> - <property name="pixels-below-lines">2</property> + <property name="pixels-above-lines">6</property> + <property name="pixels-below-lines">6</property> + <property name="monospace">0</property> <property name="editable">0</property> <property name="wrap-mode">word</property> <property name="cursor-visible">0</property> diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 2775d66388..df99bc01d2 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -11156,6 +11156,8 @@ gtk_widget_observe_controllers (GtkWidget *widget) * * Returns the widgets first child. * + * This API is primarily meant for widget implementations. + * * Returns: (transfer none) (nullable): The widget's first child */ GtkWidget * @@ -11174,6 +11176,8 @@ gtk_widget_get_first_child (GtkWidget *widget) * * Returns the widgets last child. * + * This API is primarily meant for widget implementations. + * * Returns: (transfer none) (nullable): The widget's last child */ GtkWidget * @@ -11192,6 +11196,8 @@ gtk_widget_get_last_child (GtkWidget *widget) * * Returns the widgets next sibling. * + * This API is primarily meant for widget implementations. + * * Returns: (transfer none) (nullable): The widget's next sibling */ GtkWidget * @@ -11210,6 +11216,8 @@ gtk_widget_get_next_sibling (GtkWidget *widget) * * Returns the widgets previous sibling. * + * This API is primarily meant for widget implementations. + * * Returns: (transfer none) (nullable): The widget's previous sibling */ GtkWidget * @@ -11229,12 +11237,18 @@ gtk_widget_get_prev_sibling (GtkWidget *widget) * @previous_sibling: (nullable): the new previous sibling of @widget or %NULL * * Inserts @widget into the child widget list of @parent. - * It will be placed after @previous_sibling, or at the beginning if @previous_sibling is %NULL. * - * After calling this function, gtk_widget_get_prev_sibling(widget) will return @previous_sibling. + * It will be placed after @previous_sibling, or at the beginning if + * @previous_sibling is %NULL. * - * If @parent is already set as the parent widget of @widget, this function can also be used - * to reorder @widget in the child widget list of @parent. + * After calling this function, gtk_widget_get_prev_sibling(widget) will + * return @previous_sibling. + * + * If @parent is already set as the parent widget of @widget, this function + * can also be used to reorder @widget in the child widget list of @parent. + * + * This API is primarily meant for widget implementations; if you are + * just using a widget, you *must* use its own API for adding children. */ void gtk_widget_insert_after (GtkWidget *widget, @@ -11265,12 +11279,18 @@ gtk_widget_insert_after (GtkWidget *widget, * @next_sibling: (nullable): the new next sibling of @widget or %NULL * * Inserts @widget into the child widget list of @parent. - * It will be placed before @next_sibling, or at the end if @next_sibling is %NULL. * - * After calling this function, gtk_widget_get_next_sibling(widget) will return @next_sibling. + * It will be placed before @next_sibling, or at the end if + * @next_sibling is %NULL. + * + * After calling this function, gtk_widget_get_next_sibling(widget) + * will return @next_sibling. + * + * If @parent is already set as the parent widget of @widget, this function + * can also be used to reorder @widget in the child widget list of @parent. * - * If @parent is already set as the parent widget of @widget, this function can also be used - * to reorder @widget in the child widget list of @parent. + * This API is primarily meant for widget implementations; if you are + * just using a widget, you *must* use its own API for adding children. */ void gtk_widget_insert_before (GtkWidget *widget, |
