Mercurial > pidgin.yaz
changeset 21259:512da37d0b4f
merge of '433b476c9aefc965849a15060e0feeccb640d283'
and '51f805cc8b320f8908d9b9d6049078631c011dc6'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 20 Oct 2007 05:55:44 +0000 |
parents | d655c8a8d297 (current diff) e8b0f224483f (diff) |
children | 084c5d5472ad |
files | ChangeLog.API |
diffstat | 6 files changed, 56 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Thu Oct 18 18:17:23 2007 +0000 +++ b/ChangeLog.API Sat Oct 20 05:55:44 2007 +0000 @@ -106,6 +106,8 @@ bound to a keystroke. * Added gnt_menu_get_item to activate and return a menuitem of the given id from a menu. + * Added gnt_menuitem_activate, which triggers the 'activate' signal on + the menuitem and calls the callback function, if available. version 2.2.2 (??/??/????): libpurple:
--- a/finch/libgnt/gntmenu.c Thu Oct 18 18:17:23 2007 +0000 +++ b/finch/libgnt/gntmenu.c Sat Oct 20 05:55:44 2007 +0000 @@ -181,7 +181,15 @@ static void menuitem_activate(GntMenu *menu, GntMenuItem *item) { - if (item) { + if (!item) + return; + + if (gnt_menuitem_activate(item)) { + while (menu) { + gnt_widget_hide(GNT_WIDGET(menu)); + menu = menu->parentmenu; + } + } else { if (item->submenu) { GntMenu *sub = GNT_MENU(item->submenu); menu->submenu = sub; @@ -195,12 +203,6 @@ gnt_widget_set_position(GNT_WIDGET(sub), item->priv.x, item->priv.y); GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(sub), GNT_WIDGET_INVISIBLE); gnt_widget_draw(GNT_WIDGET(sub)); - } else if (item->callback) { - item->callback(item, item->callbackdata); - while (menu) { - gnt_widget_hide(GNT_WIDGET(menu)); - menu = menu->parentmenu; - } } } } @@ -326,8 +328,7 @@ GntMenu *menu = GNT_MENU(tree); gboolean check = gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item)); gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), !check); - if (item->callback) - item->callback(item, item->callbackdata); + gnt_menuitem_activate(item); while (menu) { gnt_widget_hide(GNT_WIDGET(menu)); menu = menu->parentmenu;
--- a/finch/libgnt/gntmenuitem.c Thu Oct 18 18:17:23 2007 +0000 +++ b/finch/libgnt/gntmenuitem.c Sat Oct 20 05:55:44 2007 +0000 @@ -23,6 +23,13 @@ #include "gntmenu.h" #include "gntmenuitem.h" +enum +{ + SIG_ACTIVATE, + SIGS +}; +static guint signals[SIGS] = { 0 }; + static GObjectClass *parent_class = NULL; static void @@ -44,10 +51,18 @@ parent_class = g_type_class_peek_parent(klass); obj_class->dispose = gnt_menuitem_destroy; + + signals[SIG_ACTIVATE] = + g_signal_new("activate", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void -gnt_menuitem_init(GTypeInstance *instance, gpointer class) +gnt_menuitem_init(GTypeInstance *instance, gpointer klass) { } @@ -131,3 +146,13 @@ return item->priv.id; } +gboolean gnt_menuitem_activate(GntMenuItem *item) +{ + g_signal_emit(item, signals[SIG_ACTIVATE], 0); + if (item->callback) { + item->callback(item, item->callbackdata); + return TRUE; + } + return FALSE; +} +
--- a/finch/libgnt/gntmenuitem.h Thu Oct 18 18:17:23 2007 +0000 +++ b/finch/libgnt/gntmenuitem.h Sat Oct 20 05:55:44 2007 +0000 @@ -168,6 +168,19 @@ */ const char * gnt_menuitem_get_id(GntMenuItem *item); +/** + * Activate a menuitem. + * Activating the menuitem will first trigger the 'activate' signal for the + * menuitem. Then the callback for the menuitem is triggered, if there is one. + * + * @param item The menuitem. + * + * @return Whether the callback for the menuitem was called. + * + * @since 2.3.0 + */ +gboolean gnt_menuitem_activate(GntMenuItem *item); + G_END_DECLS #endif /* GNT_MENUITEM_H */
--- a/finch/libgnt/gntstyle.c Thu Oct 18 18:17:23 2007 +0000 +++ b/finch/libgnt/gntstyle.c Sat Oct 20 05:55:44 2007 +0000 @@ -413,11 +413,14 @@ void gnt_uninit_styles() { int i; - for (i = 0; i < GNT_STYLES; i++) + for (i = 0; i < GNT_STYLES; i++) { g_free(str_styles[i]); + str_styles[i] = NULL; + } #if GLIB_CHECK_VERSION(2,6,0) g_key_file_free(gkfile); + gkfile = NULL; #endif }