Newer
Older
#include "rugby-application.h"
#include "rugby-app-window.h"
G_DEFINE_TYPE (RugbyApplication, rugby_application, GTK_TYPE_APPLICATION);
RugbyAppWindow *win = rugby_app_window_new (RUGBY_APPLICATION (app));
gtk_window_present (GTK_WINDOW (win));
about_activated (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
GtkApplication *app = GTK_APPLICATION (user_data);
GtkWindow *window = gtk_application_get_active_window (app);
const gchar *authors[] = { "Bruce Cowan", NULL };
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
g_autoptr (GDateTime) date = g_date_time_new_now_local ();
gint year = g_date_time_get_year (date);
g_autofree gchar *copyright = g_strdup_printf ("Copyright © 2012–%d Bruce Cowan",
year);
gtk_show_about_dialog (window,
"logo-icon-name", "face-wink",
"program-name", "Rugby",
"copyright", copyright,
"license-type", GTK_LICENSE_LGPL_3_0,
"authors", authors,
"comments", "Rugby scores possiblities program",
NULL);
}
static void
quit_activated (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
{
g_application_quit (G_APPLICATION (user_data));
}
static const GActionEntry app_entries[] =
{
{ "about", about_activated, NULL, NULL, NULL },
{ "quit", quit_activated, NULL, NULL, NULL }
};
static void
rugby_application_startup (GApplication *app)
{
G_APPLICATION_CLASS (rugby_application_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
g_autoptr (GtkBuilder) builder = gtk_builder_new_from_resource ("/uk/me/bcowan/rugby/menu.ui");
GMenuModel *app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
// CSS styling
g_autoptr (GtkCssProvider) provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/uk/me/bcowan/rugby/rugby.css");
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
static void
rugby_application_class_init (RugbyApplicationClass *klass)
{
GApplicationClass *app_class = G_APPLICATION_CLASS (klass);
app_class->activate = rugby_application_activate;
app_class->startup = rugby_application_startup;
}
static void
rugby_application_init (RugbyApplication *self)
{
}
RugbyApplication *
rugby_application_new (void)
{
return g_object_new (RUGBY_TYPE_APPLICATION,
"application-id", "uk.me.bcowan.rugby",
NULL);