diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:36:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:36:24 +0000 |
commit | 9b6d8e63db85c30007b463e91f91a791969fa83f (patch) | |
tree | 0899af51d73c1bf986f73ae39a03c4436083018a /subprojects/libhandy/examples/handy-demo.c | |
parent | Initial commit. (diff) | |
download | gnome-control-center-9b6d8e63db85c30007b463e91f91a791969fa83f.tar.xz gnome-control-center-9b6d8e63db85c30007b463e91f91a791969fa83f.zip |
Adding upstream version 1:3.38.4.upstream/1%3.38.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'subprojects/libhandy/examples/handy-demo.c')
-rw-r--r-- | subprojects/libhandy/examples/handy-demo.c | 65 |
1 files changed, 65 insertions, 0 deletions
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 <gtk/gtk.h> +#include <handy.h> + +#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; +} |