X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fmain.c;h=3abe4cd2ea37ff7b542e5ab86824e8c575c10d56;hb=b4400b84fbb899a1984c8e145b91a09de3a35516;hp=41b8b18f8683f581ace859a1efa5e0b9455c8fe6;hpb=02ac7759d84d842837ef7c67c2f614576ef5b71c;p=evince.git diff --git a/shell/main.c b/shell/main.c index 41b8b18f..3abe4cd2 100644 --- a/shell/main.c +++ b/shell/main.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id$ */ #include "config.h" @@ -39,7 +38,6 @@ #endif #include "ev-stock-icons.h" -#include "ev-debug.h" #include "ev-job-queue.h" #include "ev-file-helpers.h" @@ -47,6 +45,7 @@ static gchar *ev_page_label; static gboolean preview_mode = FALSE; static gboolean fullscren_mode = FALSE; static gboolean presentation_mode = FALSE; +static gboolean unlink_temp_file = FALSE; static const char **file_arguments = NULL; static const GOptionEntry goption_options[] = @@ -55,6 +54,7 @@ static const GOptionEntry goption_options[] = { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscren_mode, N_("Run evince in fullscreen mode"), NULL }, { "presentation", 's', 0, G_OPTION_ARG_NONE, &presentation_mode, N_("Run evince in presentation mode"), NULL }, { "preview", 'w', 0, G_OPTION_ARG_NONE, &preview_mode, N_("Run evince as a previewer"), NULL }, + { "unlink-tempfile", 'u', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &unlink_temp_file, NULL, NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments, NULL, N_("[FILE...]") }, { NULL } }; @@ -72,11 +72,31 @@ arguments_parse (void) GHashTable *args; GValue *value; EvWindowRunMode mode; + GdkScreen *screen; + GdkDisplay *display; + const gchar *display_name; + gint screen_number; args = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)value_free); + + screen = gdk_screen_get_default (); + display = gdk_screen_get_display (screen); + + display_name = gdk_display_get_name (display); + screen_number = gdk_screen_get_number (screen); + + value = g_new0 (GValue, 1); + g_value_init (value, G_TYPE_STRING); + g_value_set_string (value, display_name); + g_hash_table_insert (args, g_strdup ("display"), value); + + value = g_new0 (GValue, 1); + g_value_init (value, G_TYPE_INT); + g_value_set_int (value, screen_number); + g_hash_table_insert (args, g_strdup ("screen"), value); if (ev_page_label) { value = g_new0 (GValue, 1); @@ -101,6 +121,16 @@ arguments_parse (void) g_hash_table_insert (args, g_strdup ("mode"), value); + if (mode == EV_WINDOW_MODE_PREVIEW && unlink_temp_file) { + value = g_new0 (GValue, 1); + g_value_init (value, G_TYPE_BOOLEAN); + g_value_set_boolean (value, unlink_temp_file); + + g_hash_table_insert (args, + g_strdup ("unlink-temp-file"), + value); + } + return args; } @@ -111,7 +141,7 @@ load_files (const char **files, int i; if (!files) { - ev_application_open_window (EV_APP, GDK_CURRENT_TIME, NULL); + ev_application_open_window (EV_APP, args, GDK_CURRENT_TIME, NULL); return; } @@ -150,7 +180,6 @@ load_files (const char **files, } #ifdef ENABLE_DBUS - static gboolean load_files_remote (const char **files, GHashTable *args) @@ -159,14 +188,11 @@ load_files_remote (const char **files, GError *error = NULL; DBusGConnection *connection; gboolean result = FALSE; -#if DBUS_VERSION < 35 - DBusGPendingCall *call; -#endif DBusGProxy *remote_object; GdkDisplay *display; guint32 timestamp; - display = gdk_display_get_default(); + display = gdk_display_get_default (); timestamp = gdk_x11_display_get_user_time (display); connection = dbus_g_bus_get (DBUS_BUS_STARTER, &error); @@ -182,32 +208,8 @@ load_files_remote (const char **files, "/org/gnome/evince/Evince", "org.gnome.evince.Application"); if (!files) { -#if DBUS_VERSION <= 33 - call = dbus_g_proxy_begin_call (remote_object, "OpenWindow", - DBUS_TYPE_UINT32, ×tamp, - DBUS_TYPE_INVALID); - - if (!dbus_g_proxy_end_call (remote_object, call, &error, DBUS_TYPE_INVALID)) { - g_warning (error->message); - g_clear_error (&error); - g_object_unref (remote_object); - dbus_g_connection_unref (connection); - return FALSE; - } -#elif DBUS_VERSION == 34 - call = dbus_g_proxy_begin_call (remote_object, "OpenWindow", - G_TYPE_UINT, timestamp, - G_TYPE_INVALID); - - if (!dbus_g_proxy_end_call (remote_object, call, &error, G_TYPE_INVALID)) { - g_warning (error->message); - g_clear_error (&error); - g_object_unref (remote_object); - dbus_g_connection_unref (connection); - return FALSE; - } -#else if (!dbus_g_proxy_call (remote_object, "OpenWindow", &error, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), args, G_TYPE_UINT, timestamp, G_TYPE_INVALID, G_TYPE_INVALID)) { @@ -217,7 +219,7 @@ load_files_remote (const char **files, dbus_g_connection_unref (connection); return FALSE; } -#endif + g_object_unref (remote_object); dbus_g_connection_unref (connection); @@ -230,33 +232,7 @@ load_files_remote (const char **files, uri = gnome_vfs_make_uri_from_shell_arg (files[i]); page_label = ev_page_label ? ev_page_label : ""; -#if DBUS_VERSION <= 33 - call = dbus_g_proxy_begin_call (remote_object, "OpenURI", - DBUS_TYPE_STRING, &uri, - DBUS_TYPE_STRING, &page_label, - DBUS_TYPE_UINT32, ×tamp, - DBUS_TYPE_INVALID); - - if (!dbus_g_proxy_end_call (remote_object, call, &error, DBUS_TYPE_INVALID)) { - g_warning (error->message); - g_clear_error (&error); - g_free (uri); - continue; - } -#elif DBUS_VERSION == 34 - call = dbus_g_proxy_begin_call (remote_object, "OpenURI", - G_TYPE_STRING, uri, - G_TYPE_STRING, page_label, - G_TYPE_UINT, timestamp, - G_TYPE_INVALID); - - if (!dbus_g_proxy_end_call (remote_object, call, &error, G_TYPE_INVALID)) { - g_warning (error->message); - g_clear_error (&error); - g_free (uri); - continue; - } -#else + if (!dbus_g_proxy_call (remote_object, "OpenURI", &error, G_TYPE_STRING, uri, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), args, @@ -268,7 +244,7 @@ load_files_remote (const char **files, g_free (uri); continue; } -#endif + g_free (uri); result = TRUE; } @@ -310,12 +286,12 @@ main (int argc, char *argv[]) NULL); args = arguments_parse (); - g_option_context_free (context); #ifdef ENABLE_DBUS if (!ev_application_register_service (EV_APP)) { if (load_files_remote (file_arguments, args)) { g_hash_table_destroy (args); + g_object_unref (program); return 0; } @@ -324,7 +300,6 @@ main (int argc, char *argv[]) } #endif - gdk_threads_init (); gnome_authentication_manager_init (); if (enable_metadata) { @@ -335,7 +310,6 @@ main (int argc, char *argv[]) g_set_application_name (_("Evince Document Viewer")); ev_file_helpers_init (); - ev_debug_init (); ev_stock_icons_init (); gtk_window_set_default_icon_name ("evince");