demos: Add devel styling

Add a -Dprofile=devel meson option, and add some visual
hints to the demos that you are running a nightly build.
This commit is contained in:
Matthias Clasen 2021-02-11 23:35:26 -05:00
parent 9a540841fd
commit 3aa3c21d69
12 changed files with 92 additions and 19 deletions

View File

@ -25,6 +25,8 @@
#include "demos.h"
#include "fontify.h"
#include "demo_conf.h"
static GtkWidget *info_view;
static GtkWidget *source_view;
@ -196,16 +198,20 @@ activate_about (GSimpleAction *action,
gtk_get_micro_version ());
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
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 Demo",
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Demo (Development)"
: "GTK Demo",
"version", version,
"copyright", "©1997—2020 The GTK Team",
"copyright", "©1997—2021 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK widgets",
@ -901,6 +907,9 @@ activate (GApplication *app)
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (window, "devel");
action = g_simple_action_new ("run", NULL);
g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));

View File

@ -167,6 +167,8 @@ foreach flag: common_cflags
endif
endforeach
gtkdemo_deps += [ demo_conf_h ]
executable('gtk4-demo',
sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
c_args: gtkdemo_args + demo_cflags,

View File

@ -4,6 +4,8 @@
#include "iconbrowserapp.h"
#include "iconbrowserwin.h"
#include "demo_conf.h"
struct _IconBrowserApp
{
GtkApplication parent;
@ -75,16 +77,20 @@ about_activated (GSimpleAction *action,
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",
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
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",
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Icon Browser (Development)"
: "GTK Icon Browser",
"version", version,
"copyright", "©1997—2020 The GTK Team",
"copyright", "©1997—2021 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to browse themed icons",
@ -129,6 +135,10 @@ icon_browser_app_activate (GApplication *app)
IconBrowserWindow *win;
win = icon_browser_window_new (ICON_BROWSER_APP (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_present (GTK_WINDOW (win));
}

View File

@ -14,7 +14,7 @@ iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
executable('gtk4-icon-browser',
sources: [iconbrowser_sources, iconbrowser_resources],
c_args: common_cflags,
dependencies: libgtk_dep,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags,

View File

@ -1,3 +1,19 @@
demo_conf = configuration_data()
demo_conf.set_quoted('PROFILE', get_option('profile'))
demo_conf.set_quoted('VCS_TAG', '@VCS_TAG@')
demo_conf_h = declare_dependency(
sources: vcs_tag(
command: [ 'git', 'rev-parse', '--short', 'HEAD' ],
fallback: get_option('profile') != 'default' ? 'devel' : '',
input: configure_file(
output: 'demo_conf.h.in',
configuration: demo_conf
),
output: 'demo_conf.h'
)
)
subdir('constraint-editor')
subdir('gtk-demo')
subdir('icon-browser')

View File

@ -12,7 +12,7 @@ node_editor_resources = gnome.compile_resources('node_editor_resources',
executable('gtk4-node-editor',
sources: [node_editor_sources, node_editor_resources],
dependencies: libgtk_dep,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
c_args: [
'-DNODE_EDITOR_SOURCE_DIR="@0@/../../testsuite/gsk/compare/"'.format(meson.current_source_dir())

View File

@ -23,6 +23,8 @@
#include "node-editor-window.h"
#include "demo_conf.h"
static const char *css =
"textview.editor {"
" color: rgb(192, 197, 206);"
@ -94,17 +96,21 @@ activate_about (GSimpleAction *action,
g_string_append_printf (s, "\nRenderer\n\t%s", renderer);
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"transient-for", gtk_application_get_active_window (app),
"program-name", "GTK Node Editor",
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Node Editor (Development)"
: "GTK Node Editor",
"version", version,
"copyright", "©2019—2020 The GTK Team",
"copyright", "©2019—2021 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to test GTK rendering",
@ -207,6 +213,10 @@ node_editor_application_activate (GApplication *app)
NodeEditorWindow *win;
win = node_editor_window_new (NODE_EDITOR_APPLICATION (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_present (GTK_WINDOW (win));
}

View File

@ -1,7 +1,7 @@
executable('gtk4-print-editor',
sources: ['print-editor.c'],
c_args: common_cflags,
dependencies: libgtk_dep,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags,

View File

@ -4,6 +4,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "demo_conf.h"
static GtkWidget *main_window;
static GFile *filename = NULL;
static GtkPageSetup *page_setup = NULL;
@ -641,17 +643,21 @@ activate_about (GSimpleAction *action,
g_strfreev (backends);
g_free (setting);
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"transient-for", main_window,
"program-name", "GTK Print Editor",
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Print Editor (Development)"
: "GTK Print Editor",
"version", version,
"copyright", "© 2006-2020 Red Hat, Inc",
"copyright", "© 2006-2021 Red Hat, Inc",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK printing",
@ -807,6 +813,10 @@ activate (GApplication *app)
GtkWidget *contents;
main_window = gtk_application_window_new (GTK_APPLICATION (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (main_window), "devel");
gtk_window_set_icon_name (GTK_WINDOW (main_window), "text-editor");
gtk_window_set_default_size (GTK_WINDOW (main_window), 400, 600);
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);

View File

@ -8,7 +8,7 @@ widgetfactory_resources = gnome.compile_resources('widgetfactory_resources',
executable('gtk4-widget-factory',
sources: ['widget-factory.c', widgetfactory_resources],
c_args: common_cflags,
dependencies: libgtk_dep,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags,

View File

@ -25,6 +25,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "demo_conf.h"
static void
change_dark_state (GSimpleAction *action,
GVariant *state,
@ -300,8 +302,10 @@ activate_about (GSimpleAction *action,
gtk_get_micro_version ());
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
@ -309,9 +313,11 @@ activate_about (GSimpleAction *action,
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"transient-for", gtk_application_get_active_window (app),
"modal", TRUE,
"program-name", "GTK Widget Factory",
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Widget Factory (Development)"
: "GTK Widget Factory",
"version", version,
"copyright", "©1997—2020 The GTK Team",
"copyright", "©1997—2021 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK themes and widgets",
@ -2065,6 +2071,10 @@ activate (GApplication *app)
}
window = (GtkWindow *)gtk_builder_get_object (builder, "window");
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (window), "devel");
gtk_application_add_window (GTK_APPLICATION (app), window);
g_action_map_add_action_entries (G_ACTION_MAP (window),
win_entries, G_N_ELEMENTS (win_entries),

View File

@ -111,6 +111,12 @@ option('demos',
value: 'true',
description : 'Build demo programs')
option('profile',
type: 'combo',
choices: [ 'default', 'devel' ],
value: 'default',
description : 'Profile to use for demos')
option('build-examples',
type: 'boolean',
value: 'true',