[file-roller] Use GtkApplication
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] Use GtkApplication
- Date: Thu, 31 May 2012 18:44:18 +0000 (UTC)
commit b0223c4ab5bc7ce98a3747624fd1bbc298915a94
Author: Robert Ancell <robert ancell canonical com>
Date: Thu May 31 11:01:02 2012 +1200
Use GtkApplication
configure.ac | 2 +-
src/fr-window.c | 6 ++----
src/fr-window.h | 4 ++--
src/main.c | 37 ++++++++++++++++++++++++-------------
4 files changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 21a9b4c..f699204 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ dnl ==========================================================================
GLIB_REQUIRED=2.29.14
GIO_REQUIRED=2.25.5
-GTK_REQUIRED=3.0.2
+GTK_REQUIRED=3.4.0
NAUTILUS_REQUIRED=2.22.2
AC_SUBST(GLIB_REQUIRED)
diff --git a/src/fr-window.c b/src/fr-window.c
index e0452c1..287a134 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -239,7 +239,7 @@ enum {
LAST_SIGNAL
};
-static GtkWindowClass *parent_class = NULL;
+static GtkApplicationWindowClass *parent_class = NULL;
static guint fr_window_signals[LAST_SIGNAL] = { 0 };
struct _FrWindowPrivateData {
@@ -666,8 +666,6 @@ fr_window_finalize (GObject *object)
g_hash_table_destroy (tree_pixbuf_hash);
tree_pixbuf_hash = NULL;
}
-
- gtk_main_quit ();
}
}
@@ -6057,7 +6055,7 @@ fr_window_new (void)
{
GtkWidget *window;
- window = g_object_new (FR_TYPE_WINDOW, NULL);
+ window = g_object_new (FR_TYPE_WINDOW, "application", g_application_get_default (), NULL);
fr_window_construct ((FrWindow*) window);
return window;
diff --git a/src/fr-window.h b/src/fr-window.h
index b8afcc1..290643f 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -81,14 +81,14 @@ typedef struct _FrWindowPrivateData FrWindowPrivateData;
struct _FrWindow
{
- GtkWindow __parent;
+ GtkApplicationWindow __parent;
FrArchive *archive;
FrWindowPrivateData *priv;
};
struct _FrWindowClass
{
- GtkWindowClass __parent_class;
+ GtkApplicationWindowClass __parent_class;
/*<signals>*/
diff --git a/src/main.c b/src/main.c
index b126ef6..b49b4d9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,8 +41,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.gnome.file-roller", 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]