aboutsummaryrefslogtreecommitdiffstats
path: root/embed/print-dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'embed/print-dialog.c')
-rwxr-xr-xembed/print-dialog.c108
1 files changed, 71 insertions, 37 deletions
diff --git a/embed/print-dialog.c b/embed/print-dialog.c
index 841804cc1..0cbe44d59 100755
--- a/embed/print-dialog.c
+++ b/embed/print-dialog.c
@@ -19,7 +19,11 @@
*/
#include "print-dialog.h"
+
+#include "ephy-command-manager.h"
#include "ephy-prefs.h"
+
+#include <gtk/gtktogglebutton.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkstock.h>
#include <libgnomevfs/gnome-vfs-utils.h>
@@ -83,7 +87,8 @@ enum
FROM_PROP,
COLOR_PROP,
ORIENTATION_PROP,
- PREVIEW_PROP
+ PREVIEW_PROP,
+ SELECTION_PROP
};
enum
@@ -114,6 +119,7 @@ EphyDialogProperty properties [] =
{ COLOR_PROP, "print_color_radiobutton", CONF_PRINT_COLOR, PT_NORMAL, NULL },
{ ORIENTATION_PROP, "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_NORMAL, NULL },
{ PREVIEW_PROP, "preview_button", NULL, PT_NORMAL, NULL },
+ { SELECTION_PROP, "selection_radiobutton", NULL, PT_NORMAL, NULL},
{ -1, NULL, NULL }
};
@@ -157,12 +163,54 @@ print_dialog_get_type (void)
}
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),
+ PREVIEW_PROP);
+ 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),
+ SELECTION_PROP);
+
+ 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),
+ ALL_PAGES_PROP);
+ 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),
@@ -214,14 +262,8 @@ print_dialog_new (EphyEmbed *embed,
if (ret_info != NULL)
{
- GtkWidget *button;
-
dialog->only_collect_info = TRUE;
dialog->ret_info = ret_info;
-
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog),
- PREVIEW_PROP);
- gtk_widget_hide (button);
}
return EPHY_DIALOG(dialog);
@@ -241,14 +283,8 @@ print_dialog_new_with_parent (GtkWidget *window,
if (ret_info != NULL)
{
- GtkWidget *button;
-
dialog->only_collect_info = TRUE;
dialog->ret_info = ret_info;
-
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog),
- PREVIEW_PROP);
- gtk_widget_hide (button);
}
return EPHY_DIALOG(dialog);
@@ -394,18 +430,17 @@ print_dialog_print (EphyDialog *dialog)
{
*(EPHY_PRINT_DIALOG(dialog)->ret_info) = info;
+ /* When in collect_info mode the caller owns the reference */
return;
}
- else
- {
- 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);
- }
+ 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);
g_object_unref (G_OBJECT(dialog));
}
@@ -416,22 +451,22 @@ print_dialog_preview (EphyDialog *dialog)
EmbedPrintInfo *info;
EphyEmbed *embed;
- info = print_get_info (dialog);
-
+ /* Should not be called in collect_info mode */
if(EPHY_PRINT_DIALOG(dialog)->only_collect_info && EPHY_PRINT_DIALOG(dialog)->ret_info)
{
- *(EPHY_PRINT_DIALOG(dialog)->ret_info) = info;
+ g_return_if_reached ();
}
- else
- {
- embed = ephy_embed_dialog_get_embed
- (EPHY_EMBED_DIALOG(dialog));
- g_return_if_fail (embed != NULL);
- info->preview = TRUE;
- ephy_embed_print (embed, info);
- print_free_info (info);
- }
+ info = print_get_info (dialog);
+
+ embed = ephy_embed_dialog_get_embed
+ (EPHY_EMBED_DIALOG(dialog));
+ g_return_if_fail (embed != NULL);
+
+ info->preview = TRUE;
+ ephy_embed_print (embed, info);
+ print_free_info (info);
+
g_signal_emit (G_OBJECT (dialog), print_dialog_signals[PREVIEW], 0);
g_object_unref (G_OBJECT(dialog));
@@ -443,6 +478,7 @@ print_cancel_button_cb (GtkWidget *widget,
{
if (EPHY_PRINT_DIALOG (dialog)->only_collect_info)
{
+ /* When in collect_info mode the caller owns the reference */
return;
}
@@ -460,7 +496,5 @@ void
print_preview_button_cb (GtkWidget *widget,
EphyDialog *dialog)
{
- //FIXME: Don't show preview button at all.
- if(!(EPHY_PRINT_DIALOG(dialog)->only_collect_info))
- print_dialog_preview (dialog);
+ print_dialog_preview (dialog);
}