Accept model (get_services_category_entry): Accept model
2002-01-27 Bradford Hovinen <hovinen@ximian.com> * service-info.c (load_all_services): Accept model (get_services_category_entry): Accept model (service_info_new): Accept model (get_services_category_entry): Set the parent pointer * model-entry.c (get_model_entries): Accept model * mime-type-info.c (mime_type_info_new, load_all_mime_types): Accept model * mime-edit-dialog.c (store_data): Don't perform notification * model-entry.c (model_entry_insert_child) (model_entry_remove_child): Perform notification here * mime-type-info.c (mime_type_info_set_category_name): Accept model for notification purposes (get_category): Ditto; notify the model that the new category has been created * mime-types-model.c (mime_types_model_iter_parent): Make the iterator invalid if the parent is the root node * mime-edit-dialog.c (collect_filename_extensions): Return NULL if there are no nodes in the tree at all
This commit is contained in:
parent
ffc7207157
commit
6a3797bfc5
11 changed files with 126 additions and 92 deletions
|
@ -1,3 +1,31 @@
|
|||
2002-01-27 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* service-info.c (load_all_services): Accept model
|
||||
(get_services_category_entry): Accept model
|
||||
(service_info_new): Accept model
|
||||
(get_services_category_entry): Set the parent pointer
|
||||
|
||||
* model-entry.c (get_model_entries): Accept model
|
||||
|
||||
* mime-type-info.c (mime_type_info_new, load_all_mime_types):
|
||||
Accept model
|
||||
|
||||
* mime-edit-dialog.c (store_data): Don't perform notification
|
||||
|
||||
* model-entry.c (model_entry_insert_child)
|
||||
(model_entry_remove_child): Perform notification here
|
||||
|
||||
* mime-type-info.c (mime_type_info_set_category_name): Accept
|
||||
model for notification purposes
|
||||
(get_category): Ditto; notify the model that the new category has
|
||||
been created
|
||||
|
||||
* mime-types-model.c (mime_types_model_iter_parent): Make the
|
||||
iterator invalid if the parent is the root node
|
||||
|
||||
* mime-edit-dialog.c (collect_filename_extensions): Return NULL if
|
||||
there are no nodes in the tree at all
|
||||
|
||||
2002-01-26 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* service-edit-dialog.c (response_cb): Free the structure if the
|
||||
|
|
|
@ -145,7 +145,6 @@ remove_cb (GtkButton *button, GladeXML *dialog)
|
|||
GtkTreeModel *model;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
ModelEntry *entry;
|
||||
|
||||
treeview = GTK_TREE_VIEW (WID ("mime_types_tree"));
|
||||
|
@ -154,11 +153,8 @@ remove_cb (GtkButton *button, GladeXML *dialog)
|
|||
|
||||
entry = MODEL_ENTRY_FROM_ITER (&iter);
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
model_entry_remove_child (entry->parent, entry);
|
||||
model_entry_remove_child (entry->parent, entry, model);
|
||||
model_entry_append_to_delete_list (entry);
|
||||
gtk_tree_model_row_deleted (model, path);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
selection_changed_cb (selection, dialog);
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ mime_edit_dialog_set_prop (GObject *object, guint prop_id, const GValue *value,
|
|||
mime_edit_dialog->p->is_add = g_value_get_boolean (value);
|
||||
|
||||
if (mime_edit_dialog->p->is_add) {
|
||||
mime_edit_dialog->p->info = mime_type_info_new (NULL);
|
||||
mime_edit_dialog->p->info = mime_type_info_new (NULL, NULL);
|
||||
setup_add_dialog (mime_edit_dialog);
|
||||
gtk_widget_show_all (mime_edit_dialog->p->dialog_win);
|
||||
}
|
||||
|
@ -497,7 +497,8 @@ collect_filename_extensions (MimeEditDialog *dialog)
|
|||
GValue value;
|
||||
GList *ret = NULL;
|
||||
|
||||
gtk_tree_model_get_iter_root (GTK_TREE_MODEL (dialog->p->ext_store), &iter);
|
||||
if (!gtk_tree_model_get_iter_root (GTK_TREE_MODEL (dialog->p->ext_store), &iter))
|
||||
return NULL;
|
||||
|
||||
value.g_type = G_TYPE_INVALID;
|
||||
|
||||
|
@ -532,7 +533,6 @@ store_data (MimeEditDialog *dialog)
|
|||
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GtkTreePath *old_path = NULL;
|
||||
|
||||
g_free (dialog->p->info->description);
|
||||
dialog->p->info->description = g_strdup (gtk_entry_get_text (GTK_ENTRY (WID ("description_entry"))));
|
||||
|
@ -565,21 +565,6 @@ store_data (MimeEditDialog *dialog)
|
|||
dialog->p->info->small_icon_pixbuf = NULL;
|
||||
}
|
||||
|
||||
tmp = mime_type_info_get_category_name (dialog->p->info);
|
||||
tmp1 = gtk_entry_get_text (GTK_ENTRY (WID ("category_entry")));
|
||||
if (strcmp (tmp, tmp1)) {
|
||||
cat_changed = TRUE;
|
||||
|
||||
if (!dialog->p->is_add) {
|
||||
mime_types_model_construct_iter (MIME_TYPES_MODEL (dialog->p->model),
|
||||
MODEL_ENTRY (dialog->p->info), &iter);
|
||||
old_path = gtk_tree_model_get_path (dialog->p->model, &iter);
|
||||
}
|
||||
|
||||
mime_type_info_set_category_name (dialog->p->info, tmp1);
|
||||
}
|
||||
g_free (tmp);
|
||||
|
||||
option_menu = GTK_OPTION_MENU (WID ("component_select"));
|
||||
menu_shell = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
|
||||
idx = gtk_option_menu_get_history (option_menu);
|
||||
|
@ -608,21 +593,19 @@ store_data (MimeEditDialog *dialog)
|
|||
ext_list = collect_filename_extensions (dialog);
|
||||
mime_type_info_set_file_extensions (dialog->p->info, ext_list);
|
||||
|
||||
tmp = mime_type_info_get_category_name (dialog->p->info);
|
||||
tmp1 = gtk_entry_get_text (GTK_ENTRY (WID ("category_entry")));
|
||||
if (strcmp (tmp, tmp1)) {
|
||||
cat_changed = TRUE;
|
||||
mime_type_info_set_category_name (dialog->p->info, tmp1, dialog->p->model);
|
||||
}
|
||||
g_free (tmp);
|
||||
|
||||
model_entry_append_to_dirty_list (MODEL_ENTRY (dialog->p->info));
|
||||
|
||||
mime_types_model_construct_iter (MIME_TYPES_MODEL (dialog->p->model),
|
||||
MODEL_ENTRY (dialog->p->info), &iter);
|
||||
|
||||
if (cat_changed) {
|
||||
if (old_path != NULL) {
|
||||
gtk_tree_model_row_deleted (dialog->p->model, old_path);
|
||||
gtk_tree_path_free (old_path);
|
||||
}
|
||||
|
||||
path = gtk_tree_model_get_path (dialog->p->model, &iter);
|
||||
gtk_tree_model_row_inserted (dialog->p->model, path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
} else {
|
||||
if (!cat_changed) {
|
||||
mime_types_model_construct_iter (MIME_TYPES_MODEL (dialog->p->model),
|
||||
MODEL_ENTRY (dialog->p->info), &iter);
|
||||
path = gtk_tree_model_get_path (dialog->p->model, &iter);
|
||||
gtk_tree_model_row_changed (dialog->p->model, path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
|
|
|
@ -47,25 +47,26 @@ static void get_icon_pixbuf (MimeTypeInfo *info,
|
|||
const gchar *icon_path,
|
||||
gboolean want_large);
|
||||
|
||||
static MimeCategoryInfo *get_category (const gchar *category_name);
|
||||
static MimeCategoryInfo *get_category (const gchar *category_name,
|
||||
GtkTreeModel *model);
|
||||
|
||||
|
||||
|
||||
void
|
||||
load_all_mime_types (void)
|
||||
load_all_mime_types (GtkTreeModel *model)
|
||||
{
|
||||
GList *list, *tmp;
|
||||
|
||||
list = gnome_vfs_get_registered_mime_types ();
|
||||
|
||||
for (tmp = list; tmp != NULL; tmp = tmp->next)
|
||||
mime_type_info_new (tmp->data);
|
||||
mime_type_info_new (tmp->data, model);
|
||||
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
MimeTypeInfo *
|
||||
mime_type_info_new (const gchar *mime_type)
|
||||
mime_type_info_new (const gchar *mime_type, GtkTreeModel *model)
|
||||
{
|
||||
MimeTypeInfo *info;
|
||||
|
||||
|
@ -75,9 +76,9 @@ mime_type_info_new (const gchar *mime_type)
|
|||
if (mime_type != NULL) {
|
||||
info->mime_type = g_strdup (mime_type);
|
||||
|
||||
mime_type_info_set_category_name (info, get_category_name (mime_type));
|
||||
mime_type_info_set_category_name (info, get_category_name (mime_type), model);
|
||||
} else {
|
||||
info->entry.parent = get_model_entries ();
|
||||
info->entry.parent = get_model_entries (model);
|
||||
}
|
||||
|
||||
return info;
|
||||
|
@ -222,16 +223,16 @@ mime_type_info_get_category_name (const MimeTypeInfo *info)
|
|||
}
|
||||
|
||||
void
|
||||
mime_type_info_set_category_name (const MimeTypeInfo *info, const gchar *category_name)
|
||||
mime_type_info_set_category_name (const MimeTypeInfo *info, const gchar *category_name, GtkTreeModel *model)
|
||||
{
|
||||
if (MODEL_ENTRY (info)->parent != NULL)
|
||||
model_entry_remove_child (MODEL_ENTRY (info)->parent, MODEL_ENTRY (info));
|
||||
model_entry_remove_child (MODEL_ENTRY (info)->parent, MODEL_ENTRY (info), model);
|
||||
|
||||
if (category_name != NULL) {
|
||||
MODEL_ENTRY (info)->parent = MODEL_ENTRY (get_category (category_name));
|
||||
MODEL_ENTRY (info)->parent = MODEL_ENTRY (get_category (category_name, model));
|
||||
|
||||
if (MODEL_ENTRY (info)->parent != NULL)
|
||||
model_entry_insert_child (MODEL_ENTRY (info)->parent, MODEL_ENTRY (info));
|
||||
model_entry_insert_child (MODEL_ENTRY (info)->parent, MODEL_ENTRY (info), model);
|
||||
} else {
|
||||
MODEL_ENTRY (info)->parent = NULL;
|
||||
}
|
||||
|
@ -312,7 +313,7 @@ mime_type_info_free (MimeTypeInfo *info)
|
|||
}
|
||||
|
||||
MimeCategoryInfo *
|
||||
mime_category_info_new (MimeCategoryInfo *parent, const gchar *name)
|
||||
mime_category_info_new (MimeCategoryInfo *parent, const gchar *name, GtkTreeModel *model)
|
||||
{
|
||||
MimeCategoryInfo *info;
|
||||
|
||||
|
@ -324,9 +325,7 @@ mime_category_info_new (MimeCategoryInfo *parent, const gchar *name)
|
|||
if (parent != NULL)
|
||||
MODEL_ENTRY (info)->parent = MODEL_ENTRY (parent);
|
||||
else
|
||||
MODEL_ENTRY (info)->parent = get_model_entries ();
|
||||
|
||||
model_entry_insert_child (MODEL_ENTRY (info)->parent, MODEL_ENTRY (info));
|
||||
MODEL_ENTRY (info)->parent = get_model_entries (model);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -567,7 +566,7 @@ get_icon_pixbuf (MimeTypeInfo *info, const gchar *icon_path, gboolean want_large
|
|||
}
|
||||
|
||||
static MimeCategoryInfo *
|
||||
get_category (const gchar *category_name)
|
||||
get_category (const gchar *category_name, GtkTreeModel *model)
|
||||
{
|
||||
ModelEntry *current, *child;
|
||||
gchar **categories;
|
||||
|
@ -578,7 +577,7 @@ get_category (const gchar *category_name)
|
|||
|
||||
categories = g_strsplit (category_name, "/", -1);
|
||||
|
||||
current = get_model_entries ();
|
||||
current = get_model_entries (model);
|
||||
|
||||
for (i = 0; categories[i] != NULL; i++) {
|
||||
for (child = current->first_child; child != NULL; child = child->next) {
|
||||
|
@ -589,8 +588,10 @@ get_category (const gchar *category_name)
|
|||
break;
|
||||
}
|
||||
|
||||
if (child == NULL)
|
||||
child = MODEL_ENTRY (mime_category_info_new (MIME_CATEGORY_INFO (current), categories[i]));
|
||||
if (child == NULL) {
|
||||
child = MODEL_ENTRY (mime_category_info_new (MIME_CATEGORY_INFO (current), categories[i], model));
|
||||
model_entry_insert_child (MODEL_ENTRY (child)->parent, MODEL_ENTRY (child), model);
|
||||
}
|
||||
|
||||
current = child;
|
||||
}
|
||||
|
|
|
@ -69,9 +69,10 @@ struct _MimeCategoryInfo
|
|||
gboolean needs_terminal;
|
||||
};
|
||||
|
||||
void load_all_mime_types (void);
|
||||
void load_all_mime_types (GtkTreeModel *model);
|
||||
|
||||
MimeTypeInfo *mime_type_info_new (const gchar *mime_type);
|
||||
MimeTypeInfo *mime_type_info_new (const gchar *mime_type,
|
||||
GtkTreeModel *model);
|
||||
|
||||
void mime_type_info_load_all (MimeTypeInfo *info);
|
||||
const gchar *mime_type_info_get_description (MimeTypeInfo *info);
|
||||
|
@ -87,12 +88,14 @@ gchar *mime_type_info_get_file_extensions_pretty_string
|
|||
gchar *mime_type_info_get_category_name (const MimeTypeInfo *info);
|
||||
|
||||
void mime_type_info_set_category_name (const MimeTypeInfo *info,
|
||||
const gchar *category_name);
|
||||
const gchar *category_name,
|
||||
GtkTreeModel *model);
|
||||
void mime_type_info_set_file_extensions (MimeTypeInfo *info,
|
||||
GList *list);
|
||||
|
||||
MimeCategoryInfo *mime_category_info_new (MimeCategoryInfo *parent,
|
||||
const gchar *name);
|
||||
const gchar *name,
|
||||
GtkTreeModel *model);
|
||||
void mime_category_info_load_all (MimeCategoryInfo *category);
|
||||
void mime_category_info_save (MimeCategoryInfo *category);
|
||||
GList *mime_category_info_find_apps (MimeCategoryInfo *info);
|
||||
|
|
|
@ -331,7 +331,7 @@ mime_types_model_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeP
|
|||
g_return_val_if_fail (depth > 0, FALSE);
|
||||
|
||||
parent.stamp = model->p->stamp;
|
||||
parent.user_data = get_model_entries ();
|
||||
parent.user_data = get_model_entries (tree_model);
|
||||
|
||||
if (!gtk_tree_model_iter_nth_child (tree_model, iter, &parent, indices[0]))
|
||||
return FALSE;
|
||||
|
@ -502,7 +502,7 @@ mime_types_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, Gtk
|
|||
entry = NULL;
|
||||
|
||||
if (entry == NULL)
|
||||
iter->user_data = get_model_entries ();
|
||||
iter->user_data = get_model_entries (tree_model);
|
||||
else
|
||||
iter->user_data = entry->first_child;
|
||||
|
||||
|
@ -526,7 +526,7 @@ mime_types_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
|
|||
entry = iter->user_data;
|
||||
|
||||
if (entry == NULL)
|
||||
return get_model_entries ()->first_child != NULL;
|
||||
return get_model_entries (tree_model)->first_child != NULL;
|
||||
else if (!model->p->category_only || IS_CATEGORY (entry->first_child))
|
||||
return entry->first_child != NULL;
|
||||
else {
|
||||
|
@ -556,7 +556,7 @@ mime_types_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
|
|||
entry = NULL;
|
||||
|
||||
if (entry == NULL)
|
||||
entry = get_model_entries ();
|
||||
entry = get_model_entries (tree_model);
|
||||
|
||||
if (model->p->category_only) {
|
||||
for (tmp = entry->first_child; tmp != NULL; tmp = tmp->next) {
|
||||
|
@ -588,7 +588,7 @@ mime_types_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, Gt
|
|||
entry = NULL;
|
||||
|
||||
if (entry == NULL)
|
||||
iter->user_data = model_entry_get_nth_child (get_model_entries (), n, model->p->category_only);
|
||||
iter->user_data = model_entry_get_nth_child (get_model_entries (tree_model), n, model->p->category_only);
|
||||
else
|
||||
iter->user_data = model_entry_get_nth_child (entry, n, model->p->category_only);
|
||||
|
||||
|
@ -607,8 +607,10 @@ mime_types_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTr
|
|||
model = MIME_TYPES_MODEL (tree_model);
|
||||
entry = iter->user_data;
|
||||
|
||||
if (entry != NULL)
|
||||
if (entry != NULL && entry->parent->type != MODEL_ENTRY_NONE)
|
||||
iter->user_data = entry->parent;
|
||||
else
|
||||
iter->user_data = NULL;
|
||||
|
||||
return iter->user_data != NULL;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "model-entry.h"
|
||||
#include "mime-type-info.h"
|
||||
#include "service-info.h"
|
||||
#include "mime-types-model.h"
|
||||
|
||||
/* List of MimeTypeInfo structures that have data to be committed */
|
||||
|
||||
|
@ -36,7 +37,7 @@ static GList *dirty_list = NULL;
|
|||
static GList *delete_list = NULL;
|
||||
|
||||
ModelEntry *
|
||||
get_model_entries (void)
|
||||
get_model_entries (GtkTreeModel *model)
|
||||
{
|
||||
static ModelEntry *root;
|
||||
|
||||
|
@ -44,8 +45,8 @@ get_model_entries (void)
|
|||
root = g_new0 (ModelEntry, 1);
|
||||
root->type = MODEL_ENTRY_NONE;
|
||||
|
||||
load_all_mime_types ();
|
||||
load_all_services ();
|
||||
load_all_mime_types (model);
|
||||
load_all_services (model);
|
||||
}
|
||||
|
||||
return root;
|
||||
|
@ -92,14 +93,18 @@ model_entry_get_index (ModelEntry *parent, ModelEntry *child)
|
|||
}
|
||||
|
||||
void
|
||||
model_entry_insert_child (ModelEntry *entry, ModelEntry *child)
|
||||
model_entry_insert_child (ModelEntry *entry, ModelEntry *child, GtkTreeModel *model)
|
||||
{
|
||||
ModelEntry *tmp;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (entry != NULL);
|
||||
g_return_if_fail (entry->type == MODEL_ENTRY_CATEGORY || entry->type == MODEL_ENTRY_SERVICES_CATEGORY ||
|
||||
entry->type == MODEL_ENTRY_NONE);
|
||||
g_return_if_fail (child != NULL);
|
||||
g_return_if_fail (model != NULL);
|
||||
g_return_if_fail (IS_MIME_TYPES_MODEL (model));
|
||||
|
||||
if (entry->first_child == NULL) {
|
||||
entry->first_child = child;
|
||||
|
@ -107,17 +112,26 @@ model_entry_insert_child (ModelEntry *entry, ModelEntry *child)
|
|||
for (tmp = entry->first_child; tmp->next != NULL; tmp = tmp->next);
|
||||
tmp->next = child;
|
||||
}
|
||||
|
||||
mime_types_model_construct_iter (MIME_TYPES_MODEL (model), child, &iter);
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
gtk_tree_model_row_inserted (model, path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
void
|
||||
model_entry_remove_child (ModelEntry *entry, ModelEntry *child)
|
||||
model_entry_remove_child (ModelEntry *entry, ModelEntry *child, GtkTreeModel *model)
|
||||
{
|
||||
ModelEntry *tmp;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (entry != NULL);
|
||||
g_return_if_fail (entry->type == MODEL_ENTRY_CATEGORY || entry->type == MODEL_ENTRY_SERVICES_CATEGORY ||
|
||||
entry->type == MODEL_ENTRY_NONE);
|
||||
g_return_if_fail (child != NULL);
|
||||
g_return_if_fail (model != NULL);
|
||||
g_return_if_fail (IS_MIME_TYPES_MODEL (model));
|
||||
|
||||
if (entry->first_child == NULL) {
|
||||
return;
|
||||
|
@ -128,6 +142,11 @@ model_entry_remove_child (ModelEntry *entry, ModelEntry *child)
|
|||
for (tmp = entry->first_child; tmp->next != NULL && tmp->next != child; tmp = tmp->next);
|
||||
tmp->next = child->next;
|
||||
}
|
||||
|
||||
mime_types_model_construct_iter (MIME_TYPES_MODEL (model), child, &iter);
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
gtk_tree_model_row_deleted (model, path);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -47,7 +47,7 @@ struct _ModelEntry
|
|||
struct _ModelEntry *first_child;
|
||||
};
|
||||
|
||||
ModelEntry *get_model_entries (void);
|
||||
ModelEntry *get_model_entries (GtkTreeModel *model);
|
||||
|
||||
ModelEntry *model_entry_get_nth_child (ModelEntry *entry,
|
||||
gint n,
|
||||
|
@ -57,9 +57,11 @@ gint model_entry_get_index (ModelEntry *parent,
|
|||
ModelEntry *child);
|
||||
|
||||
void model_entry_insert_child (ModelEntry *entry,
|
||||
ModelEntry *child);
|
||||
ModelEntry *child,
|
||||
GtkTreeModel *model);
|
||||
void model_entry_remove_child (ModelEntry *entry,
|
||||
ModelEntry *child);
|
||||
ModelEntry *child,
|
||||
GtkTreeModel *model);
|
||||
|
||||
void model_entry_save (ModelEntry *entry);
|
||||
void model_entry_delete (ModelEntry *entry);
|
||||
|
|
|
@ -201,7 +201,7 @@ service_edit_dialog_set_prop (GObject *object, guint prop_id, const GValue *valu
|
|||
break;
|
||||
|
||||
case PROP_INFO:
|
||||
if (g_value_get_pointer (value) != NULL) {
|
||||
if (!dialog->p->is_add && g_value_get_pointer (value) != NULL) {
|
||||
dialog->p->info = g_value_get_pointer (value);
|
||||
fill_dialog (dialog);
|
||||
gtk_widget_show_all (dialog->p->dialog_win);
|
||||
|
@ -213,7 +213,7 @@ service_edit_dialog_set_prop (GObject *object, guint prop_id, const GValue *valu
|
|||
dialog->p->is_add = g_value_get_boolean (value);
|
||||
|
||||
if (dialog->p->is_add) {
|
||||
dialog->p->info = service_info_new (NULL);
|
||||
dialog->p->info = service_info_new (NULL, NULL);
|
||||
setup_add_dialog (dialog);
|
||||
gtk_widget_show_all (dialog->p->dialog_win);
|
||||
}
|
||||
|
@ -421,15 +421,13 @@ store_data (ServiceEditDialog *dialog)
|
|||
|
||||
model_entry_append_to_dirty_list (MODEL_ENTRY (dialog->p->info));
|
||||
|
||||
mime_types_model_construct_iter (MIME_TYPES_MODEL (dialog->p->model),
|
||||
MODEL_ENTRY (dialog->p->info), &iter);
|
||||
|
||||
if (dialog->p->is_add) {
|
||||
model_entry_insert_child (get_services_category_entry (), MODEL_ENTRY (dialog->p->info));
|
||||
path = gtk_tree_model_get_path (dialog->p->model, &iter);
|
||||
gtk_tree_model_row_inserted (dialog->p->model, path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
model_entry_insert_child (get_services_category_entry (dialog->p->model),
|
||||
MODEL_ENTRY (dialog->p->info),
|
||||
dialog->p->model);
|
||||
} else {
|
||||
mime_types_model_construct_iter (MIME_TYPES_MODEL (dialog->p->model),
|
||||
MODEL_ENTRY (dialog->p->info), &iter);
|
||||
path = gtk_tree_model_get_path (dialog->p->model, &iter);
|
||||
gtk_tree_model_row_changed (dialog->p->model, path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
|
|
|
@ -65,7 +65,7 @@ static const gchar *get_protocol_name (const gchar *key);
|
|||
|
||||
|
||||
void
|
||||
load_all_services (void)
|
||||
load_all_services (GtkTreeModel *model)
|
||||
{
|
||||
GSList *url_list;
|
||||
GSList *tmp;
|
||||
|
@ -81,8 +81,8 @@ load_all_services (void)
|
|||
if (protocol_name == NULL)
|
||||
continue;
|
||||
|
||||
info = service_info_new (protocol_name);
|
||||
model_entry_insert_child (get_services_category_entry (), MODEL_ENTRY (info));
|
||||
info = service_info_new (protocol_name, model);
|
||||
model_entry_insert_child (get_services_category_entry (model), MODEL_ENTRY (info), model);
|
||||
|
||||
g_free (tmp->data);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ load_all_services (void)
|
|||
}
|
||||
|
||||
ServiceInfo *
|
||||
service_info_new (const gchar *protocol)
|
||||
service_info_new (const gchar *protocol, GtkTreeModel *model)
|
||||
{
|
||||
ServiceInfo *info;
|
||||
|
||||
|
@ -101,7 +101,7 @@ service_info_new (const gchar *protocol)
|
|||
info->protocol = g_strdup (protocol);
|
||||
|
||||
info->entry.type = MODEL_ENTRY_SERVICE;
|
||||
info->entry.parent = MODEL_ENTRY (get_services_category_entry ());
|
||||
info->entry.parent = MODEL_ENTRY (get_services_category_entry (model));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -210,15 +210,16 @@ get_apps_for_service_type (gchar *protocol)
|
|||
}
|
||||
|
||||
ModelEntry *
|
||||
get_services_category_entry (void)
|
||||
get_services_category_entry (GtkTreeModel *model)
|
||||
{
|
||||
static ModelEntry *entry = NULL;
|
||||
|
||||
if (entry == NULL) {
|
||||
entry = g_new0 (ModelEntry, 1);
|
||||
entry->type = MODEL_ENTRY_SERVICES_CATEGORY;
|
||||
entry->parent = get_model_entries (model);
|
||||
|
||||
model_entry_insert_child (get_model_entries (), entry);
|
||||
model_entry_insert_child (get_model_entries (model), entry, model);
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
|
|
@ -49,17 +49,18 @@ struct _ServiceInfo {
|
|||
gboolean need_terminal;
|
||||
};
|
||||
|
||||
void load_all_services (void);
|
||||
void load_all_services (GtkTreeModel *model);
|
||||
|
||||
ServiceInfo *service_info_new (const gchar *protocol);
|
||||
ServiceInfo *service_info_new (const gchar *protocol,
|
||||
GtkTreeModel *model);
|
||||
void service_info_load_all (ServiceInfo *info);
|
||||
const gchar *service_info_get_description (ServiceInfo *info);
|
||||
void service_info_save (const ServiceInfo *info);
|
||||
void service_info_delete (const ServiceInfo *info);
|
||||
void service_info_free (ServiceInfo *info);
|
||||
|
||||
const GList *get_apps_for_service_type (gchar *protocol);
|
||||
ModelEntry *get_services_category_entry (void);
|
||||
const GList *get_apps_for_service_type (gchar *protocol);
|
||||
ModelEntry *get_services_category_entry (GtkTreeModel *model);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue