diff options
author | Gary Kramlich <grim@reaperworld.com> | 2018-02-01 22:33:16 -0600 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2018-02-01 22:33:16 -0600 |
commit | 16a065ff9ed5078e46d564a962a84a4224650095 (patch) | |
tree | 6c9b7a6d5080bc52f6c2bb18cc94adfe92517442 | |
parent | 8eb03dcacf20efe8aed969cb50034fd8978d7727 (diff) | |
download | pidgin-16a065ff9ed5078e46d564a962a84a4224650095.tar.gz |
Move the MenuAction stuff to the new action.[ch] files
-rw-r--r-- | finch/gntblist.c | 1 | ||||
-rw-r--r-- | finch/gntmenuutil.h | 2 | ||||
-rw-r--r-- | libpurple/action.c | 126 | ||||
-rw-r--r-- | libpurple/action.h | 159 | ||||
-rw-r--r-- | libpurple/meson.build | 2 | ||||
-rw-r--r-- | libpurple/plugins/autoaccept.c | 2 | ||||
-rw-r--r-- | libpurple/plugins/buddynote.c | 2 | ||||
-rw-r--r-- | libpurple/protocols/facebook/facebook.c | 1 | ||||
-rw-r--r-- | libpurple/protocols/jabber/buddy.c | 1 | ||||
-rw-r--r-- | libpurple/protocols/novell/novell.c | 1 | ||||
-rw-r--r-- | libpurple/protocols/oscar/visibility.h | 2 | ||||
-rw-r--r-- | libpurple/protocols/sametime/sametime.c | 2 | ||||
-rw-r--r-- | libpurple/util.c | 102 | ||||
-rw-r--r-- | libpurple/util.h | 130 | ||||
-rw-r--r-- | pidgin/gtkblist.c | 1 | ||||
-rw-r--r-- | pidgin/gtkconv.c | 1 | ||||
-rw-r--r-- | pidgin/gtkutils.h | 1 | ||||
-rw-r--r-- | pidgin/plugins/markerline.c | 1 |
18 files changed, 301 insertions, 236 deletions
diff --git a/finch/gntblist.c b/finch/gntblist.c index 4eb9e14e57..17029a4736 100644 --- a/finch/gntblist.c +++ b/finch/gntblist.c @@ -24,6 +24,7 @@ #include NCURSES_HEADER #include <account.h> +#include <action.h> #include <buddylist.h> #include <log.h> #include <notify.h> diff --git a/finch/gntmenuutil.h b/finch/gntmenuutil.h index ba2e0db501..f449718bfe 100644 --- a/finch/gntmenuutil.h +++ b/finch/gntmenuutil.h @@ -28,6 +28,8 @@ * @title: Menu Utility functions */ +#include <action.h> + #include <gnt.h> #include <gntmenu.h> diff --git a/libpurple/action.c b/libpurple/action.c new file mode 100644 index 0000000000..2dcf084f05 --- /dev/null +++ b/libpurple/action.c @@ -0,0 +1,126 @@ +/* Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#include "action.h" + +struct _PurpleMenuAction { + gchar *label; + GCallback callback; + gpointer data; + GList *children; + gchar *stock_icon; +}; + +/****************************************************************************** + * ActionMenu API + *****************************************************************************/ +PurpleMenuAction * +purple_menu_action_new(const gchar *label, GCallback callback, gpointer data, + GList *children) +{ + PurpleMenuAction *act = g_new(PurpleMenuAction, 1); + + act->label = g_strdup(label); + act->callback = callback; + act->data = data; + act->children = children; + act->stock_icon = NULL; + + return act; +} + +void +purple_menu_action_free(PurpleMenuAction *act) { + g_return_if_fail(act != NULL); + + g_free(act->stock_icon); + g_free(act->label); + g_free(act); +} + +gchar * +purple_menu_action_get_label(const PurpleMenuAction *act) { + g_return_val_if_fail(act != NULL, NULL); + + return act->label; +} + +GCallback +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, gchar *label) { + g_return_if_fail(act != NULL); + + act-> label = label; +} + +void +purple_menu_action_set_callback(PurpleMenuAction *act, GCallback 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_menu_action_set_stock_icon(PurpleMenuAction *act, const gchar *stock) { + g_return_if_fail(act != NULL); + + g_free(act->stock_icon); + + act->stock_icon = g_strdup(stock); +} + +const gchar * +purple_menu_action_get_stock_icon(PurpleMenuAction *act) { + return act->stock_icon; +} + diff --git a/libpurple/action.h b/libpurple/action.h new file mode 100644 index 0000000000..58a2a8444f --- /dev/null +++ b/libpurple/action.h @@ -0,0 +1,159 @@ +/* purple + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#ifndef PURPLE_ACTION +#define PURPLE_ACTION + +#include <glib.h> +#include <glib-object.h> + +/** + * PurpleMenuAction: + * + * A generic structure that contains information about an "action." One + * place this is is used is by protocols to tell the core the list of available + * right-click actions for a buddy list row. + */ +typedef struct _PurpleMenuAction PurpleMenuAction; + +G_BEGIN_DECLS + +/** + * purple_menu_action_new: + * @label: The text label to display for this action. + * @callback: The function to be called when the action is used on + * the selected item. + * @data: Additional data to be passed to the callback. + * @children: (element-type PurpleMenuAction) (transfer full): Menu actions to + * be added as a submenu of this action. + * + * Creates a new PurpleMenuAction. + * + * Returns: The PurpleMenuAction. + */ +PurpleMenuAction *purple_menu_action_new(const gchar *label, GCallback callback, gpointer data, GList *children); + +/** + * purple_menu_action_free: + * @act: The PurpleMenuAction to free. + * + * Frees a PurpleMenuAction + */ +void purple_menu_action_free(PurpleMenuAction *act); + +/** + * purple_menu_action_get_label: + * @act: The PurpleMenuAction. + * + * Returns the label of the PurpleMenuAction. + * + * Returns: The label string. + */ +gchar *purple_menu_action_get_label(const PurpleMenuAction *act); + +/** + * purple_menu_action_get_callback: + * @act: The PurpleMenuAction. + * + * Returns the callback of the PurpleMenuAction. + * + * Returns: The callback function. + */ +GCallback purple_menu_action_get_callback(const PurpleMenuAction *act); + +/** + * purple_menu_action_get_data: + * @act: The PurpleMenuAction. + * + * Returns the data stored in the PurpleMenuAction. + * + * Returns: The data. + */ +gpointer purple_menu_action_get_data(const PurpleMenuAction *act); + +/** + * purple_menu_action_get_children: + * @act: The PurpleMenuAction. + * + * Returns the children of the PurpleMenuAction. + * + * Returns: (element-type PurpleMenuAction) (transfer none): The menu children. + */ +GList* purple_menu_action_get_children(const PurpleMenuAction *act); + +/** + * purple_menu_action_set_label: + * @act: The menu action. + * @label: The label for the menu action. + * + * Set the label to the PurpleMenuAction. + */ +void purple_menu_action_set_label(PurpleMenuAction *act, gchar *label); + +/** + * purple_menu_action_set_callback: + * @act: The menu action. + * @callback: The callback. + * + * Set the callback that will be used by the PurpleMenuAction. + */ +void purple_menu_action_set_callback(PurpleMenuAction *act, GCallback callback); + +/** + * purple_menu_action_set_data: + * @act: The menu action. + * @data: The data used by this PurpleMenuAction + * + * Set the label to the PurpleMenuAction. + */ +void purple_menu_action_set_data(PurpleMenuAction *act, gpointer data); + +/** + * purple_menu_action_set_children: + * @act: The menu action. + * @children: (element-type PurpleMenuAction) (transfer full): The menu children + * + * Set the children of the PurpleMenuAction. + */ +void purple_menu_action_set_children(PurpleMenuAction *act, GList *children); + +/** + * purple_menu_action_set_stock_icon: + * @act: The menu action. + * @stock: The stock icon identifier. + * + * Sets the icon for the PurpleMenuAction. + */ +void purple_menu_action_set_stock_icon(PurpleMenuAction *act, const gchar *stock); + +/** + * purple_menu_action_get_stock_icon: + * @act: The menu action. + * + * Gets the stock icon of the PurpleMenuAction. + * + * Returns: The stock icon identifier. + */ +const gchar *purple_menu_action_get_stock_icon(PurpleMenuAction *act); + +G_END_DECLS + +#endif /* PURPLE_ACTION */
\ No newline at end of file diff --git a/libpurple/meson.build b/libpurple/meson.build index 242a683b93..9bb02ab820 100644 --- a/libpurple/meson.build +++ b/libpurple/meson.build @@ -3,6 +3,7 @@ purple_coresources = [ 'accounts.c', 'accountopt.c', 'attention.c', + 'action.c', 'blistnode.c', 'buddy.c', 'buddylist.c', @@ -85,6 +86,7 @@ purple_coreheaders = [ 'accounts.h', 'accountopt.h', 'attention.h', + 'action.h', 'blistnode.h', 'buddy.h', 'buddylist.h', diff --git a/libpurple/plugins/autoaccept.c b/libpurple/plugins/autoaccept.c index 71968bc2bf..f1108cc751 100644 --- a/libpurple/plugins/autoaccept.c +++ b/libpurple/plugins/autoaccept.c @@ -35,12 +35,12 @@ #include <plugins.h> #include <version.h> +#include <action.h> #include <buddylist.h> #include <conversation.h> #include <xfer.h> #include <request.h> #include <notify.h> -#include <util.h> #define PREF_PREFIX "/plugins/core/" PLUGIN_ID #define PREF_PATH PREF_PREFIX "/path" diff --git a/libpurple/plugins/buddynote.c b/libpurple/plugins/buddynote.c index ae9ff7af1c..94246cc653 100644 --- a/libpurple/plugins/buddynote.c +++ b/libpurple/plugins/buddynote.c @@ -18,11 +18,11 @@ */ #include "internal.h" +#include <action.h> #include <debug.h> #include <notify.h> #include <request.h> #include <signals.h> -#include <util.h> #include <version.h> static void diff --git a/libpurple/protocols/facebook/facebook.c b/libpurple/protocols/facebook/facebook.c index 9554adc783..3a83dc77bd 100644 --- a/libpurple/protocols/facebook/facebook.c +++ b/libpurple/protocols/facebook/facebook.c @@ -23,6 +23,7 @@ #include "account.h" #include "accountopt.h" +#include "action.h" #include "blistnode.h" #include "buddy.h" #include "buddyicon.h" diff --git a/libpurple/protocols/jabber/buddy.c b/libpurple/protocols/jabber/buddy.c index 88887ad41f..dfb98773cc 100644 --- a/libpurple/protocols/jabber/buddy.c +++ b/libpurple/protocols/jabber/buddy.c @@ -29,6 +29,7 @@ #include "util.h" #include "xmlnode.h" +#include "action.h" #include "buddy.h" #include "chat.h" #include "jabber.h" diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c index 142aa6f41a..84eff57011 100644 --- a/libpurple/protocols/novell/novell.c +++ b/libpurple/protocols/novell/novell.c @@ -21,6 +21,7 @@ #include "internal.h" #include "accountopt.h" +#include "action.h" #include "debug.h" #include "plugins.h" #include "server.h" diff --git a/libpurple/protocols/oscar/visibility.h b/libpurple/protocols/oscar/visibility.h index ec68f1dad0..4efe1db5b2 100644 --- a/libpurple/protocols/oscar/visibility.h +++ b/libpurple/protocols/oscar/visibility.h @@ -23,7 +23,7 @@ #include "oscar.h" #include "plugins.h" -#include "util.h" +#include "action.h" PurpleMenuAction * create_visibility_menu_item(OscarData *od, const char *bname); void oscar_show_visible_list(PurpleProtocolAction *action); diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c index f54e1df491..2048ecdefd 100644 --- a/libpurple/protocols/sametime/sametime.c +++ b/libpurple/protocols/sametime/sametime.c @@ -33,6 +33,7 @@ /* purple includes */ #include "account.h" #include "accountopt.h" +#include "action.h" #include "circularbuffer.h" #include "conversation.h" #include "debug.h" @@ -43,7 +44,6 @@ #include "plugins.h" #include "protocol.h" #include "request.h" -#include "util.h" #include "version.h" /* meanwhile includes */ diff --git a/libpurple/util.c b/libpurple/util.c index 2667612762..ec85523b2c 100644 --- a/libpurple/util.c +++ b/libpurple/util.c @@ -29,15 +29,6 @@ #include <json-glib/json-glib.h> -struct _PurpleMenuAction -{ - char *label; - PurpleCallback callback; - gpointer data; - GList *children; - gchar *stock_icon; -}; - static char *custom_user_dir = NULL; static char *user_dir = NULL; static gchar *cache_dir = NULL; @@ -47,99 +38,6 @@ static gchar *data_dir = NULL; static JsonNode *escape_js_node = NULL; static JsonGenerator *escape_js_gen = NULL; -PurpleMenuAction * -purple_menu_action_new(const char *label, PurpleCallback callback, gpointer data, - GList *children) -{ - PurpleMenuAction *act = g_new0(PurpleMenuAction, 1); - act->label = g_strdup(label); - act->callback = callback; - act->data = data; - act->children = children; - return act; -} - -void -purple_menu_action_free(PurpleMenuAction *act) -{ - g_return_if_fail(act != NULL); - - g_free(act->stock_icon); - g_free(act->label); - 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_menu_action_set_stock_icon(PurpleMenuAction *act, - const gchar *stock) -{ - g_return_if_fail(act != NULL); - - g_free(act->stock_icon); - act->stock_icon = g_strdup(stock); -} - -const gchar * -purple_menu_action_get_stock_icon(PurpleMenuAction *act) -{ - return act->stock_icon; -} - void purple_util_init(void) { diff --git a/libpurple/util.h b/libpurple/util.h index 20c1da0654..f73a785763 100644 --- a/libpurple/util.h +++ b/libpurple/util.h @@ -34,15 +34,6 @@ #include <stdio.h> /** - * PurpleMenuAction: - * - * A generic structure that contains information about an "action." One - * place this is is used is by protocols to tell the core the list of available - * right-click actions for a buddy list row. - */ -typedef struct _PurpleMenuAction PurpleMenuAction; - -/** * PurpleKeyValuePair: * @key: The key * @value: The value @@ -73,127 +64,6 @@ struct _PurpleKeyValuePair G_BEGIN_DECLS /** - * purple_menu_action_new: - * @label: The text label to display for this action. - * @callback: The function to be called when the action is used on - * the selected item. - * @data: Additional data to be passed to the callback. - * @children: (element-type PurpleMenuAction) (transfer full): Menu actions to - * be added as a submenu of this action. - * - * Creates a new PurpleMenuAction. - * - * Returns: The PurpleMenuAction. - */ -PurpleMenuAction *purple_menu_action_new(const char *label, PurpleCallback callback, - gpointer data, GList *children); - -/** - * purple_menu_action_free: - * @act: The PurpleMenuAction to free. - * - * Frees a PurpleMenuAction - */ -void purple_menu_action_free(PurpleMenuAction *act); - -/** - * purple_menu_action_get_label: - * @act: The PurpleMenuAction. - * - * Returns the label of the PurpleMenuAction. - * - * Returns: The label string. - */ -char * purple_menu_action_get_label(const PurpleMenuAction *act); - -/** - * purple_menu_action_get_callback: - * @act: The PurpleMenuAction. - * - * Returns the callback of the PurpleMenuAction. - * - * Returns: The callback function. - */ -PurpleCallback purple_menu_action_get_callback(const PurpleMenuAction *act); - -/** - * purple_menu_action_get_data: - * @act: The PurpleMenuAction. - * - * Returns the data stored in the PurpleMenuAction. - * - * Returns: The data. - */ -gpointer purple_menu_action_get_data(const PurpleMenuAction *act); - -/** - * purple_menu_action_get_children: - * @act: The PurpleMenuAction. - * - * Returns the children of the PurpleMenuAction. - * - * Returns: (element-type PurpleMenuAction) (transfer none): The menu children. - */ -GList* purple_menu_action_get_children(const PurpleMenuAction *act); - -/** - * purple_menu_action_set_label: - * @act: The menu action. - * @label: The label for the menu action. - * - * Set the label to the PurpleMenuAction. - */ -void purple_menu_action_set_label(PurpleMenuAction *act, char *label); - -/** - * purple_menu_action_set_callback: - * @act: The menu action. - * @callback: The callback. - * - * Set the callback that will be used by the PurpleMenuAction. - */ -void purple_menu_action_set_callback(PurpleMenuAction *act, PurpleCallback callback); - -/** - * purple_menu_action_set_data: - * @act: The menu action. - * @data: The data used by this PurpleMenuAction - * - * Set the label to the PurpleMenuAction. - */ -void purple_menu_action_set_data(PurpleMenuAction *act, gpointer data); - -/** - * purple_menu_action_set_children: - * @act: The menu action. - * @children: (element-type PurpleMenuAction) (transfer full): The menu children - * - * Set the children of the PurpleMenuAction. - */ -void purple_menu_action_set_children(PurpleMenuAction *act, GList *children); - -/** - * purple_menu_action_set_stock_icon: - * @act: The menu action. - * @stock: The stock icon identifier. - * - * Sets the icon for the PurpleMenuAction. - */ -void purple_menu_action_set_stock_icon(PurpleMenuAction *act, - const gchar *stock); - -/** - * purple_menu_action_get_stock_icon: - * @act: The menu action. - * - * Gets the stock icon of the PurpleMenuAction. - * - * Returns: The stock icon identifier. - */ -const gchar * -purple_menu_action_get_stock_icon(PurpleMenuAction *act); - -/** * purple_util_set_current_song: * @title: The title of the song, %NULL to unset the value. * @artist: The artist of the song, can be %NULL. diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c index 9c135b979f..fd1f1b5032 100644 --- a/pidgin/gtkblist.c +++ b/pidgin/gtkblist.c @@ -23,6 +23,7 @@ #include "pidgin.h" #include "account.h" +#include "action.h" #include "connection.h" #include "core.h" #include "debug.h" diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c index cca869b19b..327ce35fb9 100644 --- a/pidgin/gtkconv.c +++ b/pidgin/gtkconv.c @@ -32,6 +32,7 @@ #include "account.h" #include "attention.h" +#include "action.h" #include "cmds.h" #include "core.h" #include "debug.h" diff --git a/pidgin/gtkutils.h b/pidgin/gtkutils.h index edd724dd1c..64aa71b5b3 100644 --- a/pidgin/gtkutils.h +++ b/pidgin/gtkutils.h @@ -30,6 +30,7 @@ #include "gtkconv.h" #include "pidgin.h" +#include "action.h" #include "protocol.h" #include "util.h" diff --git a/pidgin/plugins/markerline.c b/pidgin/plugins/markerline.c index debcdc6e2f..ef976e42c1 100644 --- a/pidgin/plugins/markerline.c +++ b/pidgin/plugins/markerline.c @@ -36,6 +36,7 @@ #include <gtkconv.h> #include <gtkplugin.h> #include <gtkwebview.h> +#include <action.h> #include <version.h> #define PREF_PREFIX "/plugins/gtk/" PLUGIN_ID |