[eog] Embed page setup in the print dialog



commit cffc41e7b0f255cdaf82052dad83ff1539599fdb
Author: Marek Kasik <mkasik redhat com>
Date:   Fri Apr 2 15:00:26 2010 +0200

    Embed page setup in the print dialog
    
    This patch activates paper size combo and orientation combo in the
    Page Setup tab in the print dialog. It removes "Page Setup..." from
    the file menu. It also actualize paper size in Image Settings each
    time it changes. (bug 614451)

 data/eog-ui.xml             |    1 -
 src/eog-print-image-setup.c |   31 ++++++++++++++++++++++++++++++
 src/eog-print-image-setup.h |    5 ++++
 src/eog-print.c             |    7 +++++-
 src/eog-window.c            |   44 +------------------------------------------
 5 files changed, 43 insertions(+), 45 deletions(-)
---
diff --git a/data/eog-ui.xml b/data/eog-ui.xml
index 2680f28..75cac6e 100644
--- a/data/eog-ui.xml
+++ b/data/eog-ui.xml
@@ -9,7 +9,6 @@
       <menuitem action="FileSave"/>
       <menuitem action="FileSaveAs"/>
       <separator/>
-      <menuitem action="FilePageSetup"/>
       <menuitem action="FilePrint"/>
       <separator/>
       <menuitem action="FileProperties"/>
diff --git a/src/eog-print-image-setup.c b/src/eog-print-image-setup.c
index 1f20ebf..b2f6243 100644
--- a/src/eog-print-image-setup.c
+++ b/src/eog-print-image-setup.c
@@ -1041,3 +1041,34 @@ eog_print_image_setup_get_options (EogPrintImageSetup *setup,
 	*scale = gtk_range_get_value (GTK_RANGE (priv->scaling));
 	*unit = priv->current_unit;
 }
+
+void
+eog_print_image_setup_update (GtkPrintOperation *operation,
+			      GtkWidget         *custom_widget,
+			      GtkPageSetup      *page_setup,
+			      GtkPrintSettings  *print_settings,
+			      gpointer           user_data)
+{
+	GtkWidget *preview;
+	gdouble    pos_x;
+	gdouble    pos_y;
+	EogPrintImageSetup *setup;
+
+	setup = EOG_PRINT_IMAGE_SETUP (custom_widget);
+
+	setup->priv->page_setup = gtk_page_setup_copy (page_setup);
+
+	set_initial_values (EOG_PRINT_IMAGE_SETUP (setup));
+
+	preview = EOG_PRINT_IMAGE_SETUP (setup)->priv->preview;
+	eog_print_preview_set_from_page_setup (EOG_PRINT_PREVIEW (preview),
+					       setup->priv->page_setup);
+
+	pos_x = gtk_spin_button_get_value (GTK_SPIN_BUTTON (setup->priv->left));
+	pos_y = gtk_spin_button_get_value (GTK_SPIN_BUTTON (setup->priv->top));
+	if (setup->priv->current_unit == GTK_UNIT_MM) {
+		pos_x *= FACTOR_MM_TO_INCH;
+		pos_y *= FACTOR_MM_TO_INCH;
+	}
+	eog_print_preview_set_image_position (EOG_PRINT_PREVIEW (setup->priv->preview), pos_x, pos_y);
+}
diff --git a/src/eog-print-image-setup.h b/src/eog-print-image-setup.h
index 0a6b49e..d495a96 100644
--- a/src/eog-print-image-setup.h
+++ b/src/eog-print-image-setup.h
@@ -60,6 +60,11 @@ void              eog_print_image_setup_get_options (EogPrintImageSetup *setup,
 						     gdouble            *top,
 						     gdouble            *scale,
 						     GtkUnit            *unit);
+void              eog_print_image_setup_update      (GtkPrintOperation *operation,
+						     GtkWidget         *custom_widget,
+						     GtkPageSetup      *page_setup,
+						     GtkPrintSettings  *print_settings,
+						     gpointer           user_data);
 
 G_END_DECLS
 
diff --git a/src/eog-print.c b/src/eog-print.c
index 8e2402d..681ce36 100644
--- a/src/eog-print.c
+++ b/src/eog-print.c
@@ -113,7 +113,8 @@ eog_print_create_custom_widget (GtkPrintOperation *operation,
 
 	page_setup = gtk_print_operation_get_default_page_setup (operation);
 
-	g_assert (page_setup != NULL);
+	if (page_setup == NULL)
+		page_setup = gtk_page_setup_new ();
 
 	return G_OBJECT (eog_print_image_setup_new (data->image, page_setup));
 }
@@ -180,6 +181,7 @@ eog_print_operation_new (EogImage *image,
 	gtk_print_operation_set_n_pages (print, 1);
 	gtk_print_operation_set_job_name (print,
 					  eog_image_get_caption (image));
+	gtk_print_operation_set_embed_page_setup (print, TRUE);
 
 	g_signal_connect (print, "draw_page",
 			  G_CALLBACK (eog_print_draw_page),
@@ -193,6 +195,9 @@ eog_print_operation_new (EogImage *image,
 	g_signal_connect (print, "end-print",
 			  G_CALLBACK (eog_print_end_print),
 			  data);
+	g_signal_connect (print, "update-custom-widget",
+			  G_CALLBACK (eog_print_image_setup_update),
+			  data);
 
 	gtk_print_operation_set_custom_tab_label (print, _("Image Settings"));
 
diff --git a/src/eog-window.c b/src/eog-window.c
index dfd4636..044c28e 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -825,7 +825,6 @@ update_action_groups_state (EogWindow *window)
 	GtkAction *action_fscreen;
 	GtkAction *action_sshow;
 	GtkAction *action_print;
-	GtkAction *action_page_setup;
 	gboolean print_disabled = FALSE;
 	gboolean page_setup_disabled = FALSE;
 	gboolean show_image_collection = FALSE;
@@ -857,16 +856,11 @@ update_action_groups_state (EogWindow *window)
 		gtk_action_group_get_action (priv->actions_image,
 					     "FilePrint");
 
-	action_page_setup =
-		gtk_action_group_get_action (priv->actions_image,
-					     "FilePageSetup");
-
 	g_assert (action_collection != NULL);
 	g_assert (action_sidebar != NULL);
 	g_assert (action_fscreen != NULL);
 	g_assert (action_sshow != NULL);
 	g_assert (action_print != NULL);
-	g_assert (action_page_setup != NULL);
 
 	if (priv->store != NULL) {
 		n_images = eog_list_store_length (EOG_LIST_STORE (priv->store));
@@ -946,10 +940,6 @@ update_action_groups_state (EogWindow *window)
 						     EOG_CONF_DESKTOP_CAN_SETUP_PAGE,
 						     NULL);
 
-	if (page_setup_disabled) {
-		gtk_action_set_sensitive (action_page_setup, FALSE);
-	}
-
 	if (eog_sidebar_is_empty (EOG_SIDEBAR (priv->sidebar))) {
 		gtk_action_set_sensitive (action_sidebar, FALSE);
 		gtk_widget_hide (priv->sidebar);
@@ -2328,28 +2318,6 @@ eog_window_stop_fullscreen (EogWindow *window, gboolean slideshow)
 }
 
 static void
-eog_window_page_setup (EogWindow *window)
-{
-	GtkPageSetup *new_page_setup;
-	GtkPageSetup *page_setup;
-	GtkPrintSettings *print_settings;
-
-	eog_debug (DEBUG_PRINTING);
-
-	print_settings = eog_print_get_print_settings ();
-	page_setup = eog_print_get_page_setup ();
-
-	new_page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (window),
-							  page_setup,
-							  print_settings);
-	eog_print_set_page_setup (new_page_setup);
-
-	g_object_unref (page_setup);
-	g_object_unref (new_page_setup);
-	g_object_unref (print_settings);
-}
-
-static void
 eog_window_print (EogWindow *window)
 {
 	GtkWidget *dialog;
@@ -2388,6 +2356,7 @@ eog_window_print (EogWindow *window)
 		g_error_free (error);
 	} else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
 		eog_print_set_print_settings (gtk_print_operation_get_print_settings (print));
+		eog_print_set_page_setup (gtk_print_operation_get_default_page_setup (print));
 	}
 
 	g_object_unref (page_setup);
@@ -3137,14 +3106,6 @@ eog_window_cmd_save_as (GtkAction *action, gpointer user_data)
 }
 
 static void
-eog_window_cmd_page_setup (GtkAction *action, gpointer user_data)
-{
-	EogWindow *window = EOG_WINDOW (user_data);
-
-	eog_window_page_setup (window);
-}
-
-static void
 eog_window_cmd_print (GtkAction *action, gpointer user_data)
 {
 	EogWindow *window = EOG_WINDOW (user_data);
@@ -3801,9 +3762,6 @@ static const GtkActionEntry action_entries_image[] = {
 	{ "FileSaveAs", GTK_STOCK_SAVE_AS, N_("Save _Asâ?¦"), "<control><shift>s",
 	  N_("Save the selected images with a different name"),
 	  G_CALLBACK (eog_window_cmd_save_as) },
-	{ "FilePageSetup", GTK_STOCK_PAGE_SETUP, NULL, NULL,
-	  N_("Set up the page properties for printing"),
-	  G_CALLBACK (eog_window_cmd_page_setup) },
 	{ "FilePrint", GTK_STOCK_PRINT, N_("_Printâ?¦"), "<control>p",
 	  N_("Print the selected image"),
 	  G_CALLBACK (eog_window_cmd_print) },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]