]> www.fi.muni.cz Git - evince.git/blob - shell/ev-application.c
Add app-specific icons to our icon theme. Fixes bug #425508.
[evince.git] / shell / ev-application.c
1 /* this file is part of evince, a gnome document viewer
2  *
3  *  Copyright (C) 2004 Martin Kretzschmar
4  *
5  *  Author:
6  *    Martin Kretzschmar <martink@gnome.org>
7  *
8  * Evince is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Evince is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21  */
22
23 #include "ev-application.h"
24 #include "ev-utils.h"
25 #include "ev-file-helpers.h"
26 #include "ev-document-factory.h"
27 #include "totem-scrsaver.h"
28
29 #include <glib.h>
30 #include <glib/gi18n.h>
31 #include <glib-object.h>
32 #include <gtk/gtkfilechooserdialog.h>
33 #include <gtk/gtkstock.h>
34 #include <gtk/gtkwidget.h>
35 #include <gtk/gtkmain.h>
36
37 #if WITH_GNOME
38 #include <libgnomeui/gnome-client.h>
39 #endif
40
41 #ifdef ENABLE_DBUS
42 #include "ev-application-service.h"
43 #include <dbus/dbus-glib-bindings.h>
44 #endif
45
46 #include <string.h>
47
48 static void ev_application_add_icon_path_for_screen (GdkScreen *screen);
49
50 struct _EvApplication {
51         GObject base_instance;
52
53         gchar *toolbars_file;
54
55         EggToolbarsModel *toolbars_model;
56
57 #ifndef HAVE_GTK_RECENT
58         EggRecentModel  *recent_model;
59 #endif
60
61         TotemScrsaver *scr_saver;
62
63         gchar *last_chooser_uri;
64
65 #ifdef WITH_GTK_PRINT
66         GtkPrintSettings *print_settings;
67 #if GTK_CHECK_VERSION (2, 11, 0)
68         gchar            *print_settings_file;
69 #endif
70 #endif
71 };
72
73 struct _EvApplicationClass {
74         GObjectClass base_class;
75 };
76
77 G_DEFINE_TYPE (EvApplication, ev_application, G_TYPE_OBJECT);
78
79 #define APPLICATION_SERVICE_NAME "org.gnome.evince.ApplicationService"
80
81 #ifdef ENABLE_DBUS
82 gboolean
83 ev_application_register_service (EvApplication *application)
84 {
85         static DBusGConnection *connection = NULL;
86         DBusGProxy *driver_proxy;
87         GError *err = NULL;
88         guint request_name_result;
89
90         if (connection) {
91                 g_warning ("Service already registered.");
92                 return FALSE;
93         }
94         
95         connection = dbus_g_bus_get (DBUS_BUS_STARTER, &err);
96         if (connection == NULL) {
97                 g_warning ("Service registration failed.");
98                 g_error_free (err);
99
100                 return FALSE;
101         }
102
103         driver_proxy = dbus_g_proxy_new_for_name (connection,
104                                                   DBUS_SERVICE_DBUS,
105                                                   DBUS_PATH_DBUS,
106                                                   DBUS_INTERFACE_DBUS);
107
108         if (!org_freedesktop_DBus_request_name (driver_proxy,
109                                                 APPLICATION_SERVICE_NAME,
110                                                 DBUS_NAME_FLAG_DO_NOT_QUEUE,
111                                                 &request_name_result, &err)) {
112                 g_warning ("Service registration failed.");
113                 g_clear_error (&err);
114         }
115
116         g_object_unref (driver_proxy);
117         
118         if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) {
119                 return FALSE;
120         }
121
122         dbus_g_object_type_install_info (EV_TYPE_APPLICATION,
123                                          &dbus_glib_ev_application_object_info);
124         dbus_g_connection_register_g_object (connection,
125                                              "/org/gnome/evince/Evince",
126                                              G_OBJECT (application));
127         
128         application->scr_saver = totem_scrsaver_new (connection);
129         
130         return TRUE;
131 }
132 #endif /* ENABLE_DBUS */
133
134 /**
135  * ev_application_get_instance:
136  *
137  * Checks for #EvApplication instance, if it doesn't exist it does create it.
138  *
139  * Returns: an instance of the #EvApplication data.
140  */
141 EvApplication *
142 ev_application_get_instance (void)
143 {
144         static EvApplication *instance;
145
146         if (!instance) {
147                 instance = EV_APPLICATION (g_object_new (EV_TYPE_APPLICATION, NULL));
148         }
149
150         return instance;
151 }
152
153 #if WITH_GNOME
154 static void
155 removed_from_session (GnomeClient *client, EvApplication *application)
156 {
157         ev_application_shutdown (application);
158 }
159
160 static gint
161 save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_style, gint shutdown,
162               GnomeInteractStyle interact_style, gint fast, EvApplication *application)
163 {
164         GList *windows, *l;
165         char **restart_argv;
166         int argc = 0, k;
167
168         windows = ev_application_get_windows (application);
169         restart_argv = g_new (char *, g_list_length (windows) + 1);
170         restart_argv[argc++] = g_strdup ("evince");
171
172         for (l = windows; l != NULL; l = l->next) {
173                 EvWindow *window = EV_WINDOW (l->data);
174                 restart_argv[argc++] = g_strdup (ev_window_get_uri (window));
175         }
176
177         gnome_client_set_restart_command (client, argc, restart_argv);
178
179         for (k = 0; k < argc; k++) {
180                 g_free (restart_argv[k]);
181         }
182
183         g_list_free (windows);
184         g_free (restart_argv);
185         
186         return TRUE;
187 }
188
189 static void
190 init_session (EvApplication *application)
191 {
192         GnomeClient *client;
193
194         client = gnome_master_client ();
195
196         g_signal_connect (client, "save_yourself",
197                           G_CALLBACK (save_session), application);      
198         g_signal_connect (client, "die",
199                           G_CALLBACK (removed_from_session), application);
200 }
201 #endif
202
203 /**
204  * ev_display_open_if_needed:
205  * @name: the name of the display to be open if it's needed.
206  *
207  * Search among all the open displays if any of them have the same name as the
208  * passed name. If the display isn't found it tries the open it.
209  *
210  * Returns: a #GdkDisplay of the display with the passed name.
211  */
212 static GdkDisplay *
213 ev_display_open_if_needed (const gchar *name)
214 {
215         GSList     *displays;
216         GSList     *l;
217         GdkDisplay *display = NULL;
218
219         displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
220
221         for (l = displays; l != NULL; l = l->next) {
222                 const gchar *display_name = gdk_display_get_name ((GdkDisplay *) l->data);
223
224                 if (g_ascii_strcasecmp (display_name, name) == 0) {
225                         display = l->data;
226                         break;
227                 }
228         }
229
230         g_slist_free (displays);
231
232         return display != NULL ? display : gdk_display_open (name);
233 }
234
235 /**
236  * get_screen_from_args:
237  * @args: a #GHashTable with data passed to the application.
238  *
239  * Looks for the screen in the display available in the hash table passed to the
240  * application. If the display isn't opened, it's opened and the #GdkScreen
241  * assigned to the screen in that display returned.
242  *
243  * Returns: the #GdkScreen assigned to the screen on the display indicated by
244  *          the data on the #GHashTable.
245  */
246 static GdkScreen *
247 get_screen_from_args (GHashTable *args)
248 {
249         GValue     *value = NULL;
250         GdkDisplay *display = NULL;
251         GdkScreen  *screen = NULL;
252
253         g_assert (args != NULL);
254         
255         value = g_hash_table_lookup (args, "display");
256         if (value) {
257                 const gchar *display_name;
258                 
259                 display_name = g_value_get_string (value);
260                 display = ev_display_open_if_needed (display_name);
261         }
262         
263         value = g_hash_table_lookup (args, "screen");
264         if (value) {
265                 gint screen_number;
266                 
267                 screen_number = g_value_get_int (value);
268                 screen = gdk_display_get_screen (display, screen_number);
269         }
270
271         return screen;
272 }
273
274 /**
275  * get_window_run_mode_from_args:
276  * @args: a #GHashTable with data passed to the application.
277  *
278  * It does look if the mode option has been passed from command line, using it
279  * as the window run mode, otherwise the run mode will be the normal mode.
280  *
281  * Returns: The window run mode passed from command line or
282  *          EV_WINDOW_MODE_NORMAL in other case.
283  */
284 static EvWindowRunMode
285 get_window_run_mode_from_args (GHashTable *args)
286 {
287         EvWindowRunMode  mode = EV_WINDOW_MODE_NORMAL;
288         GValue          *value = NULL;
289
290         g_assert (args != NULL);
291
292         value = g_hash_table_lookup (args, "mode");
293         if (value) {
294                 mode = g_value_get_uint (value);
295         }
296
297         return mode;
298 }
299
300 /**
301  * get_destination_from_args:
302  * @args: a #GHashTable with data passed to the application.
303  *
304  * It does look for the page-label argument parsed from the command line and
305  * if it does exist, it returns an #EvLinkDest.
306  *
307  * Returns: An #EvLinkDest to page-label if it has been passed from the command
308  *          line, NULL in other case.
309  */
310 static EvLinkDest *
311 get_destination_from_args (GHashTable *args)
312 {
313         EvLinkDest *dest = NULL;
314         GValue     *value = NULL;
315         
316         g_assert (args != NULL);
317         
318         value = g_hash_table_lookup (args, "page-label");
319         if (value) {
320                 const gchar *page_label;
321
322                 page_label = g_value_get_string (value);
323                 dest = ev_link_dest_new_page_label (page_label);
324         }
325
326         return dest;
327 }
328
329 /**
330  * get_unlink_temp_file_from_args:
331  * @args: a #GHashTable with data passed to the application.
332  *
333  * It does look if the unlink-temp-file option has been passed from the command
334  * line returning it's boolean representation, otherwise it does return %FALSE.
335  *
336  * Returns: the boolean representation of the unlink-temp-file value or %FALSE
337  *          in other case.
338  */
339 static gboolean
340 get_unlink_temp_file_from_args (GHashTable *args)
341 {
342         gboolean unlink_temp_file = FALSE;
343         GValue  *value = NULL;
344
345         g_assert (args != NULL);
346
347         value = g_hash_table_lookup (args, "unlink-temp-file");
348         if (value) {
349                 unlink_temp_file = g_value_get_boolean (value);
350         }
351         
352         return unlink_temp_file;
353 }
354
355 /**
356  * ev_application_open_window:
357  * @application: The instance of the application.
358  * @args: A #GHashTable with the arguments data.
359  * @timestamp: Current time value.
360  * @error: The #GError facility.
361  * 
362  * Creates a new window and if the args are available, it's not NULL, it gets
363  * the screen from them and assigns the just created window to it. At last it
364  * does show it.
365  *
366  * Returns: %TRUE.
367  */
368 gboolean
369 ev_application_open_window (EvApplication  *application,
370                             GHashTable     *args,
371                             guint32         timestamp,
372                             GError        **error)
373 {
374         GtkWidget *new_window = ev_window_new ();
375         GdkScreen *screen = NULL;
376
377         if (args) {
378                 screen = get_screen_from_args (args);
379         }
380         
381         if (screen) {
382                 gtk_window_set_screen (GTK_WINDOW (new_window), screen);
383         }
384         ev_application_add_icon_path_for_screen (screen);
385         
386         gtk_widget_show (new_window);
387         
388         gtk_window_present_with_time (GTK_WINDOW (new_window),
389                                       timestamp);
390         return TRUE;
391 }
392
393 /**
394  * ev_application_get_empty_window:
395  * @application: The instance of the application.
396  * @screen: The screen where the empty window will be search.
397  *
398  * It does look if there is any empty window in the indicated screen.
399  *
400  * Returns: The first empty #EvWindow in the passed #GdkScreen or NULL in other
401  *          case.
402  */
403 static EvWindow *
404 ev_application_get_empty_window (EvApplication *application,
405                                  GdkScreen     *screen)
406 {
407         EvWindow *empty_window = NULL;
408         GList *windows = ev_application_get_windows (application);
409         GList *l;
410
411         for (l = windows; l != NULL; l = l->next) {
412                 EvWindow *window = EV_WINDOW (l->data);
413
414                 if (ev_window_is_empty (window) &&
415                     gtk_window_get_screen (GTK_WINDOW (window)) == screen) {
416                         empty_window = window;
417                         break;
418                 }
419         }
420
421         g_list_free (windows);
422         
423         return empty_window;
424 }
425
426 /**
427  * ev_application_get_uri_window:
428  * @application: The instance of the application.
429  * @uri: The uri to be opened.
430  *
431  * It looks in the list of the windows for the one with the document represented
432  * by the passed uri on it. If the window is empty or the document isn't present
433  * on any window, it will return NULL.
434  *
435  * Returns: The #EvWindow where the document represented by the passed uri is
436  *          shown, NULL in other case.
437  */
438 static EvWindow *
439 ev_application_get_uri_window (EvApplication *application, const char *uri)
440 {
441         EvWindow *uri_window = NULL;
442         GList *windows = gtk_window_list_toplevels ();
443         GList *l;
444
445         g_return_val_if_fail (uri != NULL, NULL);
446
447         for (l = windows; l != NULL; l = l->next) {
448                 if (EV_IS_WINDOW (l->data)) {
449                         EvWindow *window = EV_WINDOW (l->data);
450                         const char *window_uri = ev_window_get_uri (window);
451
452                         if (window_uri && strcmp (window_uri, uri) == 0 && !ev_window_is_empty (window)) {
453                                 uri_window = window;
454                                 break;
455                         }
456                 }
457         }
458
459         g_list_free (windows);
460         
461         return uri_window;
462 }
463
464 static void
465 ev_application_add_icon_path_for_screen (GdkScreen *screen)
466 {
467         GtkIconTheme *icon_theme;
468
469         icon_theme = gtk_icon_theme_get_for_screen (screen);
470         if (icon_theme) {
471                 gchar **path = NULL;
472                 gint    n_paths;
473                 gint    i;
474                 gchar  *ev_icons_path;
475
476                 /* GtkIconTheme will then look in Evince custom hicolor dir
477                  * for icons as well as the standard search paths
478                  */
479                 ev_icons_path = g_build_filename (DATADIR, "icons", NULL);
480                 gtk_icon_theme_get_search_path (icon_theme, &path, &n_paths);
481                 for (i = n_paths - 1; i >= 0; i--) {
482                         if (g_ascii_strcasecmp (ev_icons_path, path[i]) == 0)
483                                 break;
484                 }
485
486                 if (i < 0)
487                         gtk_icon_theme_append_search_path (icon_theme,
488                                                            ev_icons_path);
489
490                 g_free (ev_icons_path);
491                 g_strfreev (path);
492         }       
493 }
494
495 /**
496  * ev_application_open_uri_at_dest:
497  * @application: The instance of the application.
498  * @uri: The uri to be opened.
499  * @screen: Thee screen where the link will be shown.
500  * @dest: The #EvLinkDest of the document.
501  * @mode: The run mode of the window.
502  * @unlink_temp_file: The unlink_temp_file option value.
503  * @timestamp: Current time value.
504  */
505 void
506 ev_application_open_uri_at_dest (EvApplication  *application,
507                                  const char     *uri,
508                                  GdkScreen      *screen,
509                                  EvLinkDest     *dest,
510                                  EvWindowRunMode mode,
511                                  gboolean        unlink_temp_file,
512                                  guint           timestamp)
513 {
514         EvWindow     *new_window;
515
516         g_return_if_fail (uri != NULL);
517         
518         ev_application_add_icon_path_for_screen (screen);
519
520         new_window = ev_application_get_uri_window (application, uri);
521         
522         if (new_window == NULL) {
523                 new_window = ev_application_get_empty_window (application, screen);
524         }
525
526         if (new_window == NULL) {
527                 new_window = EV_WINDOW (ev_window_new ());
528         }
529
530         if (screen)
531                 gtk_window_set_screen (GTK_WINDOW (new_window), screen);
532
533         /* We need to load uri before showing the window, so
534            we can restore window size without flickering */     
535         ev_window_open_uri (new_window, uri, dest, mode, unlink_temp_file);
536
537         ev_document_fc_mutex_lock ();
538         gtk_widget_show (GTK_WIDGET (new_window));
539         ev_document_fc_mutex_unlock ();
540
541         gtk_window_present_with_time (GTK_WINDOW (new_window),
542                                       timestamp);
543 }
544
545 /**
546  * ev_application_open_uri:
547  * @application: The instance of the application.
548  * @uri: The uri to be opened
549  * @args: A #GHashTable with the arguments data.
550  * @timestamp: Current time value.
551  * @error: The #GError facility.
552  */
553 gboolean
554 ev_application_open_uri (EvApplication  *application,
555                          const char     *uri,
556                          GHashTable     *args,
557                          guint           timestamp,
558                          GError        **error)
559 {
560         EvLinkDest      *dest = NULL;
561         EvWindowRunMode  mode = EV_WINDOW_MODE_NORMAL;
562         gboolean         unlink_temp_file = FALSE;
563         GdkScreen       *screen = NULL;
564
565         if (args) {
566                 screen = get_screen_from_args (args);
567                 dest = get_destination_from_args (args);
568                 mode = get_window_run_mode_from_args (args);
569                 unlink_temp_file = (mode == EV_WINDOW_MODE_PREVIEW &&
570                                     get_unlink_temp_file_from_args (args));
571         }
572         
573         ev_application_open_uri_at_dest (application, uri, screen,
574                                          dest, mode, unlink_temp_file, 
575                                          timestamp);
576
577         if (dest)
578                 g_object_unref (dest);
579
580         return TRUE;
581 }
582
583 void
584 ev_application_open_uri_list (EvApplication *application,
585                               GSList        *uri_list,
586                               GdkScreen     *screen,
587                               guint          timestamp)
588 {
589         GSList *l;
590
591         for (l = uri_list; l != NULL; l = l->next) {
592                 ev_application_open_uri_at_dest (application, (char *)l->data,
593                                                  screen, NULL, 0, FALSE, 
594                                                  timestamp);
595         }
596 }
597
598 void
599 ev_application_shutdown (EvApplication *application)
600 {
601         if (application->toolbars_model) {
602                 g_object_unref (application->toolbars_model);
603                 g_free (application->toolbars_file);
604                 application->toolbars_model = NULL;
605                 application->toolbars_file = NULL;
606         }
607
608 #ifndef HAVE_GTK_RECENT
609         if (application->recent_model) {
610                 g_object_unref (application->recent_model);
611                 application->recent_model = NULL;
612         }
613 #endif
614
615 #ifdef WITH_GTK_PRINT
616 #if GTK_CHECK_VERSION (2, 11, 0)
617         if (application->print_settings_file) {
618                 if (application->print_settings) {
619                         GError *error = NULL;
620                         
621                         gtk_print_settings_to_file (application->print_settings,
622                                                     application->print_settings_file,
623                                                     &error);
624                         if (error) {
625                                 g_warning (error->message);
626                                 g_error_free (error);
627                         }
628
629                         g_object_unref (application->print_settings);
630                         application->print_settings = NULL;
631                 }
632
633                 g_free (application->print_settings_file);
634                 application->print_settings_file = NULL;
635         }
636 #else /* ! GTK 2.11.0 */
637         if (application->print_settings) {
638                 g_object_unref (application->print_settings);
639                 application->print_settings = NULL;
640         }
641 #endif /* GTK 2.11.0 */
642 #endif /* WITH_GTK_PRINT */
643         
644         g_free (application->last_chooser_uri);
645         g_object_unref (application);
646         
647         gtk_main_quit ();
648 }
649
650 static void
651 ev_application_class_init (EvApplicationClass *ev_application_class)
652 {
653 }
654
655 static void
656 ev_application_init (EvApplication *ev_application)
657 {
658 #if WITH_GNOME
659         init_session (ev_application);
660 #endif
661
662         ev_application->toolbars_model = egg_toolbars_model_new ();
663
664         ev_application->toolbars_file = g_build_filename
665                         (ev_dot_dir (), "evince_toolbar.xml", NULL);
666
667         egg_toolbars_model_load_names (ev_application->toolbars_model,
668                                        DATADIR "/evince-toolbar.xml");
669
670         if (!egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
671                                                ev_application->toolbars_file)) {
672                 egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
673                                                   DATADIR"/evince-toolbar.xml");
674         }
675
676         egg_toolbars_model_set_flags (ev_application->toolbars_model, 0,
677                                       EGG_TB_MODEL_NOT_REMOVABLE); 
678
679 #ifndef HAVE_GTK_RECENT
680         ev_application->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
681         /* FIXME we should add a mime type filter but current eggrecent
682            has only a varargs style api which does not work well when
683            the list of mime types is dynamic */
684         egg_recent_model_set_limit (ev_application->recent_model, 5);   
685         egg_recent_model_set_filter_groups (ev_application->recent_model,
686                                             "Evince", NULL);
687 #endif /* HAVE_GTK_RECENT */
688 }
689
690 /**
691  * ev_application_get_windows:
692  * @application: The instance of the application.
693  *
694  * It creates a list of the top level windows.
695  *
696  * Returns: A #GList of the top level windows.
697  */
698 GList *
699 ev_application_get_windows (EvApplication *application)
700 {
701         GList *l, *toplevels;
702         GList *windows = NULL;
703
704         toplevels = gtk_window_list_toplevels ();
705
706         for (l = toplevels; l != NULL; l = l->next) {
707                 if (EV_IS_WINDOW (l->data)) {
708                         windows = g_list_append (windows, l->data);
709                 }
710         }
711
712         g_list_free (toplevels);
713
714         return windows;
715 }
716
717 EggToolbarsModel *
718 ev_application_get_toolbars_model (EvApplication *application)
719 {
720         return application->toolbars_model;
721 }
722
723 #ifndef HAVE_GTK_RECENT
724 EggRecentModel *
725 ev_application_get_recent_model (EvApplication *application)
726 {
727         return application->recent_model;
728 }
729 #endif
730
731 void
732 ev_application_save_toolbars_model (EvApplication *application)
733 {
734         egg_toolbars_model_save_toolbars (application->toolbars_model,
735                                           application->toolbars_file, "1.0");
736 }
737
738 void
739 ev_application_set_chooser_uri (EvApplication *application, const gchar *uri)
740 {
741         g_free (application->last_chooser_uri);
742         application->last_chooser_uri = g_strdup (uri);
743 }
744
745 const gchar *
746 ev_application_get_chooser_uri (EvApplication *application)
747 {
748         return application->last_chooser_uri;
749 }
750
751 void
752 ev_application_screensaver_enable (EvApplication *application)
753 {
754         if (application->scr_saver)
755                 totem_scrsaver_enable (application->scr_saver); 
756 }
757
758 void
759 ev_application_screensaver_disable (EvApplication *application)
760 {
761         if (application->scr_saver)
762                 totem_scrsaver_disable (application->scr_saver);        
763 }
764
765 #ifdef WITH_GTK_PRINT
766 GtkPrintSettings *
767 ev_application_get_print_settings (EvApplication *application)
768 {
769         if (application->print_settings)
770                 return application->print_settings;
771         
772 #if GTK_CHECK_VERSION (2, 11, 0)
773         if (!application->print_settings_file) {
774                 application->print_settings_file =
775                         g_build_filename (ev_dot_dir (), "print-settings", NULL);
776         }
777
778         if (g_file_test (application->print_settings_file, G_FILE_TEST_IS_REGULAR)) {
779                 GError *error = NULL;
780                 
781                 application->print_settings =
782                         gtk_print_settings_new_from_file (application->print_settings_file, &error);
783                 
784                 if (error) {
785                         g_warning (error->message);
786                         g_error_free (error);
787                 } else {
788                         return application->print_settings;
789                 }
790         }
791 #endif /* GTK 2.11.0 */
792         
793         application->print_settings = gtk_print_settings_new ();
794
795         return application->print_settings;
796 }
797
798 void
799 ev_application_set_print_settings (EvApplication    *application,
800                                    GtkPrintSettings *settings)
801 {
802         g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
803         
804         if (settings == application->print_settings)
805                 return;
806
807         if (application->print_settings)
808                 g_object_unref (application->print_settings);
809         
810         application->print_settings = g_object_ref (settings);
811 }
812 #endif /* WITH_GTK_PRINT */