[totem] main: Make TotemObject a GtkApplication



commit f9b2dd9884c7d29a44c1adcbf8113446c32e8433
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 28 15:27:19 2012 +0200

    main: Make TotemObject a GtkApplication
    
    To make it possible for us to handle the local command-line first.

 src/totem-object.c  |    4 +---
 src/totem-private.h |    3 +--
 src/totem.c         |   14 ++++++++------
 src/totem.h         |    2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/src/totem-object.c b/src/totem-object.c
index 6598161..bd0b923 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -143,7 +143,7 @@ static void totem_object_finalize (GObject *totem);
 
 static int totem_table_signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE(TotemObject, totem_object, G_TYPE_OBJECT)
+G_DEFINE_TYPE(TotemObject, totem_object, GTK_TYPE_APPLICATION)
 
 static void
 totem_object_class_init (TotemObjectClass *klass)
@@ -985,8 +985,6 @@ totem_object_action_exit (TotemObject *totem)
 		bacon_video_widget_close (totem->bvw);
 	}
 
-	if (totem->app != NULL)
-		g_object_unref (totem->app);
 	totem_action_save_state (totem, page_id);
 	g_free (page_id);
 
diff --git a/src/totem-private.h b/src/totem-private.h
index 760462c..6d025d3 100644
--- a/src/totem-private.h
+++ b/src/totem-private.h
@@ -69,7 +69,7 @@ typedef enum {
 } TotemStates;
 
 struct _TotemObject {
-	GObject parent;
+	GtkApplication parent;
 
 	/* Control window */
 	GtkBuilder *xml;
@@ -152,7 +152,6 @@ struct _TotemObject {
 	gint64 seek_to;
 	TotemPlaylist *playlist;
 	GSettings *settings;
-	GtkApplication *app;
 	TotemStates state;
 	TotemOpenLocation *open_location;
 	gboolean remember_position;
diff --git a/src/totem.c b/src/totem.c
index d5270bf..bd973fd 100644
--- a/src/totem.c
+++ b/src/totem.c
@@ -169,7 +169,7 @@ app_init (Totem *totem, char **argv)
 	if (optionstate.fullscreen == FALSE)
 		gdk_window_set_cursor (gtk_widget_get_window (totem->win), NULL);
 
-	gtk_window_set_application (GTK_WINDOW (totem->win), totem->app);
+	gtk_window_set_application (GTK_WINDOW (totem->win), GTK_APPLICATION (totem));
 }
 
 static void
@@ -275,16 +275,18 @@ main (int argc, char **argv)
 	g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL);
 
 	/* Build the main Totem object */
-	totem = g_object_new (TOTEM_TYPE_OBJECT, NULL);
+	totem = g_object_new (TOTEM_TYPE_OBJECT,
+			      "application-id", "org.gnome.Totem",
+			      "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
+			      NULL);
 	totem->settings = g_settings_new (TOTEM_GSETTINGS_SCHEMA);
 
-	totem->app = gtk_application_new ("org.gnome.Totem", G_APPLICATION_HANDLES_COMMAND_LINE);
-	g_signal_connect (G_OBJECT (totem->app), "startup",
+	g_signal_connect (G_OBJECT (totem), "startup",
 			  G_CALLBACK (app_startup), totem);
-	g_signal_connect (G_OBJECT (totem->app), "command-line",
+	g_signal_connect (G_OBJECT (totem), "command-line",
 			  G_CALLBACK (app_command_line), totem);
 
-	g_application_run (G_APPLICATION (totem->app), argc, argv);
+	g_application_run (G_APPLICATION (totem), argc, argv);
 
 	return 0;
 }
diff --git a/src/totem.h b/src/totem.h
index 6294781..80fcf02 100644
--- a/src/totem.h
+++ b/src/totem.h
@@ -163,7 +163,7 @@ typedef struct _TotemObject TotemObject;
  * The class structure for the #TotemPlParser type.
  **/
 typedef struct {
-	GObjectClass parent_class;
+	GtkApplicationClass parent_class;
 
 	void (*file_opened)			(TotemObject *totem, const char *mrl);
 	void (*file_closed)			(TotemObject *totem);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]