[Commits] callbacks.c 1.14 1.15 extension-loader.c 1.5 1.6 extension-loader.h 1.2 1.3
miras at claws-mail.org
miras at claws-mail.org
Wed Dec 14 09:27:05 CET 2011
Update of /home/claws-mail/contacts/src
In directory claws-mail:/tmp/cvs-serv28932/src
Modified Files:
callbacks.c extension-loader.c extension-loader.h
Log Message:
2011-12-14 [mir] 0.6.0cvs47
* extensions/example/src/example-extension.c
* src/callbacks.c
* src/extension-loader.c
* src/extension-loader.h
Added feature that enables to insert new
items into submenus in the context menu.
See example-extension.c for details.
Index: callbacks.c
===================================================================
RCS file: /home/claws-mail/contacts/src/callbacks.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- callbacks.c 9 Dec 2011 23:01:21 -0000 1.14
+++ callbacks.c 14 Dec 2011 08:27:03 -0000 1.15
@@ -233,7 +233,7 @@
*contact_print, *contact_delete;
GtkAccelGroup* accel;
const gchar* name = widget->name;
- GtkWidget* context;
+ GSList* context;
debug_print("Popup called from %s\n", name);
if (! (strcmp(name, "abook_list") == 0 ||
@@ -311,8 +311,13 @@
/* Insert requested menu_items from extensions */
context = get_menu_items(CONTACTS_ADDRESSBOOK_MENU);
if (context) {
- gtk_widget_unparent(context);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), g_object_ref(context));
+ GSList* cur = context;
+ while (cur) {
+ GtkWidget* widget = (GtkWidget *) cur->data;
+ gtk_widget_unparent(widget);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), g_object_ref(widget));
+ cur = cur->next;
+ }
}
}
else if (strcmp(name, "contact_list") == 0) {
@@ -362,8 +367,13 @@
/* Insert requested menu_items from extensions */
context = get_menu_items(CONTACTS_CONTACT_MENU);
if (context) {
- gtk_widget_unparent(context);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), g_object_ref(context));
+ GSList* cur = context;
+ while (cur) {
+ GtkWidget* widget = (GtkWidget *) cur->data;
+ gtk_widget_unparent(widget);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), g_object_ref(widget));
+ cur = cur->next;
+ }
}
}
else {
Index: extension-loader.h
===================================================================
RCS file: /home/claws-mail/contacts/src/extension-loader.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- extension-loader.h 9 Dec 2011 23:01:21 -0000 1.2
+++ extension-loader.h 14 Dec 2011 08:27:03 -0000 1.3
@@ -66,7 +66,7 @@
void extension_loader_done(void);
void load_extensions(gchar** error);
void unload_extensions(void);
-GtkWidget* get_menu_items(ContactsMenu menu);
+GSList* get_menu_items(ContactsMenu menu);
G_END_DECLS
Index: extension-loader.c
===================================================================
RCS file: /home/claws-mail/contacts/src/extension-loader.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- extension-loader.c 13 Dec 2011 15:09:33 -0000 1.5
+++ extension-loader.c 14 Dec 2011 08:27:03 -0000 1.6
@@ -45,8 +45,8 @@
static GSList* active_hooks[EXTENSION_HOOK_N];
static GSList* user_menu_items = NULL;
-static GtkWidget* abook_context = NULL;
-static GtkWidget* contact_context = NULL;
+static GSList* abook_context = NULL;
+static GSList* contact_context = NULL;
/* The number corresponts to the default number of GtkMenu - 1 */
static guint menu_count = 4;
/* The number corresponts to the default number of GtkMenu - separator and quit */
@@ -386,21 +386,21 @@
extension_loader_done();
}
-GtkWidget* get_menu_items(ContactsMenu menu) {
- GtkWidget* widget = NULL;
+GSList* get_menu_items(ContactsMenu menu) {
+ GSList* widgets = NULL;
switch (menu) {
case CONTACTS_ADDRESSBOOK_MENU:
- widget = abook_context;
+ widgets = abook_context;
break;
case CONTACTS_CONTACT_MENU:
- widget = contact_context;
+ widgets = contact_context;
break;
default:
break;
}
- return widget;
+ return widgets;
}
static GtkWidget* create_menu_item(GtkWidget** widget, const gchar* label) {
@@ -426,7 +426,7 @@
gboolean force = FALSE;
if (menu_item->submenu) {
- for (cur = user_menu_items; cur && ! menu; cur = g_slist_next(cur)) {
+ for (cur = user_menu_items; cur && ! menu && ! force; cur = g_slist_next(cur)) {
UserMenuItem* item = (UserMenuItem *) cur->data;
if (utf8_collate((gchar *) item->parent, (gchar *) menu_item->parent) == 0) {
if (utf8_collate((gchar *) item->sublabel, (gchar *) menu_item->sublabel) == 0 ||
@@ -557,27 +557,15 @@
menu_elem = insert_sub_menu(image_menu, menu_item, menu);
if (menu->sublabel && menu_item->parent)
menu->parent = menu_item->parent;
- else {
- g_free(menu);
- menu = NULL;
- }
- if (! contact_context)
- contact_context = menu_elem;
- else
- gtk_menu_shell_append(GTK_MENU_SHELL(contact_context), menu_elem);
+ if (menu_elem)
+ contact_context = g_slist_append(contact_context, menu_elem);
}
else if (menu_item->menu == CONTACTS_ADDRESSBOOK_MENU) {
menu_elem = insert_sub_menu(image_menu, menu_item, menu);
if (menu->sublabel && menu_item->parent)
menu->parent = menu_item->parent;
- else {
- g_free(menu);
- menu = NULL;
- }
- if (! abook_context)
- abook_context = menu_elem;
- else
- gtk_menu_shell_append(GTK_MENU_SHELL(abook_context), menu_elem);
+ if (menu_elem)
+ abook_context = g_slist_append(abook_context, menu_elem);
}
else {
// error!!!!
More information about the Commits
mailing list