static void panel_addto_prepend_alias (GSList **parent_list, MateMenuTreeAlias *alias, const char *filename) { MateMenuTreeItem *aliased_item; aliased_item = matemenu_tree_alias_get_item (alias); switch (matemenu_tree_item_get_type (aliased_item)) { case MATEMENU_TREE_ITEM_DIRECTORY: panel_addto_prepend_directory (parent_list, MATEMENU_TREE_DIRECTORY (aliased_item), filename); break; case MATEMENU_TREE_ITEM_ENTRY: panel_addto_prepend_entry (parent_list, MATEMENU_TREE_ENTRY (aliased_item), filename); break; default: break; } matemenu_tree_item_unref (aliased_item); }
static void add_drawers_from_alias (MateMenuTreeAlias *alias, const char *toplevel_id) { MateMenuTreeItem *aliased_item; aliased_item = matemenu_tree_alias_get_item (alias); switch (matemenu_tree_item_get_type (aliased_item)) { case MATEMENU_TREE_ITEM_DIRECTORY: add_drawers_from_dir (MATEMENU_TREE_DIRECTORY (aliased_item), G_MAXINT/2, toplevel_id); break; case MATEMENU_TREE_ITEM_ENTRY: panel_launcher_create_with_id (toplevel_id, G_MAXINT/2, matemenu_tree_entry_get_desktop_file_path (MATEMENU_TREE_ENTRY (aliased_item))); break; default: break; } matemenu_tree_item_unref (aliased_item); }
static void create_menuitem_from_alias (GtkWidget *menu, MateMenuTreeAlias *alias) { MateMenuTreeItem *aliased_item; aliased_item = matemenu_tree_alias_get_item (alias); switch (matemenu_tree_item_get_type (aliased_item)) { case MATEMENU_TREE_ITEM_DIRECTORY: create_submenu (menu, MATEMENU_TREE_DIRECTORY (aliased_item), matemenu_tree_alias_get_directory (alias)); break; case MATEMENU_TREE_ITEM_ENTRY: create_menuitem (menu, MATEMENU_TREE_ENTRY (aliased_item), matemenu_tree_alias_get_directory (alias)); break; default: break; } matemenu_tree_item_unref (aliased_item); }
static GtkWidget * populate_menu_from_directory (GtkWidget *menu, MateMenuTreeDirectory *directory) { GList *children; GSList *l; GSList *items; gboolean add_separator; children = gtk_container_get_children (GTK_CONTAINER (menu)); add_separator = (children != NULL); g_list_free (children); items = matemenu_tree_directory_get_contents (directory); for (l = items; l; l = l->next) { MateMenuTreeItem *item = l->data; if (add_separator || matemenu_tree_item_get_type (item) == MATEMENU_TREE_ITEM_SEPARATOR) { add_menu_separator (menu); add_separator = FALSE; } switch (matemenu_tree_item_get_type (item)) { case MATEMENU_TREE_ITEM_DIRECTORY: create_submenu (menu, MATEMENU_TREE_DIRECTORY (item), NULL); break; case MATEMENU_TREE_ITEM_ENTRY: create_menuitem (menu, MATEMENU_TREE_ENTRY (item), NULL); break; case MATEMENU_TREE_ITEM_SEPARATOR : /* already added */ break; case MATEMENU_TREE_ITEM_ALIAS: create_menuitem_from_alias (menu, MATEMENU_TREE_ALIAS (item)); break; case MATEMENU_TREE_ITEM_HEADER: create_header (menu, MATEMENU_TREE_HEADER (item)); break; default: break; } matemenu_tree_item_unref (item); } g_slist_free (items); return menu; }
static void add_drawers_from_dir (MateMenuTreeDirectory *directory, int pos, const char *toplevel_id) { const char *name; const char *icon; GSList *items; GSList *l; char *attached_toplevel_id; name = matemenu_tree_directory_get_name (directory); icon = matemenu_tree_directory_get_icon (directory); attached_toplevel_id = panel_drawer_create_with_id (toplevel_id, pos, icon, icon != NULL, name); if (!attached_toplevel_id) return; items = matemenu_tree_directory_get_contents (directory); for (l = items; l; l = l->next) { MateMenuTreeItem *item = l->data; switch (matemenu_tree_item_get_type (item)) { case MATEMENU_TREE_ITEM_ENTRY: panel_launcher_create_with_id (attached_toplevel_id, G_MAXINT/2, matemenu_tree_entry_get_desktop_file_path (MATEMENU_TREE_ENTRY (item))); break; case MATEMENU_TREE_ITEM_DIRECTORY: add_drawers_from_dir (MATEMENU_TREE_DIRECTORY (item), G_MAXINT/2, attached_toplevel_id); break; case MATEMENU_TREE_ITEM_ALIAS: add_drawers_from_alias (MATEMENU_TREE_ALIAS (item), attached_toplevel_id); break; default: break; } matemenu_tree_item_unref (item); } g_slist_free (items); g_free (attached_toplevel_id); }