xed-print-preview.c: Clean up code styling
This commit is contained in:
parent
c2eab264a3
commit
663511c1d1
|
@ -161,9 +161,7 @@ update_layout_size (XedPrintPreview *preview)
|
||||||
priv = preview->priv;
|
priv = preview->priv;
|
||||||
|
|
||||||
/* force size of the drawing area to make the scrolled window work */
|
/* force size of the drawing area to make the scrolled window work */
|
||||||
gtk_layout_set_size (GTK_LAYOUT (priv->layout),
|
gtk_layout_set_size (GTK_LAYOUT (priv->layout), priv->tile_w * priv->cols, priv->tile_h * priv->rows);
|
||||||
priv->tile_w * priv->cols,
|
|
||||||
priv->tile_h * priv->rows);
|
|
||||||
|
|
||||||
gtk_widget_queue_draw (preview->priv->layout);
|
gtk_widget_queue_draw (preview->priv->layout);
|
||||||
}
|
}
|
||||||
|
@ -254,12 +252,8 @@ set_zoom_fit_to_size (XedPrintPreview *preview)
|
||||||
|
|
||||||
priv = preview->priv;
|
priv = preview->priv;
|
||||||
|
|
||||||
g_object_get (gtk_layout_get_hadjustment (GTK_LAYOUT (priv->layout)),
|
g_object_get (gtk_layout_get_hadjustment (GTK_LAYOUT (priv->layout)), "page-size", &width, NULL);
|
||||||
"page-size", &width,
|
g_object_get (gtk_layout_get_vadjustment (GTK_LAYOUT (priv->layout)), "page-size", &height, NULL);
|
||||||
NULL);
|
|
||||||
g_object_get (gtk_layout_get_vadjustment (GTK_LAYOUT (priv->layout)),
|
|
||||||
"page-size", &height,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
width /= priv->cols;
|
width /= priv->cols;
|
||||||
height /= priv->rows;
|
height /= priv->rows;
|
||||||
|
@ -301,27 +295,25 @@ set_zoom_fit_to_size (XedPrintPreview *preview)
|
||||||
static void
|
static void
|
||||||
zoom_in (XedPrintPreview *preview)
|
zoom_in (XedPrintPreview *preview)
|
||||||
{
|
{
|
||||||
set_zoom_factor (preview,
|
set_zoom_factor (preview, preview->priv->scale * ZOOM_IN_FACTOR);
|
||||||
preview->priv->scale * ZOOM_IN_FACTOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zoom_out (XedPrintPreview *preview)
|
zoom_out (XedPrintPreview *preview)
|
||||||
{
|
{
|
||||||
set_zoom_factor (preview,
|
set_zoom_factor (preview, preview->priv->scale * ZOOM_OUT_FACTOR);
|
||||||
preview->priv->scale * ZOOM_OUT_FACTOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
goto_page (XedPrintPreview *preview, gint page)
|
goto_page (XedPrintPreview *preview,
|
||||||
|
gint page)
|
||||||
{
|
{
|
||||||
gchar c[32];
|
gchar c[32];
|
||||||
|
|
||||||
g_snprintf (c, 32, "%d", page + 1);
|
g_snprintf (c, 32, "%d", page + 1);
|
||||||
gtk_entry_set_text (GTK_ENTRY (preview->priv->page_entry), c);
|
gtk_entry_set_text (GTK_ENTRY (preview->priv->page_entry), c);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (preview->priv->prev),
|
gtk_widget_set_sensitive (GTK_WIDGET (preview->priv->prev), (page > 0) && (preview->priv->n_pages > 1));
|
||||||
(page > 0) && (preview->priv->n_pages > 1));
|
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (preview->priv->next),
|
gtk_widget_set_sensitive (GTK_WIDGET (preview->priv->next),
|
||||||
(page != (preview->priv->n_pages - 1)) &&
|
(page != (preview->priv->n_pages - 1)) &&
|
||||||
(preview->priv->n_pages > 1));
|
(preview->priv->n_pages > 1));
|
||||||
|
@ -330,9 +322,11 @@ goto_page (XedPrintPreview *preview, gint page)
|
||||||
{
|
{
|
||||||
preview->priv->cur_page = page;
|
preview->priv->cur_page = page;
|
||||||
if (preview->priv->n_pages > 0)
|
if (preview->priv->n_pages > 0)
|
||||||
|
{
|
||||||
gtk_widget_queue_draw (preview->priv->layout);
|
gtk_widget_queue_draw (preview->priv->layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prev_button_clicked (GtkWidget *button,
|
prev_button_clicked (GtkWidget *button,
|
||||||
|
@ -344,9 +338,13 @@ prev_button_clicked (GtkWidget *button,
|
||||||
event = gtk_get_current_event ();
|
event = gtk_get_current_event ();
|
||||||
|
|
||||||
if (event->button.state & GDK_SHIFT_MASK)
|
if (event->button.state & GDK_SHIFT_MASK)
|
||||||
|
{
|
||||||
page = 0;
|
page = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
page = preview->priv->cur_page - preview->priv->rows * preview->priv->cols;
|
page = preview->priv->cur_page - preview->priv->rows * preview->priv->cols;
|
||||||
|
}
|
||||||
|
|
||||||
goto_page (preview, MAX (page, 0));
|
goto_page (preview, MAX (page, 0));
|
||||||
|
|
||||||
|
@ -363,9 +361,13 @@ next_button_clicked (GtkWidget *button,
|
||||||
event = gtk_get_current_event ();
|
event = gtk_get_current_event ();
|
||||||
|
|
||||||
if (event->button.state & GDK_SHIFT_MASK)
|
if (event->button.state & GDK_SHIFT_MASK)
|
||||||
|
{
|
||||||
page = preview->priv->n_pages - 1;
|
page = preview->priv->n_pages - 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
page = preview->priv->cur_page + preview->priv->rows * preview->priv->cols;
|
page = preview->priv->cur_page + preview->priv->rows * preview->priv->cols;
|
||||||
|
}
|
||||||
|
|
||||||
goto_page (preview, MIN (page, preview->priv->n_pages - 1));
|
goto_page (preview, MIN (page, preview->priv->n_pages - 1));
|
||||||
|
|
||||||
|
@ -442,25 +444,29 @@ page_entry_focus_out (GtkWidget *widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_1x1_clicked (GtkMenuItem *i, XedPrintPreview *preview)
|
on_1x1_clicked (GtkMenuItem *i,
|
||||||
|
XedPrintPreview *preview)
|
||||||
{
|
{
|
||||||
set_rows_and_cols (preview, 1, 1);
|
set_rows_and_cols (preview, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_1x2_clicked (GtkMenuItem *i, XedPrintPreview *preview)
|
on_1x2_clicked (GtkMenuItem *i,
|
||||||
|
XedPrintPreview *preview)
|
||||||
{
|
{
|
||||||
set_rows_and_cols (preview, 1, 2);
|
set_rows_and_cols (preview, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_2x1_clicked (GtkMenuItem *i, XedPrintPreview *preview)
|
on_2x1_clicked (GtkMenuItem *i,
|
||||||
|
XedPrintPreview *preview)
|
||||||
{
|
{
|
||||||
set_rows_and_cols (preview, 2, 1);
|
set_rows_and_cols (preview, 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_2x2_clicked (GtkMenuItem *i, XedPrintPreview *preview)
|
on_2x2_clicked (GtkMenuItem *i,
|
||||||
|
XedPrintPreview *preview)
|
||||||
{
|
{
|
||||||
set_rows_and_cols (preview, 2, 2);
|
set_rows_and_cols (preview, 2, 2);
|
||||||
}
|
}
|
||||||
|
@ -473,10 +479,8 @@ multi_button_clicked (GtkWidget *button,
|
||||||
|
|
||||||
m = gtk_menu_new ();
|
m = gtk_menu_new ();
|
||||||
gtk_widget_show (m);
|
gtk_widget_show (m);
|
||||||
g_signal_connect (m,
|
g_signal_connect (m, "selection_done",
|
||||||
"selection_done",
|
G_CALLBACK (gtk_widget_destroy), m);
|
||||||
G_CALLBACK (gtk_widget_destroy),
|
|
||||||
m);
|
|
||||||
|
|
||||||
i = gtk_menu_item_new_with_label ("1x1");
|
i = gtk_menu_item_new_with_label ("1x1");
|
||||||
gtk_widget_show (i);
|
gtk_widget_show (i);
|
||||||
|
@ -498,9 +502,7 @@ multi_button_clicked (GtkWidget *button,
|
||||||
gtk_menu_attach (GTK_MENU (m), i, 1, 2, 1, 2);
|
gtk_menu_attach (GTK_MENU (m), i, 1, 2, 1, 2);
|
||||||
g_signal_connect (i, "activate", G_CALLBACK (on_2x2_clicked), preview);
|
g_signal_connect (i, "activate", G_CALLBACK (on_2x2_clicked), preview);
|
||||||
|
|
||||||
gtk_menu_popup (GTK_MENU (m),
|
gtk_menu_popup (GTK_MENU (m), NULL, NULL, NULL, preview, 0, GDK_CURRENT_TIME);
|
||||||
NULL, NULL, NULL, preview, 0,
|
|
||||||
GDK_CURRENT_TIME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -550,35 +552,26 @@ create_bar (XedPrintPreview *preview)
|
||||||
priv = preview->priv;
|
priv = preview->priv;
|
||||||
|
|
||||||
toolbar = gtk_toolbar_new ();
|
toolbar = gtk_toolbar_new ();
|
||||||
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
|
||||||
GTK_TOOLBAR_BOTH_HORIZ);
|
|
||||||
gtk_widget_show (toolbar);
|
gtk_widget_show (toolbar);
|
||||||
gtk_box_pack_start (GTK_BOX (preview),
|
gtk_box_pack_start (GTK_BOX (preview), toolbar, FALSE, FALSE, 0);
|
||||||
toolbar,
|
|
||||||
FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
priv->prev = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
|
priv->prev = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
|
||||||
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->prev),
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->prev), "P_revious Page");
|
||||||
"P_revious Page");
|
|
||||||
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->prev), TRUE);
|
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->prev), TRUE);
|
||||||
gtk_tool_item_set_tooltip_text (priv->prev, _("Show the previous page"));
|
gtk_tool_item_set_tooltip_text (priv->prev, _("Show the previous page"));
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->prev, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->prev, -1);
|
||||||
g_signal_connect (priv->prev,
|
g_signal_connect (priv->prev, "clicked",
|
||||||
"clicked",
|
G_CALLBACK (prev_button_clicked), preview);
|
||||||
G_CALLBACK (prev_button_clicked),
|
|
||||||
preview);
|
|
||||||
gtk_widget_show (GTK_WIDGET (priv->prev));
|
gtk_widget_show (GTK_WIDGET (priv->prev));
|
||||||
|
|
||||||
priv->next = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
|
priv->next = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
|
||||||
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->next),
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->next), "_Next Page");
|
||||||
"_Next Page");
|
|
||||||
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->next), TRUE);
|
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->next), TRUE);
|
||||||
gtk_tool_item_set_tooltip_text (priv->next, _("Show the next page"));
|
gtk_tool_item_set_tooltip_text (priv->next, _("Show the next page"));
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->next, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->next, -1);
|
||||||
g_signal_connect (priv->next,
|
g_signal_connect (priv->next, "clicked",
|
||||||
"clicked",
|
G_CALLBACK (next_button_clicked), preview);
|
||||||
G_CALLBACK (next_button_clicked),
|
|
||||||
preview);
|
|
||||||
gtk_widget_show (GTK_WIDGET (priv->next));
|
gtk_widget_show (GTK_WIDGET (priv->next));
|
||||||
|
|
||||||
i = gtk_separator_tool_item_new ();
|
i = gtk_separator_tool_item_new ();
|
||||||
|
@ -591,34 +584,22 @@ create_bar (XedPrintPreview *preview)
|
||||||
gtk_entry_set_max_length (GTK_ENTRY (priv->page_entry), 6);
|
gtk_entry_set_max_length (GTK_ENTRY (priv->page_entry), 6);
|
||||||
gtk_widget_set_tooltip_text (priv->page_entry, _("Current page (Alt+P)"));
|
gtk_widget_set_tooltip_text (priv->page_entry, _("Current page (Alt+P)"));
|
||||||
|
|
||||||
g_signal_connect (priv->page_entry,
|
g_signal_connect (priv->page_entry, "activate",
|
||||||
"activate",
|
G_CALLBACK (page_entry_activated), preview);
|
||||||
G_CALLBACK (page_entry_activated),
|
g_signal_connect (priv->page_entry, "insert-text",
|
||||||
preview);
|
G_CALLBACK (page_entry_insert_text), NULL);
|
||||||
g_signal_connect (priv->page_entry,
|
g_signal_connect (priv->page_entry, "focus-out-event",
|
||||||
"insert-text",
|
G_CALLBACK (page_entry_focus_out), preview);
|
||||||
G_CALLBACK (page_entry_insert_text),
|
|
||||||
NULL);
|
|
||||||
g_signal_connect (priv->page_entry,
|
|
||||||
"focus-out-event",
|
|
||||||
G_CALLBACK (page_entry_focus_out),
|
|
||||||
preview);
|
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (status),
|
gtk_box_pack_start (GTK_BOX (status), priv->page_entry, FALSE, FALSE, 0);
|
||||||
priv->page_entry,
|
|
||||||
FALSE, FALSE, 0);
|
|
||||||
/* gtk_label_set_mnemonic_widget ((GtkLabel *) l, mp->priv->page_entry); */
|
/* gtk_label_set_mnemonic_widget ((GtkLabel *) l, mp->priv->page_entry); */
|
||||||
|
|
||||||
/* We are displaying 'XXX of XXX'. */
|
/* We are displaying 'XXX of XXX'. */
|
||||||
gtk_box_pack_start (GTK_BOX (status),
|
|
||||||
/* Translators: the "of" from "1 of 19" in print preview. */
|
/* Translators: the "of" from "1 of 19" in print preview. */
|
||||||
gtk_label_new (_("of")),
|
gtk_box_pack_start (GTK_BOX (status), gtk_label_new (_("of")), FALSE, FALSE, 0);
|
||||||
FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
priv->last = gtk_label_new ("");
|
priv->last = gtk_label_new ("");
|
||||||
gtk_box_pack_start (GTK_BOX (status),
|
gtk_box_pack_start (GTK_BOX (status), priv->last, FALSE, FALSE, 0);
|
||||||
priv->last,
|
|
||||||
FALSE, FALSE, 0);
|
|
||||||
atko = gtk_widget_get_accessible (priv->last);
|
atko = gtk_widget_get_accessible (priv->last);
|
||||||
atk_object_set_name (atko, _("Page total"));
|
atk_object_set_name (atko, _("Page total"));
|
||||||
atk_object_set_description (atko, _("The total number of pages in the document"));
|
atk_object_set_description (atko, _("The total number of pages in the document"));
|
||||||
|
@ -635,15 +616,12 @@ create_bar (XedPrintPreview *preview)
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), i, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), i, -1);
|
||||||
|
|
||||||
priv->multi = gtk_tool_button_new_from_stock (GTK_STOCK_DND_MULTIPLE);
|
priv->multi = gtk_tool_button_new_from_stock (GTK_STOCK_DND_MULTIPLE);
|
||||||
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->multi),
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->multi), "_Show Multiple Pages");
|
||||||
"_Show Multiple Pages");
|
|
||||||
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->multi), TRUE);
|
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->multi), TRUE);
|
||||||
gtk_tool_item_set_tooltip_text (priv->multi, _("Show multiple pages"));
|
gtk_tool_item_set_tooltip_text (priv->multi, _("Show multiple pages"));
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->multi, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->multi, -1);
|
||||||
g_signal_connect (priv->multi,
|
g_signal_connect (priv->multi, "clicked",
|
||||||
"clicked",
|
G_CALLBACK (multi_button_clicked), preview);
|
||||||
G_CALLBACK (multi_button_clicked),
|
|
||||||
preview);
|
|
||||||
gtk_widget_show (GTK_WIDGET (priv->multi));
|
gtk_widget_show (GTK_WIDGET (priv->multi));
|
||||||
|
|
||||||
i = gtk_separator_tool_item_new ();
|
i = gtk_separator_tool_item_new ();
|
||||||
|
@ -653,37 +631,29 @@ create_bar (XedPrintPreview *preview)
|
||||||
priv->zoom_one = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_100);
|
priv->zoom_one = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_100);
|
||||||
gtk_tool_item_set_tooltip_text (priv->zoom_one, _("Zoom 1:1"));
|
gtk_tool_item_set_tooltip_text (priv->zoom_one, _("Zoom 1:1"));
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_one, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_one, -1);
|
||||||
g_signal_connect (priv->zoom_one,
|
g_signal_connect (priv->zoom_one, "clicked",
|
||||||
"clicked",
|
G_CALLBACK (zoom_one_button_clicked), preview);
|
||||||
G_CALLBACK (zoom_one_button_clicked),
|
|
||||||
preview);
|
|
||||||
gtk_widget_show (GTK_WIDGET (priv->zoom_one));
|
gtk_widget_show (GTK_WIDGET (priv->zoom_one));
|
||||||
|
|
||||||
priv->zoom_fit = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
|
priv->zoom_fit = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
|
||||||
gtk_tool_item_set_tooltip_text (priv->zoom_fit, _("Zoom to fit the whole page"));
|
gtk_tool_item_set_tooltip_text (priv->zoom_fit, _("Zoom to fit the whole page"));
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_fit, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_fit, -1);
|
||||||
g_signal_connect (priv->zoom_fit,
|
g_signal_connect (priv->zoom_fit, "clicked",
|
||||||
"clicked",
|
G_CALLBACK (zoom_fit_button_clicked), preview);
|
||||||
G_CALLBACK (zoom_fit_button_clicked),
|
|
||||||
preview);
|
|
||||||
gtk_widget_show (GTK_WIDGET (priv->zoom_fit));
|
gtk_widget_show (GTK_WIDGET (priv->zoom_fit));
|
||||||
|
|
||||||
priv->zoom_in = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_IN);
|
priv->zoom_in = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_IN);
|
||||||
gtk_tool_item_set_tooltip_text (priv->zoom_in, _("Zoom the page in"));
|
gtk_tool_item_set_tooltip_text (priv->zoom_in, _("Zoom the page in"));
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_in, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_in, -1);
|
||||||
g_signal_connect (priv->zoom_in,
|
g_signal_connect (priv->zoom_in, "clicked",
|
||||||
"clicked",
|
G_CALLBACK (zoom_in_button_clicked), preview);
|
||||||
G_CALLBACK (zoom_in_button_clicked),
|
|
||||||
preview);
|
|
||||||
gtk_widget_show (GTK_WIDGET (priv->zoom_in));
|
gtk_widget_show (GTK_WIDGET (priv->zoom_in));
|
||||||
|
|
||||||
priv->zoom_out = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
|
priv->zoom_out = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
|
||||||
gtk_tool_item_set_tooltip_text (priv->zoom_out, _("Zoom the page out"));
|
gtk_tool_item_set_tooltip_text (priv->zoom_out, _("Zoom the page out"));
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_out, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->zoom_out, -1);
|
||||||
g_signal_connect (priv->zoom_out,
|
g_signal_connect (priv->zoom_out, "clicked",
|
||||||
"clicked",
|
G_CALLBACK (zoom_out_button_clicked), preview);
|
||||||
G_CALLBACK (zoom_out_button_clicked),
|
|
||||||
preview);
|
|
||||||
gtk_widget_show (GTK_WIDGET (priv->zoom_out));
|
gtk_widget_show (GTK_WIDGET (priv->zoom_out));
|
||||||
|
|
||||||
i = gtk_separator_tool_item_new ();
|
i = gtk_separator_tool_item_new ();
|
||||||
|
@ -723,7 +693,9 @@ get_page_at_coords (XedPrintPreview *preview,
|
||||||
priv = preview->priv;
|
priv = preview->priv;
|
||||||
|
|
||||||
if (priv->tile_h <= 0 || priv->tile_h <= 0)
|
if (priv->tile_h <= 0 || priv->tile_h <= 0)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (priv->layout));
|
hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (priv->layout));
|
||||||
vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (priv->layout));
|
vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (priv->layout));
|
||||||
|
@ -735,13 +707,17 @@ get_page_at_coords (XedPrintPreview *preview,
|
||||||
c = 1 + x / (priv->tile_w);
|
c = 1 + x / (priv->tile_w);
|
||||||
|
|
||||||
if (c > priv->cols)
|
if (c > priv->cols)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
pg = get_first_page_displayed (preview) - 1;
|
pg = get_first_page_displayed (preview) - 1;
|
||||||
pg += (r - 1) * priv->cols + c;
|
pg += (r - 1) * priv->cols + c;
|
||||||
|
|
||||||
if (pg >= priv->n_pages)
|
if (pg >= priv->n_pages)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: we could try to be picky and check
|
/* FIXME: we could try to be picky and check
|
||||||
* if we actually are inside the page */
|
* if we actually are inside the page */
|
||||||
|
@ -761,7 +737,9 @@ preview_layout_query_tooltip (GtkWidget *widget,
|
||||||
|
|
||||||
pg = get_page_at_coords (preview, x, y);
|
pg = get_page_at_coords (preview, x, y);
|
||||||
if (pg < 0)
|
if (pg < 0)
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
tip = g_strdup_printf (_("Page %d of %d"), pg + 1, preview->priv->n_pages);
|
tip = g_strdup_printf (_("Page %d of %d"), pg + 1, preview->priv->n_pages);
|
||||||
gtk_tooltip_set_text (tooltip, tip);
|
gtk_tooltip_set_text (tooltip, tip);
|
||||||
|
@ -809,7 +787,8 @@ preview_layout_key_press (GtkWidget *widget,
|
||||||
hstep = 10;
|
hstep = 10;
|
||||||
vstep = 10;
|
vstep = 10;
|
||||||
|
|
||||||
switch (event->keyval) {
|
switch (event->keyval)
|
||||||
|
{
|
||||||
case '1':
|
case '1':
|
||||||
set_zoom_fit_to_size (preview);
|
set_zoom_fit_to_size (preview);
|
||||||
break;
|
break;
|
||||||
|
@ -957,16 +936,12 @@ create_preview_layout (XedPrintPreview *preview)
|
||||||
|
|
||||||
gtk_widget_set_can_focus (priv->layout, TRUE);
|
gtk_widget_set_can_focus (priv->layout, TRUE);
|
||||||
|
|
||||||
g_signal_connect (priv->layout,
|
g_signal_connect (priv->layout, "key-press-event",
|
||||||
"key-press-event",
|
G_CALLBACK (preview_layout_key_press), preview);
|
||||||
G_CALLBACK (preview_layout_key_press),
|
|
||||||
preview);
|
|
||||||
|
|
||||||
g_object_set (priv->layout, "has-tooltip", TRUE, NULL);
|
g_object_set (priv->layout, "has-tooltip", TRUE, NULL);
|
||||||
g_signal_connect (priv->layout,
|
g_signal_connect (priv->layout, "query-tooltip",
|
||||||
"query-tooltip",
|
G_CALLBACK (preview_layout_query_tooltip), preview);
|
||||||
G_CALLBACK (preview_layout_query_tooltip),
|
|
||||||
preview);
|
|
||||||
|
|
||||||
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
||||||
|
@ -974,9 +949,7 @@ create_preview_layout (XedPrintPreview *preview)
|
||||||
GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_AUTOMATIC);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (priv->scrolled_window), priv->layout);
|
gtk_container_add (GTK_CONTAINER (priv->scrolled_window), priv->layout);
|
||||||
gtk_box_pack_end (GTK_BOX (preview),
|
gtk_box_pack_end (GTK_BOX (preview), priv->scrolled_window, TRUE, TRUE, 0);
|
||||||
priv->scrolled_window,
|
|
||||||
TRUE, TRUE, 0);
|
|
||||||
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (priv->scrolled_window));
|
gtk_widget_show_all (GTK_WIDGET (priv->scrolled_window));
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (priv->layout));
|
gtk_widget_grab_focus (GTK_WIDGET (priv->layout));
|
||||||
|
@ -987,9 +960,7 @@ xed_print_preview_init (XedPrintPreview *preview)
|
||||||
{
|
{
|
||||||
XedPrintPreviewPrivate *priv;
|
XedPrintPreviewPrivate *priv;
|
||||||
|
|
||||||
priv = G_TYPE_INSTANCE_GET_PRIVATE (preview,
|
priv = G_TYPE_INSTANCE_GET_PRIVATE (preview, XED_TYPE_PRINT_PREVIEW, XedPrintPreviewPrivate);
|
||||||
XED_TYPE_PRINT_PREVIEW,
|
|
||||||
XedPrintPreviewPrivate);
|
|
||||||
|
|
||||||
preview->priv = priv;
|
preview->priv = priv;
|
||||||
|
|
||||||
|
@ -997,8 +968,7 @@ xed_print_preview_init (XedPrintPreview *preview)
|
||||||
priv->context = NULL;
|
priv->context = NULL;
|
||||||
priv->gtk_preview = NULL;
|
priv->gtk_preview = NULL;
|
||||||
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (preview),
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (preview), GTK_ORIENTATION_VERTICAL);
|
||||||
GTK_ORIENTATION_VERTICAL);
|
|
||||||
|
|
||||||
create_bar (preview);
|
create_bar (preview);
|
||||||
create_preview_layout (preview);
|
create_preview_layout (preview);
|
||||||
|
@ -1039,8 +1009,7 @@ draw_page_content (cairo_t *cr,
|
||||||
preview->priv->dpi,
|
preview->priv->dpi,
|
||||||
preview->priv->dpi);
|
preview->priv->dpi);
|
||||||
|
|
||||||
gtk_print_operation_preview_render_page (preview->priv->gtk_preview,
|
gtk_print_operation_preview_render_page (preview->priv->gtk_preview, page_number);
|
||||||
page_number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For the frame, we scale and rotate manually, since
|
/* For the frame, we scale and rotate manually, since
|
||||||
|
@ -1071,16 +1040,12 @@ draw_page_frame (cairo_t *cr,
|
||||||
|
|
||||||
/* drop shadow */
|
/* drop shadow */
|
||||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||||
cairo_rectangle (cr,
|
cairo_rectangle (cr, PAGE_SHADOW_OFFSET, PAGE_SHADOW_OFFSET, w, h);
|
||||||
PAGE_SHADOW_OFFSET, PAGE_SHADOW_OFFSET,
|
|
||||||
w, h);
|
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
/* page frame */
|
/* page frame */
|
||||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||||
cairo_rectangle (cr,
|
cairo_rectangle (cr, 0, 0, w, h);
|
||||||
0, 0,
|
|
||||||
w, h);
|
|
||||||
cairo_fill_preserve (cr);
|
cairo_fill_preserve (cr);
|
||||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||||
cairo_set_line_width (cr, 1);
|
cairo_set_line_width (cr, 1);
|
||||||
|
@ -1120,7 +1085,9 @@ preview_draw (GtkWidget *widget,
|
||||||
bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (priv->layout));
|
bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (priv->layout));
|
||||||
|
|
||||||
if (!gtk_cairo_should_draw_window (cr, bin_window))
|
if (!gtk_cairo_should_draw_window (cr, bin_window))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
|
||||||
|
@ -1133,20 +1100,17 @@ preview_draw (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
for (j = 0; j < priv->rows; ++j)
|
for (j = 0; j < priv->rows; ++j)
|
||||||
{
|
{
|
||||||
if (!gtk_print_operation_preview_is_selected (priv->gtk_preview,
|
if (!gtk_print_operation_preview_is_selected (priv->gtk_preview, pg))
|
||||||
pg))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pg == priv->n_pages)
|
if (pg == priv->n_pages)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
draw_page (cr,
|
draw_page (cr, j * priv->tile_w, i * priv->tile_h, pg, preview);
|
||||||
j * priv->tile_w,
|
|
||||||
i * priv->tile_h,
|
|
||||||
pg,
|
|
||||||
preview);
|
|
||||||
|
|
||||||
++pg;
|
++pg;
|
||||||
}
|
}
|
||||||
|
@ -1207,10 +1171,8 @@ preview_ready (GtkPrintOperationPreview *gtk_preview,
|
||||||
set_zoom_factor (preview, 1.0);
|
set_zoom_factor (preview, 1.0);
|
||||||
|
|
||||||
/* let the default gtklayout handler clear the background */
|
/* let the default gtklayout handler clear the background */
|
||||||
g_signal_connect_after (preview->priv->layout,
|
g_signal_connect_after (preview->priv->layout, "draw",
|
||||||
"draw",
|
G_CALLBACK (preview_draw), preview);
|
||||||
G_CALLBACK (preview_draw),
|
|
||||||
preview);
|
|
||||||
|
|
||||||
gtk_widget_queue_draw (preview->priv->layout);
|
gtk_widget_queue_draw (preview->priv->layout);
|
||||||
}
|
}
|
||||||
|
@ -1263,8 +1225,7 @@ create_preview_surface_platform (GtkPaperSize *paper_size,
|
||||||
|
|
||||||
*dpi_x = *dpi_y = PRINTER_DPI;
|
*dpi_x = *dpi_y = PRINTER_DPI;
|
||||||
|
|
||||||
sf = cairo_pdf_surface_create_for_stream (dummy_write_func, NULL,
|
sf = cairo_pdf_surface_create_for_stream (dummy_write_func, NULL, width, height);
|
||||||
width, height);
|
|
||||||
return sf;
|
return sf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue