aboutsummaryrefslogtreecommitdiffstats
path: root/embed/print-dialog.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-12-07 18:23:31 +0800
committerChristian Persch <chpe@src.gnome.org>2003-12-07 18:23:31 +0800
commitec22aa6d6229b0e3405e5fca4be0662f41946b77 (patch)
tree2fa06838674189651e1cdfd5a03a2c3a021af94e /embed/print-dialog.c
parent83bcb61ae1b7790c9d483d3706641dcc61686c67 (diff)
downloadgsoc2013-epiphany-ec22aa6d6229b0e3405e5fca4be0662f41946b77.tar
gsoc2013-epiphany-ec22aa6d6229b0e3405e5fca4be0662f41946b77.tar.gz
gsoc2013-epiphany-ec22aa6d6229b0e3405e5fca4be0662f41946b77.tar.bz2
gsoc2013-epiphany-ec22aa6d6229b0e3405e5fca4be0662f41946b77.tar.lz
gsoc2013-epiphany-ec22aa6d6229b0e3405e5fca4be0662f41946b77.tar.xz
gsoc2013-epiphany-ec22aa6d6229b0e3405e5fca4be0662f41946b77.tar.zst
gsoc2013-epiphany-ec22aa6d6229b0e3405e5fca4be0662f41946b77.zip
Split print dialogue in print setup and actual print, and move print
2003-12-07 Christian Persch <chpe@cvs.gnome.org> * data/glade/print.glade: * data/ui/epiphany-ui.xml: * embed/mozilla/PrintingPromptService.cpp: * embed/mozilla/mozilla-embed.cpp: * embed/print-dialog.c: (ephy_print_info_free), (ephy_print_get_print_info), (ephy_print_dialog_response_cb), (print_filechooser_response_cb), (ephy_print_dialog_browse_button_cb), (ephy_print_setup_dialog_close_button_cb), (ephy_print_dialog_new), (ephy_print_setup_dialog_new): * embed/print-dialog.h: * src/ephy-nautilus-view.c: (ephy_nautilus_view_new_component), (gnv_cmd_file_print): * src/ephy-nautilus-view.h: * src/ephy-shell.c: (ephy_shell_get_type), (ephy_shell_class_init), (ephy_automation_factory_cb), (ephy_automation_factory_new), (ephy_shell_init), (server_timeout), (ephy_shell_startup), (ephy_shell_finalize), (ephy_shell_new_tab), (ephy_shell_get_session), (ephy_shell_get_bookmarks), (ephy_shell_get_toolbars_model), (ephy_shell_get_bookmarks_editor), (ephy_shell_get_history_window), (ephy_shell_get_print_setup_dialog), (ephy_shell_delete_on_exit): * src/ephy-shell.h: * src/ephy-window.c: (ephy_window_set_print_preview), (ephy_window_print): * src/ephy-window.h: * src/window-commands.c: (window_cmd_file_print_setup), (window_cmd_file_print_preview): * src/window-commands.h: Split print dialogue in print setup and actual print, and move print preview into the menus too. Made print setup a global dialogue, print a per-window dialogue. * lib/ephy-dialog.c: (set_value_from_pref), (set_pref_from_value), (set_value_from_combobox), (set_combo_box_from_value), (set_radiobuttongroup_from_value), (set_pref_from_info_and_emit), (togglebutton_clicked_cb), (radiobutton_clicked_cb), (spinbutton_timeout_cb), (changed_cb), (init_props), (load_info), (save_info), (impl_show), (ephy_dialog_set_size_group), (ephy_dialog_construct), (run_response_cb), (ephy_dialog_run), (ephy_dialog_set_parent), (ephy_dialog_class_init), (ephy_dialog_new_with_parent): * lib/ephy-dialog.h: * src/language-editor.c: (language_editor_class_init): * src/language-editor.h: * src/pdm-dialog.c: (pdm_dialog_init): * src/prefs-dialog.c: (fonts_language_changed_cb), (create_fonts_language_menu), (prefs_dialog_init), (prefs_language_more_button_clicked_cb): Slight api change; port callers.
Diffstat (limited to 'embed/print-dialog.c')
-rwxr-xr-xembed/print-dialog.c590
1 files changed, 221 insertions, 369 deletions
diff --git a/embed/print-dialog.c b/embed/print-dialog.c
index e09b1a6c9..fed912b78 100755
--- a/embed/print-dialog.c
+++ b/embed/print-dialog.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2002 Jorn Baayen
+ * Copyright (C) 2003 Christian Persch
*
* 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
@@ -19,53 +20,37 @@
*/
#include "print-dialog.h"
+#include "ephy-embed-dialog.h"
+#include "ephy-file-chooser.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-debug.h"
-#include "ephy-command-manager.h"
-#include "ephy-prefs.h"
-
-#include <gtk/gtktogglebutton.h>
+#include <gtk/gtkwindow.h>
#include <gtk/gtkdialog.h>
+#include <gtk/gtkentry.h>
#include <gtk/gtkstock.h>
#include <libgnomevfs/gnome-vfs-utils.h>
-
-#define CONF_PRINT_BOTTOM_MARGIN "/apps/epiphany/dialogs/print_bottom_margin"
-#define CONF_PRINT_TOP_MARGIN "/apps/epiphany/dialogs/print_top_margin"
-#define CONF_PRINT_LEFT_MARGIN "/apps/epiphany/dialogs/print_left_margin"
-#define CONF_PRINT_RIGHT_MARGIN "/apps/epiphany/dialogs/print_right_margin"
-#define CONF_PRINT_PAGE_TITLE "/apps/epiphany/dialogs/print_page_title"
-#define CONF_PRINT_PAGE_URL "/apps/epiphany/dialogs/print_page_url"
-#define CONF_PRINT_DATE "/apps/epiphany/dialogs/print_date"
-#define CONF_PRINT_PAGE_NUMBERS "/apps/epiphany/dialogs/print_page_numbers"
-#define CONF_PRINT_PRINTER "/apps/epiphany/dialogs/print_printer"
-#define CONF_PRINT_FILE "/apps/epiphany/dialogs/print_file"
-#define CONF_PRINT_PRINTON "/apps/epiphany/dialogs/print_on"
-#define CONF_PRINT_PAPER "/apps/epiphany/dialogs/print_paper"
-#define CONF_PRINT_ALL_PAGES "/apps/epiphany/dialogs/print_all_pages"
-#define CONF_PRINT_COLOR "/apps/epiphany/dialogs/print_color"
-#define CONF_PRINT_ORIENTATION "/apps/epiphany/dialogs/print_orientation"
-
-static void print_dialog_class_init (PrintDialogClass *klass);
-static void print_dialog_init (PrintDialog *dialog);
-
-/* Glade callbacks */
-void
-print_cancel_button_cb (GtkWidget *widget,
- EphyDialog *dialog);
-void
-print_ok_button_cb (GtkWidget *widget,
- EphyDialog *dialog);
-void
-print_preview_button_cb (GtkWidget *widget,
- EphyDialog *dialog);
-
-static GObjectClass *parent_class = NULL;
-
-#define EPHY_PRINT_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_PRINT_DIALOG, PrintDialogPrivate))
-
-struct PrintDialogPrivate
-{
- GtkWidget *window;
-};
+#include <glib/gi18n.h>
+
+#define CONF_PRINT_PRINTER "/apps/epiphany/dialogs/print_printer"
+#define CONF_PRINT_FILE "/apps/epiphany/dialogs/print_file"
+#define CONF_PRINT_DIR "/apps/epiphany/directories/print_to_file"
+#define CONF_PRINT_PRINTON "/apps/epiphany/dialogs/print_on"
+#define CONF_PRINT_ALL_PAGES "/apps/epiphany/dialogs/print_all_pages"
+#define CONF_PRINT_FROM_PAGE "/apps/epiphany/dialogs/print_from_page"
+#define CONF_PRINT_TO_PAGE "/apps/epiphany/dialogs/print_to_page"
+
+#define CONF_PRINT_BOTTOM_MARGIN "/apps/epiphany/dialogs/print_bottom_margin"
+#define CONF_PRINT_TOP_MARGIN "/apps/epiphany/dialogs/print_top_margin"
+#define CONF_PRINT_LEFT_MARGIN "/apps/epiphany/dialogs/print_left_margin"
+#define CONF_PRINT_RIGHT_MARGIN "/apps/epiphany/dialogs/print_right_margin"
+#define CONF_PRINT_PAGE_TITLE "/apps/epiphany/dialogs/print_page_title"
+#define CONF_PRINT_PAGE_URL "/apps/epiphany/dialogs/print_page_url"
+#define CONF_PRINT_DATE "/apps/epiphany/dialogs/print_date"
+#define CONF_PRINT_PAGE_NUMBERS "/apps/epiphany/dialogs/print_page_numbers"
+#define CONF_PRINT_PAPER "/apps/epiphany/dialogs/print_paper"
+#define CONF_PRINT_COLOR "/apps/epiphany/dialogs/print_color"
+#define CONF_PRINT_ORIENTATION "/apps/epiphany/dialogs/print_orientation"
enum
{
@@ -73,6 +58,30 @@ enum
PRINTON_PROP,
PRINTER_PROP,
FILE_PROP,
+ ALL_PAGES_PROP,
+ SELECTION_PROP,
+ TO_PROP,
+ FROM_PROP
+};
+
+static const
+EphyDialogProperty print_props [] =
+{
+ { "print_dialog", NULL, PT_NORMAL, 0 },
+ { "printer_radiobutton", CONF_PRINT_PRINTON, PT_AUTOAPPLY, 0 },
+ { "printer_entry", CONF_PRINT_PRINTER, PT_AUTOAPPLY, 0 },
+ { "file_entry", CONF_PRINT_FILE, PT_AUTOAPPLY, 0 },
+ { "all_pages_radiobutton", CONF_PRINT_ALL_PAGES, PT_AUTOAPPLY, 0 },
+ { "selection_radiobutton", NULL, PT_NORMAL, 0 },
+ { "to_spinbutton", CONF_PRINT_FROM_PAGE, PT_AUTOAPPLY, G_TYPE_INT },
+ { "from_spinbutton", CONF_PRINT_TO_PAGE, PT_AUTOAPPLY, G_TYPE_INT },
+
+ { NULL }
+};
+
+enum
+{
+ SETUP_WINDOW_PROP,
PAPER_PROP,
TOP_PROP,
BOTTOM_PROP,
@@ -82,44 +91,25 @@ enum
PAGE_URL_PROP,
PAGE_NUMBERS_PROP,
DATE_PROP,
- ALL_PAGES_PROP,
- TO_PROP,
- FROM_PROP,
COLOR_PROP,
ORIENTATION_PROP,
- PREVIEW_PROP,
- SELECTION_PROP
-};
-
-enum
-{
- PREVIEW,
- LAST_SIGNAL
};
static const
-EphyDialogProperty properties [] =
+EphyDialogProperty setup_props [] =
{
- { "print_dialog", NULL, PT_NORMAL, 0 },
- { "printer_radiobutton", CONF_PRINT_PRINTON, PT_NORMAL, 0 },
- { "printer_entry", CONF_PRINT_PRINTER, PT_NORMAL, 0 },
- { "file_entry", CONF_PRINT_FILE, PT_NORMAL, 0 },
- { "A4_radiobutton", CONF_PRINT_PAPER, PT_NORMAL, G_TYPE_STRING },
- { "top_spinbutton", CONF_PRINT_TOP_MARGIN, PT_NORMAL, 0 },
- { "bottom_spinbutton", CONF_PRINT_BOTTOM_MARGIN, PT_NORMAL, 0 },
- { "left_spinbutton", CONF_PRINT_LEFT_MARGIN, PT_NORMAL, 0 },
- { "right_spinbutton", CONF_PRINT_RIGHT_MARGIN, PT_NORMAL, 0 },
- { "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_NORMAL, 0 },
- { "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_NORMAL, 0 },
- { "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_NORMAL, 0 },
- { "print_date_checkbutton", CONF_PRINT_DATE, PT_NORMAL, 0 },
- { "all_pages_radiobutton", CONF_PRINT_ALL_PAGES, PT_NORMAL, 0 },
- { "to_spinbutton", NULL, PT_NORMAL, 0 },
- { "from_spinbutton", NULL, PT_NORMAL, 0 },
- { "print_color_radiobutton", CONF_PRINT_COLOR, PT_NORMAL, 0 },
- { "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_NORMAL, 0 },
- { "preview_button", NULL, PT_NORMAL, 0 },
- { "selection_radiobutton", NULL, PT_NORMAL, 0 },
+ { "print_setup_dialog", NULL, PT_NORMAL, 0 },
+ { "A4_radiobutton", CONF_PRINT_PAPER, PT_AUTOAPPLY, G_TYPE_STRING },
+ { "top_spinbutton", CONF_PRINT_TOP_MARGIN, PT_AUTOAPPLY, G_TYPE_INT },
+ { "bottom_spinbutton", CONF_PRINT_BOTTOM_MARGIN, PT_AUTOAPPLY, G_TYPE_INT },
+ { "left_spinbutton", CONF_PRINT_LEFT_MARGIN, PT_AUTOAPPLY, G_TYPE_INT },
+ { "right_spinbutton", CONF_PRINT_RIGHT_MARGIN, PT_AUTOAPPLY, G_TYPE_INT },
+ { "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_AUTOAPPLY, 0 },
+ { "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_AUTOAPPLY, 0 },
+ { "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_AUTOAPPLY, 0 },
+ { "print_date_checkbutton", CONF_PRINT_DATE, PT_AUTOAPPLY, 0 },
+ { "print_color_radiobutton", CONF_PRINT_COLOR, PT_AUTOAPPLY, 0 },
+ { "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_AUTOAPPLY, 0 },
{ NULL }
};
@@ -131,169 +121,19 @@ char *paper_format_enum [] =
};
static guint n_paper_format_enum = G_N_ELEMENTS (paper_format_enum);
-static guint print_dialog_signals[LAST_SIGNAL] = { 0 };
-
-GType
-print_dialog_get_type (void)
-{
- static GType print_dialog_type = 0;
-
- if (print_dialog_type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (PrintDialogClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) print_dialog_class_init,
- NULL,
- NULL, /* class_data */
- sizeof (PrintDialog),
- 0, /* n_preallocs */
- (GInstanceInitFunc) print_dialog_init
- };
-
- print_dialog_type = g_type_register_static (EPHY_TYPE_EMBED_DIALOG,
- "PrintDialog",
- &our_info, 0);
- }
-
- return print_dialog_type;
-
-}
-
-static void
-impl_show (EphyDialog *dialog)
-{
- PrintDialog *print_dialog = EPHY_PRINT_DIALOG (dialog);
- EphyEmbed *embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG (dialog));
-
- EPHY_DIALOG_CLASS (parent_class)->show (dialog);
-
- if (print_dialog->only_collect_info)
- {
- GtkWidget *button;
-
- /* disappear preview button */
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog),
- properties[PREVIEW_PROP].id);
- gtk_widget_hide (button);
- }
-
- if (ephy_command_manager_can_do_command
- (EPHY_COMMAND_MANAGER (embed), "cmd_copy") == FALSE)
- {
- GtkWidget *widget;
-
- /* Make selection button disabled */
- widget = ephy_dialog_get_control (EPHY_DIALOG (dialog),
- properties[SELECTION_PROP].id);
-
- gtk_widget_set_sensitive (widget, FALSE);
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- {
- GtkWidget *all_pages;
- all_pages = ephy_dialog_get_control (EPHY_DIALOG (dialog),
- properties[ALL_PAGES_PROP].id);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (all_pages), TRUE);
- }
- }
-}
-
-static void
-print_dialog_class_init (PrintDialogClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- EphyDialogClass *dialog_class = EPHY_DIALOG_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- dialog_class->show = impl_show;
-
- print_dialog_signals[PREVIEW] =
- g_signal_new ("preview",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (PrintDialogClass, preview),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (object_class, sizeof(PrintDialogPrivate));
-}
-
-static void
-print_dialog_init (PrintDialog *dialog)
-{
- GdkPixbuf *icon;
- dialog->priv = EPHY_PRINT_DIALOG_GET_PRIVATE (dialog);
-
- dialog->only_collect_info = FALSE;
- dialog->ret_info = NULL;
-
- ephy_dialog_construct (EPHY_DIALOG(dialog),
- properties,
- "print.glade", "print_dialog");
-
- dialog->priv->window = ephy_dialog_get_control (EPHY_DIALOG(dialog),
- properties[WINDOW_PROP].id);
-
- ephy_dialog_add_enum (EPHY_DIALOG (dialog), properties[PAPER_PROP].id,
- n_paper_format_enum, paper_format_enum);
-
- icon = gtk_widget_render_icon (dialog->priv->window,
- GTK_STOCK_PRINT,
- GTK_ICON_SIZE_MENU,
- "print_dialog");
- gtk_window_set_icon (GTK_WINDOW(dialog->priv->window), icon);
- g_object_unref (icon);
-}
-
-EphyDialog *
-print_dialog_new (EphyEmbed *embed,
- EmbedPrintInfo **ret_info)
-{
- PrintDialog *dialog;
-
- dialog = EPHY_PRINT_DIALOG (g_object_new (EPHY_TYPE_PRINT_DIALOG,
- "embed", embed,
- NULL));
-
- if (ret_info != NULL)
- {
- dialog->only_collect_info = TRUE;
- dialog->ret_info = ret_info;
- }
-
- return EPHY_DIALOG(dialog);
-}
-
-EphyDialog *
-print_dialog_new_with_parent (GtkWidget *window,
- EphyEmbed *embed,
- EmbedPrintInfo **ret_info)
-{
- PrintDialog *dialog;
-
- dialog = EPHY_PRINT_DIALOG (g_object_new (EPHY_TYPE_PRINT_DIALOG,
- "embed", embed,
- "parent-window", window,
- NULL));
-
- if (ret_info != NULL)
- {
- dialog->only_collect_info = TRUE;
- dialog->ret_info = ret_info;
- }
-
- return EPHY_DIALOG(dialog);
-}
+void ephy_print_dialog_response_cb (GtkWidget *widget,
+ int response,
+ EphyDialog *dialog);
+void ephy_print_dialog_browse_button_cb (GtkWidget *widget,
+ EphyDialog *dialog);
+void ephy_print_setup_dialog_close_button_cb (GtkWidget *widget,
+ EphyDialog *dialog);
void
-print_free_info (EmbedPrintInfo *info)
+ephy_print_info_free (EmbedPrintInfo *info)
{
+ g_return_if_fail (info != NULL);
+
g_free (info->printer);
g_free (info->file);
g_free (info->paper);
@@ -306,196 +146,208 @@ print_free_info (EmbedPrintInfo *info)
g_free (info);
}
-static EmbedPrintInfo *
-print_get_info (EphyDialog *dialog)
+EmbedPrintInfo *
+ephy_print_get_print_info (void)
{
EmbedPrintInfo *info;
- GValue print_to_file = {0, };
- GValue printer = {0, };
- GValue file = {0, };
- GValue top_margin = {0, };
- GValue bottom_margin = {0, };
- GValue left_margin = {0, };
- GValue right_margin = {0, };
- GValue from_page = {0, };
- GValue to_page = {0, };
- GValue paper = {0, };
- GValue pages = {0, };
- GValue print_color = {0, };
- GValue orientation = {0, };
- GValue page_title = {0, };
- GValue page_url = {0, };
- GValue date = {0, };
- GValue page_numbers = {0, };
- const char *filename;
+ char *filename;
info = g_new0 (EmbedPrintInfo, 1);
- ephy_dialog_get_value (dialog, properties[PRINTON_PROP].id, &print_to_file);
- info->print_to_file = g_value_get_int (&print_to_file);
- g_value_unset (&print_to_file);
-
- ephy_dialog_get_value (dialog, properties[PRINTER_PROP].id, &printer);
- info->printer = g_strdup (g_value_get_string (&printer));
- g_value_unset (&printer);
-
- ephy_dialog_get_value (dialog, properties[FILE_PROP].id, &file);
- filename = g_value_get_string (&file);
+ filename = eel_gconf_get_string (print_props[FILE_PROP].pref);
if (filename != NULL)
{
- info->file = gnome_vfs_expand_initial_tilde (g_value_get_string (&file));
+ char *expanded;
+
+ expanded = gnome_vfs_expand_initial_tilde (filename);
+ info->file = g_filename_to_utf8 (expanded, -1, NULL, NULL, NULL);
}
else
{
info->file = NULL;
}
- g_value_unset (&file);
-
- ephy_dialog_get_value (dialog, properties[BOTTOM_PROP].id, &bottom_margin);
- info->bottom_margin = g_value_get_float (&bottom_margin);
- g_value_unset (&bottom_margin);
-
- ephy_dialog_get_value (dialog, properties[LEFT_PROP].id, &left_margin);
- info->left_margin = g_value_get_float (&left_margin);
- g_value_unset (&left_margin);
-
- ephy_dialog_get_value (dialog, properties[TOP_PROP].id, &top_margin);
- info->top_margin = g_value_get_float (&top_margin);
- g_value_unset (&top_margin);
+ g_free (filename);
- ephy_dialog_get_value (dialog, properties[RIGHT_PROP].id, &right_margin);
- info->right_margin = g_value_get_float (&right_margin);
- g_value_unset (&right_margin);
+ info->print_to_file = eel_gconf_get_integer (print_props[PRINTON_PROP].pref) == 1;
+ info->printer = eel_gconf_get_string (print_props[PRINTER_PROP].pref);
- ephy_dialog_get_value (dialog, properties[FROM_PROP].id, &from_page);
- info->from_page = g_value_get_float (&from_page);
- g_value_unset (&from_page);
+ info->pages = eel_gconf_get_integer (print_props[ALL_PAGES_PROP].pref);
+ info->from_page = eel_gconf_get_integer (print_props[FROM_PROP].pref);
+ info->to_page = eel_gconf_get_integer (print_props[TO_PROP].pref);
- ephy_dialog_get_value (dialog, properties[TO_PROP].id, &to_page);
- info->to_page = g_value_get_float (&to_page);
- g_value_unset (&to_page);
+ info->paper = eel_gconf_get_string (setup_props[PAPER_PROP].pref);
+ info->orientation = eel_gconf_get_integer (setup_props[ORIENTATION_PROP].pref);
+ info->print_color = ! eel_gconf_get_integer (setup_props[COLOR_PROP].pref);
- ephy_dialog_get_value (dialog, properties[PAPER_PROP].id, &paper);
- info->paper = g_strdup (paper_format_enum[g_value_get_int (&paper)]);
- g_value_unset (&paper);
-
- ephy_dialog_get_value (dialog, properties[ALL_PAGES_PROP].id, &pages);
- info->pages = g_value_get_int (&pages);
- g_value_unset (&pages);
-
- ephy_dialog_get_value (dialog, properties[COLOR_PROP].id, &print_color);
- info->print_color = !g_value_get_int (&print_color);
- g_value_unset (&print_color);
-
- ephy_dialog_get_value (dialog, properties[ORIENTATION_PROP].id, &orientation);
- info->orientation = g_value_get_int (&orientation);
- g_value_unset (&orientation);
-
- info->frame_type = 0;
+ info->bottom_margin = eel_gconf_get_integer (setup_props[BOTTOM_PROP].pref);
+ info->top_margin = eel_gconf_get_integer (setup_props[TOP_PROP].pref);
+ info->left_margin = eel_gconf_get_integer (setup_props[LEFT_PROP].pref);
+ info->right_margin = eel_gconf_get_integer (setup_props[RIGHT_PROP].pref);
- ephy_dialog_get_value (dialog, properties[PAGE_TITLE_PROP].id, &page_title);
- info->header_left_string = g_value_get_boolean (&page_title) ?
+ info->header_left_string = eel_gconf_get_boolean (setup_props[PAGE_TITLE_PROP].pref) ?
g_strdup ("&T") : g_strdup ("");
- g_value_unset (&page_title);
-
- ephy_dialog_get_value (dialog, properties[PAGE_URL_PROP].id, &page_url);
- info->header_right_string = g_value_get_boolean (&page_url) ?
+ info->header_right_string = eel_gconf_get_boolean (setup_props[PAGE_URL_PROP].pref) ?
g_strdup ("&U") : g_strdup ("");
- g_value_unset (&page_url);
-
- ephy_dialog_get_value (dialog, properties[PAGE_NUMBERS_PROP].id, &page_numbers);
- info->footer_left_string = g_value_get_boolean (&page_numbers) ?
+ info->footer_left_string = eel_gconf_get_boolean (setup_props[PAGE_NUMBERS_PROP].pref) ?
g_strdup ("&PT") : g_strdup ("");
- g_value_unset (&page_numbers);
-
- ephy_dialog_get_value (dialog, properties[DATE_PROP].id, &date);
- info->footer_right_string = g_value_get_boolean (&date) ?
+ info->footer_right_string = eel_gconf_get_boolean (setup_props[DATE_PROP].pref) ?
g_strdup ("&D") : g_strdup ("");
- g_value_unset (&date);
-
info->header_center_string = g_strdup("");
info->footer_center_string = g_strdup("");
+ info->frame_type = 0;
+ info->preview = FALSE;
+
return info;
}
-static void
-print_dialog_print (EphyDialog *dialog)
+void
+ephy_print_dialog_response_cb (GtkWidget *widget,
+ int response,
+ EphyDialog *dialog)
{
- EmbedPrintInfo *info;
EphyEmbed *embed;
+ EmbedPrintInfo *info;
+ gboolean only_collect_info;
- info = print_get_info (dialog);
+ only_collect_info = GPOINTER_TO_INT
+ (g_object_get_data (G_OBJECT (dialog), "only-collect-info"));
- if(EPHY_PRINT_DIALOG(dialog)->only_collect_info && EPHY_PRINT_DIALOG(dialog)->ret_info)
+ if (only_collect_info)
{
- *(EPHY_PRINT_DIALOG(dialog)->ret_info) = info;
-
- /* When in collect_info mode the caller owns the reference */
return;
}
- embed = ephy_embed_dialog_get_embed
- (EPHY_EMBED_DIALOG(dialog));
- g_return_if_fail (embed != NULL);
-
- info->preview = FALSE;
- ephy_embed_print (embed, info);
- print_free_info (info);
+ if (response == GTK_RESPONSE_OK)
+ {
+ info = ephy_print_get_print_info ();
+
+ embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG (dialog));
+ g_return_if_fail (EPHY_IS_EMBED (embed));
+
+ ephy_embed_print (embed, info);
+
+ ephy_print_info_free (info);
+ }
- g_object_unref (G_OBJECT(dialog));
+ g_object_unref (dialog);
}
static void
-print_dialog_preview (EphyDialog *dialog)
+print_filechooser_response_cb (GtkDialog *fc,
+ int response,
+ EphyDialog *dialog)
{
- EmbedPrintInfo *info;
- EphyEmbed *embed;
-
- /* Should not be called in collect_info mode */
- if(EPHY_PRINT_DIALOG(dialog)->only_collect_info && EPHY_PRINT_DIALOG(dialog)->ret_info)
+ if (response == EPHY_RESPONSE_SAVE)
{
- g_return_if_reached ();
- }
+ char *filename;
- info = print_get_info (dialog);
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc));
+ if (filename != NULL)
+ {
+ GtkWidget *entry;
+ char *converted;
- embed = ephy_embed_dialog_get_embed
- (EPHY_EMBED_DIALOG(dialog));
- g_return_if_fail (embed != NULL);
+ converted = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
- info->preview = TRUE;
- ephy_embed_print (embed, info);
- print_free_info (info);
+ entry = ephy_dialog_get_control (dialog, print_props[FILE_PROP].id);
+ gtk_entry_set_text (GTK_ENTRY (entry), converted);
- g_signal_emit (G_OBJECT (dialog), print_dialog_signals[PREVIEW], 0);
+ g_free (converted);
+ g_free (filename);
+ }
+ }
- g_object_unref (G_OBJECT(dialog));
+ gtk_widget_destroy (GTK_WIDGET (fc));
}
void
-print_cancel_button_cb (GtkWidget *widget,
- EphyDialog *dialog)
+ephy_print_dialog_browse_button_cb (GtkWidget *widget,
+ EphyDialog *dialog)
{
- if (EPHY_PRINT_DIALOG (dialog)->only_collect_info)
- {
- /* When in collect_info mode the caller owns the reference */
- return;
- }
+ GtkWidget *parent;
+ EphyFileChooser *fc;
+
+ parent = ephy_dialog_get_control (dialog, print_props[WINDOW_PROP].id);
- g_object_unref (G_OBJECT(dialog));
+ fc = ephy_file_chooser_new (_("Print to"),
+ GTK_WIDGET (parent),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ CONF_PRINT_DIR);
+
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (fc), TRUE);
+
+ g_signal_connect (GTK_DIALOG (fc), "response",
+ G_CALLBACK (print_filechooser_response_cb),
+ dialog);
+
+ gtk_widget_show (GTK_WIDGET (fc));
}
void
-print_ok_button_cb (GtkWidget *widget,
- EphyDialog *dialog)
+ephy_print_setup_dialog_close_button_cb (GtkWidget *widget,
+ EphyDialog *dialog)
{
- print_dialog_print (dialog);
+ g_object_unref (dialog);
}
-void
-print_preview_button_cb (GtkWidget *widget,
- EphyDialog *dialog)
+EphyDialog *
+ephy_print_dialog_new (GtkWidget *parent,
+ EphyEmbed *embed,
+ gboolean only_collect_info)
{
- print_dialog_preview (dialog);
+ EphyDialog *dialog;
+ GtkWidget *window;
+ GdkPixbuf *icon;
+
+ dialog = EPHY_DIALOG (g_object_new (EPHY_TYPE_EMBED_DIALOG,
+ "embed", embed,
+ NULL));
+
+ if (parent != NULL)
+ {
+ g_object_set (G_OBJECT (dialog), "parent-window", parent, NULL);
+ }
+
+ ephy_dialog_construct (dialog, print_props,
+ "print.glade", "print_dialog");
+
+ window = ephy_dialog_get_control (dialog, print_props[WINDOW_PROP].id);
+ icon = gtk_widget_render_icon (window,
+ GTK_STOCK_PRINT,
+ GTK_ICON_SIZE_MENU,
+ "print_dialog");
+ gtk_window_set_icon (GTK_WINDOW (window), icon);
+ g_object_unref (icon);
+
+ g_object_set_data (G_OBJECT (dialog), "only-collect-info",
+ GINT_TO_POINTER (only_collect_info));
+
+ return dialog;
+}
+
+EphyDialog *
+ephy_print_setup_dialog_new (void)
+{
+ EphyDialog *dialog;
+ GtkWidget *window;
+ GdkPixbuf *icon;
+
+ dialog = EPHY_DIALOG (g_object_new (EPHY_TYPE_DIALOG, NULL));
+
+ ephy_dialog_construct (dialog, setup_props,
+ "print.glade", "print_setup_dialog");
+
+ ephy_dialog_add_enum (dialog, setup_props[PAPER_PROP].id,
+ n_paper_format_enum, paper_format_enum);
+
+ window = ephy_dialog_get_control (dialog, setup_props[SETUP_WINDOW_PROP].id);
+ icon = gtk_widget_render_icon (window,
+ GTK_STOCK_PROPERTIES,
+ GTK_ICON_SIZE_MENU,
+ "print_setup_dialog");
+ gtk_window_set_icon (GTK_WINDOW (window), icon);
+ g_object_unref (icon);
+
+ return dialog;
}