From 9b6d8e63db85c30007b463e91f91a791969fa83f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 16:36:24 +0200 Subject: Adding upstream version 1:3.38.4. Signed-off-by: Daniel Baumann --- subprojects/libhandy/examples/handy-demo.c | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 subprojects/libhandy/examples/handy-demo.c (limited to 'subprojects/libhandy/examples/handy-demo.c') diff --git a/subprojects/libhandy/examples/handy-demo.c b/subprojects/libhandy/examples/handy-demo.c new file mode 100644 index 0000000..052ce4c --- /dev/null +++ b/subprojects/libhandy/examples/handy-demo.c @@ -0,0 +1,65 @@ +#include +#include + +#include "hdy-demo-preferences-window.h" +#include "hdy-demo-window.h" + +static void +show_preferences (GSimpleAction *action, + GVariant *state, + gpointer user_data) +{ + GtkApplication *app = GTK_APPLICATION (user_data); + GtkWindow *window = gtk_application_get_active_window (app); + HdyDemoPreferencesWindow *preferences = hdy_demo_preferences_window_new (); + + gtk_window_set_transient_for (GTK_WINDOW (preferences), window); + gtk_widget_show (GTK_WIDGET (preferences)); +} + +static void +startup (GtkApplication *app) +{ + GtkCssProvider *css_provider = gtk_css_provider_new (); + + hdy_init (); + + gtk_css_provider_load_from_resource (css_provider, "/sm/puri/Handy/Demo/ui/style.css"); + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (css_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + + g_object_unref (css_provider); +} + +static void +show_window (GtkApplication *app) +{ + HdyDemoWindow *window; + + window = hdy_demo_window_new (app); + + gtk_widget_show (GTK_WIDGET (window)); +} + +int +main (int argc, + char **argv) +{ + GtkApplication *app; + int status; + static GActionEntry app_entries[] = { + { "preferences", show_preferences, NULL, NULL, NULL }, + }; + + app = gtk_application_new ("sm.puri.Handy.Demo", G_APPLICATION_FLAGS_NONE); + g_action_map_add_action_entries (G_ACTION_MAP (app), + app_entries, G_N_ELEMENTS (app_entries), + app); + g_signal_connect (app, "startup", G_CALLBACK (startup), NULL); + g_signal_connect (app, "activate", G_CALLBACK (show_window), NULL); + status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + + return status; +} -- cgit v1.2.3