Updating branch refs/heads/ristretto-0.0 to feebe0cf4c3df003121cb97768ef2d7e7e3f36c3 (commit) from 89880a545af123dac21c238051def0054a06f76e (commit)
commit feebe0cf4c3df003121cb97768ef2d7e7e3f36c3 Author: Stephan Arts <stephan@thor.(none)> Date: Sun May 17 11:40:47 2009 +0200 Add printing button configure.in.in | 2 + src/Makefile.am | 2 + src/main_window.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ src/main_window_ui.xml | 2 + 4 files changed, 67 insertions(+), 0 deletions(-) diff --git a/configure.in.in b/configure.in.in index 64493a2..e935ab8 100644 --- a/configure.in.in +++ b/configure.in.in @@ -63,6 +63,8 @@ XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.6.0]) XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0]) +XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.8.0]) + dnl ************************** dnl *** Check for xsltproc *** dnl ************************** diff --git a/src/Makefile.am b/src/Makefile.am index bf1f55c..0f31f46 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,6 +21,7 @@ ristretto_CFLAGS = \ $(GIO_CFLAGS) \ $(LIBEXIF_CFLAGS) \ $(XFCONF_CFLAGS) \ + $(CAIRO_CFLAGS) \ $(LIBXFCE4UTIL_CFLAGS) \ $(LIBXFCEGUI4_CFLAGS) \ -DDATADIR=\"$(datadir)\" \ @@ -33,6 +34,7 @@ ristretto_LDADD = \ $(GTHREAD_LIBS) \ $(GIO_LIBS) \ $(LIBEXIF_LIBS) \ + $(CAIRO_LIBS) \ $(XFCONF_LIBS) \ $(LIBXFCE4UTIL_LIBS) \ $(LIBXFCEGUI4_LIBS) diff --git a/src/main_window.c b/src/main_window.c index b66554c..b6e39d5 100644 --- a/src/main_window.c +++ b/src/main_window.c @@ -26,6 +26,8 @@ #include <libxfcegui4/libxfcegui4.h> #include <libexif/exif-data.h> +#include <cairo/cairo.h> + #include "image.h" #include "settings.h" @@ -165,6 +167,14 @@ static void cb_rstto_main_window_save_as (GtkWidget *widget, RsttoMainWindow *window); static void +cb_rstto_main_window_print (GtkWidget *widget, RsttoMainWindow *window); +static void +rstto_main_window_print_draw_page (GtkPrintOperation *operation, + GtkPrintContext *print_context, + gint page_nr, + RsttoMainWindow *window); + +static void cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window); static void cb_rstto_main_window_pause(GtkWidget *widget, RsttoMainWindow *window); @@ -205,6 +215,7 @@ static GtkActionEntry action_entries[] = { "open", GTK_STOCK_OPEN, N_ ("_Open"), "<control>O", N_ ("Open an image"), G_CALLBACK (cb_rstto_main_window_open_image), }, { "open-folder", NULL, N_ ("Open _Folder"), NULL, N_ ("Open a folder"), G_CALLBACK (cb_rstto_main_window_open_folder), }, { "save-as", GTK_STOCK_SAVE_AS, N_ ("_Save as"), "<control>s", N_ ("Save the image"), G_CALLBACK (cb_rstto_main_window_save_as), }, + { "print", GTK_STOCK_PRINT, N_ ("_Print"), "<control>p", N_ ("Print the image"), G_CALLBACK (cb_rstto_main_window_print), }, { "close", GTK_STOCK_CLOSE, N_ ("_Close"), "<control>W", N_ ("Close this image"), G_CALLBACK (cb_rstto_main_window_close), }, { "close-all", NULL, N_ ("_Close All"), NULL, N_ ("Close all images"), G_CALLBACK (cb_rstto_main_window_close_all), }, { "quit", GTK_STOCK_QUIT, N_ ("_Quit"), "<control>Q", N_ ("Quit Ristretto"), G_CALLBACK (cb_rstto_main_window_quit), }, @@ -1159,6 +1170,56 @@ cb_rstto_main_window_save_as (GtkWidget *widget, RsttoMainWindow *window) } /** + * cb_rstto_main_window_print: + * @widget: + * @window: + * + * + */ +static void +cb_rstto_main_window_print (GtkWidget *widget, RsttoMainWindow *window) +{ + + GtkPrintSettings *print_settings = gtk_print_settings_new (); + g_object_set (print_settings, + "export-filename", "test.pdf", + NULL); + GtkPrintOperation *print_operation = gtk_print_operation_new (); + gtk_print_operation_set_print_settings (print_operation, print_settings); + + g_signal_connect (print_operation, "draw-page", G_CALLBACK (rstto_main_window_print_draw_page), window); + + gtk_print_operation_run (print_operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, window, NULL); + +} + +static void +rstto_main_window_print_draw_page (GtkPrintOperation *operation, + GtkPrintContext *print_context, + gint page_nr, + RsttoMainWindow *window) +{ + g_debug ("%s", __FUNCTION__); + RsttoImage *image = rstto_navigator_iter_get_image (window->priv->iter); + GdkPixbuf *pixbuf = rstto_image_get_pixbuf (image); + + guchar *data = gdk_pixbuf_get_pixels (pixbuf); + gint width = gdk_pixbuf_get_width (pixbuf); + gint height = gdk_pixbuf_get_height (pixbuf); + gint rowstride = gdk_pixbuf_get_rowstride (pixbuf); + + cairo_surface_t *surface = cairo_image_surface_create_for_data (data, + CAIRO_FORMAT_RGB24, + width, + height, + rowstride); + cairo_t *context = gtk_print_context_get_cairo_context (print_context); + + cairo_set_source_surface (context, surface, 0, 0); +} + + +/** * cb_rstto_main_window_play: * @widget: * @window: diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml index c2aaf0b..c244100 100644 --- a/src/main_window_ui.xml +++ b/src/main_window_ui.xml @@ -11,6 +11,8 @@ <separator/> <menuitem action="save-as"/> <separator/> + <menuitem action="print"/> + <separator/> <menuitem action="close"/> <menuitem action="close-all"/> <menuitem action="quit"/> _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits