Hello community, here is the log from the commit of package viewnior for openSUSE:Factory checked in at 2014-01-20 16:24:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/viewnior (Old) and /work/SRC/openSUSE:Factory/.viewnior.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "viewnior" Changes: -------- --- /work/SRC/openSUSE:Factory/viewnior/viewnior.changes 2012-03-16 13:27:30.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.viewnior.new/viewnior.changes 2014-01-23 15:57:47.000000000 +0100 @@ -1,0 +2,7 @@ +Sat Jan 4 19:27:26 UTC 2014 - [email protected] + +- Add viewnior-print.patch: add printing support (lp#816563); the + patch is updated for the current version of Viewnior. +- BuildRequires: libtool. + +------------------------------------------------------------------- New: ---- viewnior-print.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ viewnior.spec ++++++ --- /var/tmp/diff_new_pack.c248LB/_old 2014-01-23 15:57:48.000000000 +0100 +++ /var/tmp/diff_new_pack.c248LB/_new 2014-01-23 15:57:48.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package viewnior # -# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,7 +25,10 @@ Url: http://xsisqox.github.com/Viewnior Source0: http://cloud.github.com/downloads/xsisqox/Viewnior/%{name}-%{version}.tar.gz Patch0: %{name}-1.1-ld_fix.patch +# PATCH-FEATURE-UPSTREAM viewnior-print.patch lp#816563 [email protected] -- add printing support +Patch1: viewnior-print.patch BuildRequires: intltool +BuildRequires: libtool BuildRequires: update-desktop-files BuildRequires: pkgconfig(gtk+-2.0) Recommends: %{name}-lang @@ -49,17 +52,19 @@ %prep %setup -q %patch0 -p1 +%patch1 -p1 # fix spurious executable perms chmod 0644 AUTHORS ChangeLog COPYING NEWS README TODO src/* %build +autoreconf -fiv %configure -make %{?_smp_mflags} V=1 +make %{?_smp_mflags} %install %make_install -%find_lang %{name} -%suse_update_desktop_file %{name} +%find_lang %{name} %{?no_lang_C} +%suse_update_desktop_file -r -G "Elegant Image Viewer" %{name} Graphics Viewer GTK %post %desktop_database_post ++++++ viewnior-print.patch ++++++ Index: viewnior-1.3/configure.ac =================================================================== --- viewnior-1.3.orig/configure.ac +++ viewnior-1.3/configure.ac @@ -51,6 +51,7 @@ GDKPIXBUF_REQUIRED=2.4.0 VNR_MODULES="gtk+-2.0 >= $GTK_REQUIRED \ + gtk+-unix-print-2.0 >= $GTK_REQUIRED \ glib-2.0 >= $GLIB_REQUIRED \ gio-2.0 >= $GLIB_REQUIRED \ shared-mime-info >= $SHARED_MIME_INFO_REQUIRED \ Index: viewnior-1.3/src/vnr-prefs.c =================================================================== --- viewnior-1.3.orig/src/vnr-prefs.c +++ viewnior-1.3/src/vnr-prefs.c @@ -167,6 +167,8 @@ vnr_prefs_set_default(VnrPrefs *prefs) prefs->start_slideshow = FALSE; prefs->start_fullscreen = FALSE; prefs->auto_resize = FALSE; + prefs->page_setup = NULL; + prefs->print_settings = NULL; } static GtkWidget * @@ -365,6 +367,9 @@ vnr_prefs_load (VnrPrefs *prefs) prefs->jpeg_quality = g_key_file_get_integer (conf, "prefs", "jpeg-quality", &error); prefs->png_compression = g_key_file_get_integer (conf, "prefs", "png-compression", &error); + prefs->page_setup = gtk_page_setup_new_from_key_file (conf, NULL, NULL); + prefs->print_settings = gtk_print_settings_new_from_key_file (conf, NULL, NULL); + if(error != NULL) { g_warning("Parsing config file: %s. All preferences are set to their default values.", error->message); @@ -453,6 +458,11 @@ vnr_prefs_save (VnrPrefs *prefs) g_key_file_set_integer (conf, "prefs", "jpeg-quality", prefs->jpeg_quality); g_key_file_set_integer (conf, "prefs", "png-compression", prefs->png_compression); + if (prefs->page_setup) + gtk_page_setup_to_key_file (prefs->page_setup, conf, NULL); + if (prefs->print_settings) + gtk_print_settings_to_key_file (prefs->print_settings, conf, NULL); + if(g_mkdir_with_parents (dir, 0700) != 0) g_warning("Error creating config file's parent directory (%s)\n", dir); Index: viewnior-1.3/src/vnr-prefs.h =================================================================== --- viewnior-1.3.orig/src/vnr-prefs.h +++ viewnior-1.3/src/vnr-prefs.h @@ -96,6 +96,9 @@ struct _VnrPrefs { GtkWidget *vnr_win; GtkSpinButton *slideshow_timeout_widget; + + GtkPrintSettings *print_settings; + GtkPageSetup *page_setup; }; struct _VnrPrefsClass { Index: viewnior-1.3/src/vnr-window.c =================================================================== --- viewnior-1.3.orig/src/vnr-window.c +++ viewnior-1.3/src/vnr-window.c @@ -25,6 +25,7 @@ #include <glib/gstdio.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#include <gtk/gtkunixprint.h> #include <errno.h> #include <sys/wait.h> #include "vnr-window.h" @@ -69,6 +70,9 @@ const gchar *ui_definition = "<ui>" "<menuitem action=\"FileReload\"/>" "<menuitem action=\"FileProperties\"/>" "<separator/>" + "<menuitem action=\"FilePageSetup\"/>" + "<menuitem action=\"FilePrint\"/>" + "<separator/>" "<menu action=\"Edit\">" "<menuitem action=\"FileDelete\"/>" "<separator/>" @@ -112,6 +116,8 @@ const gchar *ui_definition = "<ui>" "<separator/>" "<toolitem action=\"ImageRotateCCW\"/>" "<toolitem action=\"ImageRotateCW\"/>" + "<separator/>" + "<toolitem action=\"FilePrint\"/>" "<separator expand=\"true\"/>" "<toolitem action=\"Properties\"/>" "</toolbar>" @@ -132,6 +138,8 @@ const gchar *ui_definition = "<ui>" "<menuitem name=\"Fullscreen\" action=\"ViewFullscreen\"/>" "<separator/>" "<menuitem action=\"FileProperties\"/>" + "<separator/>" + "<menuitem action=\"FilePrint\"/>" "</popup>" "<accelerator name=\"ControlEqualAccel\" action=\"ControlEqual\"/>" "<accelerator name=\"ControlKPAddAccel\" action=\"ControlKpAdd\"/>" @@ -935,6 +943,51 @@ vnr_window_cmd_main_menu_hidden (GtkWidg } static void +draw_page_cb (GtkPrintOperation * oper, + GtkPrintContext * context, + gint nr, VnrWindow *window) +{ + cairo_t *cr; + GdkPixbuf *source_pixbuf; + + cr = gtk_print_context_get_cairo_context (context); + + source_pixbuf = UNI_IMAGE_VIEW (window->view)->pixbuf; + + if (source_pixbuf) + { + GdkPixbuf *pixbuf; + guint iw, ih; + gdouble pw, ph; + gdouble factor; + + /* scale image to page size */ + pw = gtk_page_setup_get_paper_width (window->prefs->page_setup, GTK_UNIT_POINTS) + - gtk_page_setup_get_left_margin (window->prefs->page_setup, GTK_UNIT_POINTS) + - gtk_page_setup_get_right_margin (window->prefs->page_setup, GTK_UNIT_POINTS); + ph = gtk_page_setup_get_paper_height (window->prefs->page_setup, GTK_UNIT_POINTS) + - gtk_page_setup_get_top_margin (window->prefs->page_setup, GTK_UNIT_POINTS) + - gtk_page_setup_get_bottom_margin (window->prefs->page_setup, GTK_UNIT_POINTS); + + iw = gdk_pixbuf_get_width (source_pixbuf); + ih = gdk_pixbuf_get_height (source_pixbuf); + + factor = MIN (pw / iw, ph / ih); + factor = (factor > 1.0) ? 1.0 : factor; + + pixbuf = gdk_pixbuf_scale_simple (source_pixbuf, + iw * factor, ih * factor, + GDK_INTERP_HYPER); + + /* add image to surface */ + gdk_cairo_set_source_pixbuf (cr, pixbuf, 0.0, 0.0); + cairo_paint (cr); + + g_object_unref (pixbuf); + } +} + +static void leave_fs_cb (GtkButton *button, VnrWindow *window) { vnr_window_unfullscreen (window); @@ -1270,6 +1323,65 @@ vnr_window_cmd_about (GtkAction *action, } static void +vnr_window_cmd_page_setup (GtkAction *action, VnrWindow *window) +{ + GtkWidget *dlg; + + dlg = gtk_page_setup_unix_dialog_new(_("Page settings"), GTK_WINDOW(window)); + if (window->prefs->page_setup) + gtk_page_setup_unix_dialog_set_page_setup(GTK_PAGE_SETUP_UNIX_DIALOG(dlg), + window->prefs->page_setup); + if (window->prefs->print_settings) + gtk_page_setup_unix_dialog_set_print_settings(GTK_PAGE_SETUP_UNIX_DIALOG(dlg), + window->prefs->print_settings); + if (gtk_dialog_run (GTK_DIALOG (dlg)) == 0) + { + window->prefs->page_setup = gtk_page_setup_unix_dialog_get_page_setup + (GTK_PAGE_SETUP_UNIX_DIALOG (dlg)); + window->prefs->print_settings = gtk_page_setup_unix_dialog_get_print_settings + (GTK_PAGE_SETUP_UNIX_DIALOG (dlg)); + } + gtk_widget_destroy (dlg); +} + +static void +vnr_window_cmd_print (GtkAction *action, VnrWindow *window) +{ + GtkPrintOperation *op; + + op = gtk_print_operation_new (); + + if (!window->prefs->page_setup) + { + GtkPaperSize *size = gtk_paper_size_new (GTK_PAPER_NAME_A4); + + window->prefs->page_setup = gtk_page_setup_new (); + + gtk_page_setup_set_paper_size (window->prefs->page_setup, size); + gtk_page_setup_set_top_margin (window->prefs->page_setup, 0.5, GTK_UNIT_INCH); + gtk_page_setup_set_bottom_margin (window->prefs->page_setup, 0.5, GTK_UNIT_INCH); + gtk_page_setup_set_left_margin (window->prefs->page_setup, 0.5, GTK_UNIT_INCH); + gtk_page_setup_set_right_margin (window->prefs->page_setup, 0.5, GTK_UNIT_INCH); + gtk_page_setup_set_orientation (window->prefs->page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); + + gtk_paper_size_free (size); + } + if (!window->prefs->print_settings) + window->prefs->print_settings = gtk_print_settings_new (); + + gtk_print_operation_set_n_pages (op, 1); + gtk_print_operation_set_default_page_setup (op, window->prefs->page_setup); + gtk_print_operation_set_print_settings (op, window->prefs->print_settings); + + g_signal_connect (G_OBJECT (op), "draw-page", G_CALLBACK (draw_page_cb), window); + + gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, + GTK_WINDOW (window), NULL); + + g_object_unref (op); +} + +static void vnr_set_wallpaper(GtkAction *action, VnrWindow *win) { pid_t pid; @@ -1602,6 +1714,15 @@ static const GtkActionEntry action_entri G_CALLBACK (vnr_window_cmd_preferences) } }; +static const GtkActionEntry action_entries_print[] = { + { "FilePageSetup", GTK_STOCK_PAGE_SETUP, N_("Page Setup"), NULL, + N_("Set printer page settings"), + G_CALLBACK (vnr_window_cmd_page_setup) }, + { "FilePrint", GTK_STOCK_PRINT, N_("_Print"), "<control>P", + N_("Print current image"), + G_CALLBACK (vnr_window_cmd_print) } +}; + static const GtkActionEntry action_entry_save[] = { { "FileSave", GTK_STOCK_SAVE, N_("_Save"), "<control>S", N_("Save changes"), @@ -1922,6 +2043,20 @@ vnr_window_init (VnrWindow * window) gtk_ui_manager_insert_action_group (window->ui_mngr, window->action_properties, 0); + window->actions_print = gtk_action_group_new("MenuActionPrint"); + + + gtk_action_group_set_translation_domain (window->actions_print, + GETTEXT_PACKAGE); + + gtk_action_group_add_actions (window->actions_print, + action_entries_print, + G_N_ELEMENTS (action_entries_print), + window); + + gtk_ui_manager_insert_action_group (window->ui_mngr, + window->actions_print, 0); + window->actions_static_image = gtk_action_group_new("MenuActionsStaticImage"); @@ -2020,6 +2155,7 @@ vnr_window_init (VnrWindow * window) gtk_action_group_set_sensitive(window->actions_image, FALSE); gtk_action_group_set_sensitive(window->actions_static_image, FALSE); gtk_action_group_set_sensitive(window->action_save, FALSE); + gtk_action_group_set_sensitive(window->actions_print, FALSE); gtk_action_group_set_sensitive(window->action_toolbar, TRUE); /* Continue with layout */ @@ -2183,9 +2319,15 @@ vnr_window_open (VnrWindow * window, gbo /* Return TRUE if the image is static */ if ( uni_anim_view_set_anim (UNI_ANIM_VIEW (window->view), pixbuf) ) + { + gtk_action_group_set_sensitive(window->actions_print, TRUE); gtk_action_group_set_sensitive(window->actions_static_image, TRUE); + } else + { + gtk_action_group_set_sensitive(window->actions_print, FALSE); gtk_action_group_set_sensitive(window->actions_static_image, FALSE); + } if(window->mode != VNR_WINDOW_MODE_NORMAL && window->prefs->fit_on_fullscreen) { @@ -2277,6 +2419,7 @@ vnr_window_close(VnrWindow *window) { gtk_window_set_title (GTK_WINDOW (window), "Viewnior"); uni_anim_view_set_anim (UNI_ANIM_VIEW (window->view), NULL); + gtk_action_group_set_sensitive(window->actions_print, FALSE); gtk_action_group_set_sensitive(window->actions_image, FALSE); gtk_action_group_set_sensitive(window->action_wallpaper, FALSE); gtk_action_group_set_sensitive(window->actions_static_image, FALSE); Index: viewnior-1.3/src/vnr-window.h =================================================================== --- viewnior-1.3.orig/src/vnr-window.h +++ viewnior-1.3/src/vnr-window.h @@ -53,6 +53,7 @@ struct _VnrWindow { GtkActionGroup *actions_static_image; GtkActionGroup *actions_collection; GtkActionGroup *action_save; + GtkActionGroup *actions_print; GtkActionGroup *action_properties; GtkActionGroup *action_toolbar; GtkActionGroup *actions_open_with; -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
