3232#include "eom-application.h"
3333#include "eom-util.h"
3434
35- #ifdef HAVE_DBUS
3635#include "totem-scrsaver.h"
37- #endif
3836
3937#include <string.h>
4038#include <glib.h>
4341#include <gtk/gtk.h>
4442#include <gdk/gdkx.h>
4543
46- #ifdef HAVE_DBUS
47- #include "eom-application-service.h"
48- #include <dbus/dbus-glib-bindings.h>
49-
5044#define APPLICATION_SERVICE_NAME "org.mate.eom.ApplicationService"
51- #endif
5245
5346static void eom_application_load_accelerators (void );
5447static void eom_application_save_accelerators (void );
5548
5649#define EOM_APPLICATION_GET_PRIVATE (object ) \
5750 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EOM_TYPE_APPLICATION, EomApplicationPrivate))
5851
59- G_DEFINE_TYPE (EomApplication , eom_application , G_TYPE_OBJECT );
52+ G_DEFINE_TYPE (EomApplication , eom_application , GTK_TYPE_APPLICATION );
6053
61- #ifdef HAVE_DBUS
54+ static void
55+ eom_application_activate (GApplication * application )
56+ {
57+ eom_application_open_window (EOM_APPLICATION (application ),
58+ GDK_CURRENT_TIME ,
59+ EOM_APPLICATION (application )-> flags ,
60+ NULL );
61+ }
6262
63- /**
64- * eom_application_register_service:
65- * @application: An #EomApplication.
66- *
67- * Registers #EomApplication<!-- -->'s DBus service, to allow
68- * remote calls. If the DBus service is already registered,
69- * or there is any other connection error, returns %FALSE.
70- *
71- * Returns: %TRUE if the service was registered succesfully. %FALSE
72- * otherwise.
73- **/
74- gboolean
75- eom_application_register_service (EomApplication * application )
63+ static void
64+ eom_application_open (GApplication * application ,
65+ GFile * * files ,
66+ gint n_files ,
67+ const gchar * hint )
7668{
77- static DBusGConnection * connection = NULL ;
78- DBusGProxy * driver_proxy ;
79- GError * err = NULL ;
80- guint request_name_result ;
81-
82- if (connection ) {
83- g_warning ("Service already registered." );
84- return FALSE;
85- }
69+ GSList * list = NULL ;
8670
87- connection = dbus_g_bus_get (DBUS_BUS_STARTER , & err );
71+ while (n_files -- )
72+ list = g_slist_prepend (list , files [n_files ]);
8873
89- if (connection == NULL ) {
90- g_warning ("Service registration failed." );
91- g_error_free (err );
74+ eom_application_open_file_list (EOM_APPLICATION (application ),
75+ list , GDK_CURRENT_TIME ,
76+ EOM_APPLICATION (application )-> flags ,
77+ NULL );
78+ }
9279
93- return FALSE;
94- }
80+ static void
81+ eom_application_finalize (GObject * object )
82+ {
83+ EomApplication * application = EOM_APPLICATION (object );
9584
96- driver_proxy = dbus_g_proxy_new_for_name (connection ,
97- DBUS_SERVICE_DBUS ,
98- DBUS_PATH_DBUS ,
99- DBUS_INTERFACE_DBUS );
100-
101- if (!org_freedesktop_DBus_request_name (driver_proxy ,
102- APPLICATION_SERVICE_NAME ,
103- DBUS_NAME_FLAG_DO_NOT_QUEUE ,
104- & request_name_result , & err )) {
105- g_warning ("Service registration failed." );
106- g_clear_error (& err );
85+ if (application -> toolbars_model ) {
86+ g_object_unref (application -> toolbars_model );
87+ application -> toolbars_model = NULL ;
88+ g_free (application -> toolbars_file );
89+ application -> toolbars_file = NULL ;
10790 }
108-
109- g_object_unref (driver_proxy );
110-
111- if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS ) {
112- return FALSE;
91+ if (application -> plugin_engine ) {
92+ g_object_unref (application -> plugin_engine );
93+ application -> plugin_engine = NULL ;
11394 }
95+ eom_application_save_accelerators ();
96+ }
11497
115- dbus_g_object_type_install_info (EOM_TYPE_APPLICATION ,
116- & dbus_glib_eom_application_object_info );
98+ static void
99+ eom_application_add_platform_data (GApplication * application ,
100+ GVariantBuilder * builder )
101+ {
102+ EomApplication * app = EOM_APPLICATION (application );
117103
118- dbus_g_connection_register_g_object (connection ,
119- "/org/mate/eom/Eom" ,
120- G_OBJECT (application ));
104+ G_APPLICATION_CLASS (eom_application_parent_class )-> add_platform_data (application ,
105+ builder );
121106
122- application -> scr_saver = totem_scrsaver_new ();
123- g_object_set (application -> scr_saver ,
124- "reason" , _ ("Running in fullscreen mode" ),
125- NULL );
107+ if (app -> flags ) {
108+ g_variant_builder_add (builder , "{sv}" ,
109+ "eom-application-startup-flags" ,
110+ g_variant_new_byte (app -> flags ));
111+ }
112+ }
126113
127- return TRUE;
114+ static void
115+ eom_application_before_emit (GApplication * application ,
116+ GVariant * platform_data )
117+ {
118+ GVariantIter iter ;
119+ const gchar * key ;
120+ GVariant * value ;
121+
122+ EOM_APPLICATION (application )-> flags = 0 ;
123+ g_variant_iter_init (& iter , platform_data );
124+ while (g_variant_iter_loop (& iter , "{&sv}" , & key , & value )) {
125+ if (strcmp (key , "eom-application-startup-flags" ) == 0 ) {
126+ EOM_APPLICATION (application )-> flags = g_variant_get_byte (value );
127+ }
128+ }
129+
130+ G_APPLICATION_CLASS (eom_application_parent_class )-> before_emit (application ,
131+ platform_data );
128132}
129- #endif /* ENABLE_DBUS */
130133
131134static void
132135eom_application_class_init (EomApplicationClass * eom_application_class )
133136{
137+ GApplicationClass * application_class ;
138+ GObjectClass * object_class ;
139+
140+ application_class = (GApplicationClass * ) eom_application_class ;
141+ object_class = (GObjectClass * ) eom_application_class ;
142+
143+ object_class -> finalize = eom_application_finalize ;
144+
145+ application_class -> activate = eom_application_activate ;
146+ application_class -> open = eom_application_open ;
147+ application_class -> add_platform_data = eom_application_add_platform_data ;
148+ application_class -> before_emit = eom_application_before_emit ;
134149}
135150
136151static void
@@ -140,9 +155,9 @@ eom_application_init (EomApplication *eom_application)
140155
141156 eom_session_init (eom_application );
142157
143- eom_application -> plugin_engine = eom_plugin_engine_new ();
144-
145158 eom_application -> toolbars_model = egg_toolbars_model_new ();
159+ eom_application -> plugin_engine = eom_plugin_engine_new ();
160+ eom_application -> flags = 0 ;
146161
147162 egg_toolbars_model_load_names (eom_application -> toolbars_model ,
148163 EOM_DATA_DIR "/eom-toolbar.xml" );
@@ -178,7 +193,10 @@ eom_application_get_instance (void)
178193 static EomApplication * instance ;
179194
180195 if (!instance ) {
181- instance = EOM_APPLICATION (g_object_new (EOM_TYPE_APPLICATION , NULL ));
196+ instance = EOM_APPLICATION (g_object_new (EOM_TYPE_APPLICATION ,
197+ "application-id" , APPLICATION_SERVICE_NAME ,
198+ "flags" , G_APPLICATION_HANDLES_OPEN ,
199+ NULL ));
182200 }
183201
184202 return instance ;
@@ -193,7 +211,7 @@ eom_application_get_empty_window (EomApplication *application)
193211
194212 g_return_val_if_fail (EOM_IS_APPLICATION (application ), NULL );
195213
196- windows = eom_application_get_windows ( application );
214+ windows = gtk_application_get_windows ( GTK_APPLICATION ( application ) );
197215
198216 for (l = windows ; l != NULL ; l = l -> next ) {
199217 EomWindow * window = EOM_WINDOW (l -> data );
@@ -204,8 +222,6 @@ eom_application_get_empty_window (EomApplication *application)
204222 }
205223 }
206224
207- g_list_free (windows );
208-
209225 return empty_window ;
210226}
211227
@@ -386,7 +402,6 @@ eom_application_open_uri_list (EomApplication *application,
386402 error );
387403}
388404
389- #ifdef HAVE_DBUS
390405/**
391406 * eom_application_open_uris:
392407 * @application: an #EomApplication
@@ -415,70 +430,6 @@ eom_application_open_uris (EomApplication *application,
415430 return eom_application_open_file_list (application , file_list , timestamp ,
416431 flags , error );
417432}
418- #endif
419-
420- /**
421- * eom_application_shutdown:
422- * @application: An #EomApplication.
423- *
424- * Takes care of shutting down the Eye of MATE, and quits.
425- **/
426- void
427- eom_application_shutdown (EomApplication * application )
428- {
429- g_return_if_fail (EOM_IS_APPLICATION (application ));
430-
431- if (application -> toolbars_model ) {
432- g_object_unref (application -> toolbars_model );
433- application -> toolbars_model = NULL ;
434-
435- g_free (application -> toolbars_file );
436- application -> toolbars_file = NULL ;
437- }
438-
439- if (application -> plugin_engine ) {
440- g_object_unref (application -> plugin_engine );
441- application -> plugin_engine = NULL ;
442- }
443-
444- eom_application_save_accelerators ();
445-
446- g_object_unref (application );
447-
448- gtk_main_quit ();
449- }
450-
451- /**
452- * eom_application_get_windows:
453- * @application: An #EomApplication.
454- *
455- * Gets the list of existing #EomApplication<!-- -->s. The windows
456- * in this list are not individually referenced, you need to keep
457- * your own references if you want to perform actions that may destroy
458- * them.
459- *
460- * Returns: (element-type EomWindow) (transfer container): A new list of #EomWindow<!-- -->s.
461- **/
462- GList *
463- eom_application_get_windows (EomApplication * application )
464- {
465- GList * l , * toplevels ;
466- GList * windows = NULL ;
467-
468- g_return_val_if_fail (EOM_IS_APPLICATION (application ), NULL );
469-
470- toplevels = gtk_window_list_toplevels ();
471-
472- for (l = toplevels ; l != NULL ; l = l -> next ) {
473- if (EOM_IS_WINDOW (l -> data )) {
474- windows = g_list_append (windows , l -> data );
475- }
476- }
477-
478- g_list_free (toplevels );
479-
480- return windows ;
481- }
482433
483434/**
484435 * eom_application_get_toolbars_model:
@@ -534,7 +485,6 @@ eom_application_reset_toolbars_model (EomApplication *app)
534485 EGG_TB_MODEL_NOT_REMOVABLE );
535486}
536487
537- #ifdef HAVE_DBUS
538488/**
539489 * eom_application_screensaver_enable:
540490 * @application: an #EomApplication.
@@ -562,7 +512,6 @@ eom_application_screensaver_disable (EomApplication *application)
562512 if (application -> scr_saver )
563513 totem_scrsaver_disable (application -> scr_saver );
564514}
565- #endif
566515
567516static void
568517eom_application_load_accelerators (void )
0 commit comments