/dev/tomkiewicz/e2ee: 19edf7808ec1: E2EE: basic menu implementation
Tomasz Wasilczyk
twasilczyk at pidgin.im
Sat Oct 5 12:59:11 EDT 2013
Changeset: 19edf7808ec1701a4747a78b5b56aacb38034960
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2013-10-05 18:59 +0200
Branch: default
URL: https://hg.pidgin.im/dev/tomkiewicz/e2ee/rev/19edf7808ec1
Description:
E2EE: basic menu implementation
diffstat:
libpurple/e2ee.c | 18 ++++++++++++++++++
libpurple/e2ee.h | 10 ++++++++++
pidgin/gtkconv.c | 13 +++++++++++++
3 files changed, 41 insertions(+), 0 deletions(-)
diffs (89 lines):
diff --git a/libpurple/e2ee.c b/libpurple/e2ee.c
--- a/libpurple/e2ee.c
+++ b/libpurple/e2ee.c
@@ -43,6 +43,7 @@ struct _PurpleE2eeProvider
gchar *name;
PurpleE2eeFeatures features;
PurpleE2eeState *default_state;
+ PurpleE2eeConvMenuCallback conv_menu_cb;
};
static PurpleE2eeProvider *main_provider = NULL;
@@ -234,3 +235,20 @@ purple_e2ee_provider_get_default_state(P
return provider->default_state;
}
+
+void
+purple_e2ee_provider_set_conv_menu_cb(PurpleE2eeProvider *provider,
+ PurpleE2eeConvMenuCallback conv_menu_cb)
+{
+ g_return_if_fail(provider != NULL);
+
+ provider->conv_menu_cb = conv_menu_cb;
+}
+
+PurpleE2eeConvMenuCallback
+purple_e2ee_provider_get_conv_menu_cb(PurpleE2eeProvider *provider)
+{
+ g_return_val_if_fail(provider != NULL, NULL);
+
+ return provider->conv_menu_cb;
+}
diff --git a/libpurple/e2ee.h b/libpurple/e2ee.h
--- a/libpurple/e2ee.h
+++ b/libpurple/e2ee.h
@@ -38,6 +38,9 @@ typedef enum
} PurpleE2eeFeatures;
#include <glib.h>
+#include "conversation.h"
+
+typedef GList * (*PurpleE2eeConvMenuCallback)(PurpleConversation *conv);
G_BEGIN_DECLS
@@ -110,6 +113,13 @@ purple_e2ee_provider_set_default_state(P
PurpleE2eeState *
purple_e2ee_provider_get_default_state(PurpleE2eeProvider *provider);
+void
+purple_e2ee_provider_set_conv_menu_cb(PurpleE2eeProvider *provider,
+ PurpleE2eeConvMenuCallback conv_menu_cb);
+
+PurpleE2eeConvMenuCallback
+purple_e2ee_provider_get_conv_menu_cb(PurpleE2eeProvider *provider);
+
/*@}*/
G_END_DECLS
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -4153,6 +4153,8 @@ generate_e2ee_controls(PidginWindow *win
PurpleE2eeState *state;
PurpleE2eeProvider *provider;
GtkWidget *menu;
+ PurpleE2eeConvMenuCallback menu_cb;
+ GList *menu_actions = NULL, *it;
gtkconv = pidgin_conv_window_get_active_gtkconv(win);
g_return_if_fail(gtkconv != NULL);
@@ -4187,6 +4189,17 @@ generate_e2ee_controls(PidginWindow *win
gtk_widget_set_tooltip_text(win->menu.e2ee,
purple_e2ee_state_get_name(state));
+ menu_cb = purple_e2ee_provider_get_conv_menu_cb(provider);
+ if (menu_cb)
+ menu_actions = menu_cb(conv);
+
+ for (it = g_list_first(menu_actions); it; it = g_list_next(it)) {
+ PurpleMenuAction *action = it->data;
+
+ gtk_widget_show_all(
+ pidgin_append_menu_action(menu, action, conv));
+ }
+
gtk_widget_show(win->menu.e2ee);
gtk_widget_show(menu);
}
More information about the Commits
mailing list