Skip to content

Commit 09bb60b

Browse files
committed
#1239 Add print support, new menu option in 'Tools'
1 parent 983254f commit 09bb60b

File tree

5 files changed

+75
-7
lines changed

5 files changed

+75
-7
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ To be released
55
* Rewrite GtkPaned position restoration to GSettings bindings
66
(Lars Windolf)
77

8+
* #1239 Add print support, new menu option in 'Tools'
9+
(Lars Windolf)
10+
811
* #1304 Show full feed properties dialog on 'Advanced' subscribe
912
(Lars Windolf)
1013

glade/liferea_menu.ui

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,23 @@
169169
<attribute name="action">app.show-update-monitor</attribute>
170170
<attribute name="label" translatable="yes">_Update Monitor</attribute>
171171
</item>
172+
</section>
173+
<section>
172174
<item>
173175
<attribute name="action">app.show-preferences</attribute>
174176
<attribute name="label" translatable="yes">_Preferences</attribute>
175177
</item>
176-
<item>
178+
<item>
177179
<attribute name="action">app.manage-plugins</attribute>
178180
<attribute name="label" translatable="yes">_Manage Plugins</attribute>
179181
</item>
180182
</section>
183+
<section>
184+
<item>
185+
<attribute name="action">app.print</attribute>
186+
<attribute name="label" translatable="yes">_Print</attribute>
187+
</item>
188+
</section>
181189
</submenu>
182190
<submenu>
183191
<attribute name="label" translatable="yes">S_earch</attribute>

src/ui/liferea_shell.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "ui/search_dialog.h"
5656
#include "ui/ui_common.h"
5757
#include "ui/ui_update.h"
58+
#include "webkit/liferea_web_view.h"
5859

5960
extern gboolean searchFolderRebuild; /* db.c */
6061

@@ -917,6 +918,25 @@ on_menu_export (GSimpleAction *action, GVariant *parameter, gpointer user_data)
917918
export_OPML_file ();
918919
}
919920

921+
static void
922+
on_print_activate (GSimpleAction *action, GVariant *parameter, gpointer user_data)
923+
{
924+
LifereaBrowser *browser;
925+
GtkWidget *webview;
926+
927+
// First see if a browser tab is active
928+
browser = browser_tabs_get_active_htmlview ();
929+
930+
// If not print the item view
931+
if (!browser)
932+
g_object_get (G_OBJECT (shell->itemview), "html-view", &browser, NULL);
933+
934+
g_return_if_fail (browser != NULL);
935+
936+
g_object_get (G_OBJECT (browser), "renderwidget", &webview, NULL);
937+
liferea_web_view_print (LIFEREA_WEB_VIEW (webview));
938+
}
939+
920940
/* methods to receive URLs which were dropped anywhere in the main window */
921941
static void
922942
liferea_shell_URL_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time_received)
@@ -1025,6 +1045,7 @@ static const GActionEntry liferea_shell_gaction_entries[] = {
10251045
{"show-help-contents", on_topics_activate, NULL, NULL, NULL},
10261046
{"show-shortcuts", on_shortcuts_activate, NULL, NULL, NULL},
10271047
{"show-about", on_about_activate, NULL, NULL, NULL},
1048+
{"print", on_print_activate, NULL, NULL, NULL},
10281049

10291050
/* Parameter type must be NULL for toggle. */
10301051
{"fullscreen", NULL, NULL, "@b false", on_menu_fullscreen_activate},

src/webkit/liferea_web_view.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "feedlist.h"
2929
#include "social.h"
3030
#include "ui/browser_tabs.h"
31+
#include "ui/liferea_shell.h"
3132
#include "ui/liferea_browser.h"
3233
#include "ui/item_list_view.h"
3334
#include "ui/itemview.h"
@@ -276,6 +277,15 @@ on_popup_webinspector_activate (GSimpleAction *action, GVariant *parameter, gpoi
276277
webkit_web_inspector_show (WEBKIT_WEB_INSPECTOR(inspector));
277278
}
278279

280+
void
281+
liferea_web_view_print (LifereaWebView *self)
282+
{
283+
g_autoptr(WebKitPrintOperation) operation = NULL;
284+
285+
operation = webkit_print_operation_new (WEBKIT_WEB_VIEW (self));
286+
webkit_print_operation_run_dialog (operation, GTK_WINDOW (liferea_shell_get_window ()));
287+
}
288+
279289
static const GActionEntry liferea_web_view_gaction_entries[] = {
280290
{"save-link", on_popup_save_link_activate, "s", NULL, NULL},
281291
{"subscribe-link", on_popup_subscribe_link_activate, "s", NULL, NULL},

src/webkit/liferea_web_view.h

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,38 @@ typedef struct _LifereaWebViewClass LifereaWebViewClass;
3636

3737
GType liferea_web_view_get_type (void);
3838

39-
LifereaWebView *
40-
liferea_web_view_new (void);
39+
/**
40+
* liferea_web_view_new:
41+
*
42+
* Create a new #LifereaWebView.
43+
*
44+
* Returns: a new #LifereaWebView
45+
*/
46+
LifereaWebView *liferea_web_view_new (void);
47+
48+
/**
49+
* liferea_web_view_set_dbus_connection: (skip)
50+
* Set the D-Bus connection to be used by the web view.
51+
*
52+
* @self: a #LifereaWebView
53+
* @connection: a #GDBusConnection
54+
*/
55+
void liferea_web_view_set_dbus_connection (LifereaWebView *self, GDBusConnection *connection);
4156

42-
void
43-
liferea_web_view_set_dbus_connection (LifereaWebView *self, GDBusConnection *connection);
57+
/**
58+
* liferea_web_view_scroll_pagedown:
59+
* Scroll the web view down by one page.
60+
*
61+
* @self: a #LifereaWebView
62+
*/
63+
void liferea_web_view_scroll_pagedown (LifereaWebView *self);
64+
65+
/**
66+
* liferea_web_view_print:
67+
* Print the contents of the web view.
68+
*
69+
* @self: a #LifereaWebView
70+
*/
71+
void liferea_web_view_print (LifereaWebView *self);
4472

45-
void
46-
liferea_web_view_scroll_pagedown (LifereaWebView *self);
4773
#endif

0 commit comments

Comments
 (0)