*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include <string.h> /* For strlen */
#include <glib/gi18n.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkprogressbar.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkwindow.h>
+#include <gtk/gtk.h>
#include <libgnomeprintui/gnome-print-dialog.h>
#include <libgnomeprintui/gnome-print-job-preview.h>
GtkWidget *progressbar;
GtkWindow *parent;
+ gboolean done;
};
static GeditPrintJobInfo* gedit_print_job_info_new (GtkTextView *view);
{
gedit_debug (DEBUG_PRINT, "");
- g_return_if_fail (pji != NULL);
+ cm_return_if_fail (pji != NULL);
if (pji->pjob != NULL)
g_object_unref (pji->pjob);
gedit_debug (DEBUG_PRINT, "");
- g_return_val_if_fail (pji != NULL, NULL);
+ cm_return_val_if_fail (pji != NULL, NULL);
if (!gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (pji->doc), NULL, NULL))
selection_flag = GNOME_PRINT_RANGE_SELECTION_UNSENSITIVE;
else
selection_flag = GNOME_PRINT_RANGE_SELECTION;
- g_return_val_if_fail(pji->pjob != NULL, NULL);
+ cm_return_val_if_fail(pji->pjob != NULL, NULL);
config = gtk_source_print_job_get_config (pji->pjob);
dialog = g_object_new (GNOME_TYPE_PRINT_DIALOG, "print_config", config, NULL);
default:
gtk_widget_destroy (dialog);
- gedit_print_job_info_destroy (pji, FALSE);
+ pji->done = TRUE;
}
}
GtkWidget *label;
GtkWidget *progressbar;
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "gedit-print");
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (window), TRUE);
g_free (str);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pji->progressbar),
- 1.0 * page_num / total);
+ (total == 0) ? 0 : 1.0 * page_num / total);
/* Update UI */
while (gtk_events_pending ())
gtk_widget_destroy (pji->dialog);
if (pji->preview == PREVIEW)
- gedit_print_job_info_destroy (pji, FALSE);
+ pji->done = TRUE;
else
{
g_signal_handlers_disconnect_by_func (pji->pjob, (GCallback) page_cb, pji);
gtk_widget_destroy (pji->dialog);
- gedit_print_job_info_destroy (pji, TRUE);
+ pji->done = TRUE;
}
void
gedit_debug (DEBUG_PRINT, "");
- g_return_if_fail (view != NULL);
+ cm_return_if_fail (view != NULL);
pji = gedit_print_job_info_new (view);
pji->preview = PREVIEW_NO;
pji);
gtk_widget_show (dialog);
+ while (pji->done != TRUE)
+ gtk_main_iteration();
+ gedit_print_job_info_destroy (pji, pji->preview ? FALSE:TRUE);
+
}
static void
}
}
-void
-gedit_print_preview (GtkTextView *view)
-{
- GeditPrintJobInfo *pji;
- GtkTextIter start, end;
-
- gedit_debug (DEBUG_PRINT, "");
-
- g_return_if_fail (view != NULL);
-
- pji = gedit_print_job_info_new (view);
-
- gtk_text_buffer_get_bounds (pji->doc, &start, &end);
-
- pji->preview = PREVIEW;
- gedit_print_preview_real (pji, &start, &end,
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))));
-}
-
static GeditPrintJobInfo *
gedit_print_job_info_new (GtkTextView* view)
{
gedit_debug (DEBUG_PRINT, "");
- g_return_val_if_fail (view != NULL, NULL);
+ cm_return_val_if_fail (view != NULL, NULL);
buffer = gtk_text_view_get_buffer (view);
- g_return_val_if_fail (buffer != NULL, NULL);
+ cm_return_val_if_fail (buffer != NULL, NULL);
config = gnome_print_config_default ();
- g_return_val_if_fail (config != NULL, NULL);
+ cm_return_val_if_fail (config != NULL, NULL);
gnome_print_config_set_int (config, GNOME_PRINT_KEY_NUM_COPIES, 1);
gnome_print_config_set_boolean (config, GNOME_PRINT_KEY_COLLATE, FALSE);
gtk_source_print_job_set_print_footer (pjob, TRUE);
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (view));
- font_desc = pango_context_get_font_description (pango_context);
+ if (prefs_common.use_different_print_font)
+ {
+ font_desc = pango_font_description_from_string (prefs_common.printfont);
+ }
+ else
+ {
+ font_desc = pango_context_get_font_description (pango_context);
+ }
gtk_source_print_job_set_font_desc (pjob, font_desc);
+ if (prefs_common.use_different_print_font)
+ {
+ pango_font_description_free (font_desc);
+ }
pji = g_new0 (GeditPrintJobInfo, 1);