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(static_cast<const gchar *>(data), "Image text font") == 0)
{
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));
- 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);
- }
+ g_signal_connect(dialog, "font-activated", G_CALLBACK(font_activated_cb), option);
+ g_signal_connect(dialog, "response", G_CALLBACK(font_response_cb), option);
- gtk_widget_destroy(dialog);
+ gtk_widget_show(dialog);
}
static gint set_toggle(GSList *list, TextPosition pos)
*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
+enum {
+ 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, nullptr, "Header 1",
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(nullptr, nullptr);
+ 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(nullptr, GTK_STOCK_SELECT_FONT, _("Font"), FALSE,
+ 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, nullptr, "Header 1",
gtk_widget_show(hbox);
pw->page_group = (gtk_radio_button_get_group(GTK_RADIO_BUTTON(button2)));
- scrolled = gtk_scrolled_window_new(nullptr, nullptr);
+ 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(nullptr, GTK_STOCK_SELECT_FONT, _("Font"), FALSE,
+ 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)
{
auto pw = static_cast<PrintWindow *>(data);
{
return TRUE;
}
- else
- {
- return FALSE;
- }
+
+ return FALSE;
}
gchar *form_image_text(const gchar *template_string, FileData *fd, PrintWindow *pw, gint page_nr, gint total)
if (fd->pixbuf)
{
- gint w, h;
+ gint w;
+ gint h;
w = gdk_pixbuf_get_width(fd->pixbuf);
h = gdk_pixbuf_get_height(fd->pixbuf);
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)
{
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;
PangoFontDescription *desc;
GString *image_text = g_string_new(nullptr);
GString *page_text = g_string_new(nullptr);
- PangoRectangle ink_rect, logical_rect;
- gdouble w, h, scale;
- gdouble image_text_width, image_text_height, page_text_width, page_text_height;
+ 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;
if (rotated) g_object_unref(rotated);
}
-static void begin_print(GtkPrintOperation *operation,
- GtkPrintContext *UNUSED(context),
- gpointer user_data)
+static void begin_print(GtkPrintOperation *operation, GtkPrintContext *, gpointer user_data)
{
auto pw = static_cast<PrintWindow *>(user_data);
gint page_count;
}
-GObject *option_tab_cb(GtkPrintOperation *UNUSED(operation), gpointer user_data)
+GObject *option_tab_cb(GtkPrintOperation *, gpointer user_data)
{
auto pw = static_cast<PrintWindow *>(user_data);
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)
{
auto pw = static_cast<PrintWindow *>(data);
GList *work;
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 *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, nullptr);
"%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);
}