summaryrefslogtreecommitdiff
path: root/shell/ev-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r--shell/ev-window.c202
1 files changed, 54 insertions, 148 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index a3387df0..16685012 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -99,6 +99,7 @@
#include "ev-bookmark-action.h"
#ifdef ENABLE_DBUS
+#include "ev-gdbus-generated.h"
#include "ev-media-player-keys.h"
#endif /* ENABLE_DBUS */
@@ -225,8 +226,8 @@ struct _EvWindowPrivate {
GSettings *lockdown_settings;
#ifdef ENABLE_DBUS
/* DBus */
- guint dbus_object_id;
- gchar *dbus_object_path;
+ EvAtrilWindow *skeleton;
+ gchar *dbus_object_path;
#endif
/* Caret navigation */
@@ -5970,16 +5971,13 @@ ev_window_dispose (GObject *object)
}
#ifdef ENABLE_DBUS
- if (priv->dbus_object_id > 0) {
- ev_window_emit_closed (window);
- g_dbus_connection_unregister_object (ev_application_get_dbus_connection (EV_APP),
- priv->dbus_object_id);
- priv->dbus_object_id = 0;
- }
-
- if (priv->dbus_object_path) {
- g_free (priv->dbus_object_path);
- priv->dbus_object_path = NULL;
+ if (priv->skeleton != NULL) {
+ ev_window_emit_closed (window);
+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (priv->skeleton));
+ g_object_unref (priv->skeleton);
+ priv->skeleton = NULL;
+ g_free (priv->dbus_object_path);
+ priv->dbus_object_path = NULL;
}
#endif /* ENABLE_DBUS */
@@ -7504,17 +7502,11 @@ static void
ev_window_sync_source (EvWindow *window,
EvSourceLink *link)
{
- GDBusConnection *connection;
- GError *error = NULL;
guint32 timestamp;
gchar *uri_input;
GFile *input_gfile;
- if (window->priv->dbus_object_id <= 0)
- return;
-
- connection = ev_application_get_dbus_connection (EV_APP);
- if (!connection)
+ if (window->priv->skeleton == NULL)
return;
timestamp = gtk_get_current_event_time ();
@@ -7540,144 +7532,57 @@ ev_window_sync_source (EvWindow *window,
uri_input = g_file_get_uri (input_gfile);
g_object_unref (input_gfile);
- g_dbus_connection_emit_signal (connection,
- NULL,
- window->priv->dbus_object_path,
- EV_WINDOW_DBUS_INTERFACE,
- "SyncSource",
- g_variant_new ("(s(ii)u)",
- uri_input,
- link->line,
- link->col,
- timestamp),
- &error);
+ ev_atril_window_emit_sync_source (window->priv->skeleton,
+ uri_input,
+ g_variant_new ("(ii)", link->line, link->col),
+ timestamp);
g_free (uri_input);
- if (error) {
- g_printerr ("Failed to emit DBus signal SyncSource: %s\n",
- error->message);
- g_error_free (error);
- }
}
static void
ev_window_emit_closed (EvWindow *window)
{
- GDBusConnection *connection;
- GError *error = NULL;
-
- if (window->priv->dbus_object_id <= 0)
- return;
-
- connection = ev_application_get_dbus_connection (EV_APP);
- if (!connection)
+ if (window->priv->skeleton == NULL)
return;
- g_dbus_connection_emit_signal (connection,
- NULL,
- window->priv->dbus_object_path,
- EV_WINDOW_DBUS_INTERFACE,
- "Closed",
- NULL,
- &error);
- if (error) {
- g_printerr ("Failed to emit DBus signal Closed: %s\n",
- error->message);
- g_error_free (error);
-
- return;
- }
+ ev_atril_window_emit_closed (window->priv->skeleton);
/* If this is the last window call g_dbus_connection_flush_sync()
* to make sure the signal is emitted.
*/
if (ev_application_get_n_windows (EV_APP) == 1)
- g_dbus_connection_flush_sync (connection, NULL, NULL);
+ g_dbus_connection_flush_sync (ev_application_get_dbus_connection (EV_APP), NULL, NULL);
}
static void
ev_window_emit_doc_loaded (EvWindow *window)
{
- GDBusConnection *connection;
- GError *error = NULL;
-
- if (window->priv->dbus_object_id <= 0)
- return;
-
- connection = ev_application_get_dbus_connection (EV_APP);
- if (!connection)
- return;
-
- g_dbus_connection_emit_signal (connection,
- NULL,
- window->priv->dbus_object_path,
- EV_WINDOW_DBUS_INTERFACE,
- "DocumentLoaded",
- g_variant_new("(s)", window->priv->uri),
- &error);
- if (error) {
- g_printerr ("Failed to emit DBus signal DocumentLoaded: %s\n",
- error->message);
- g_error_free (error);
+ if (window->priv->skeleton == NULL)
+ return;
- return;
- }
+ ev_atril_window_emit_document_loaded (window->priv->skeleton, window->priv->uri);
}
-static void
-method_call_cb (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
+static gboolean
+handle_sync_view_cb (EvAtrilWindow *object,
+ GDBusMethodInvocation *invocation,
+ const gchar *source_file,
+ GVariant *source_point,
+ guint timestamp,
+ EvWindow *window)
{
- EvWindow *window = EV_WINDOW (user_data);
- if (window->priv->document->iswebdocument == TRUE ) return;
-
- if (g_strcmp0 (method_name, "SyncView") != 0)
- return;
-
if (window->priv->document && ev_document_has_synctex (window->priv->document)) {
EvSourceLink link;
- guint32 timestamp;
-
- g_variant_get (parameters, "(&s(ii)u)", &link.filename, &link.line, &link.col, &timestamp);
+ link.filename = (char *) source_file;
+ g_variant_get (source_point, "(ii)", &link.line, &link.col);
ev_view_highlight_forward_search (EV_VIEW (window->priv->view), &link);
gtk_window_present_with_time (GTK_WINDOW (window), timestamp);
}
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
-}
-
-static const char introspection_xml[] =
- "<node>"
- "<interface name='org.mate.atril.Window'>"
- "<method name='SyncView'>"
- "<arg type='s' name='source_file' direction='in'/>"
- "<arg type='(ii)' name='source_point' direction='in'/>"
- "<arg type='u' name='timestamp' direction='in'/>"
- "</method>"
- "<signal name='SyncSource'>"
- "<arg type='s' name='source_file' direction='out'/>"
- "<arg type='(ii)' name='source_point' direction='out'/>"
- "<arg type='u' name='timestamp' direction='out'/>"
- "</signal>"
- "<signal name='Closed'/>"
- "<signal name='DocumentLoaded'>"
- "<arg type='s' name='uri' direction='out'/>"
- "</signal>"
- "</interface>"
- "</node>";
-
-static const GDBusInterfaceVTable interface_vtable = {
- method_call_cb,
- NULL,
- NULL
-};
+ ev_atril_window_complete_sync_view (object, invocation);
-static GDBusNodeInfo *introspection_data;
+ return TRUE;
+}
#endif /* ENABLE_DBUS */
static void
@@ -7706,30 +7611,31 @@ ev_window_init (EvWindow *ev_window)
#ifdef ENABLE_DBUS
connection = ev_application_get_dbus_connection (EV_APP);
if (connection) {
- if (!introspection_data) {
- introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, &error);
- if (error) g_warning ("%s\n", error->message);
- }
- g_assert (introspection_data != NULL);
-
- ev_window->priv->dbus_object_path = g_strdup_printf (EV_WINDOW_DBUS_OBJECT_PATH, window_id++);
- ev_window->priv->dbus_object_id =
- g_dbus_connection_register_object (connection,
- ev_window->priv->dbus_object_path,
- introspection_data->interfaces[0],
- &interface_vtable,
- ev_window, NULL,
- &error);
- if (ev_window->priv->dbus_object_id == 0) {
+ EvAtrilWindow *skeleton;
+
+ ev_window->priv->dbus_object_path = g_strdup_printf (EV_WINDOW_DBUS_OBJECT_PATH, window_id++);
+
+ skeleton = ev_atril_window_skeleton_new ();
+ if (g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton),
+ connection,
+ ev_window->priv->dbus_object_path,
+ &error)) {
+ ev_window->priv->skeleton = skeleton;
+ g_signal_connect (skeleton, "handle-sync-view",
+ G_CALLBACK (handle_sync_view_cb),
+ ev_window);
+ } else {
g_printerr ("Failed to register bus object %s: %s\n",
- ev_window->priv->dbus_object_path, error->message);
+ ev_window->priv->dbus_object_path, error->message);
g_error_free (error);
- g_free (ev_window->priv->dbus_object_path);
- ev_window->priv->dbus_object_path = NULL;
- error = NULL;
+ g_free (ev_window->priv->dbus_object_path);
+ ev_window->priv->dbus_object_path = NULL;
+ error = NULL;
+
+ g_object_unref (skeleton);
+ ev_window->priv->skeleton = NULL;
}
}
-
#endif /* ENABLE_DBUS */
ev_window->priv->model = ev_document_model_new ();