9999#include "ev-bookmark-action.h"
100100
101101#ifdef ENABLE_DBUS
102+ #include "ev-gdbus-generated.h"
102103#include "ev-media-player-keys.h"
103104#endif /* ENABLE_DBUS */
104105
@@ -225,8 +226,8 @@ struct _EvWindowPrivate {
225226 GSettings * lockdown_settings ;
226227#ifdef ENABLE_DBUS
227228 /* DBus */
228- guint dbus_object_id ;
229- gchar * dbus_object_path ;
229+ EvAtrilWindow * skeleton ;
230+ gchar * dbus_object_path ;
230231#endif
231232
232233 /* Caret navigation */
@@ -5970,16 +5971,13 @@ ev_window_dispose (GObject *object)
59705971 }
59715972
59725973#ifdef ENABLE_DBUS
5973- if (priv -> dbus_object_id > 0 ) {
5974- ev_window_emit_closed (window );
5975- g_dbus_connection_unregister_object (ev_application_get_dbus_connection (EV_APP ),
5976- priv -> dbus_object_id );
5977- priv -> dbus_object_id = 0 ;
5978- }
5979-
5980- if (priv -> dbus_object_path ) {
5981- g_free (priv -> dbus_object_path );
5982- priv -> dbus_object_path = NULL ;
5974+ if (priv -> skeleton != NULL ) {
5975+ ev_window_emit_closed (window );
5976+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (priv -> skeleton ));
5977+ g_object_unref (priv -> skeleton );
5978+ priv -> skeleton = NULL ;
5979+ g_free (priv -> dbus_object_path );
5980+ priv -> dbus_object_path = NULL ;
59835981 }
59845982#endif /* ENABLE_DBUS */
59855983
@@ -7504,17 +7502,11 @@ static void
75047502ev_window_sync_source (EvWindow * window ,
75057503 EvSourceLink * link )
75067504{
7507- GDBusConnection * connection ;
7508- GError * error = NULL ;
75097505 guint32 timestamp ;
75107506 gchar * uri_input ;
75117507 GFile * input_gfile ;
75127508
7513- if (window -> priv -> dbus_object_id <= 0 )
7514- return ;
7515-
7516- connection = ev_application_get_dbus_connection (EV_APP );
7517- if (!connection )
7509+ if (window -> priv -> skeleton == NULL )
75187510 return ;
75197511
75207512 timestamp = gtk_get_current_event_time ();
@@ -7540,144 +7532,57 @@ ev_window_sync_source (EvWindow *window,
75407532 uri_input = g_file_get_uri (input_gfile );
75417533 g_object_unref (input_gfile );
75427534
7543- g_dbus_connection_emit_signal (connection ,
7544- NULL ,
7545- window -> priv -> dbus_object_path ,
7546- EV_WINDOW_DBUS_INTERFACE ,
7547- "SyncSource" ,
7548- g_variant_new ("(s(ii)u)" ,
7549- uri_input ,
7550- link -> line ,
7551- link -> col ,
7552- timestamp ),
7553- & error );
7535+ ev_atril_window_emit_sync_source (window -> priv -> skeleton ,
7536+ uri_input ,
7537+ g_variant_new ("(ii)" , link -> line , link -> col ),
7538+ timestamp );
75547539 g_free (uri_input );
7555- if (error ) {
7556- g_printerr ("Failed to emit DBus signal SyncSource: %s\n" ,
7557- error -> message );
7558- g_error_free (error );
7559- }
75607540}
75617541
75627542static void
75637543ev_window_emit_closed (EvWindow * window )
75647544{
7565- GDBusConnection * connection ;
7566- GError * error = NULL ;
7567-
7568- if (window -> priv -> dbus_object_id <= 0 )
7569- return ;
7570-
7571- connection = ev_application_get_dbus_connection (EV_APP );
7572- if (!connection )
7545+ if (window -> priv -> skeleton == NULL )
75737546 return ;
75747547
7575- g_dbus_connection_emit_signal (connection ,
7576- NULL ,
7577- window -> priv -> dbus_object_path ,
7578- EV_WINDOW_DBUS_INTERFACE ,
7579- "Closed" ,
7580- NULL ,
7581- & error );
7582- if (error ) {
7583- g_printerr ("Failed to emit DBus signal Closed: %s\n" ,
7584- error -> message );
7585- g_error_free (error );
7586-
7587- return ;
7588- }
7548+ ev_atril_window_emit_closed (window -> priv -> skeleton );
75897549
75907550 /* If this is the last window call g_dbus_connection_flush_sync()
75917551 * to make sure the signal is emitted.
75927552 */
75937553 if (ev_application_get_n_windows (EV_APP ) == 1 )
7594- g_dbus_connection_flush_sync (connection , NULL , NULL );
7554+ g_dbus_connection_flush_sync (ev_application_get_dbus_connection ( EV_APP ) , NULL , NULL );
75957555}
75967556
75977557static void
75987558ev_window_emit_doc_loaded (EvWindow * window )
75997559{
7600- GDBusConnection * connection ;
7601- GError * error = NULL ;
7602-
7603- if (window -> priv -> dbus_object_id <= 0 )
7604- return ;
7605-
7606- connection = ev_application_get_dbus_connection (EV_APP );
7607- if (!connection )
7608- return ;
7609-
7610- g_dbus_connection_emit_signal (connection ,
7611- NULL ,
7612- window -> priv -> dbus_object_path ,
7613- EV_WINDOW_DBUS_INTERFACE ,
7614- "DocumentLoaded" ,
7615- g_variant_new ("(s)" , window -> priv -> uri ),
7616- & error );
7617- if (error ) {
7618- g_printerr ("Failed to emit DBus signal DocumentLoaded: %s\n" ,
7619- error -> message );
7620- g_error_free (error );
7560+ if (window -> priv -> skeleton == NULL )
7561+ return ;
76217562
7622- return ;
7623- }
7563+ ev_atril_window_emit_document_loaded (window -> priv -> skeleton , window -> priv -> uri );
76247564}
76257565
7626- static void
7627- method_call_cb (GDBusConnection * connection ,
7628- const gchar * sender ,
7629- const gchar * object_path ,
7630- const gchar * interface_name ,
7631- const gchar * method_name ,
7632- GVariant * parameters ,
7633- GDBusMethodInvocation * invocation ,
7634- gpointer user_data )
7566+ static gboolean
7567+ handle_sync_view_cb (EvAtrilWindow * object ,
7568+ GDBusMethodInvocation * invocation ,
7569+ const gchar * source_file ,
7570+ GVariant * source_point ,
7571+ guint timestamp ,
7572+ EvWindow * window )
76357573{
7636- EvWindow * window = EV_WINDOW (user_data );
7637- if (window -> priv -> document -> iswebdocument == TRUE ) return ;
7638-
7639- if (g_strcmp0 (method_name , "SyncView" ) != 0 )
7640- return ;
7641-
76427574 if (window -> priv -> document && ev_document_has_synctex (window -> priv -> document )) {
76437575 EvSourceLink link ;
7644- guint32 timestamp ;
7645-
7646- g_variant_get (parameters , "(&s(ii)u)" , & link .filename , & link .line , & link .col , & timestamp );
7576+ link .filename = (char * ) source_file ;
7577+ g_variant_get (source_point , "(ii)" , & link .line , & link .col );
76477578 ev_view_highlight_forward_search (EV_VIEW (window -> priv -> view ), & link );
76487579 gtk_window_present_with_time (GTK_WINDOW (window ), timestamp );
76497580 }
76507581
7651- g_dbus_method_invocation_return_value (invocation , g_variant_new ("()" ));
7652- }
7653-
7654- static const char introspection_xml [] =
7655- "<node>"
7656- "<interface name='org.mate.atril.Window'>"
7657- "<method name='SyncView'>"
7658- "<arg type='s' name='source_file' direction='in'/>"
7659- "<arg type='(ii)' name='source_point' direction='in'/>"
7660- "<arg type='u' name='timestamp' direction='in'/>"
7661- "</method>"
7662- "<signal name='SyncSource'>"
7663- "<arg type='s' name='source_file' direction='out'/>"
7664- "<arg type='(ii)' name='source_point' direction='out'/>"
7665- "<arg type='u' name='timestamp' direction='out'/>"
7666- "</signal>"
7667- "<signal name='Closed'/>"
7668- "<signal name='DocumentLoaded'>"
7669- "<arg type='s' name='uri' direction='out'/>"
7670- "</signal>"
7671- "</interface>"
7672- "</node>" ;
7673-
7674- static const GDBusInterfaceVTable interface_vtable = {
7675- method_call_cb ,
7676- NULL ,
7677- NULL
7678- };
7582+ ev_atril_window_complete_sync_view (object , invocation );
76797583
7680- static GDBusNodeInfo * introspection_data ;
7584+ return TRUE;
7585+ }
76817586#endif /* ENABLE_DBUS */
76827587
76837588static void
@@ -7706,30 +7611,31 @@ ev_window_init (EvWindow *ev_window)
77067611#ifdef ENABLE_DBUS
77077612 connection = ev_application_get_dbus_connection (EV_APP );
77087613 if (connection ) {
7709- if (!introspection_data ) {
7710- introspection_data = g_dbus_node_info_new_for_xml (introspection_xml , & error );
7711- if (error ) g_warning ("%s\n" , error -> message );
7712- }
7713- g_assert (introspection_data != NULL );
7714-
7715- ev_window -> priv -> dbus_object_path = g_strdup_printf (EV_WINDOW_DBUS_OBJECT_PATH , window_id ++ );
7716- ev_window -> priv -> dbus_object_id =
7717- g_dbus_connection_register_object (connection ,
7718- ev_window -> priv -> dbus_object_path ,
7719- introspection_data -> interfaces [0 ],
7720- & interface_vtable ,
7721- ev_window , NULL ,
7722- & error );
7723- if (ev_window -> priv -> dbus_object_id == 0 ) {
7614+ EvAtrilWindow * skeleton ;
7615+
7616+ ev_window -> priv -> dbus_object_path = g_strdup_printf (EV_WINDOW_DBUS_OBJECT_PATH , window_id ++ );
7617+
7618+ skeleton = ev_atril_window_skeleton_new ();
7619+ if (g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton ),
7620+ connection ,
7621+ ev_window -> priv -> dbus_object_path ,
7622+ & error )) {
7623+ ev_window -> priv -> skeleton = skeleton ;
7624+ g_signal_connect (skeleton , "handle-sync-view" ,
7625+ G_CALLBACK (handle_sync_view_cb ),
7626+ ev_window );
7627+ } else {
77247628 g_printerr ("Failed to register bus object %s: %s\n" ,
7725- ev_window -> priv -> dbus_object_path , error -> message );
7629+ ev_window -> priv -> dbus_object_path , error -> message );
77267630 g_error_free (error );
7727- g_free (ev_window -> priv -> dbus_object_path );
7728- ev_window -> priv -> dbus_object_path = NULL ;
7729- error = NULL ;
7631+ g_free (ev_window -> priv -> dbus_object_path );
7632+ ev_window -> priv -> dbus_object_path = NULL ;
7633+ error = NULL ;
7634+
7635+ g_object_unref (skeleton );
7636+ ev_window -> priv -> skeleton = NULL ;
77307637 }
77317638 }
7732-
77337639#endif /* ENABLE_DBUS */
77347640
77357641 ev_window -> priv -> model = ev_document_model_new ();
0 commit comments