150
value_free (GValue *value)
152
g_value_unset (value);
159
* Parses the arguments and creates a #GHashTable with this data.
163
* dislay -> display at the default screen.
164
* screen -> screen number.
165
* page-label -> only if the page label argument has been passed,
166
* the page of the document to display.
167
* mode -> only if the view mode is one of the availables,
170
* Returns: a pointer into #GHashTable with data from the arguments.
173
arguments_parse (void)
177
EvWindowRunMode mode;
180
const gchar *display_name;
183
args = g_hash_table_new_full (g_str_hash,
185
(GDestroyNotify)g_free,
186
(GDestroyNotify)value_free);
188
screen = gdk_screen_get_default ();
189
display = gdk_screen_get_display (screen);
191
display_name = gdk_display_get_name (display);
192
screen_number = gdk_screen_get_number (screen);
194
value = g_new0 (GValue, 1);
195
g_value_init (value, G_TYPE_STRING);
196
g_value_set_string (value, display_name);
197
g_hash_table_insert (args, g_strdup ("display"), value);
199
value = g_new0 (GValue, 1);
200
g_value_init (value, G_TYPE_INT);
201
g_value_set_int (value, screen_number);
202
g_hash_table_insert (args, g_strdup ("screen"), value);
205
value = g_new0 (GValue, 1);
206
g_value_init (value, G_TYPE_STRING);
207
g_value_set_string (value, ev_page_label);
209
g_hash_table_insert (args, g_strdup ("page-label"), value);
211
g_free (ev_page_label);
212
ev_page_label = NULL;
215
if (ev_find_string) {
216
value = g_new0 (GValue, 1);
217
g_value_init (value, G_TYPE_STRING);
218
g_value_set_string (value, ev_find_string);
220
g_hash_table_insert (args, g_strdup ("find-string"), value);
222
g_free (ev_find_string);
223
ev_page_label = NULL;
145
load_files (const char **files)
147
GdkScreen *screen = gdk_screen_get_default ();
148
EvWindowRunMode mode = EV_WINDOW_MODE_NORMAL;
150
EvLinkDest *global_dest = NULL;
153
if (!ev_application_has_window (EV_APP))
154
ev_application_open_window (EV_APP, screen, GDK_CURRENT_TIME);
159
global_dest = ev_link_dest_new_page_label (ev_page_label);
226
161
if (fullscreen_mode)
227
162
mode = EV_WINDOW_MODE_FULLSCREEN;
228
163
else if (presentation_mode)
229
164
mode = EV_WINDOW_MODE_PRESENTATION;
233
value = g_new0 (GValue, 1);
234
g_value_init (value, G_TYPE_UINT);
235
g_value_set_uint (value, mode);
237
g_hash_table_insert (args, g_strdup ("mode"), value);
243
find_window_list (EvWindow *window,
246
return g_ascii_strcasecmp (uri, ev_window_get_uri (window));
250
load_files (const char **files,
256
windows = ev_application_get_windows (EV_APP);
260
ev_application_open_window (EV_APP, args, GDK_CURRENT_TIME, NULL);
262
g_list_free (windows);
266
166
for (i = 0; files[i]; i++) {
170
EvLinkDest *dest = NULL;
171
const gchar *app_uri;
272
173
file = g_file_new_for_commandline_arg (files[i]);
273
174
uri = g_file_get_uri (file);
274
175
g_object_unref (file);
276
if (g_list_find_custom (windows, uri, (GCompareFunc) find_window_list)) {
177
app_uri = ev_application_get_uri (EV_APP);
178
if (app_uri && strcmp (app_uri, uri) == 0) {
281
183
label = strchr (uri, '#');
288
old = g_hash_table_lookup (args, "page-label");
290
new = g_new0 (GValue, 1);
291
g_value_init (new, G_TYPE_STRING);
292
g_value_set_string (new, label);
294
g_hash_table_insert (args, g_strdup ("page-label"), new);
298
ev_application_open_uri (EV_APP, uri, args,
299
GDK_CURRENT_TIME, NULL);
302
g_hash_table_insert (args, g_strdup ("page-label"), old);
307
g_list_free (windows);
312
load_files_remote (const char **files,
316
GError *error = NULL;
317
DBusGConnection *connection;
318
gboolean result = FALSE;
319
DBusGProxy *remote_object;
323
display = gdk_display_get_default ();
324
timestamp = gdk_x11_display_get_user_time (display);
325
connection = dbus_g_bus_get (DBUS_BUS_STARTER, &error);
327
if (connection == NULL) {
328
g_warning ("%s", error->message);
329
g_error_free (error);
334
remote_object = dbus_g_proxy_new_for_name (connection,
335
"org.gnome.evince.ApplicationService",
336
"/org/gnome/evince/Evince",
337
"org.gnome.evince.Application");
339
if (!dbus_g_proxy_call (remote_object, "OpenWindow", &error,
340
dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), args,
341
G_TYPE_UINT, timestamp,
344
g_warning ("%s", error->message);
345
g_clear_error (&error);
346
g_object_unref (remote_object);
347
dbus_g_connection_unref (connection);
351
g_object_unref (remote_object);
352
dbus_g_connection_unref (connection);
357
for (i = 0; files[i]; i++) {
358
const char *page_label;
362
file = g_file_new_for_commandline_arg (files[i]);
363
uri = g_file_get_uri (file);
364
g_object_unref (file);
366
page_label = ev_page_label ? ev_page_label : "";
368
if (!dbus_g_proxy_call (remote_object, "OpenURI", &error,
370
dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), args,
371
G_TYPE_UINT, timestamp,
374
g_warning ("%s", error->message);
375
g_clear_error (&error);
384
g_object_unref (remote_object);
385
dbus_g_connection_unref (connection);
387
gdk_notify_startup_complete ();
391
#endif /* ENABLE_DBUS */
187
dest = ev_link_dest_new_page_label (label);
188
} else if (global_dest) {
189
dest = g_object_ref (global_dest);
192
ev_application_open_uri_at_dest (EV_APP, uri, screen, dest,
193
mode, ev_find_string,
197
g_object_unref (dest);
394
203
main (int argc, char *argv[])
396
205
GOptionContext *context;
398
GError *error = NULL;
206
GError *error = NULL;
400
208
#ifdef G_OS_WIN32