pidgin: bfae5475: Hide-a-PurpleMenuAction.
masca at cpw.pidgin.im
masca at cpw.pidgin.im
Thu Sep 1 02:22:47 EDT 2011
----------------------------------------------------------------------
Revision: bfae54755d0a683ab945fea4666da04aeb1113d1
Parent: 49c0344b0fbfdcf6f15806030752ef761a959eae
Author: masca at cpw.pidgin.im
Date: 09/01/11 00:23:42
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/bfae54755d0a683ab945fea4666da04aeb1113d1
Changelog:
Hide-a-PurpleMenuAction.
Changes against parent 49c0344b0fbfdcf6f15806030752ef761a959eae
patched ChangeLog.API
patched finch/gntblist.c
patched libpurple/util.c
patched libpurple/util.h
patched pidgin/gtkutils.c
-------------- next part --------------
============================================================
--- libpurple/util.c 2c2e02bfc21ec20a99176958dc93bdd6a3394d4e
+++ libpurple/util.c 3daea11476e54c7dc25c389ae4cbc9038aa5ce02
@@ -73,6 +73,14 @@ struct _PurpleUtilFetchUrlData
PurpleAccount *account;
};
+struct _PurpleMenuAction
+{
+ char *label;
+ PurpleCallback callback;
+ gpointer data;
+ GList *children;
+};
+
static char *custom_user_dir = NULL;
static char *user_dir = NULL;
@@ -98,6 +106,62 @@ purple_menu_action_free(PurpleMenuAction
g_free(act);
}
+char * purple_menu_action_get_label(const PurpleMenuAction *act)
+{
+ g_return_val_if_fail(act != NULL, NULL);
+
+ return act->label;
+}
+
+PurpleCallback purple_menu_action_get_callback(const PurpleMenuAction *act)
+{
+ g_return_val_if_fail(act != NULL, NULL);
+
+ return act->callback;
+}
+
+gpointer purple_menu_action_get_data(const PurpleMenuAction *act)
+{
+ g_return_val_if_fail(act != NULL, NULL);
+
+ return act->data;
+}
+
+GList* purple_menu_action_get_children(const PurpleMenuAction *act)
+{
+ g_return_val_if_fail(act != NULL, NULL);
+
+ return act->children;
+}
+
+void purple_menu_action_set_label(PurpleMenuAction *act, char *label)
+{
+ g_return_if_fail(act != NULL);
+
+ act-> label = label;
+}
+
+void purple_menu_action_set_callback(PurpleMenuAction *act, PurpleCallback callback)
+{
+ g_return_if_fail(act != NULL);
+
+ act->callback = callback;
+}
+
+void purple_menu_action_set_data(PurpleMenuAction *act, gpointer data)
+{
+ g_return_if_fail(act != NULL);
+
+ act->data = data;
+}
+
+void purple_menu_action_set_children(PurpleMenuAction *act, GList *children)
+{
+ g_return_if_fail(act != NULL);
+
+ act->children = children;
+}
+
void
purple_util_init(void)
{
============================================================
--- pidgin/gtkutils.c e7b2720dc2845f4c7dfd06c9862c6d89d5413f91
+++ pidgin/gtkutils.c 0d1b6aee14af6571333a2b6074e708906c27457b
@@ -1816,21 +1816,27 @@ pidgin_append_menu_action(GtkWidget *men
gpointer object)
{
GtkWidget *menuitem;
+ GList *list;
if (act == NULL) {
return pidgin_separator(menu);
}
- if (act->children == NULL) {
- menuitem = gtk_menu_item_new_with_mnemonic(act->label);
+ list = purple_menu_action_get_children(act);
+ menuitem = gtk_menu_item_new_with_mnemonic(purple_menu_action_get_label(act));
- if (act->callback != NULL) {
+ if (list == NULL) {
+ PurpleCallback callback;
+
+ callback = purple_menu_action_get_callback(act);
+
+ if (callback != NULL) {
g_object_set_data(G_OBJECT(menuitem),
"purplecallback",
- act->callback);
+ callback);
g_object_set_data(G_OBJECT(menuitem),
"purplecallbackdata",
- act->data);
+ purple_menu_action_get_data(act));
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(menu_action_cb),
object);
@@ -1844,7 +1850,6 @@ pidgin_append_menu_action(GtkWidget *men
GtkWidget *submenu = NULL;
GtkAccelGroup *group;
- menuitem = gtk_menu_item_new_with_mnemonic(act->label);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
submenu = gtk_menu_new();
@@ -1852,19 +1857,20 @@ pidgin_append_menu_action(GtkWidget *men
group = gtk_menu_get_accel_group(GTK_MENU(menu));
if (group) {
- char *path = g_strdup_printf("%s/%s", GTK_MENU_ITEM(menuitem)->accel_path, act->label);
+ char *path = g_strdup_printf("%s/%s", GTK_MENU_ITEM(menuitem)->accel_path,
+ purple_menu_action_get_label(act));
gtk_menu_set_accel_path(GTK_MENU(submenu), path);
g_free(path);
gtk_menu_set_accel_group(GTK_MENU(submenu), group);
}
- for (l = act->children; l; l = l->next) {
+ for (l = list; l; l = l->next) {
PurpleMenuAction *act = (PurpleMenuAction *)l->data;
pidgin_append_menu_action(submenu, act, object);
}
- g_list_free(act->children);
- act->children = NULL;
+ g_list_free(list);
+ purple_menu_action_set_children(act, NULL);
}
purple_menu_action_free(act);
return menuitem;
============================================================
--- libpurple/util.h bdbdbec6b6696edbb793a3ae983c9a2039ccb439
+++ libpurple/util.h e1bbcdca669277e7f9c15b4f9f443f47cb46c2fb
@@ -51,14 +51,6 @@ extern "C" {
extern "C" {
#endif
-struct _PurpleMenuAction
-{
- char *label;
- PurpleCallback callback;
- gpointer data;
- GList *children;
-};
-
typedef char *(*PurpleInfoFieldFormatCallback)(const char *field, size_t len);
/**
@@ -96,6 +88,74 @@ void purple_menu_action_free(PurpleMenuA
void purple_menu_action_free(PurpleMenuAction *act);
/**
+ * Returns the label of the PurpleMenuAction.
+ *
+ * @param act The PurpleMenuAction.
+ *
+ * @return The label string.
+ */
+char * purple_menu_action_get_label(const PurpleMenuAction *act);
+
+/**
+ * Returns the callback of the PurpleMenuAction.
+ *
+ * @param act The PurpleMenuAction.
+ *
+ * @return The callback function.
+ */
+PurpleCallback purple_menu_action_get_callback(const PurpleMenuAction *act);
+
+/**
+ * Returns the data stored in the PurpleMenuAction.
+ *
+ * @param act The PurpleMenuAction.
+ *
+ * @return The data.
+ */
+gpointer purple_menu_action_get_data(const PurpleMenuAction *act);
+
+/**
+ * Returns the children of the PurpleMenuAction.
+ *
+ * @param act The PurpleMenuAction.
+ *
+ * @return The GList of children.
+ */
+GList* purple_menu_action_get_children(const PurpleMenuAction *act);
+
+/**
+ * Set the label to the PurpleMenuAction.
+ *
+ * @param act The menu action.
+ * @param label The label for the menu action.
+ */
+void purple_menu_action_set_label(PurpleMenuAction *act, char *label);
+
+/**
+ * Set the callback that will be used by the PurpleMenuAction.
+ *
+ * @param act The menu action.
+ * @param callback The callback.
+ */
+void purple_menu_action_set_callback(PurpleMenuAction *act, PurpleCallback callback);
+
+/**
+ * Set the label to the PurpleMenuAction.
+ *
+ * @param act The menu action.
+ * @param data The data used by this PurpleMenuAction
+ */
+void purple_menu_action_set_data(PurpleMenuAction *act, gpointer data);
+
+/**
+ * Set the children of the PurpleMenuAction.
+ *
+ * @param act The menu action.
+ * @param children The PurpleMenuAtion children
+ */
+void purple_menu_action_set_children(PurpleMenuAction *act, GList *children);
+
+/**
* Set the appropriate presence values for the currently playing song.
*
* @param title The title of the song, @c NULL to unset the value.
============================================================
--- ChangeLog.API 65d7b8ed5d61d7f2294b5bb31023da92af435d3b
+++ ChangeLog.API ab0c5c5a94fb126854a0ddb86925773461f055ab
@@ -8,6 +8,13 @@ version 3.0.0 (??/??/????):
* purple_notify_searchresult_column_is_visible
* purple_notify_searchresult_column_set_visible
* purple_notify_user_info_prepend_pair_plaintext
+ * purple_menu_action_get_callback
+ * purple_menu_action_get_children
+ * purple_menu_action_get_data
+ * purple_menu_action_set_label
+ * purple_menu_action_set_data
+ * purple_menu_action_set_callback
+ * purple_menu_action_set_children
* purple_request_field_get_tooltip
* purple_request_field_group_get_fields_list
* purple_request_field_set_tooltip
@@ -90,6 +97,7 @@ version 3.0.0 (??/??/????):
purple_util_fetch_url_request_len, insetad.
* PurpleConnectionUiOps.report_disconnect_reason
* struct _GtkIMHtmlFontDetail
+ * struct _PurpleMenuAction
* struct _PurplePounce
* struct _PurpleRequestField
* struct _PurpleRoomlist
============================================================
--- finch/gntblist.c 483ab5c2a24b0f337670d51577741dfc6ec6c4df
+++ finch/gntblist.c c9928c8dc55e8ec16ca472213c779862dee33667
@@ -1078,9 +1078,10 @@ context_menu_callback(GntMenuItem *item,
PurpleBlistNode *node = ggblist->cnode;
if (action) {
void (*callback)(PurpleBlistNode *, gpointer);
- callback = (void (*)(PurpleBlistNode *, gpointer))action->callback;
+ callback = (void (*)(PurpleBlistNode *, gpointer))
+ purple_menu_action_get_callback(action);
if (callback)
- callback(node, action->data);
+ callback(node, purple_menu_action_get_data(action));
else
return;
}
@@ -1095,15 +1096,17 @@ gnt_append_menu_action(GntMenu *menu, Pu
if (action == NULL)
return;
- item = gnt_menuitem_new(action->label);
- if (action->callback)
+ item = gnt_menuitem_new(purple_menu_action_get_label(action));
+ if (purple_menu_action_get_callback(action))
gnt_menuitem_set_callback(GNT_MENU_ITEM(item), context_menu_callback, action);
gnt_menu_add_item(menu, GNT_MENU_ITEM(item));
- if (action->children) {
+ list = purple_menu_action_get_children(action);
+
+ if (list) {
GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP);
gnt_menuitem_set_submenu(item, GNT_MENU(sub));
- for (list = action->children; list; list = list->next)
+ for (; list; list = list->next)
gnt_append_menu_action(GNT_MENU(sub), list->data, action);
}
}
@@ -1123,7 +1126,7 @@ append_proto_menu(GntMenu *menu, PurpleC
PurpleMenuAction *act = (PurpleMenuAction *) list->data;
if (!act)
continue;
- act->data = node;
+ purple_menu_action_set_data(act, node);
gnt_append_menu_action(menu, act, NULL);
g_signal_connect_swapped(G_OBJECT(menu), "destroy",
G_CALLBACK(purple_menu_action_free), act);
@@ -1216,7 +1219,7 @@ autojoin_toggled(GntMenuItem *item, gpoi
autojoin_toggled(GntMenuItem *item, gpointer data)
{
PurpleMenuAction *action = data;
- purple_blist_node_set_bool(action->data, "gnt-autojoin",
+ purple_blist_node_set_bool(purple_menu_action_get_data(action), "gnt-autojoin",
gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item)));
}
@@ -1224,7 +1227,8 @@ create_chat_menu(GntMenu *menu, PurpleCh
create_chat_menu(GntMenu *menu, PurpleChat *chat)
{
PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL);
- GntMenuItem *check = gnt_menuitem_check_new(action->label);
+ GntMenuItem *check = gnt_menuitem_check_new(
+ purple_menu_action_get_label(action));
gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check),
purple_blist_node_get_bool((PurpleBlistNode*)chat, "gnt-autojoin"));
gnt_menu_add_item(menu, check);
More information about the Commits
mailing list