diff options
author | ZenWalker <[email protected]> | 2016-07-09 22:50:29 +0200 |
---|---|---|
committer | ZenWalker <[email protected]> | 2016-07-10 03:05:56 +0200 |
commit | 1c4f7a65536c801a4fc25b920163ffdbc3aa5bb9 (patch) | |
tree | 8ba2c02f6be4ba13d8e3d92b498a84508e0bd21e /src/main.c | |
parent | 134ab265dec2de6b1668a55d6164de265e5b3f99 (diff) | |
download | engrampa-1c4f7a65536c801a4fc25b920163ffdbc3aa5bb9.tar.bz2 engrampa-1c4f7a65536c801a4fc25b920163ffdbc3aa5bb9.tar.xz |
Use GtkApplication
file-roller commits:
https://git.gnome.org/browse/file-roller/commit/?id=b0223c4ab5bc7ce98a3747624fd1bbc298915a94
https://git.gnome.org/browse/file-roller/commit/?id=6d03df7fdfdab9089ced1ca7682ec7ffffa1bbc7
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 37 |
1 files changed, 24 insertions, 13 deletions
@@ -44,8 +44,6 @@ static int extract; static int extract_here; static char *default_url = NULL; -static guint startup_id = 0; - /* argv[0] from main(); used as the command to restart the program */ static const char *program_argv0 = NULL; @@ -141,7 +139,7 @@ prepare_app (void) /**/ if (remaining_args == NULL) { /* No archive specified. */ - gtk_widget_show (fr_window_new ()); + fr_window_new (); return; } @@ -216,7 +214,6 @@ prepare_app (void) char *uri; window = fr_window_new (); - gtk_widget_show (window); file = g_file_new_for_commandline_arg (filename); uri = g_file_get_uri (file); @@ -231,16 +228,23 @@ prepare_app (void) } -static gboolean -startup_cb (gpointer data) +static void +startup_cb (GApplication *application) { - g_source_remove (startup_id); - startup_id = 0; - initialize_data (); prepare_app (); +} + + +static void +activate_cb (GApplication *application) +{ + GList *link; - return FALSE; + for (link = WindowList; link; link = link->next) { + FrWindow *window = link->data; + gtk_widget_show (GTK_WIDGET (window)); + } } @@ -280,12 +284,15 @@ fr_save_state (EggSMClient *client, GKeyFile *state, gpointer user_data) g_key_file_set_integer (state, "Session", "archives", i); } + int main (int argc, char **argv) { GOptionContext *context = NULL; GError *error = NULL; + GtkApplication *app = NULL; EggSMClient *client = NULL; + int status; program_argv0 = argv[0]; @@ -318,9 +325,13 @@ main (int argc, char **argv) gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), PKG_DATA_DIR G_DIR_SEPARATOR_S "icons"); - startup_id = g_idle_add (startup_cb, NULL); - gtk_main (); + app = gtk_application_new ("org.mate.engrampa", G_APPLICATION_FLAGS_NONE); + g_signal_connect (app, "startup", G_CALLBACK (startup_cb), NULL); + g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL); + + status = g_application_run (G_APPLICATION (app), argc, argv); + release_data (); - return 0; + return status; } |