+void menu_entry_remove(ObMenuEntry *self)
+{
+ self->menu->entries = g_list_remove(self->menu->entries, self);
+ menu_entry_free(self);
+}
+
+ObMenuEntry* menu_add_normal(ObMenu *self, gint id, const gchar *label,
+ GSList *actions)
+{
+ ObMenuEntry *e;
+
+ e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_NORMAL, id);
+ e->data.normal.actions = actions;
+
+ menu_entry_set_label(e, label);
+
+ self->entries = g_list_append(self->entries, e);
+ return e;
+}
+
+ObMenuEntry* menu_add_submenu(ObMenu *self, gint id, const gchar *submenu)
+{
+ ObMenuEntry *e;
+
+ e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_SUBMENU, id);
+ e->data.submenu.name = g_strdup(submenu);
+
+ self->entries = g_list_append(self->entries, e);
+ return e;
+}
+
+ObMenuEntry* menu_add_separator(ObMenu *self, gint id, const gchar *label)
+{
+ ObMenuEntry *e;
+
+ e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_SEPARATOR, id);
+
+ menu_entry_set_label(e, label);
+
+ self->entries = g_list_append(self->entries, e);
+ return e;
+}
+
+void menu_set_update_func(ObMenu *self, ObMenuUpdateFunc func)
+{
+ self->update_func = func;
+}
+
+void menu_set_execute_func(ObMenu *self, ObMenuExecuteFunc func)
+{
+ self->execute_func = func;
+}
+
+void menu_set_destroy_func(ObMenu *self, ObMenuDestroyFunc func)
+{
+ self->destroy_func = func;
+}
+
+ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id)
+{
+ ObMenuEntry *ret = NULL;
+ GList *it;
+
+ for (it = self->entries; it; it = g_list_next(it)) {
+ ObMenuEntry *e = it->data;
+
+ if (e->id == id) {
+ ret = e;
+ break;
+ }
+ }
+ return ret;
+}
+
+void menu_find_submenus(ObMenu *self)
+{
+ GList *it;
+
+ for (it = self->entries; it; it = g_list_next(it)) {
+ ObMenuEntry *e = it->data;
+
+ if (e->type == OB_MENU_ENTRY_TYPE_SUBMENU)
+ e->data.submenu.submenu = menu_from_name(e->data.submenu.name);
+ }
+}
+
+void menu_entry_set_label(ObMenuEntry *self, const gchar *label)
+{
+ switch (self->type) {
+ case OB_MENU_ENTRY_TYPE_SEPARATOR:
+ g_free(self->data.separator.label);
+ self->data.separator.label = g_strdup(label);
+ break;
+ case OB_MENU_ENTRY_TYPE_NORMAL:
+ g_free(self->data.normal.label);
+ self->data.normal.shortcut =
+ parse_shortcut(label, &self->data.normal.label,
+ &self->data.normal.shortcut_position);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
+void menu_show_all_shortcuts(ObMenu *self, gboolean show)
+{
+ self->show_all_shortcuts = show;