* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "main.h"
#include "print.h"
+#include <cstddef>
+
+#include <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdk.h>
+#include <glib-object.h>
+#include <pango/pango.h>
+#include <pango/pangocairo.h>
+
+#include "compat.h"
+#include "debug.h"
#include "exif.h"
#include "filedata.h"
#include "image-load.h"
+#include "intl.h"
+#include "main-defines.h"
+#include "options.h"
#include "osd.h"
#include "pixbuf-util.h"
-#include "ui-misc.h"
#include "ui-fileops.h"
+#include "ui-misc.h"
#define PRINT_SETTINGS "print_settings" // filename save printer settings
#define PAGE_SETUP "page_setup" // filename save page setup
/* method to use when scaling down image data */
#define PRINT_MAX_INTERP GDK_INTERP_BILINEAR
+namespace
+{
+
+constexpr gint PRE_FORMATTED_COLUMNS = 4;
+
+} // namespace
+
/* reverse order is important */
-typedef enum {
+enum TextPosition {
FOOTER_2,
FOOTER_1,
HEADER_2,
HEADER_1
-} TextPosition;
+};
-typedef struct _PrintWindow PrintWindow;
-struct _PrintWindow
+struct PrintWindow
{
GtkWidget *vbox;
GList *source_selection;
static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
GdkPixbuf *pixbuf;
pixbuf = image_loader_get_pixbuf(il);
pw->print_pixbuf_queue = g_list_append(pw->print_pixbuf_queue, pixbuf);
image_loader_free(pw->job_loader);
- pw->job_loader = NULL;
+ pw->job_loader = nullptr;
pw->job_page++;
static gboolean print_job_render_image(PrintWindow *pw)
{
- FileData *fd = NULL;
+ FileData *fd = nullptr;
- fd = g_list_nth_data(pw->source_selection, pw->job_page);
+ fd = static_cast<FileData *>(g_list_nth_data(pw->source_selection, pw->job_page));
if (!fd) return FALSE;
image_loader_free(pw->job_loader);
- pw->job_loader = NULL;
+ pw->job_loader = nullptr;
pw->job_loader = image_loader_new(fd);
g_signal_connect(G_OBJECT(pw->job_loader), "done",
if (!image_loader_start(pw->job_loader))
{
image_loader_free(pw->job_loader);
- pw->job_loader= NULL;
+ pw->job_loader= nullptr;
}
return TRUE;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
+static void font_activated_cb(GtkFontChooser *widget, gchar *fontname, gpointer option)
+{
+ option = g_strdup(fontname);
+
+ g_free(fontname);
+
+ gq_gtk_widget_destroy(GTK_WIDGET(widget));
+}
+#pragma GCC diagnostic pop
+
+static void font_response_cb(GtkDialog *dialog, int response_id, gpointer option)
+{
+ gchar *font;
+
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ font = gtk_font_chooser_get_font(GTK_FONT_CHOOSER(dialog));
+ g_free(option);
+ option = g_strdup(font);
+ g_free(font);
+ }
+
+ gq_gtk_widget_destroy(GTK_WIDGET(dialog));
+}
static void print_set_font_cb(GtkWidget *widget, gpointer data)
{
gpointer option;
+ GtkWidget *dialog;
- if (g_strcmp0(data, "Image text font") == 0)
+ if (g_strcmp0(static_cast<const gchar *>(data), "Image text font") == 0)
{
option = options->printer.image_font;
}
option = options->printer.page_font;
}
- GtkWidget *dialog;
- char *font;
- PangoFontDescription *font_desc;
+ dialog = gtk_font_chooser_dialog_new(static_cast<const gchar *>(data), GTK_WINDOW(gtk_widget_get_toplevel(widget)));
+ gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+ gtk_font_chooser_set_font(GTK_FONT_CHOOSER(dialog), static_cast<const gchar *>(option));
- dialog = gtk_font_chooser_dialog_new(data, GTK_WINDOW(gtk_widget_get_toplevel(widget)));
- gtk_font_chooser_set_font(GTK_FONT_CHOOSER(dialog), option);
+ g_signal_connect(dialog, "font-activated", G_CALLBACK(font_activated_cb), option);
+ g_signal_connect(dialog, "response", G_CALLBACK(font_response_cb), option);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL)
- {
- font_desc = gtk_font_chooser_get_font_desc(GTK_FONT_CHOOSER(dialog));
- font = pango_font_description_to_string(font_desc);
- g_free(option);
- option = g_strdup(font);
- g_free(font);
- }
-
- gtk_widget_destroy(dialog);
+ gtk_widget_show(dialog);
}
static gint set_toggle(GSList *list, TextPosition pos)
GtkToggleButton *new_sel;
gint new_pos = - 1;
- current_sel = g_slist_nth(list, pos)->data;
+ current_sel = static_cast<GtkToggleButton *>(g_slist_nth(list, pos)->data);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(current_sel)))
{
new_pos = (pos - 1);
{
new_pos = HEADER_1;
}
- new_sel = g_slist_nth(list, new_pos)->data;
+ new_sel = static_cast<GtkToggleButton *>(g_slist_nth(list, new_pos)->data);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(new_sel), TRUE);
}
return new_pos;
static void image_text_position_h1_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
static void image_text_position_h2_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
static void image_text_position_f1_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
static void image_text_position_f2_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
static void page_text_position_h1_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
static void page_text_position_h2_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
static void page_text_position_f1_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
static void page_text_position_f2_cb(GtkWidget *widget, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
gint new_set;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
*template_string = g_strdup(value);
}
-static void image_text_template_view_changed_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void image_text_template_view_changed_cb(GtkWidget *, gpointer data)
{
GtkWidget *pTextView;
GtkTextBuffer *pTextBuffer;
gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE));
}
-#define PRE_FORMATTED_COLUMNS 4
static void print_text_menu(GtkWidget *box, PrintWindow *pw)
{
GtkWidget *group;
pref_checkbox_link_sensitivity(image_text_button, subgroup);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start(GTK_BOX(subgroup), hbox, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(subgroup), hbox, FALSE, FALSE, 0);
/* order is important */
- button1 = pref_radiobutton_new(hbox, NULL, "Header 1",
+ button1 = pref_radiobutton_new(hbox, nullptr, _("Header 1"),
options->printer.image_text_position == HEADER_1,
G_CALLBACK(image_text_position_h1_cb), pw);
- button1 = pref_radiobutton_new(hbox, button1, "Header 2",
+ button1 = pref_radiobutton_new(hbox, button1, _("Header 2"),
options->printer.image_text_position == HEADER_2,
G_CALLBACK(image_text_position_h2_cb), pw);
- button1 = pref_radiobutton_new(hbox, button1, "Footer 1",
+ button1 = pref_radiobutton_new(hbox, button1, _("Footer 1"),
options->printer.image_text_position == FOOTER_1,
G_CALLBACK(image_text_position_f1_cb), pw);
- button1 = pref_radiobutton_new(hbox, button1, "Footer 2",
+ button1 = pref_radiobutton_new(hbox, button1, _("Footer 2"),
options->printer.image_text_position == FOOTER_2,
G_CALLBACK(image_text_position_f2_cb), pw);
gtk_widget_show(hbox);
image_text_template_view = gtk_text_view_new();
scrolled_pre_formatted = osd_new(PRE_FORMATTED_COLUMNS, image_text_template_view);
- gtk_box_pack_start(GTK_BOX(subgroup), scrolled_pre_formatted, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(subgroup), scrolled_pre_formatted, FALSE, FALSE, 0);
gtk_widget_show(scrolled_pre_formatted);
gtk_widget_show(subgroup);
gtk_widget_set_tooltip_markup(image_text_template_view,
_("Extensive formatting options are shown in the Help file"));
- scrolled = gtk_scrolled_window_new(NULL, NULL);
+ scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
gtk_widget_set_size_request(scrolled, 200, 50);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
+ gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(subgroup), scrolled, TRUE, TRUE, 5);
+ gq_gtk_box_pack_start(GTK_BOX(subgroup), scrolled, TRUE, TRUE, 5);
gtk_widget_show(scrolled);
- gtk_container_add(GTK_CONTAINER(scrolled), image_text_template_view);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), image_text_template_view);
gtk_widget_show(image_text_template_view);
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(image_text_template_view));
hbox = pref_box_new(subgroup, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
- button = pref_button_new(NULL, GTK_STOCK_SELECT_FONT, _("Font"), FALSE,
- G_CALLBACK(print_set_font_cb), "Image text font");
+ button = pref_button_new(nullptr, GQ_ICON_SELECT_FONT, _("Font"),
+ G_CALLBACK(print_set_font_cb), const_cast<char *>("Image text font"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
pref_spacer(group, PREF_PAD_GAP);
pref_checkbox_link_sensitivity(page_text_button, subgroup);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start(GTK_BOX(subgroup), hbox, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(subgroup), hbox, FALSE, FALSE, 0);
/* order is important */
- button2 = pref_radiobutton_new(hbox, NULL, "Header 1",
+ button2 = pref_radiobutton_new(hbox, nullptr, _("Header 1"),
options->printer.page_text_position == HEADER_1,
G_CALLBACK(page_text_position_h1_cb), pw);
- button2 = pref_radiobutton_new(hbox, button2, "Header 2",
+ button2 = pref_radiobutton_new(hbox, button2, _("Header 2"),
options->printer.page_text_position == HEADER_2,
G_CALLBACK(page_text_position_h2_cb), pw);
- button2 = pref_radiobutton_new(hbox, button2, "Footer 1",
+ button2 = pref_radiobutton_new(hbox, button2, _("Footer 1"),
options->printer.page_text_position == FOOTER_1,
G_CALLBACK(page_text_position_f1_cb), pw);
- button2 = pref_radiobutton_new(hbox, button2, "Footer 2",
+ button2 = pref_radiobutton_new(hbox, button2, _("Footer 2"),
options->printer.page_text_position == FOOTER_2,
G_CALLBACK(page_text_position_f2_cb), pw);
gtk_widget_show(hbox);
pw->page_group = (gtk_radio_button_get_group(GTK_RADIO_BUTTON(button2)));
- scrolled = gtk_scrolled_window_new(NULL, NULL);
+ scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
gtk_widget_set_size_request(scrolled, 50, 50);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
+ gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(subgroup), scrolled, TRUE, TRUE, 5);
+ gq_gtk_box_pack_start(GTK_BOX(subgroup), scrolled, TRUE, TRUE, 5);
gtk_widget_show(scrolled);
page_text_view = gtk_text_view_new();
g_object_ref(pw->page_text);
gtk_widget_set_tooltip_markup(page_text_view, (_("Text shown on each page of a single or multi-page print job")));
- gtk_container_add(GTK_CONTAINER(scrolled), page_text_view);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), page_text_view);
gtk_widget_show(page_text_view);
hbox = pref_box_new(subgroup, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
- button = pref_button_new(NULL, GTK_STOCK_SELECT_FONT, _("Font"), FALSE,
- G_CALLBACK(print_set_font_cb), "Page text font");
+ button = pref_button_new(nullptr, GQ_ICON_SELECT_FONT, _("Font"),
+ G_CALLBACK(print_set_font_cb), const_cast<char *>("Page text font"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
}
-static gboolean paginate_cb(GtkPrintOperation *UNUSED(operation),
- GtkPrintContext *UNUSED(context),
- gpointer data)
+static gboolean paginate_cb(GtkPrintOperation *, GtkPrintContext *, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
if (pw->job_render_finished)
{
return TRUE;
}
- else
- {
- return FALSE;
- }
+
+ return FALSE;
}
gchar *form_image_text(const gchar *template_string, FileData *fd, PrintWindow *pw, gint page_nr, gint total)
{
const gchar *name;
- gchar *text = NULL;
+ gchar *text = nullptr;
GHashTable *vars;
gchar *window_title;
gchar *delimiter;
gchar *collection_name;
- if (!fd) return NULL;
+ if (!fd) return nullptr;
name = fd->name;
- vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+ vars = g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, g_free);
window_title = g_strdup(gtk_window_get_title(GTK_WINDOW(pw->parent)));
delimiter = g_strstr_len(window_title, -1, " - Collection - ");
}
else
{
- collection_name = NULL;
+ collection_name = nullptr;
}
g_free(window_title);
osd_template_insert(vars, "number", g_strdup_printf("%d", page_nr + 1), OSDT_NO_DUP);
osd_template_insert(vars, "total", g_strdup_printf("%d", total), OSDT_NO_DUP);
- osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
- osd_template_insert(vars, "date", fd ? ((gchar *) text_from_time(fd->date)) : "", OSDT_NONE);
+ osd_template_insert(vars, "name", const_cast<gchar *>(name), OSDT_NONE);
+ osd_template_insert(vars, "date", fd ? (const_cast<gchar *>(text_from_time(fd->date))) : "", OSDT_NONE);
osd_template_insert(vars, "size", fd ? (text_from_size_abrev(fd->size)) : g_strdup(""), OSDT_FREE);
if (fd->pixbuf)
{
- gint w, h;
+ gint w;
+ gint h;
w = gdk_pixbuf_get_width(fd->pixbuf);
h = gdk_pixbuf_get_height(fd->pixbuf);
}
else
{
- osd_template_insert(vars, "width", NULL, OSDT_NONE);
- osd_template_insert(vars, "height", NULL, OSDT_NONE);
- osd_template_insert(vars, "res", NULL, OSDT_NONE);
+ osd_template_insert(vars, "width", nullptr, OSDT_NONE);
+ osd_template_insert(vars, "height", nullptr, OSDT_NONE);
+ osd_template_insert(vars, "res", nullptr, OSDT_NONE);
}
text = image_osd_mkinfo(template_string, fd, vars);
return text;
}
-static void draw_page(GtkPrintOperation *UNUSED(operation), GtkPrintContext *context,
- gint page_nr, gpointer data)
+static void draw_page(GtkPrintOperation *, GtkPrintContext *context, gint page_nr, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
FileData *fd;
cairo_t *cr;
- gdouble context_width, context_height;
- gdouble pixbuf_image_width, pixbuf_image_height;
+ gdouble context_width;
+ gdouble context_height;
+ gdouble pixbuf_image_width;
+ gdouble pixbuf_image_height;
gdouble width_offset;
gdouble height_offset;
GdkPixbuf *pixbuf;
- GdkPixbuf *rotated = NULL;
- PangoLayout *layout_image = NULL;
- PangoLayout *layout_page = NULL;
+ GdkPixbuf *rotated = nullptr;
+ PangoLayout *layout_image = nullptr;
+ PangoLayout *layout_page = nullptr;
PangoFontDescription *desc;
- GString *image_text = g_string_new(NULL);
- GString *page_text = g_string_new(NULL);
- PangoRectangle ink_rect, logical_rect;
- gdouble w, h, scale;
- gdouble image_text_width, image_text_height, page_text_width, page_text_height;
+ GString *image_text = g_string_new(nullptr);
+ GString *page_text = g_string_new(nullptr);
+ PangoRectangle ink_rect;
+ PangoRectangle logical_rect;
+ gdouble w;
+ gdouble h;
+ gdouble scale;
+ gdouble image_text_width;
+ gdouble image_text_height;
+ gdouble page_text_width;
+ gdouble page_text_height;
gint image_y;
gint incr_y;
gdouble pango_height;
gdouble pango_image_height;
gdouble pango_page_height;
- GtkTextIter start, end;
+ GtkTextIter start;
+ GtkTextIter end;
gchar *tmp;
gint total;
- fd = g_list_nth_data(pw->source_selection, page_nr);
+ fd = static_cast<FileData *>(g_list_nth_data(pw->source_selection, page_nr));
total = g_list_length(pw->source_selection);
- pixbuf = g_list_nth_data(pw->print_pixbuf_queue, page_nr);
+ pixbuf = static_cast<GdkPixbuf *>(g_list_nth_data(pw->print_pixbuf_queue, page_nr));
if (fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
{
rotated = pixbuf_apply_orientation(pixbuf, fd->exif_orientation);
pango_layout_set_font_description(layout_image, desc);
pango_layout_get_extents(layout_image, &ink_rect, &logical_rect);
- image_text_width = ((gdouble)logical_rect.width / PANGO_SCALE) ;
- image_text_height = ((gdouble)logical_rect.height / PANGO_SCALE);
+ image_text_width = (static_cast<gdouble>(logical_rect.width) / PANGO_SCALE) ;
+ image_text_height = (static_cast<gdouble>(logical_rect.height) / PANGO_SCALE);
pango_layout_set_alignment(layout_image, PANGO_ALIGN_CENTER);
pango_layout_set_text(layout_image, image_text->str, -1);
pango_layout_set_font_description(layout_page, desc);
pango_layout_get_extents(layout_page, &ink_rect, &logical_rect);
- page_text_width = ((gdouble)logical_rect.width / PANGO_SCALE) ;
- page_text_height = ((gdouble)logical_rect.height / PANGO_SCALE);
+ page_text_width = (static_cast<gdouble>(logical_rect.width) / PANGO_SCALE) ;
+ page_text_height = (static_cast<gdouble>(logical_rect.height) / PANGO_SCALE);
pango_layout_set_alignment(layout_page, PANGO_ALIGN_CENTER);
pango_layout_set_text(layout_page, page_text->str, -1);
}
if (rotated) g_object_unref(rotated);
-
- return;
}
-static void begin_print(GtkPrintOperation *operation,
- GtkPrintContext *UNUSED(context),
- gpointer user_data)
+static void begin_print(GtkPrintOperation *operation, GtkPrintContext *, gpointer user_data)
{
- PrintWindow *pw = user_data;
+ auto pw = static_cast<PrintWindow *>(user_data);
gint page_count;
page_count = print_layout_page_count(pw);
}
-GObject *option_tab_cb(GtkPrintOperation *UNUSED(operation), gpointer user_data)
+GObject *option_tab_cb(GtkPrintOperation *, gpointer user_data)
{
- PrintWindow *pw = user_data;
+ auto pw = static_cast<PrintWindow *>(user_data);
return G_OBJECT(pw->vbox);
}
static void print_pref_store(PrintWindow *pw)
{
gchar *tmp;
- GtkTextIter start, end;
+ GtkTextIter start;
+ GtkTextIter end;
gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(pw->page_text), &start, &end);
tmp = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(pw->page_text), &start, &end, FALSE);
g_free(tmp);
}
-static void end_print_cb(GtkPrintOperation *operation,
- GtkPrintContext *UNUSED(context), gpointer data)
+static void end_print_cb(GtkPrintOperation *operation, GtkPrintContext *, gpointer data)
{
- PrintWindow *pw = data;
+ auto pw = static_cast<PrintWindow *>(data);
GList *work;
GdkPixbuf *pixbuf;
gchar *path;
GtkPrintSettings *print_settings;
GtkPageSetup *page_setup;
- GError *error = NULL;
+ GError *error = nullptr;
print_settings = gtk_print_operation_get_print_settings(operation);
path = g_build_filename(get_rc_dir(), PRINT_SETTINGS, NULL);
{
log_printf("Error: Print settings save failed:\n%s", error->message);
g_error_free(error);
- error = NULL;
+ error = nullptr;
}
g_free(path);
g_object_unref(print_settings);
{
log_printf("Error: Print page setup save failed:\n%s", error->message);
g_error_free(error);
- error = NULL;
+ error = nullptr;
}
g_free(path);
g_object_unref(page_setup);
work = pw->print_pixbuf_queue;
while (work)
{
- pixbuf = work->data;
+ pixbuf = static_cast<GdkPixbuf *>(work->data);
if (pixbuf)
{
g_object_unref(pixbuf);
g_free(pw);
}
-void print_window_new(FileData *UNUSED(fd), GList *selection, GList *UNUSED(list), GtkWidget *parent)
+static void print_response_cb(GtkDialog *dialog, gint, gpointer)
+{
+ gq_gtk_widget_destroy(GTK_WIDGET(dialog));
+}
+
+void print_window_new(FileData *, GList *selection, GList *, GtkWidget *parent)
{
- PrintWindow *pw;
GtkWidget *vbox;
GtkPrintOperation *operation;
GtkPageSetup *page_setup;
gchar *uri;
const gchar *dir;
- GError *error = NULL;
+ GError *error = nullptr;
gchar *path;
GtkPrintSettings *settings;
- pw = g_new0(PrintWindow, 1);
+ auto pw = g_new0(PrintWindow, 1);
- pw->source_selection = file_data_process_groups_in_selection(selection, FALSE, NULL);
+ pw->source_selection = file_data_process_groups_in_selection(selection, FALSE, nullptr);
if (print_layout_page_count(pw) == 0)
{
print_text_menu(vbox, pw);
pw->vbox = vbox;
- pw->print_pixbuf_queue = NULL;
+ pw->print_pixbuf_queue = nullptr;
pw->job_render_finished = FALSE;
pw->job_page = 0;
operation = gtk_print_operation_new();
settings = gtk_print_settings_new();
- gtk_print_operation_set_custom_tab_label(operation, "Options");
+ gtk_print_operation_set_custom_tab_label(operation, _("Options"));
gtk_print_operation_set_use_full_page(operation, TRUE);
gtk_print_operation_set_unit(operation, GTK_UNIT_POINTS);
gtk_print_operation_set_embed_page_setup(operation, TRUE);
gtk_print_operation_set_allow_async (operation, TRUE);
dir = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS);
- if (dir == NULL)
+ if (dir == nullptr)
{
dir = g_get_home_dir();
}
{
log_printf("Error: Printer settings load failed:\n%s", error->message);
g_error_free(error);
- error = NULL;
+ error = nullptr;
}
gtk_print_operation_set_print_settings(operation, settings);
g_free(path);
{
log_printf("Error: Print page setup load failed:\n%s", error->message);
g_error_free(error);
- error = NULL;
+ error = nullptr;
}
gtk_print_operation_set_default_page_setup(operation, page_setup);
g_free(path);
"%s", error->message);
g_error_free (error);
- g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
+ g_signal_connect(dialog, "response", G_CALLBACK(print_response_cb), NULL);
gtk_widget_show (dialog);
}