X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-application.c;h=5327825d5b705860832b4476571c13ccc8de07d8;hb=8c953cdc1375d46bd4fcc9341ec263b6b2eedad8;hp=49ffe0c91c17b57cace57d805b786a594911c45f;hpb=6936524259e0f4209a2ef61bde8570062c074dbf;p=evince.git diff --git a/shell/ev-application.c b/shell/ev-application.c index 49ffe0c9..5327825d 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -751,49 +751,66 @@ method_call_cb (GDBusConnection *connection, const gchar *search_string = NULL; GdkScreen *screen = NULL; - if (g_strcmp0 (method_name, "Reload") != 0) - return; + if (g_strcmp0 (method_name, "Reload") == 0) { + g_variant_get (parameters, "(a{sv}u)", &iter, ×tamp); + + while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) { + if (strcmp (key, "display") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { + display = ev_display_open_if_needed (g_variant_get_string (value, NULL)); + } else if (strcmp (key, "screen") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { + screen_number = g_variant_get_int32 (value); + } else if (strcmp (key, "mode") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_UINT32) { + mode = g_variant_get_uint32 (value); + } else if (strcmp (key, "page-label") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { + dest = ev_link_dest_new_page_label (g_variant_get_string (value, NULL)); + } else if (strcmp (key, "find-string") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { + search_string = g_variant_get_string (value, NULL); + } + } + g_variant_iter_free (iter); - g_variant_get (parameters, "(a{sv}u)", &iter, ×tamp); - - while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) { - if (strcmp (key, "display") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { - display = ev_display_open_if_needed (g_variant_get_string (value, NULL)); - } else if (strcmp (key, "screen") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { - screen_number = g_variant_get_int32 (value); - } else if (strcmp (key, "mode") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_UINT32) { - mode = g_variant_get_uint32 (value); - } else if (strcmp (key, "page-label") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { - dest = ev_link_dest_new_page_label (g_variant_get_string (value, NULL)); - } else if (strcmp (key, "find-string") == 0 && g_variant_classify (value) == G_VARIANT_CLASS_STRING) { - search_string = g_variant_get_string (value, NULL); - } - } - g_variant_iter_free (iter); - - if (display != NULL && - screen_number >= 0 && - screen_number < gdk_display_get_n_screens (display)) - screen = gdk_display_get_screen (display, screen_number); - else - screen = gdk_screen_get_default (); - - windows = ev_application_get_windows (application); - for (l = windows; l != NULL; l = g_list_next (l)) { - EvWindow *ev_window = EV_WINDOW (l->data); - - ev_application_open_uri_in_window (application, application->uri, - ev_window, - screen, dest, mode, - search_string, - timestamp); - } - g_list_free (windows); + if (display != NULL && + screen_number >= 0 && + screen_number < gdk_display_get_n_screens (display)) + screen = gdk_display_get_screen (display, screen_number); + else + screen = gdk_screen_get_default (); - if (dest) - g_object_unref (dest); + windows = ev_application_get_windows (application); + for (l = windows; l != NULL; l = g_list_next (l)) { + EvWindow *ev_window = EV_WINDOW (l->data); - g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + ev_application_open_uri_in_window (application, application->uri, + ev_window, + screen, dest, mode, + search_string, + timestamp); + } + g_list_free (windows); + + if (dest) + g_object_unref (dest); + + g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + } else if (g_strcmp0 (method_name, "GetWindowList") == 0) { + GList *windows = ev_application_get_windows (application); + GVariantBuilder builder; + GList *l; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("(ao)")); + g_variant_builder_open (&builder, G_VARIANT_TYPE ("ao")); + + for (l = windows; l; l = g_list_next (l)) { + EvWindow *window = (EvWindow *)l->data; + + g_variant_builder_add (&builder, "o", ev_window_get_dbus_object_path (window)); + } + + g_variant_builder_close (&builder); + g_list_free (windows); + + g_dbus_method_invocation_return_value (invocation, g_variant_builder_end (&builder)); + } } static const char introspection_xml[] = @@ -803,6 +820,9 @@ static const char introspection_xml[] = "" "" "" + "" + "" + "" "" ""; @@ -965,7 +985,7 @@ ev_application_init (EvApplication *ev_application) g_free (dir); } #else - ev_application->data_dir = g_strdup (DATADIR); + ev_application->data_dir = g_strdup (EVINCEDATADIR); #endif ev_application_init_session (ev_application); @@ -1016,10 +1036,35 @@ ev_application_get_dbus_connection (EvApplication *application) gboolean ev_application_has_window (EvApplication *application) { - GList *windows = ev_application_get_windows (application); - gboolean retval = windows != NULL; + GList *l, *toplevels; + gboolean retval = FALSE; - g_list_free (windows); + toplevels = gtk_window_list_toplevels (); + + for (l = toplevels; l != NULL && !retval; l = l->next) { + if (EV_IS_WINDOW (l->data)) + retval = TRUE; + } + + g_list_free (toplevels); + + return retval; +} + +guint +ev_application_get_n_windows (EvApplication *application) +{ + GList *l, *toplevels; + guint retval = 0; + + toplevels = gtk_window_list_toplevels (); + + for (l = toplevels; l != NULL; l = l->next) { + if (EV_IS_WINDOW (l->data)) + retval++; + } + + g_list_free (toplevels); return retval; }