Tidy up nw_entries_p
authorThomas White <taw@bitwiz.me.uk>
Sun, 15 Apr 2018 18:49:27 +0000 (20:49 +0200)
committerThomas White <taw@bitwiz.me.uk>
Sun, 15 Apr 2018 18:49:27 +0000 (20:49 +0200)
src/narrative_window.c
src/print.c
src/print.h

index d09942a..33609eb 100644 (file)
@@ -475,10 +475,17 @@ static gint export_pdf_response_sig(GtkWidget *d, gint response,
 }
 
 
+static void print_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+       NarrativeWindow *nw = vp;
+       run_printing(nw->p, nw->window);
+}
+
+
 static void exportpdf_sig(GSimpleAction *action, GVariant *parameter,
                           gpointer vp)
 {
-       struct presentation *p = vp;
+       NarrativeWindow *nw = vp;
        GtkWidget *d;
 
        d = gtk_file_chooser_dialog_new(_("Export PDF"),
@@ -491,7 +498,7 @@ static void exportpdf_sig(GSimpleAction *action, GVariant *parameter,
                                                       TRUE);
 
        g_signal_connect(G_OBJECT(d), "response",
-                        G_CALLBACK(export_pdf_response_sig), p);
+                        G_CALLBACK(export_pdf_response_sig), nw->p);
 
        gtk_widget_show_all(d);
 }
@@ -743,10 +750,6 @@ GActionEntry nw_entries[] = {
        { "prev", prev_para_sig, NULL, NULL, NULL },
        { "next", next_para_sig, NULL, NULL, NULL },
        { "last", last_para_sig, NULL, NULL, NULL },
-};
-
-
-GActionEntry nw_entries_p[] = {
        { "print", print_sig, NULL, NULL, NULL  },
        { "exportpdf", exportpdf_sig, NULL, NULL, NULL  },
 };
@@ -798,8 +801,6 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp
 
        g_action_map_add_action_entries(G_ACTION_MAP(nw->window), nw_entries,
                                        G_N_ELEMENTS(nw_entries), nw);
-       g_action_map_add_action_entries(G_ACTION_MAP(nw->window), nw_entries_p,
-                                       G_N_ELEMENTS(nw_entries_p), p);
 
        nw_update_titlebar(nw);
 
index b0e3a84..ce52ba8 100644 (file)
@@ -291,9 +291,8 @@ static void print_draw(GtkPrintOperation *op, GtkPrintContext *ctx, gint page,
 }
 
 
-void print_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+void run_printing(struct presentation *p, GtkWidget *parent)
 {
-       struct presentation *p = vp;
        GtkPrintOperation *print;
        GtkPrintOperationResult res;
        struct print_stuff *ps;
@@ -317,7 +316,7 @@ void print_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
 
        res = gtk_print_operation_run(print,
                                      GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
-                                     GTK_WINDOW(NULL), NULL);
+                                     GTK_WINDOW(parent), NULL);
 
        if ( res == GTK_PRINT_OPERATION_RESULT_APPLY ) {
                if ( print_settings != NULL ) {
index dffc7e8..265b7c1 100644 (file)
@@ -27,6 +27,6 @@
 #include <config.h>
 #endif
 
-extern void print_sig(GSimpleAction *action, GVariant *parameter, gpointer vp);
+extern void run_printing(struct presentation *p, GtkWidget *parent);
 
 #endif /* PRINT_H */