static void tb_editor_menu_configure_toolbar_activate_cb(GtkWidget *menuitem, MidoriBrowser *browser) { GSList *node, *used_items, *all_items; GtkTreeIter iter; GtkTreePath *path; TBEditorWidget *tbw; /* read the current active toolbar items */ used_items = tb_editor_parse_active_items(browser); /* get all available actions */ all_items = tb_editor_get_available_actions(browser); /* create the GUI */ tbw = tb_editor_create_dialog(browser); /* cache some pointers, this is safe enough since the dialog is run modally */ tbw->action_group = midori_browser_get_action_group(browser); tbw->browser = browser; /* fill the stores */ for (node = all_items; node != NULL; node = node->next) { if (strcmp(node->data, "Separator") == 0 || g_slist_find_custom(used_items, node->data, (GCompareFunc) strcmp) == NULL) { gtk_list_store_append(tbw->store_available, &iter); tb_editor_set_item_values(tbw, node->data, tbw->store_available, &iter); } } for (node = used_items; node != NULL; node = node->next) { gtk_list_store_append(tbw->store_used, &iter); tb_editor_set_item_values(tbw, node->data, tbw->store_used, &iter); } /* select first item */ path = gtk_tree_path_new_from_string("0"); gtk_tree_selection_select_path(gtk_tree_view_get_selection(tbw->tree_used), path); gtk_tree_path_free(path); /* connect the changed signals after populating the store */ g_signal_connect(tbw->store_used, "row-changed", G_CALLBACK(tb_editor_available_items_changed_cb), tbw); g_signal_connect(tbw->store_used, "row-deleted", G_CALLBACK(tb_editor_available_items_deleted_cb), tbw); /* run it */ gtk_dialog_run(GTK_DIALOG(tbw->dialog)); gtk_widget_destroy(tbw->dialog); g_slist_foreach(used_items, (GFunc) g_free, NULL); g_slist_foreach(all_items, (GFunc) g_free, NULL); g_slist_free(used_items); g_slist_free(all_items); tb_editor_free_path(tbw); g_free(tbw); }
void marlin_toolbar_editor_dialog_show (MarlinViewWindow *mvw) { GtkTreeIter iter; GtkTreePath *path; TBEditorWidget *tbw; char **used_item; char **used_items; char **all_items; char **all_item; /* read the current active toolbar items */ used_items = g_settings_get_strv (settings, CONF_UI_TOOLBAR_ITEMS); /* get all available actions */ all_items = rb_get_toolbar_actions (); /* create the GUI */ tbw = tb_editor_create_dialog(mvw); /* cache some pointers, this is safe enough since the dialog is run modally */ tbw->mvw = mvw; /* fill the stores */ for (all_item=all_items; *all_item; all_item++) { if (strcmp(*all_item, "Separator") == 0 || !find_in_used_items(used_items, *all_item)) { gtk_list_store_append(tbw->store_available, &iter); tb_editor_set_item_values(tbw, *all_item, tbw->store_available, &iter); } } for (used_item=used_items; *used_item; used_item++) { gtk_list_store_append(tbw->store_used, &iter); tb_editor_set_item_values(tbw, *used_item, tbw->store_used, &iter); } /* connect the changed signals after populating the store */ g_signal_connect(tbw->store_used, "row-changed", G_CALLBACK(tb_editor_available_items_changed_cb), tbw); g_signal_connect(tbw->store_used, "row-deleted", G_CALLBACK(tb_editor_available_items_deleted_cb), tbw); /* run it */ gtk_dialog_run(GTK_DIALOG(tbw->dialog)); gtk_widget_destroy(tbw->dialog); g_strfreev (used_items); tb_editor_free_path(tbw); g_free(tbw); }