Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2582
This commit is contained in:
Matthias Clasen 2020-09-15 11:04:54 +00:00
commit 9eb4eef48b
6 changed files with 87 additions and 27 deletions

View File

@ -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);

View File

@ -29,29 +29,24 @@
<item>
<attribute name="label" translatable="yes">_New</attribute>
<attribute name="action">win.new</attribute>
<attribute name="accel">&lt;Control&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open</attribute>
<attribute name="action">win.open</attribute>
<attribute name="accel">&lt;Control&gt;o</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">win.save</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save _As</attribute>
<attribute name="action">win.save-as</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">win.quit</attribute>
<attribute name="accel">&lt;Control&gt;&lt;Shift&gt;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">&lt;Control&gt;c</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Cut</attribute>
<attribute name="action">win.cut</attribute>
<attribute name="accel">&lt;Control&gt;x</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Paste</attribute>
<attribute name="action">win.paste</attribute>
<attribute name="accel">&lt;Control&gt;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>

View File

@ -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>

View File

@ -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. */

View File

@ -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>

View File

@ -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.
*
* 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_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.
*
* 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,