Free the structure if the user clicks cancel and this is an add dialog
2002-01-26 Bradford Hovinen <hovinen@ximian.com> * service-edit-dialog.c (response_cb): Free the structure if the user clicks cancel and this is an add dialog * mime-edit-dialog.c (response_cb): Free the structure if the user clicks cancel and this is an add dialog * service-info.c (load_all_services): Call model_entry_insert_child here (service_info_new): Don't call model_entry_insert_child (get_services_category_entry): Make this public * service-edit-dialog.c (store_data): Call model_entry_insert_child here
This commit is contained in:
parent
d8c7752324
commit
54d540dd47
10 changed files with 132 additions and 51 deletions
|
@ -1,5 +1,26 @@
|
|||
2002-01-26 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* service-edit-dialog.c (response_cb): Free the structure if the
|
||||
user clicks cancel and this is an add dialog
|
||||
|
||||
* mime-edit-dialog.c (response_cb): Free the structure if the user
|
||||
clicks cancel and this is an add dialog
|
||||
|
||||
* service-info.c (load_all_services): Call
|
||||
model_entry_insert_child here
|
||||
(service_info_new): Don't call model_entry_insert_child
|
||||
(get_services_category_entry): Make this public
|
||||
|
||||
* service-edit-dialog.c (store_data): Call
|
||||
model_entry_insert_child here
|
||||
|
||||
* file-types-capplet.c (apply_cb): Call
|
||||
model_entry_commit_delete_list
|
||||
|
||||
* model-entry.c (model_entry_remove): Implement
|
||||
(model_entry_append_to_delete_list)
|
||||
(model_entry_commit_delete_list): Implement
|
||||
|
||||
* mime-type-info.c (intersect_lists, reduce_supported_app_list)
|
||||
(mime_category_info_find_apps): Implement
|
||||
(find_possible_supported_apps): Implement
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
- Add categories to many types in MIME database
|
||||
- Fix gnome_url_show
|
||||
- Need a way to get all apps in the app registry
|
||||
- Better checking for duplicate service names, check for duplicate MIME types
|
||||
- Don't enable Remove button for categories
|
||||
- Only enable "look at content" if GnomeVFS supports the protocol
|
||||
- Better sorting on the MIME types tree
|
||||
- Don't consider a mime type when generating category handler list if the mime type overrides the category default
|
||||
- Implement override_category_default flag
|
||||
- Implement mime_category_info_save, mime_category_info_load_all
|
||||
- Implement remove for Internet services
|
||||
- Better checking for duplicate service names, check for duplicate MIME types
|
||||
- Don't enable Remove button for categories
|
||||
- Make sure cancel on add is handled properly
|
||||
- Add categories to many types in MIME database
|
||||
- Fix gnome_url_show
|
||||
- Need a way to get all apps in the app registry
|
||||
- Better sorting on the MIME types tree
|
||||
- Translating category names
|
||||
|
|
|
@ -44,8 +44,6 @@
|
|||
|
||||
#define WID(x) (glade_xml_get_widget (dialog, x))
|
||||
|
||||
static GList *remove_list = NULL;
|
||||
|
||||
static void
|
||||
add_mime_cb (GtkButton *button, GladeXML *dialog)
|
||||
{
|
||||
|
@ -156,14 +154,11 @@ remove_cb (GtkButton *button, GladeXML *dialog)
|
|||
|
||||
entry = MODEL_ENTRY_FROM_ITER (&iter);
|
||||
|
||||
if (entry->type == MODEL_ENTRY_MIME_TYPE) {
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
model_entry_remove_child (entry->parent, entry);
|
||||
remove_list = g_list_prepend (remove_list, MIME_TYPE_INFO (entry)->mime_type);
|
||||
model_entry_remove_from_dirty_list (entry);
|
||||
model_entry_append_to_delete_list (entry);
|
||||
gtk_tree_model_row_deleted (model, path);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
selection_changed_cb (selection, dialog);
|
||||
}
|
||||
|
@ -233,10 +228,7 @@ static void
|
|||
apply_cb (void)
|
||||
{
|
||||
model_entry_commit_dirty_list ();
|
||||
|
||||
g_list_foreach (remove_list, (GFunc) gnome_vfs_mime_registered_mime_type_delete, NULL);
|
||||
g_list_foreach (remove_list, (GFunc) g_free, NULL);
|
||||
g_list_free (remove_list);
|
||||
model_entry_commit_delete_list ();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -1077,14 +1077,6 @@
|
|||
<pack>GTK_PACK_END</pack>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button13</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button14</name>
|
||||
|
@ -1098,7 +1090,7 @@
|
|||
<name>button15</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
|
|
|
@ -764,6 +764,9 @@ response_cb (MimeEditDialog *dialog, gint response_id)
|
|||
g_object_unref (G_OBJECT (dialog));
|
||||
}
|
||||
} else {
|
||||
if (dialog->p->is_add)
|
||||
mime_type_info_free (dialog->p->info);
|
||||
|
||||
g_object_unref (G_OBJECT (dialog));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
/* List of MimeTypeInfo structures that have data to be committed */
|
||||
|
||||
static GList *dirty_list = NULL;
|
||||
static GList *delete_list = NULL;
|
||||
|
||||
ModelEntry *
|
||||
get_model_entries (void)
|
||||
|
@ -150,6 +151,25 @@ model_entry_save (ModelEntry *entry)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
model_entry_delete (ModelEntry *entry)
|
||||
{
|
||||
switch (entry->type) {
|
||||
case MODEL_ENTRY_MIME_TYPE:
|
||||
gnome_vfs_mime_registered_mime_type_delete (MIME_TYPE_INFO (entry)->mime_type);
|
||||
mime_type_info_free (MIME_TYPE_INFO (entry));
|
||||
break;
|
||||
|
||||
case MODEL_ENTRY_SERVICE:
|
||||
service_info_delete (SERVICE_INFO (entry));
|
||||
service_info_free (SERVICE_INFO (entry));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
model_entry_append_to_dirty_list (ModelEntry *entry)
|
||||
{
|
||||
|
@ -169,4 +189,24 @@ model_entry_commit_dirty_list (void)
|
|||
gnome_vfs_mime_freeze ();
|
||||
g_list_foreach (dirty_list, (GFunc) model_entry_save, NULL);
|
||||
gnome_vfs_mime_thaw ();
|
||||
|
||||
g_list_free (dirty_list);
|
||||
dirty_list = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
model_entry_append_to_delete_list (ModelEntry *entry)
|
||||
{
|
||||
model_entry_remove_from_dirty_list (entry);
|
||||
delete_list = g_list_prepend (delete_list, entry);
|
||||
}
|
||||
|
||||
void
|
||||
model_entry_commit_delete_list (void)
|
||||
{
|
||||
g_list_foreach (delete_list, (GFunc) model_entry_delete, NULL);
|
||||
|
||||
g_list_free (delete_list);
|
||||
delete_list = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,11 +62,15 @@ void model_entry_remove_child (ModelEntry *entry,
|
|||
ModelEntry *child);
|
||||
|
||||
void model_entry_save (ModelEntry *entry);
|
||||
void model_entry_delete (ModelEntry *entry);
|
||||
|
||||
void model_entry_append_to_dirty_list (ModelEntry *entry);
|
||||
void model_entry_remove_from_dirty_list (ModelEntry *entry);
|
||||
void model_entry_commit_dirty_list (void);
|
||||
|
||||
void model_entry_append_to_delete_list (ModelEntry *entry);
|
||||
void model_entry_commit_delete_list (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MODEL_ENTRY_H */
|
||||
|
|
|
@ -425,6 +425,7 @@ store_data (ServiceEditDialog *dialog)
|
|||
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);
|
||||
|
@ -520,6 +521,9 @@ response_cb (ServiceEditDialog *dialog, gint response_id)
|
|||
g_object_unref (G_OBJECT (dialog));
|
||||
}
|
||||
} else {
|
||||
if (dialog->p->is_add)
|
||||
service_info_free (dialog->p->info);
|
||||
|
||||
g_object_unref (G_OBJECT (dialog));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@
|
|||
|
||||
static GHashTable *service_apps = NULL;
|
||||
|
||||
static ModelEntry *get_services_category_entry (void);
|
||||
|
||||
const gchar *url_descriptions[][2] = {
|
||||
{ "unknown", N_("Unknown service types") },
|
||||
{ "http", N_("World wide web") },
|
||||
|
@ -62,7 +60,6 @@ static gchar *get_string (ServiceInfo *info,
|
|||
const gchar *end);
|
||||
static gboolean get_bool (const ServiceInfo *info,
|
||||
gchar *end);
|
||||
static ModelEntry *get_services_category_entry (void);
|
||||
static const gchar *get_protocol_name (const gchar *key);
|
||||
|
||||
|
||||
|
@ -73,6 +70,7 @@ load_all_services (void)
|
|||
GSList *url_list;
|
||||
GSList *tmp;
|
||||
const gchar *protocol_name;
|
||||
ServiceInfo *info;
|
||||
|
||||
tmp = url_list = gconf_client_all_dirs
|
||||
(gconf_client_get_default (), "/desktop/gnome/url-handlers", NULL);
|
||||
|
@ -83,7 +81,8 @@ load_all_services (void)
|
|||
if (protocol_name == NULL)
|
||||
continue;
|
||||
|
||||
service_info_new (protocol_name);
|
||||
info = service_info_new (protocol_name);
|
||||
model_entry_insert_child (get_services_category_entry (), MODEL_ENTRY (info));
|
||||
|
||||
g_free (tmp->data);
|
||||
}
|
||||
|
@ -103,7 +102,6 @@ service_info_new (const gchar *protocol)
|
|||
|
||||
info->entry.type = MODEL_ENTRY_SERVICE;
|
||||
info->entry.parent = MODEL_ENTRY (get_services_category_entry ());
|
||||
model_entry_insert_child (get_services_category_entry (), MODEL_ENTRY (info));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -166,6 +164,32 @@ service_info_save (const ServiceInfo *info)
|
|||
set_bool (info, "need-terminal", info->need_terminal);
|
||||
}
|
||||
|
||||
void
|
||||
service_info_delete (const ServiceInfo *info)
|
||||
{
|
||||
gchar *tmp;
|
||||
|
||||
tmp = get_key_name (info, "type");
|
||||
gconf_client_unset (gconf_client_get_default (), tmp, NULL);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = get_key_name (info, "description");
|
||||
gconf_client_unset (gconf_client_get_default (), tmp, NULL);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = get_key_name (info, "command");
|
||||
gconf_client_unset (gconf_client_get_default (), tmp, NULL);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = get_key_name (info, "command-id");
|
||||
gconf_client_unset (gconf_client_get_default (), tmp, NULL);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = get_key_name (info, "need-terminal");
|
||||
gconf_client_unset (gconf_client_get_default (), tmp, NULL);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
void
|
||||
service_info_free (ServiceInfo *info)
|
||||
{
|
||||
|
@ -185,6 +209,21 @@ get_apps_for_service_type (gchar *protocol)
|
|||
return g_hash_table_lookup (service_apps, protocol);
|
||||
}
|
||||
|
||||
ModelEntry *
|
||||
get_services_category_entry (void)
|
||||
{
|
||||
static ModelEntry *entry = NULL;
|
||||
|
||||
if (entry == NULL) {
|
||||
entry = g_new0 (ModelEntry, 1);
|
||||
entry->type = MODEL_ENTRY_SERVICES_CATEGORY;
|
||||
|
||||
model_entry_insert_child (get_model_entries (), entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static gchar *
|
||||
|
@ -274,21 +313,6 @@ get_bool (const ServiceInfo *info, gchar *end)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static ModelEntry *
|
||||
get_services_category_entry (void)
|
||||
{
|
||||
static ModelEntry *entry = NULL;
|
||||
|
||||
if (entry == NULL) {
|
||||
entry = g_new0 (ModelEntry, 1);
|
||||
entry->type = MODEL_ENTRY_SERVICES_CATEGORY;
|
||||
|
||||
model_entry_insert_child (get_model_entries (), entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
get_protocol_name (const gchar *key)
|
||||
{
|
||||
|
|
|
@ -55,9 +55,11 @@ ServiceInfo *service_info_new (const gchar *protocol);
|
|||
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);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue