gedit r6084 - branches/printing/gedit



Author: pborelli
Date: Sun Jan 13 15:18:12 2008
New Revision: 6084
URL: http://svn.gnome.org/viewvc/gedit?rev=6084&view=rev

Log:
first cut at embedded preview in tab


Modified:
   branches/printing/gedit/gedit-print-job.c
   branches/printing/gedit/gedit-print-job.h
   branches/printing/gedit/gedit-tab.c

Modified: branches/printing/gedit/gedit-print-job.c
==============================================================================
--- branches/printing/gedit/gedit-print-job.c	(original)
+++ branches/printing/gedit/gedit-print-job.c	Sun Jan 13 15:18:12 2008
@@ -39,6 +39,7 @@
 #include "gedit-print-job.h"
 #include "gedit-debug.h"
 #include "gedit-prefs-manager-app.h"
+#include "gedit-print-preview.h"
 #include "gedit-marshal.h"
 #include "gedit-utils.h"
 
@@ -51,7 +52,9 @@
 	
 	GtkPrintOperation        *operation;
 	GtkSourcePrintCompositor *compositor;
-	
+
+	GtkWidget                *preview;
+
 	GeditPrintJobStatus       status;
 	
 	gchar                    *status_string;
@@ -62,12 +65,13 @@
 enum
 {
 	PROP_0,
-	PROP_VIEW,
+	PROP_VIEW
 };
 
 enum 
 {
 	PRINTING,
+	SHOW_PREVIEW,
 	DONE,
 	LAST_SIGNAL
 };
@@ -169,6 +173,17 @@
 			      1,
 			      G_TYPE_UINT);
 
+	print_job_signals[SHOW_PREVIEW] =
+		g_signal_new ("show-preview",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GeditPrintJobClass, show_preview),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__OBJECT,
+			      G_TYPE_NONE,
+			      1,
+			      GTK_TYPE_WIDGET);
+
 	print_job_signals[DONE] =
 		g_signal_new ("done",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -259,6 +274,31 @@
 	g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
 }
 
+static void
+preview_ready (GtkPrintOperationPreview *gtk_preview,
+	       GtkPrintContext          *context,
+	       GeditPrintJob            *job)
+{
+	g_signal_emit (job, print_job_signals[SHOW_PREVIEW], 0, job->priv->preview);
+}
+
+static gboolean 
+preview_cb (GtkPrintOperation        *op,
+	    GtkPrintOperationPreview *gtk_preview,
+	    GtkPrintContext          *context,
+	    GtkWindow                *parent,
+	    GeditPrintJob            *job)
+{
+	job->priv->preview = gedit_print_preview_new (op, gtk_preview, context);
+
+	g_signal_connect_after (gtk_preview,
+			        "ready",
+				G_CALLBACK (preview_ready),
+				job);
+
+	return TRUE;
+}
+
 static gboolean
 paginate_cb (GtkPrintOperation *operation, 
 	     GtkPrintContext   *context,
@@ -414,7 +454,11 @@
   	g_signal_connect (job->priv->operation,
 			  "begin-print", 
 			  G_CALLBACK (begin_print_cb),
-			  job); 
+			  job);
+	g_signal_connect (job->priv->operation,
+			  "preview",
+			  G_CALLBACK (preview_cb),
+			  job);
   	g_signal_connect (job->priv->operation,
 			  "paginate", 
 			  G_CALLBACK (paginate_cb),

Modified: branches/printing/gedit/gedit-print-job.h
==============================================================================
--- branches/printing/gedit/gedit-print-job.h	(original)
+++ branches/printing/gedit/gedit-print-job.h	Sun Jan 13 15:18:12 2008
@@ -88,16 +88,17 @@
 struct _GeditPrintJobClass 
 {
 	GObjectClass parent_class;
-	
+
         /* Signals */
 	void (* printing) (GeditPrintJob       *job,
 	                   GeditPrintJobStatus  status);
-	                   
+
+	void (* show_preview) (GeditPrintJob   *job,
+	                       GtkWidget       *preview);
+
         void (*done)      (GeditPrintJob       *job,
 		           GeditPrintJobResult  result,
                            const GError        *error);
-        
-        // TODO: add a "preview" signal
 };
 
 /*

Modified: branches/printing/gedit/gedit-tab.c
==============================================================================
--- branches/printing/gedit/gedit-tab.c	(original)
+++ branches/printing/gedit/gedit-tab.c	Sun Jan 13 15:18:12 2008
@@ -2220,6 +2220,33 @@
 	}	
 }
 
+static void
+show_preview_cb (GeditPrintJob       *job,
+		 GeditPrintPreview   *preview,
+		 GeditTab            *tab)
+{
+//	g_return_if_fail (tab->priv->state == GEDIT_TAB_STATE_PRINT_PREVIEWING);
+	g_return_if_fail (tab->priv->print_preview == NULL);
+
+	set_message_area (tab, NULL); /* destroy the message area */
+
+	tab->priv->print_preview = GTK_WIDGET (preview);
+	gtk_box_pack_end (GTK_BOX (tab),
+			  tab->priv->print_preview,
+			  TRUE,
+			  TRUE,
+			  0);
+	gtk_widget_show (tab->priv->print_preview);
+	gtk_widget_grab_focus (tab->priv->print_preview);
+
+	g_signal_connect (tab->priv->print_preview,
+			  "destroy",
+			  G_CALLBACK (print_preview_destroyed),
+			  tab);	
+
+	gedit_tab_set_state (tab, GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW);
+}
+
 #if 0
 
 static void
@@ -2330,8 +2357,18 @@
 
 	show_printing_message_area (tab, is_preview);
 
-	g_signal_connect (tab->priv->print_job, "printing", (GCallback) printing_cb, tab);
-	g_signal_connect (tab->priv->print_job, "done", (GCallback) done_printing_cb, tab);
+	g_signal_connect (tab->priv->print_job,
+			  "printing",
+			  G_CALLBACK (printing_cb),
+			  tab);
+	g_signal_connect (tab->priv->print_job,
+			  "show-preview",
+			  G_CALLBACK (show_preview_cb),
+			  tab);
+	g_signal_connect (tab->priv->print_job,
+			  "done",
+			  G_CALLBACK (done_printing_cb),
+			  tab);
 
 	if (is_preview)
 		gedit_tab_set_state (tab, GEDIT_TAB_STATE_PRINT_PREVIEWING);



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