Made pages list in preferences dialog a list, not a tree

This commit is contained in:
Yevgen Muntyan 2006-02-26 19:18:26 -06:00
parent 703ddfe09b
commit e3bc0cff16
4 changed files with 14 additions and 29 deletions

View File

@ -1018,8 +1018,7 @@ cmp_page_and_id (GObject *page,
} }
static void static void
sync_pages (MooPrefsDialog *dialog, sync_pages (MooPrefsDialog *dialog)
MooPrefsDialogPage *main_page)
{ {
GSList *old_plugin_pages, *plugin_pages, *plugin_ids, *l, *plugins; GSList *old_plugin_pages, *plugin_pages, *plugin_ids, *l, *plugins;
@ -1058,7 +1057,7 @@ sync_pages (MooPrefsDialog *dialog,
g_strdup (moo_plugin_id (plugin)), g_strdup (moo_plugin_id (plugin)),
g_free); g_free);
plugin_pages = g_slist_append (plugin_pages, plugin_page); plugin_pages = g_slist_append (plugin_pages, plugin_page);
moo_prefs_dialog_insert_page (dialog, plugin_page, GTK_WIDGET (main_page), -1); moo_prefs_dialog_insert_page (dialog, plugin_page, -1);
} }
} }
} }
@ -1112,7 +1111,7 @@ prefs_init (MooPrefsDialog *dialog,
selection_changed (gtk_tree_view_get_selection (treeview), page); selection_changed (gtk_tree_view_get_selection (treeview), page);
g_slist_free (plugins); g_slist_free (plugins);
sync_pages (dialog, page); sync_pages (dialog);
} }
@ -1153,7 +1152,7 @@ prefs_apply (MooPrefsDialog *dialog,
} }
while (gtk_tree_model_iter_next (model, &iter)); while (gtk_tree_model_iter_next (model, &iter));
sync_pages (dialog, page); sync_pages (dialog);
} }

View File

@ -1306,7 +1306,6 @@
(return-type "none") (return-type "none")
(parameters (parameters
'("GtkWidget*" "page") '("GtkWidget*" "page")
'("GtkWidget*" "parent_page")
'("int" "position") '("int" "position")
) )
) )

View File

@ -202,7 +202,7 @@ setup_pages_list (MooPrefsDialog *dialog)
GtkTreeViewColumn *icon_column, *label_column; GtkTreeViewColumn *icon_column, *label_column;
GtkTreeSelection *selection; GtkTreeSelection *selection;
dialog->store = gtk_tree_store_new (N_COLUMNS, dialog->store = gtk_list_store_new (N_COLUMNS,
GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
@ -396,41 +396,29 @@ void
moo_prefs_dialog_append_page (MooPrefsDialog *dialog, moo_prefs_dialog_append_page (MooPrefsDialog *dialog,
GtkWidget *page) GtkWidget *page)
{ {
moo_prefs_dialog_insert_page (dialog, page, NULL, -1); moo_prefs_dialog_insert_page (dialog, page, -1);
} }
void void
moo_prefs_dialog_insert_page (MooPrefsDialog *dialog, moo_prefs_dialog_insert_page (MooPrefsDialog *dialog,
GtkWidget *page, GtkWidget *page,
GtkWidget *parent_page,
int position) int position)
{ {
char *label = NULL, *icon_id = NULL; char *label = NULL, *icon_id = NULL;
GdkPixbuf *icon = NULL; GdkPixbuf *icon = NULL;
GtkTreeIter iter, parent_iter; GtkTreeIter iter;
GtkTreeRowReference *ref; GtkTreeRowReference *ref;
GtkTreePath *path = NULL; GtkTreePath *path = NULL;
g_return_if_fail (MOO_IS_PREFS_DIALOG (dialog)); g_return_if_fail (MOO_IS_PREFS_DIALOG (dialog));
g_return_if_fail (MOO_IS_PREFS_DIALOG_PAGE (page)); g_return_if_fail (MOO_IS_PREFS_DIALOG_PAGE (page));
g_return_if_fail (page->parent == NULL); g_return_if_fail (page->parent == NULL);
g_return_if_fail (!parent_page || MOO_IS_PREFS_DIALOG_PAGE (parent_page));
g_return_if_fail (!parent_page || parent_page->parent == GTK_WIDGET (dialog->notebook));
if (parent_page) if (position < 0)
{ position = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (dialog->store), NULL);
ref = g_object_get_data (G_OBJECT (parent_page), "moo-prefs-dialog-row");
g_return_if_fail (ref && gtk_tree_row_reference_valid (ref)); gtk_list_store_insert (dialog->store, &iter, position);
path = gtk_tree_row_reference_get_path (ref);
gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->store), &parent_iter, path);
gtk_tree_store_insert (dialog->store, &iter, &parent_iter, position);
gtk_tree_path_free (path);
}
else
{
gtk_tree_store_insert (dialog->store, &iter, NULL, position);
}
gtk_widget_show (page); gtk_widget_show (page);
gtk_notebook_insert_page (dialog->notebook, page, NULL, -1); gtk_notebook_insert_page (dialog->notebook, page, NULL, -1);
@ -441,7 +429,7 @@ moo_prefs_dialog_insert_page (MooPrefsDialog *dialog,
"icon-stock-id", &icon_id, "icon-stock-id", &icon_id,
NULL); NULL);
gtk_tree_store_set (dialog->store, &iter, gtk_list_store_set (dialog->store, &iter,
ICON_ID_COLUMN, icon_id, ICON_ID_COLUMN, icon_id,
ICON_COLUMN, icon, ICON_COLUMN, icon,
LABEL_COLUMN, label, LABEL_COLUMN, label,
@ -479,7 +467,7 @@ moo_prefs_dialog_remove_page (MooPrefsDialog *dialog,
path = gtk_tree_row_reference_get_path (ref); path = gtk_tree_row_reference_get_path (ref);
gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->store), &iter, path); gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->store), &iter, path);
gtk_tree_store_remove (dialog->store, &iter); gtk_list_store_remove (dialog->store, &iter);
g_object_set_data (G_OBJECT (page), "moo-prefs-dialog-row", NULL); g_object_set_data (G_OBJECT (page), "moo-prefs-dialog-row", NULL);
gtk_tree_path_free (path); gtk_tree_path_free (path);

View File

@ -34,7 +34,7 @@ struct _MooPrefsDialog
{ {
GtkDialog dialog; GtkDialog dialog;
GtkNotebook *notebook; GtkNotebook *notebook;
GtkTreeStore *store; GtkListStore *store;
GtkTreeView *pages_list; GtkTreeView *pages_list;
gboolean hide_on_delete; gboolean hide_on_delete;
}; };
@ -61,7 +61,6 @@ void moo_prefs_dialog_remove_page (MooPrefsDialog *dialog,
GtkWidget *page); GtkWidget *page);
void moo_prefs_dialog_insert_page (MooPrefsDialog *dialog, void moo_prefs_dialog_insert_page (MooPrefsDialog *dialog,
GtkWidget *page, GtkWidget *page,
GtkWidget *parent_page,
int position); int position);