[atomix/wip/gtk3-port] Use new icon and GtkApplication (bgo#742871)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [atomix/wip/gtk3-port] Use new icon and GtkApplication (bgo#742871)
- Date: Sat, 26 Dec 2015 01:31:50 +0000 (UTC)
commit 881bacc49ce5c3f844e306821cb79e84628eeb4d
Author: Robert Roth <robert roth off gmail com>
Date: Sat Dec 26 03:30:59 2015 +0200
Use new icon and GtkApplication (bgo#742871)
src/main.c | 59 +++++++++++++++++++++++------------------------------------
1 files changed, 23 insertions(+), 36 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index 8dc1f92..e8b2543 100644
--- a/src/main.c
+++ b/src/main.c
@@ -573,7 +573,6 @@ static AtomixApp *create_gui (void)
{
AtomixApp *app;
gchar *ui_path;
- gchar *icon_path;
GtkBuilder *builder;
GtkWidget *stats_grid;
GtkWidget *time_label;
@@ -588,10 +587,6 @@ static AtomixApp *create_gui (void)
gtk_builder_add_from_file (builder, ui_path, NULL);
g_free (ui_path);
-// ui_path = g_build_filename (PKGDATADIR, "ui", "menus.ui", NULL);
-// gtk_builder_add_from_file (builder, ui_path, NULL);
-// g_free (ui_path);
-
app->mainwin = GTK_WIDGET (gtk_builder_get_object (builder, "mainwin"));
app->actions = g_hash_table_new (NULL, NULL);
@@ -654,52 +649,44 @@ static AtomixApp *create_gui (void)
g_object_unref (builder);
- icon_path = g_build_filename (DATADIR,
- "pixmaps",
- "atomix-icon.png",
- NULL);
- gtk_window_set_default_icon_from_file (icon_path,
- NULL);
- g_free (icon_path);
+ gtk_window_set_icon_name (GTK_WINDOW (app->mainwin), "atomix");
gtk_widget_show_all (GTK_WIDGET (app->mainwin));
return app;
}
+static void
+app_activate (GApplication *app_instance, gpointer user_data)
+{
+ /* make a few initalisations here */
+ app = create_gui ();
+
+ game_init ();
+
+ gtk_widget_set_size_request (GTK_WIDGET (app->mainwin), 678, 520);
+ //gtk_window_set_resizable (GTK_WINDOW (app->mainwin), FALSE);
+ gtk_widget_show (app->mainwin);
+ gtk_application_add_window (GTK_APPLICATION (app_instance), GTK_WINDOW (app->mainwin));
+}
+
int main (int argc, char *argv[])
{
- GOptionContext *context;
- gboolean retval;
- GError *error = NULL;
-
- context = g_option_context_new (NULL);
- g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
- g_option_context_add_group (context, gtk_get_option_group (TRUE));
-
- retval = g_option_context_parse (context, &argc, &argv, &error);
- g_option_context_free (context);
- if (!retval) {
- g_print ("%s", error->message);
- g_error_free (error);
- exit (1);
- }
+ GtkApplication *gtk_app;
+
+ int status;
g_set_application_name (_("Atomix"));
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
-
- /* make a few initalisations here */
- app = create_gui ();
- game_init ();
+ gtk_app = gtk_application_new ("org.gnome.atomix", G_APPLICATION_FLAGS_NONE);
+ g_signal_connect (gtk_app, "activate", G_CALLBACK (app_activate), NULL);
- gtk_widget_set_size_request (GTK_WIDGET (app->mainwin), 678, 520);
- //gtk_window_set_resizable (GTK_WINDOW (app->mainwin), FALSE);
- gtk_widget_show (app->mainwin);
+ status = g_application_run (G_APPLICATION (gtk_app), argc, argv);
+ g_object_unref (gtk_app);
- gtk_main ();
- return 0;
+ return status;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]