/dev/twasilczyk/screenshot: 98e92d543d73: Initial implementation...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Mon Apr 28 20:22:12 EDT 2014
Changeset: 98e92d543d73032f2a4f6948bc8660781b147560
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-04-29 02:21 +0200
Branch: default
URL: https://hg.pidgin.im/dev/twasilczyk/screenshot/rev/98e92d543d73
Description:
Initial implementation fot the screencap plugin
diffstat:
pidgin/gtkwebview.c | 11 +
pidgin/gtkwebview.h | 13 +-
pidgin/gtkwebviewtoolbar.c | 82 ++++++--
pidgin/gtkwebviewtoolbar.h | 22 ++
pidgin/pidginstock.c | 1 +
pidgin/pidginstock.h | 1 +
pidgin/pixmaps/Makefile.am | 1 +
pidgin/pixmaps/toolbar/16/insert-screenshot.png | Bin
pidgin/plugins/Makefile.am | 4 +
pidgin/plugins/screencap.c | 234 ++++++++++++++++++++++++
10 files changed, 345 insertions(+), 24 deletions(-)
diffs (truncated from 563 to 300 lines):
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -2243,6 +2243,17 @@ pidgin_webview_set_toolbar(PidginWebView
priv->toolbar = PIDGIN_WEBVIEWTOOLBAR(toolbar);
}
+GtkWidget *
+pidgin_webview_get_toolbar(PidginWebView *webview)
+{
+ PidginWebViewPriv *priv;
+
+ g_return_val_if_fail(webview != NULL, NULL);
+
+ priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
+ return GTK_WIDGET(priv->toolbar);
+}
+
void
pidgin_webview_show_toolbar(PidginWebView *webview)
{
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
--- a/pidgin/gtkwebview.h
+++ b/pidgin/gtkwebview.h
@@ -628,10 +628,21 @@ void
pidgin_webview_switch_active_conversation(PidginWebView *webview,
PurpleConversation *conv);
-/* Do not use. */
+/* Do not use. TODO: rename to _pidgin and move to gtkinternal.h */
void
pidgin_webview_set_toolbar(PidginWebView *webview, GtkWidget *toolbar);
+/**
+ * pidgin_webview_get_toolbar:
+ * @webview: The PidginWebView
+ *
+ * Returns the toolbar associated with the webview.
+ *
+ * Returns: the toolbar.
+ */
+GtkWidget *
+pidgin_webview_get_toolbar(PidginWebView *webview);
+
G_END_DECLS
#endif /* _PIDGIN_WEBVIEW_H_ */
diff --git a/pidgin/gtkwebviewtoolbar.c b/pidgin/gtkwebviewtoolbar.c
--- a/pidgin/gtkwebviewtoolbar.c
+++ b/pidgin/gtkwebviewtoolbar.c
@@ -1504,20 +1504,32 @@ pidgin_webviewtoolbar_create_wide_view(P
gtk_toolbar_set_style(GTK_TOOLBAR(priv->wide_view), GTK_TOOLBAR_ICONS);
for (i = 0; i < G_N_ELEMENTS(layout); i++) {
- if (layout[i])
+ if (layout[i]) {
item = GTK_TOOL_ITEM(gtk_action_create_tool_item(layout[i]));
- else
+ g_object_set_data_full(G_OBJECT(item), "action-name",
+ g_strdup(gtk_action_get_name(layout[i])), g_free);
+ } else
item = gtk_separator_tool_item_new();
gtk_toolbar_insert(GTK_TOOLBAR(priv->wide_view), item, -1);
}
}
+static inline void
+lean_view_add_menu_item(GtkWidget *menu, GtkAction *action)
+{
+ GtkWidget *menuitem;
+
+ menuitem = gtk_action_create_menu_item(action);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ g_object_set_data_full(G_OBJECT(menuitem), "action-name",
+ g_strdup(gtk_action_get_name(action)), g_free);
+}
+
static void
pidgin_webviewtoolbar_create_lean_view(PidginWebViewToolbar *toolbar)
{
PidginWebViewToolbarPriv *priv = PIDGIN_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
GtkWidget *label;
- GtkWidget *menuitem;
GtkToolItem *sep;
GtkToolItem *font_button;
GtkWidget *font_menu;
@@ -1531,12 +1543,10 @@ pidgin_webviewtoolbar_create_lean_view(P
gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
gtk_toolbar_set_style(GTK_TOOLBAR(priv->lean_view), GTK_TOOLBAR_BOTH_HORIZ);
-#define ADD_MENU_ITEM(menu, item) \
- menuitem = gtk_action_create_menu_item((item)); \
- gtk_menu_shell_append(GTK_MENU_SHELL((menu)), menuitem);
-
/* Fonts */
font_button = gtk_toggle_tool_button_new();
+ g_object_set_data_full(G_OBJECT(font_button), "action-name",
+ g_strdup("font"), g_free);
gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), font_button, -1);
gtk_tool_item_set_is_important(font_button, TRUE);
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(font_button), GTK_STOCK_BOLD);
@@ -1545,20 +1555,21 @@ pidgin_webviewtoolbar_create_lean_view(P
gtk_tool_button_set_label_widget(GTK_TOOL_BUTTON(font_button), label);
priv->font_menu = font_menu = gtk_menu_new();
+ g_object_set_data(G_OBJECT(font_button), "menu", font_menu);
- ADD_MENU_ITEM(font_menu, priv->bold);
- ADD_MENU_ITEM(font_menu, priv->italic);
- ADD_MENU_ITEM(font_menu, priv->underline);
- ADD_MENU_ITEM(font_menu, priv->strike);
- ADD_MENU_ITEM(font_menu, priv->larger_size);
+ lean_view_add_menu_item(font_menu, priv->bold);
+ lean_view_add_menu_item(font_menu, priv->italic);
+ lean_view_add_menu_item(font_menu, priv->underline);
+ lean_view_add_menu_item(font_menu, priv->strike);
+ lean_view_add_menu_item(font_menu, priv->larger_size);
#if 0
- ADD_MENU_ITEM(font_menu, priv->normal_size);
+ lean_view_add_menu_item(font_menu, priv->normal_size);
#endif
- ADD_MENU_ITEM(font_menu, priv->smaller_size);
- ADD_MENU_ITEM(font_menu, priv->font);
- ADD_MENU_ITEM(font_menu, priv->fgcolor);
- ADD_MENU_ITEM(font_menu, priv->bgcolor);
- ADD_MENU_ITEM(font_menu, priv->clear);
+ lean_view_add_menu_item(font_menu, priv->smaller_size);
+ lean_view_add_menu_item(font_menu, priv->font);
+ lean_view_add_menu_item(font_menu, priv->fgcolor);
+ lean_view_add_menu_item(font_menu, priv->bgcolor);
+ lean_view_add_menu_item(font_menu, priv->clear);
g_signal_connect(G_OBJECT(font_button), "toggled",
G_CALLBACK(pidgin_menu_clicked), font_menu);
@@ -1573,6 +1584,8 @@ pidgin_webviewtoolbar_create_lean_view(P
/* Insert */
insert_button = gtk_toggle_tool_button_new();
+ g_object_set_data_full(G_OBJECT(insert_button), "action-name",
+ g_strdup("insert"), g_free);
gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), insert_button, -1);
gtk_tool_item_set_is_important(insert_button, TRUE);
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(insert_button),
@@ -1581,10 +1594,11 @@ pidgin_webviewtoolbar_create_lean_view(P
gtk_tool_button_set_label_widget(GTK_TOOL_BUTTON(insert_button), label);
priv->insert_menu = insert_menu = gtk_menu_new();
+ g_object_set_data(G_OBJECT(insert_button), "menu", insert_menu);
- ADD_MENU_ITEM(insert_menu, priv->image);
- ADD_MENU_ITEM(insert_menu, priv->link);
- ADD_MENU_ITEM(insert_menu, priv->hr);
+ lean_view_add_menu_item(insert_menu, priv->image);
+ lean_view_add_menu_item(insert_menu, priv->link);
+ lean_view_add_menu_item(insert_menu, priv->hr);
g_signal_connect(G_OBJECT(insert_button), "toggled",
G_CALLBACK(pidgin_menu_clicked), insert_menu);
@@ -1597,6 +1611,8 @@ pidgin_webviewtoolbar_create_lean_view(P
/* Smiley */
smiley_button = gtk_action_create_tool_item(priv->smiley);
+ g_object_set_data_full(G_OBJECT(smiley_button), "action-name",
+ g_strdup("smiley"), g_free);
gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view),
GTK_TOOL_ITEM(smiley_button), -1);
@@ -1606,10 +1622,10 @@ pidgin_webviewtoolbar_create_lean_view(P
/* Attention */
attention_button = gtk_action_create_tool_item(priv->attention);
+ g_object_set_data_full(G_OBJECT(attention_button), "action-name",
+ g_strdup("attention"), g_free);
gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view),
GTK_TOOL_ITEM(attention_button), -1);
-
-#undef ADD_MENU_ITEM
}
static void
@@ -1815,3 +1831,23 @@ pidgin_webviewtoolbar_activate(PidginWeb
gtk_action_activate(act);
}
+
+GtkWidget *
+pidgin_webviewtoolbar_get_wide_view(PidginWebViewToolbar *toolbar)
+{
+ PidginWebViewToolbarPriv *priv = PIDGIN_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+
+ g_return_val_if_fail(toolbar != NULL, NULL);
+
+ return priv->wide_view;
+}
+
+GtkWidget *
+pidgin_webviewtoolbar_get_lean_view(PidginWebViewToolbar *toolbar)
+{
+ PidginWebViewToolbarPriv *priv = PIDGIN_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+
+ g_return_val_if_fail(toolbar != NULL, NULL);
+
+ return priv->lean_view;
+}
diff --git a/pidgin/gtkwebviewtoolbar.h b/pidgin/gtkwebviewtoolbar.h
--- a/pidgin/gtkwebviewtoolbar.h
+++ b/pidgin/gtkwebviewtoolbar.h
@@ -104,6 +104,28 @@ void pidgin_webviewtoolbar_switch_active
void pidgin_webviewtoolbar_activate(PidginWebViewToolbar *toolbar,
PidginWebViewAction action);
+/**
+ * pidgin_webviewtoolbar_get_wide_view:
+ * @toolbar: The PidginWebViewToolbar object
+ *
+ * Returns the wide toolbar variant widget for the given @toolbar.
+ *
+ * Returns: the wide toolbar variant.
+ */
+GtkWidget *
+pidgin_webviewtoolbar_get_wide_view(PidginWebViewToolbar *toolbar);
+
+/**
+ * pidgin_webviewtoolbar_get_lean_view:
+ * @toolbar: The PidginWebViewToolbar object
+ *
+ * Returns the lean toolbar variant widget for the given @toolbar.
+ *
+ * Returns: the lean toolbar variant.
+ */
+GtkWidget *
+pidgin_webviewtoolbar_get_lean_view(PidginWebViewToolbar *toolbar);
+
G_END_DECLS
#endif /* _PIDGINWEBVIEWTOOLBAR_H_ */
diff --git a/pidgin/pidginstock.c b/pidgin/pidginstock.c
--- a/pidgin/pidginstock.c
+++ b/pidgin/pidginstock.c
@@ -168,6 +168,7 @@ const SizedStockIcon sized_stock_icons [
{ PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, "toolbar", "font-size-up.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_INSERT, "toolbar", "insert.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, "toolbar", "insert-image.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { PIDGIN_STOCK_TOOLBAR_INSERT_SCREENSHOT, "toolbar", "insert-screenshot.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_INSERT_LINK, "toolbar", "insert-link.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, "toolbar", "message-new.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ PIDGIN_STOCK_TOOLBAR_PENDING, "toolbar", "message-new.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
diff --git a/pidgin/pidginstock.h b/pidgin/pidginstock.h
--- a/pidgin/pidginstock.h
+++ b/pidgin/pidginstock.h
@@ -147,6 +147,7 @@
#define PIDGIN_STOCK_TOOLBAR_TEXT_LARGER "pidgin-text-larger"
#define PIDGIN_STOCK_TOOLBAR_INSERT "pidgin-insert"
#define PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE "pidgin-insert-image"
+#define PIDGIN_STOCK_TOOLBAR_INSERT_SCREENSHOT "pidgin-insert-screenshot"
#define PIDGIN_STOCK_TOOLBAR_INSERT_LINK "pidgin-insert-link"
#define PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW "pidgin-message-new"
#define PIDGIN_STOCK_TOOLBAR_PENDING "pidgin-pending"
diff --git a/pidgin/pixmaps/Makefile.am b/pidgin/pixmaps/Makefile.am
--- a/pidgin/pixmaps/Makefile.am
+++ b/pidgin/pixmaps/Makefile.am
@@ -436,6 +436,7 @@ TOOLBAR_16 = \
toolbar/16/insert.png \
toolbar/16/insert-image.png \
toolbar/16/insert-link.png \
+ toolbar/16/insert-screenshot.png \
toolbar/16/message-new.png \
toolbar/16/plugins.png \
toolbar/16/send-file.png \
diff --git a/pidgin/pixmaps/toolbar/16/insert-screenshot.png b/pidgin/pixmaps/toolbar/16/insert-screenshot.png
new file mode 100644
index 0000000000000000000000000000000000000000..f84bbb9a53abd31fca813e7eaa4aee72c54d3fab
GIT binary patch
literal 689
zc$@*T0#5yjP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0007bNkl<ZILoDz
zNl4Uj6vsdRb)-VHhJkFxHb;nx%v;nUsO-`L5`r)kbnIG0&^fWJ=n~Z>N;JK6Xg#z*
zhZZXuN6ZC^D4VG<b19Vk|JDu`T68FS at Vz{E?|t5v_uxOnIen(3SxR}xTI>B&q2uTv
z2u^amrAZlM?9*pm_T2fiw(IE=YmBkKhcV_CDJAXkmL}!?oc#RxGm at z!U0qKo7K<n)
zky0R~K!^w-1pR|AiK1!x26_PpYpv%47-LwydJVZ;H|caW6B84Rj(*1TJYpp=Vqr)a
z#z-wmA(f;uxfEkG06st at BGOe=R8%bC{m>9MZeFLMVGlSn`${cP(~_xg7HcgQOWaA!
zHkh28<kjm}jE;>`$QStX^$R!_Yr$H}*!Vb?TRX{i=crx3j!dS3veJbBxByZJlu>A{
z&_-j7K`Mn*5~U?=ZEXy`=_Bve at F1I~wY3wa#cTs11zIVT(ik%%^`lrSMNh7Wom)P#
zxn_v3eu`YK7p>=bAbt`Uh1N3!`iDsXHS5<flE2Hwm3 at r79cNi`E!vn_f=EPIW3bl#
z at o4JzG%#tl(Q!3Fdf6%(8|yK138a+xzE2PYELs#Nm8_(!w44Rk_Yu5*#Bwi2?L1&3
zzzev233S9Re}(m3*PSjFKbFMfal){K;o>lbLP4~*w}*+Sn(elqMCJlsc_mg&<9H!@
z>@A;K4=@<iTydID9NQWM!9iop2EcJ$_py}n)RDtS?*R<#XR{N8H&Z+I&M!$U=3DU{
z`CA=RR>>W!F7m+no5#s!*y0A^wTex3^FKViGi9XMUE9X}e|p<&hPv*3{%|%!-Q4_l
XqKbC~nknF?00000NkvXXu0mjf2UI at M
diff --git a/pidgin/plugins/Makefile.am b/pidgin/plugins/Makefile.am
--- a/pidgin/plugins/Makefile.am
+++ b/pidgin/plugins/Makefile.am
@@ -46,6 +46,7 @@ iconaway_la_LDFLAGS = -module @P
markerline_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
notify_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
relnot_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
+screencap_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
sendbutton_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
spellchk_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
themeedit_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
More information about the Commits
mailing list