diff options
author | Matthias Clasen <mclasen@redhat.com> | 2007-04-30 06:03:01 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2007-04-30 06:03:01 +0000 |
commit | 7253a5a2928f8dd555b43fcc92b01593ce1a22ec (patch) | |
tree | 6e960f15840d1c9f0d672cfc0e4aa13206f3e2f8 | |
parent | 23263cd43c0aa753d1901f8c286a4d9109f81b25 (diff) | |
download | gtk+-7253a5a2928f8dd555b43fcc92b01593ce1a22ec.tar.gz |
Rename gtk_paper_size_get_builtins() to gtk_paper_size_get_paper_sizes()
2007-04-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
* gtk/gtkpapersize.[hc]: Rename gtk_paper_size_get_builtins()
to gtk_paper_size_get_paper_sizes() and optionally include
custom paper sizes.
* gtk/gtkpagesetupunixdialog.c: Internally export a function
to load custom paper sizes.
* modules/printbackends/file/gtkprintbackendfile.c: Implement
printer_list_papers, returning all paper sizes. (#434329,
Christian Persch)
svn path=/trunk/; revision=17728
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | docs/reference/gtk/gtk-sections.txt | 2 | ||||
-rw-r--r-- | gtk/gtk.symbols | 2 | ||||
-rw-r--r-- | gtk/gtkpagesetupunixdialog.c | 32 | ||||
-rw-r--r-- | gtk/gtkpapersize.c | 16 | ||||
-rw-r--r-- | modules/printbackends/file/gtkprintbackendfile.c | 27 |
6 files changed, 81 insertions, 12 deletions
@@ -1,4 +1,18 @@ 2007-04-30 Matthias Clasen <mclasen@redhat.com> + + * gtk/gtk.symbols: + * gtk/gtkpapersize.[hc]: Rename gtk_paper_size_get_builtins() + to gtk_paper_size_get_paper_sizes() and optionally include + custom paper sizes. + + * gtk/gtkpagesetupunixdialog.c: Internally export a function + to load custom paper sizes. + + * modules/printbackends/file/gtkprintbackendfile.c: Implement + printer_list_papers, returning all paper sizes. (#434329, + Christian Persch) + +2007-04-30 Matthias Clasen <mclasen@redhat.com> * gtk/gtkprintoperation.c: Translate the default job name, and don't utf8-validate the job name in the diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 5e4c3fdd24..df1856b004 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -6366,7 +6366,7 @@ gtk_paper_size_new_custom gtk_paper_size_copy gtk_paper_size_free gtk_paper_size_is_equal -gtk_paper_size_get_builtins +gtk_paper_size_get_paper_sizes gtk_paper_size_get_name gtk_paper_size_get_display_name gtk_paper_size_get_ppd_name diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 0f981c416f..6100d68a34 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -2561,7 +2561,7 @@ gtk_paper_size_to_key_file gtk_paper_size_copy gtk_paper_size_free gtk_paper_size_is_equal -gtk_paper_size_get_builtins +gtk_paper_size_get_paper_sizes gtk_paper_size_get_name gtk_paper_size_get_display_name gtk_paper_size_get_ppd_name diff --git a/gtk/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c index 638d480bfa..2bd76c154e 100644 --- a/gtk/gtkpagesetupunixdialog.c +++ b/gtk/gtkpagesetupunixdialog.c @@ -181,14 +181,15 @@ custom_paper_get_filename (void) return filename; } -static void -load_custom_papers (GtkListStore *store) +GList * +_gtk_load_custom_papers (void) { GKeyFile *keyfile; gchar *filename; gchar **groups; gsize n_groups, i; gboolean load_ok; + GList *result = NULL; filename = custom_paper_get_filename (); @@ -198,7 +199,7 @@ load_custom_papers (GtkListStore *store) if (!load_ok) { g_key_file_free (keyfile); - return; + return NULL; } groups = g_key_file_get_groups (keyfile, &n_groups); @@ -211,15 +212,34 @@ load_custom_papers (GtkListStore *store) if (!page_setup) continue; + result = g_list_prepend (result, page_setup); + } + + g_strfreev (groups); + g_key_file_free (keyfile); + + return g_list_reverse (result); +} + +static void +load_custom_papers (GtkListStore *store) +{ + GtkTreeIter iter; + GList *papers, *p; + GtkPageSetup *page_setup; + + papers = _gtk_load_custom_papers (); + for (p = papers; p; p = p->next) + { + page_setup = p->data; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, page_setup, -1); g_object_unref (page_setup); } - - g_strfreev (groups); - g_key_file_free (keyfile); + + g_list_free (papers); } static void diff --git a/gtk/gtkpapersize.c b/gtk/gtkpapersize.c index c0045dc3df..12d23f2244 100644 --- a/gtk/gtkpapersize.c +++ b/gtk/gtkpapersize.c @@ -433,10 +433,14 @@ gtk_paper_size_is_equal (GtkPaperSize *size1, gtk_paper_size_get_name (size2)) == 0; } +GList * _gtk_load_custom_papers (void); + /** - * gtk_paper_size_get_builtins: + * gtk_paper_size_get_paper_sizes: + * @include_custom: whether to include custom paper sizes + * as defined in the page setup dialog * - * Creates a list of builtin paper sizes. + * Creates a list of known paper sizes. * * Return value: a newly allocated list of newly * allocated #GtkPaperSize objects @@ -444,11 +448,14 @@ gtk_paper_size_is_equal (GtkPaperSize *size1, * Since: 2.12 */ GList * -gtk_paper_size_get_builtins (void) +gtk_paper_size_get_paper_sizes (gboolean include_custom) { GList *list = NULL; guint i; + if (include_custom) + list = _gtk_load_custom_papers (); + for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i) { GtkPaperSize *size; @@ -457,9 +464,10 @@ gtk_paper_size_get_builtins (void) list = g_list_prepend (list, size); } - return list; + return g_list_reverse (list); } + /** * gtk_paper_size_get_name: * @size: a #GtkPaperSize object diff --git a/modules/printbackends/file/gtkprintbackendfile.c b/modules/printbackends/file/gtkprintbackendfile.c index bfe27a5f24..c596aec0b8 100644 --- a/modules/printbackends/file/gtkprintbackendfile.c +++ b/modules/printbackends/file/gtkprintbackendfile.c @@ -103,6 +103,8 @@ static cairo_surface_t * file_printer_create_cairo_surface (GtkPrinter gdouble height, GIOChannel *cache_io); +static GList * file_printer_list_papers (GtkPrinter *printer); + static void gtk_print_backend_file_register_type (GTypeModule *module) { @@ -179,6 +181,7 @@ gtk_print_backend_file_class_init (GtkPrintBackendFileClass *class) backend_class->printer_get_options = file_printer_get_options; backend_class->printer_get_settings_from_options = file_printer_get_settings_from_options; backend_class->printer_prepare_for_print = file_printer_prepare_for_print; + backend_class->printer_list_papers = file_printer_list_papers; } /* return N_FORMATS if no explicit format in the settings */ @@ -600,3 +603,27 @@ file_printer_prepare_for_print (GtkPrinter *printer, print_job->page_set = gtk_print_settings_get_page_set (settings); print_job->rotate_to_orientation = TRUE; } + +static GList * +file_printer_list_papers (GtkPrinter *printer) +{ + GList *result = NULL; + GList *papers, *p; + GtkPageSetup *page_setup; + + papers = gtk_paper_size_get_paper_sizes (TRUE); + + for (p = papers; p; p = p->next) + { + GtkPaperSize *paper_size = p->data; + + page_setup = gtk_page_setup_new (); + gtk_page_setup_set_paper_size (page_setup, paper_size); + gtk_paper_size_free (paper_size); + result = g_list_prepend (result, page_setup); + } + + g_list_free (papers); + + return g_list_reverse (result); +} |