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

Matthiasc/for master

See merge request GNOME/gtk!1772
This commit is contained in:
Matthias Clasen 2020-04-27 03:30:30 +00:00
commit bf1a9b2b0d
8 changed files with 277 additions and 15 deletions

View File

@ -309,4 +309,7 @@
<file>icons/16x16/status/battery-caution-charging-symbolic.symbolic.png</file>
<file>icons/16x16/categories/applications-other.png</file>
</gresource>
<gresource prefix="/org/gtk/Demo4/gtk">
<file preprocess="xml-stripblanks">help-overlay.ui</file>
</gresource>
</gresources>

View File

@ -0,0 +1,25 @@
<interface>
<object class="GtkShortcutsWindow" id="help_overlay">
<child>
<object class="GtkShortcutsSection">
<child>
<object class="GtkShortcutsGroup">
<property name="title">General</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">F1</property>
<property name="title">Show About Dialog</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Control&gt;q</property>
<property name="title">Quit</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -55,6 +55,8 @@ activate_about (GSimpleAction *action,
glib_major_version,
glib_minor_version,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
@ -1184,6 +1186,14 @@ main (int argc, char **argv)
{ "quit", activate_quit, NULL, NULL, NULL },
{ "inspector", activate_inspector, NULL, NULL, NULL },
};
struct {
const gchar *action_and_target;
const gchar *accelerators[2];
} accels[] = {
{ "app.about", { "F1", NULL } },
{ "app.quit", { "<Control>q", NULL } },
};
int i;
/* Most code in gtk-demo is intended to be exemplary, but not
* these few lines, which are just a hack so gtk-demo will work
@ -1201,6 +1211,9 @@ main (int argc, char **argv)
app_entries, G_N_ELEMENTS (app_entries),
app);
for (i = 0; i < G_N_ELEMENTS (accels); i++)
gtk_application_set_accels_for_action (app, accels[i].action_and_target, accels[i].accelerators);
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0, G_OPTION_ARG_NONE, "Show program version", NULL);
g_application_add_main_option (G_APPLICATION (app), "run", 0, 0, G_OPTION_ARG_STRING, "Run an example", "EXAMPLE");
g_application_add_main_option (G_APPLICATION (app), "list", 0, 0, G_OPTION_ARG_NONE, "List examples", NULL);

View File

@ -6,6 +6,10 @@
<attribute name="label" translatable="yes">_Inspector</attribute>
<attribute name="action">app.inspector</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">win.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About GTK Demo</attribute>
<attribute name="action">app.about</attribute>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <gtk/gtk.h>
#include "iconbrowserapp.h"
@ -28,9 +29,75 @@ quit_activated (GSimpleAction *action,
g_application_quit (G_APPLICATION (app));
}
static void
inspector_activated (GSimpleAction *action,
GVariant *parameter,
gpointer app)
{
gtk_window_set_interactive_debugging (TRUE);
}
static void
about_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkApplication *app = user_data;
const gchar *authors[] = {
"The GTK Team",
NULL
};
char *icon_theme;
char *version;
GString *s;
g_object_get (gtk_settings_get_default (),
"gtk-icon-theme-name", &icon_theme,
NULL);
s = g_string_new ("");
g_string_append (s, "System libraries\n");
g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
glib_major_version,
glib_minor_version,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
g_string_append_printf (s, "\nIcon theme\n\t%s", icon_theme);
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
"program-name", "GTK Icon Browser",
"version", version,
"copyright", "©1997—2020 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to browse themed icons",
"authors", authors,
"logo-icon-name", "org.gtk.Demo4",
"title", "About GTK Icon Browser",
"system-information", s->str,
NULL);
g_string_free (s, TRUE);
g_free (version);
g_free (icon_theme);
}
static GActionEntry app_entries[] =
{
{ "quit", quit_activated, NULL, NULL, NULL }
{ "quit", quit_activated, NULL, NULL, NULL },
{ "inspector", inspector_activated, NULL, NULL, NULL },
{ "about", about_activated, NULL, NULL, NULL }
};
static void

View File

@ -1,5 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="gear_menu">
<section>
<item>
<attribute name="label" translatable="yes">_Inspector</attribute>
<attribute name="action">app.inspector</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About GTK Icon Browser</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
<object class="IconStore" id="store"/>
<object class="GtkTreeModelFilter" id="filter_model">
<property name="child-model">store</property>
@ -36,6 +48,13 @@
</child>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<child type="end">
<object class="GtkToggleButton" id="search">
<style>

View File

@ -99,7 +99,7 @@ change_transition_state (GSimpleAction *action,
GtkStackTransitionType transition;
if (g_variant_get_boolean (state))
transition = GTK_STACK_TRANSITION_TYPE_ROTATE_LEFT_RIGHT;
transition = GTK_STACK_TRANSITION_TYPE_CROSSFADE;
else
transition = GTK_STACK_TRANSITION_TYPE_NONE;
@ -265,6 +265,8 @@ activate_about (GSimpleAction *action,
glib_major_version,
glib_minor_version,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),

View File

@ -37,7 +37,7 @@
</section>
</submenu>
<item>
<attribute name="label" translatable="yes">Slide Pages</attribute>
<attribute name="label" translatable="yes">Transition Pages</attribute>
<attribute name="action">win.transition</attribute>
</item>
</section>
@ -460,7 +460,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="margin-bottom">10</property>
<child>
<object class="GtkStack" id="toplevel_stack">
<property name="transition-duration">1000</property>
<property name="transition-duration">250</property>
<child>
<object class="GtkStackPage">
<property name="name">page1</property>
@ -539,6 +539,13 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
</object>
</child>
<child>
<object class="GtkPasswordEntry">
<property name="halign">fill</property>
<property name="show-peek-icon">1</property>
<property name="placeholder-text" translatable="yes">Password…</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="hexpand">0</property>
@ -1042,7 +1049,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkBox" id="box26">
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="spacing">10</property>
<property name="hexpand">1</property>
<child>
<object class="GtkFrame" id="frame1">
@ -1068,6 +1075,73 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="vexpand">1</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label">Large Title</property>
<style><class name="large-title"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Title 1</property>
<style><class name="title-1"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Title 2</property>
<style><class name="title-2"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Title 3</property>
<style><class name="title-3"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Title 4</property>
<style><class name="title-4"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Heading</property>
<style><class name="heading"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Body</property>
<style><class name="body"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Caption Heading</property>
<style><class name="caption-heading"/></style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Caption</property>
<style><class name="Caption"/></style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
@ -1502,8 +1576,8 @@ microphone-sensitivity-medium-symbolic</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkStack" id="stack">
<property name="transition-type">crossfade</property>
<property name="transition-duration">1000</property>
<property name="transition-type">rotate-left-right</property>
<property name="transition-duration">250</property>
<child>
<object class="GtkStackPage">
<property name="name">page1</property>
@ -1572,6 +1646,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">200</property>
<property name="hexpand">0</property>
<property name="vexpand">1</property>
<child>
<object class="GtkListBox" id="listbox">
<property name="selection-mode">none</property>
@ -1771,6 +1846,46 @@ microphone-sensitivity-medium-symbolic</property>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listboxrow7">
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Row 7</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listboxrow8">
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Row 8</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
@ -2466,37 +2581,47 @@ microphone-sensitivity-medium-symbolic</property>
</child>
</object>
</child>
<child>
<object class="GtkFrame">
<child>
<object class="GtkBox">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkButton" id="toolbutton1">
<property name="icon-name">document-open-symbolic</property>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Insert ⌘</property>
</object>
</child>
<child>
<object class="GtkButton" id="toolbutton2">
<property name="icon-name">send-to-symbolic</property>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Insert ⚽</property>
</object>
</child>
<child>
<object class="GtkButton" id="toolbutton3">
<property name="icon-name">view-fullscreen-symbolic</property>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Insert ⤢</property>
</object>
</child>
<child>
<object class="GtkButton" id="toolbutton4">
<property name="icon-name">star-new-symbolic</property>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Insert ☆</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="has-frame">1</property>
<property name="hexpand">1</property>
<child>
<object class="GtkTextView" id="tooltextview"/>
@ -2506,10 +2631,6 @@ microphone-sensitivity-medium-symbolic</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
@ -2520,18 +2641,24 @@ microphone-sensitivity-medium-symbolic</property>
<object class="GtkButton" id="cutbutton">
<property name="sensitive">0</property>
<property name="icon-name">edit-cut-symbolic</property>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Cut</property>
</object>
</child>
<child>
<object class="GtkButton" id="copybutton">
<property name="sensitive">0</property>
<property name="icon-name">edit-copy-symbolic</property>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Copy</property>
</object>
</child>
<child>
<object class="GtkButton" id="pastebutton">
<property name="sensitive">0</property>
<property name="icon-name">edit-paste-symbolic</property>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Paste</property>
</object>
</child>
</object>
@ -2541,8 +2668,8 @@ microphone-sensitivity-medium-symbolic</property>
<property name="sensitive">0</property>
<property name="valign">end</property>
<property name="icon-name">edit-delete-symbolic</property>
</object>
</child>
<property name="focus-on-click">0</property>
<property name="tooltip-text" translatable="yes">Delete</property>
</object>
</child>
</object>
@ -3204,6 +3331,8 @@ bad things might happen.</property>
<widget name="listboxrow4"/>
<widget name="listboxrow5"/>
<widget name="listboxrow6"/>
<widget name="listboxrow7"/>
<widget name="listboxrow8"/>
</widgets>
</object>
<object class="GtkSizeGroup">