Implement
2002-01-28 Bradford Hovinen <hovinen@ximian.com> * mime-type-info.c (mime_type_info_using_custom_app) (mime_category_info_using_custom_app): Implement * mime-edit-dialog.c (store_data): Update: don't use custom_line, needs_terminal * mime-type-info.[ch]: Eliminate custom_line and needs_terminal; will use default_action for that now
This commit is contained in:
parent
31dd650951
commit
a2b1d26374
5 changed files with 161 additions and 128 deletions
|
@ -1,10 +1,24 @@
|
||||||
2002-01-28 Bradford Hovinen <hovinen@ximian.com>
|
2002-01-28 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* mime-type-info.c (mime_type_info_using_custom_app)
|
||||||
|
(mime_category_info_using_custom_app): Implement
|
||||||
|
|
||||||
|
* mime-edit-dialog.c (store_data): Update: don't use custom_line,
|
||||||
|
needs_terminal
|
||||||
|
|
||||||
|
* mime-type-info.[ch]: Eliminate custom_line and needs_terminal;
|
||||||
|
will use default_action for that now
|
||||||
|
|
||||||
|
* mime-category-edit-dialog.c (store_data): Set fields in
|
||||||
|
default_action from custom_line
|
||||||
|
|
||||||
* mime-type-info.c (mime_category_info_save): Don't set tmp1 with
|
* mime-type-info.c (mime_category_info_save): Don't set tmp1 with
|
||||||
the full category name, free tmp too
|
the full category name, free tmp too
|
||||||
(mime_category_info_load_all): strdup app->command
|
(mime_category_info_load_all): strdup app->command
|
||||||
(get_gconf_base_name): Don't put /default-action-id after the key
|
(get_gconf_base_name): Don't put /default-action-id after the key
|
||||||
name
|
name
|
||||||
|
(mime_category_info_load_all): Set default_action even if the app
|
||||||
|
is custom
|
||||||
|
|
||||||
* category-names.h: Update category names
|
* category-names.h: Update category names
|
||||||
|
|
||||||
|
|
|
@ -321,6 +321,7 @@ populate_application_list (MimeCategoryEditDialog *dialog)
|
||||||
for (tmp = app_list, i = 0; tmp != NULL; tmp = tmp->next, i++) {
|
for (tmp = app_list, i = 0; tmp != NULL; tmp = tmp->next, i++) {
|
||||||
app = gnome_vfs_application_registry_get_mime_application (tmp->data);
|
app = gnome_vfs_application_registry_get_mime_application (tmp->data);
|
||||||
if (dialog->p->info->default_action != NULL &&
|
if (dialog->p->info->default_action != NULL &&
|
||||||
|
dialog->p->info->default_action->id != NULL &&
|
||||||
!strcmp (tmp->data, dialog->p->info->default_action->id))
|
!strcmp (tmp->data, dialog->p->info->default_action->id))
|
||||||
found_idx = i;
|
found_idx = i;
|
||||||
|
|
||||||
|
@ -342,13 +343,12 @@ populate_application_list (MimeCategoryEditDialog *dialog)
|
||||||
|
|
||||||
if (found_idx < 0) {
|
if (found_idx < 0) {
|
||||||
found_idx = i;
|
found_idx = i;
|
||||||
if (dialog->p->info->custom_line != NULL) {
|
if (dialog->p->info->default_action->command != NULL)
|
||||||
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("program_entry")),
|
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("program_entry")),
|
||||||
dialog->p->info->custom_line);
|
dialog->p->info->default_action->command);
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")),
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")),
|
||||||
dialog->p->info->needs_terminal);
|
dialog->p->info->default_action->requires_terminal);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE);
|
gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE);
|
||||||
}
|
}
|
||||||
|
@ -377,17 +377,24 @@ store_data (MimeCategoryEditDialog *dialog)
|
||||||
idx = gtk_option_menu_get_history (option_menu);
|
idx = gtk_option_menu_get_history (option_menu);
|
||||||
menu_item = (g_list_nth (menu_shell->children, idx))->data;
|
menu_item = (g_list_nth (menu_shell->children, idx))->data;
|
||||||
|
|
||||||
gnome_vfs_mime_application_free (dialog->p->info->default_action);
|
|
||||||
app = g_object_get_data (menu_item, "app");
|
app = g_object_get_data (menu_item, "app");
|
||||||
if (app != NULL)
|
if (app != NULL) {
|
||||||
|
gnome_vfs_mime_application_free (dialog->p->info->default_action);
|
||||||
dialog->p->info->default_action = gnome_vfs_mime_application_copy (app);
|
dialog->p->info->default_action = gnome_vfs_mime_application_copy (app);
|
||||||
else
|
} else {
|
||||||
dialog->p->info->default_action = NULL;
|
if (!mime_category_info_using_custom_app (dialog->p->info)) {
|
||||||
|
gnome_vfs_mime_application_free (dialog->p->info->default_action);
|
||||||
|
dialog->p->info->default_action = g_new0 (GnomeVFSMimeApplication, 1);
|
||||||
|
}
|
||||||
|
|
||||||
dialog->p->info->custom_line = g_strdup (gtk_entry_get_text (GTK_ENTRY
|
g_free (dialog->p->info->default_action->command);
|
||||||
(gnome_file_entry_gtk_entry
|
dialog->p->info->default_action->command
|
||||||
(GNOME_FILE_ENTRY (WID ("program_entry"))))));
|
= g_strdup (gtk_entry_get_text (GTK_ENTRY
|
||||||
dialog->p->info->needs_terminal = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")));
|
(gnome_file_entry_gtk_entry
|
||||||
|
(GNOME_FILE_ENTRY (WID ("program_entry"))))));
|
||||||
|
dialog->p->info->default_action->requires_terminal
|
||||||
|
= gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")));
|
||||||
|
}
|
||||||
|
|
||||||
dialog->p->info->use_parent_category =
|
dialog->p->info->use_parent_category =
|
||||||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("use_category_toggle")));
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("use_category_toggle")));
|
||||||
|
|
|
@ -367,11 +367,6 @@ fill_dialog (MimeEditDialog *dialog)
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("use_category_defaults_toggle")), dialog->p->use_cat_dfl);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("use_category_defaults_toggle")), dialog->p->use_cat_dfl);
|
||||||
update_sensitivity (dialog);
|
update_sensitivity (dialog);
|
||||||
|
|
||||||
if (dialog->p->info->custom_line != NULL)
|
|
||||||
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("program_entry")), dialog->p->info->custom_line);
|
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")), dialog->p->info->needs_terminal);
|
|
||||||
|
|
||||||
if (dialog->p->info->mime_type != NULL && *dialog->p->info->mime_type != '\0')
|
if (dialog->p->info->mime_type != NULL && *dialog->p->info->mime_type != '\0')
|
||||||
gtk_widget_set_sensitive (WID ("mime_type_entry"), FALSE);
|
gtk_widget_set_sensitive (WID ("mime_type_entry"), FALSE);
|
||||||
|
|
||||||
|
@ -474,6 +469,7 @@ populate_application_list (MimeEditDialog *dialog)
|
||||||
app = tmp->data;
|
app = tmp->data;
|
||||||
|
|
||||||
if (dialog->p->info->default_action != NULL &&
|
if (dialog->p->info->default_action != NULL &&
|
||||||
|
dialog->p->info->default_action->id != NULL &&
|
||||||
!strcmp (app->id, dialog->p->info->default_action->id))
|
!strcmp (app->id, dialog->p->info->default_action->id))
|
||||||
found_idx = i;
|
found_idx = i;
|
||||||
|
|
||||||
|
@ -495,9 +491,13 @@ populate_application_list (MimeEditDialog *dialog)
|
||||||
|
|
||||||
if (found_idx < 0) {
|
if (found_idx < 0) {
|
||||||
found_idx = i;
|
found_idx = i;
|
||||||
if (dialog->p->info->custom_line != NULL)
|
if (dialog->p->info->default_action->command != NULL)
|
||||||
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("program_entry")),
|
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("program_entry")),
|
||||||
dialog->p->info->custom_line);
|
dialog->p->info->default_action->command);
|
||||||
|
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")),
|
||||||
|
dialog->p->info->default_action->requires_terminal);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE);
|
gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE);
|
||||||
}
|
}
|
||||||
|
@ -614,17 +614,24 @@ store_data (MimeEditDialog *dialog)
|
||||||
idx = gtk_option_menu_get_history (option_menu);
|
idx = gtk_option_menu_get_history (option_menu);
|
||||||
menu_item = (g_list_nth (menu_shell->children, idx))->data;
|
menu_item = (g_list_nth (menu_shell->children, idx))->data;
|
||||||
|
|
||||||
gnome_vfs_mime_application_free (dialog->p->info->default_action);
|
|
||||||
app = g_object_get_data (menu_item, "app");
|
app = g_object_get_data (menu_item, "app");
|
||||||
if (app != NULL)
|
if (app != NULL) {
|
||||||
|
gnome_vfs_mime_application_free (dialog->p->info->default_action);
|
||||||
dialog->p->info->default_action = gnome_vfs_mime_application_copy (app);
|
dialog->p->info->default_action = gnome_vfs_mime_application_copy (app);
|
||||||
else
|
} else {
|
||||||
dialog->p->info->default_action = NULL;
|
if (!mime_type_info_using_custom_app (dialog->p->info)) {
|
||||||
|
gnome_vfs_mime_application_free (dialog->p->info->default_action);
|
||||||
|
dialog->p->info->default_action = g_new0 (GnomeVFSMimeApplication, 1);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (dialog->p->info->custom_line);
|
g_free (dialog->p->info->default_action->command);
|
||||||
dialog->p->info->custom_line = g_strdup (gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (WID ("program_entry")), FALSE));
|
dialog->p->info->default_action->command
|
||||||
|
= g_strdup (gtk_entry_get_text (GTK_ENTRY
|
||||||
dialog->p->info->needs_terminal = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")));
|
(gnome_file_entry_gtk_entry
|
||||||
|
(GNOME_FILE_ENTRY (WID ("program_entry"))))));
|
||||||
|
dialog->p->info->default_action->requires_terminal
|
||||||
|
= gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")));
|
||||||
|
}
|
||||||
|
|
||||||
ext_list = collect_filename_extensions (dialog);
|
ext_list = collect_filename_extensions (dialog);
|
||||||
mime_type_info_set_file_extensions (dialog->p->info, ext_list);
|
mime_type_info_set_file_extensions (dialog->p->info, ext_list);
|
||||||
|
|
|
@ -92,8 +92,6 @@ mime_type_info_new (const gchar *mime_type, GtkTreeModel *model)
|
||||||
void
|
void
|
||||||
mime_type_info_load_all (MimeTypeInfo *info)
|
mime_type_info_load_all (MimeTypeInfo *info)
|
||||||
{
|
{
|
||||||
gchar *tmp;
|
|
||||||
|
|
||||||
mime_type_info_get_description (info);
|
mime_type_info_get_description (info);
|
||||||
mime_type_info_get_file_extensions (info);
|
mime_type_info_get_file_extensions (info);
|
||||||
|
|
||||||
|
@ -103,21 +101,11 @@ mime_type_info_load_all (MimeTypeInfo *info)
|
||||||
if (info->icon_pixbuf == NULL)
|
if (info->icon_pixbuf == NULL)
|
||||||
get_icon_pixbuf (info, info->icon_name, TRUE);
|
get_icon_pixbuf (info, info->icon_name, TRUE);
|
||||||
|
|
||||||
if (info->default_action == NULL && info->custom_line == NULL) {
|
if (info->default_action == NULL)
|
||||||
info->default_action = gnome_vfs_mime_get_default_application (info->mime_type);
|
info->default_action = gnome_vfs_mime_get_default_application (info->mime_type);
|
||||||
|
|
||||||
tmp = g_strdup_printf ("Custom %s", info->mime_type);
|
if (info->default_action == NULL)
|
||||||
|
info->default_action = g_new0 (GnomeVFSMimeApplication, 1);
|
||||||
if (info->default_action != NULL && !strcmp (info->default_action->name, tmp)) {
|
|
||||||
info->custom_line = g_strdup (info->default_action->command);
|
|
||||||
info->needs_terminal = gnome_vfs_application_registry_get_bool_value
|
|
||||||
(info->default_action->id, "requires_terminal", NULL);
|
|
||||||
gnome_vfs_mime_application_free (info->default_action);
|
|
||||||
info->default_action = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info->default_component == NULL)
|
if (info->default_component == NULL)
|
||||||
info->default_component = gnome_vfs_mime_get_default_component (info->mime_type);
|
info->default_component = gnome_vfs_mime_get_default_component (info->mime_type);
|
||||||
|
@ -226,6 +214,22 @@ mime_type_info_get_category_name (const MimeTypeInfo *info)
|
||||||
return mime_category_info_get_full_name (MIME_CATEGORY_INFO (info->entry.parent));
|
return mime_category_info_get_full_name (MIME_CATEGORY_INFO (info->entry.parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mime_type_info_using_custom_app (const MimeTypeInfo *info)
|
||||||
|
{
|
||||||
|
gchar *tmp;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
if (info->default_action->name == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
tmp = g_strdup_printf ("Custom %s", info->mime_type);
|
||||||
|
ret = !strcmp (tmp, info->default_action->name);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mime_type_info_set_category_name (const MimeTypeInfo *info, const gchar *category_name, GtkTreeModel *model)
|
mime_type_info_set_category_name (const MimeTypeInfo *info, const gchar *category_name, GtkTreeModel *model)
|
||||||
{
|
{
|
||||||
|
@ -252,34 +256,38 @@ mime_type_info_set_file_extensions (MimeTypeInfo *info, GList *list)
|
||||||
void
|
void
|
||||||
mime_type_info_save (const MimeTypeInfo *info)
|
mime_type_info_save (const MimeTypeInfo *info)
|
||||||
{
|
{
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
uuid_t app_uuid;
|
uuid_t app_uuid;
|
||||||
gchar app_uuid_str[100];
|
gchar app_uuid_str[100];
|
||||||
GnomeVFSMimeApplication app;
|
|
||||||
|
|
||||||
gnome_vfs_mime_set_description (info->mime_type, info->description);
|
gnome_vfs_mime_set_description (info->mime_type, info->description);
|
||||||
gnome_vfs_mime_set_icon (info->mime_type, info->icon_name);
|
gnome_vfs_mime_set_icon (info->mime_type, info->icon_name);
|
||||||
|
|
||||||
if (info->default_action != NULL) {
|
if (info->default_action != NULL && info->default_action->command != NULL && *info->default_action->command != '\0') {
|
||||||
|
tmp = g_strdup_printf ("Custom %s", info->mime_type);
|
||||||
|
|
||||||
|
if (info->default_action->name == NULL)
|
||||||
|
info->default_action->name = tmp;
|
||||||
|
|
||||||
|
if (info->default_action->id == NULL) {
|
||||||
|
uuid_generate (app_uuid);
|
||||||
|
uuid_unparse (app_uuid, app_uuid_str);
|
||||||
|
|
||||||
|
info->default_action->id = g_strdup (app_uuid_str);
|
||||||
|
|
||||||
|
gnome_vfs_application_registry_save_mime_application (info->default_action);
|
||||||
|
gnome_vfs_application_registry_sync ();
|
||||||
|
}
|
||||||
|
else if (!strcmp (tmp, info->default_action->name)) {
|
||||||
|
gnome_vfs_application_registry_set_value (info->default_action->id, "command",
|
||||||
|
info->default_action->command);
|
||||||
|
gnome_vfs_application_registry_set_bool_value (info->default_action->id, "requires_terminal",
|
||||||
|
info->default_action->requires_terminal);
|
||||||
|
}
|
||||||
|
|
||||||
gnome_vfs_mime_set_default_application (info->mime_type, info->default_action->id);
|
gnome_vfs_mime_set_default_application (info->mime_type, info->default_action->id);
|
||||||
}
|
} else {
|
||||||
else if (info->custom_line != NULL && *info->custom_line != '\0') {
|
gnome_vfs_mime_set_default_application (info->mime_type, NULL);
|
||||||
uuid_generate (app_uuid);
|
|
||||||
uuid_unparse (app_uuid, app_uuid_str);
|
|
||||||
|
|
||||||
app.id = app_uuid_str;
|
|
||||||
app.name = g_strdup_printf ("Custom %s", info->mime_type);
|
|
||||||
app.command = info->custom_line;
|
|
||||||
app.can_open_multiple_files = FALSE;
|
|
||||||
app.expects_uris = FALSE;
|
|
||||||
app.supported_uri_schemes = NULL;
|
|
||||||
app.requires_terminal = info->needs_terminal;
|
|
||||||
|
|
||||||
gnome_vfs_application_registry_save_mime_application (&app);
|
|
||||||
gnome_vfs_application_registry_sync ();
|
|
||||||
|
|
||||||
gnome_vfs_mime_set_default_application (info->mime_type, app.id);
|
|
||||||
g_free (app.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = form_extensions_string (info, " ", NULL);
|
tmp = form_extensions_string (info, " ", NULL);
|
||||||
|
@ -308,7 +316,6 @@ mime_type_info_free (MimeTypeInfo *info)
|
||||||
gnome_vfs_mime_extensions_list_free (info->file_extensions);
|
gnome_vfs_mime_extensions_list_free (info->file_extensions);
|
||||||
CORBA_free (info->default_component);
|
CORBA_free (info->default_component);
|
||||||
gnome_vfs_mime_application_free (info->default_action);
|
gnome_vfs_mime_application_free (info->default_action);
|
||||||
g_free (info->custom_line);
|
|
||||||
|
|
||||||
if (info->icon_pixbuf != NULL)
|
if (info->icon_pixbuf != NULL)
|
||||||
g_object_unref (G_OBJECT (info->icon_pixbuf));
|
g_object_unref (G_OBJECT (info->icon_pixbuf));
|
||||||
|
@ -357,31 +364,18 @@ mime_category_info_load_all (MimeCategoryInfo *category)
|
||||||
{
|
{
|
||||||
gchar *tmp, *tmp1;
|
gchar *tmp, *tmp1;
|
||||||
gchar *appid;
|
gchar *appid;
|
||||||
GnomeVFSMimeApplication *app;
|
|
||||||
|
|
||||||
tmp1 = get_gconf_base_name (category);
|
tmp1 = get_gconf_base_name (category);
|
||||||
|
|
||||||
if (category->default_action == NULL && category->custom_line == NULL) {
|
if (category->default_action == NULL) {
|
||||||
tmp = g_strconcat (tmp1, "/default-action-id", NULL);
|
tmp = g_strconcat (tmp1, "/default-action-id", NULL);
|
||||||
appid = gconf_client_get_string (gconf_client_get_default (), tmp, NULL);
|
appid = gconf_client_get_string (gconf_client_get_default (), tmp, NULL);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
|
||||||
if (appid != NULL && *appid != '\0') {
|
if (appid != NULL && *appid != '\0')
|
||||||
tmp = g_strdup_printf ("Custom %s", category->name);
|
category->default_action = gnome_vfs_application_registry_get_mime_application (appid);
|
||||||
app = gnome_vfs_application_registry_get_mime_application (appid);
|
else
|
||||||
if (!strcmp (app->name, tmp)) {
|
category->default_action = g_new0 (GnomeVFSMimeApplication, 1);
|
||||||
category->default_action = NULL;
|
|
||||||
category->custom_line = g_strdup (app->command);
|
|
||||||
category->needs_terminal = app->requires_terminal;
|
|
||||||
gnome_vfs_mime_application_free (app);
|
|
||||||
} else {
|
|
||||||
category->default_action = app;
|
|
||||||
category->custom_line = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
category->default_action = NULL;
|
|
||||||
category->custom_line = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!category->use_parent_cat_loaded) {
|
if (!category->use_parent_cat_loaded) {
|
||||||
|
@ -399,6 +393,22 @@ mime_category_info_load_all (MimeCategoryInfo *category)
|
||||||
g_free (tmp1);
|
g_free (tmp1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mime_category_info_using_custom_app (const MimeCategoryInfo *category)
|
||||||
|
{
|
||||||
|
gchar *tmp;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
if (category->default_action->name == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
tmp = g_strdup_printf ("Custom %s", category->name);
|
||||||
|
ret = !strcmp (tmp, category->default_action->name);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_subcategory_ids (ModelEntry *entry, MimeCategoryInfo *category, gchar *app_id)
|
set_subcategory_ids (ModelEntry *entry, MimeCategoryInfo *category, gchar *app_id)
|
||||||
{
|
{
|
||||||
|
@ -425,41 +435,46 @@ set_subcategory_ids (ModelEntry *entry, MimeCategoryInfo *category, gchar *app_i
|
||||||
void
|
void
|
||||||
mime_category_info_save (MimeCategoryInfo *category)
|
mime_category_info_save (MimeCategoryInfo *category)
|
||||||
{
|
{
|
||||||
gchar *tmp, *tmp1;
|
gchar *tmp, *tmp1, *tmp2;
|
||||||
gchar *app_id;
|
uuid_t app_uuid;
|
||||||
uuid_t app_uuid;
|
gchar app_uuid_str[100];
|
||||||
gchar app_uuid_str[100];
|
gboolean set_ids;
|
||||||
GnomeVFSMimeApplication app;
|
|
||||||
|
|
||||||
tmp1 = get_gconf_base_name (category);
|
tmp1 = get_gconf_base_name (category);
|
||||||
|
|
||||||
tmp = g_strconcat (tmp1, "/default-action-id", NULL);
|
tmp = g_strconcat (tmp1, "/default-action-id", NULL);
|
||||||
|
|
||||||
if (category->default_action != NULL) {
|
if (category->default_action != NULL &&
|
||||||
|
category->default_action->command != NULL &&
|
||||||
|
*category->default_action->command != '\0')
|
||||||
|
{
|
||||||
|
tmp2 = g_strdup_printf ("Custom %s", category->name);
|
||||||
|
|
||||||
|
if (category->default_action->name == NULL)
|
||||||
|
category->default_action->name = tmp2;
|
||||||
|
|
||||||
|
if (category->default_action->id == NULL) {
|
||||||
|
uuid_generate (app_uuid);
|
||||||
|
uuid_unparse (app_uuid, app_uuid_str);
|
||||||
|
|
||||||
|
category->default_action->id = g_strdup (app_uuid_str);
|
||||||
|
|
||||||
|
gnome_vfs_application_registry_save_mime_application (category->default_action);
|
||||||
|
gnome_vfs_application_registry_sync ();
|
||||||
|
}
|
||||||
|
else if (!strcmp (tmp, category->default_action->name)) {
|
||||||
|
gnome_vfs_application_registry_set_value (category->default_action->id, "command",
|
||||||
|
category->default_action->command);
|
||||||
|
gnome_vfs_application_registry_set_bool_value (category->default_action->id, "requires_terminal",
|
||||||
|
category->default_action->requires_terminal);
|
||||||
|
}
|
||||||
|
|
||||||
gconf_client_set_string (gconf_client_get_default (),
|
gconf_client_set_string (gconf_client_get_default (),
|
||||||
tmp, category->default_action->id, NULL);
|
tmp, category->default_action->id, NULL);
|
||||||
app_id = category->default_action->id;
|
set_ids = TRUE;
|
||||||
}
|
|
||||||
else if (category->custom_line != NULL && *category->custom_line != '\0') {
|
|
||||||
uuid_generate (app_uuid);
|
|
||||||
uuid_unparse (app_uuid, app_uuid_str);
|
|
||||||
|
|
||||||
app.id = app_uuid_str;
|
|
||||||
app.name = g_strdup_printf ("Custom %s", category->name);
|
|
||||||
app.command = category->custom_line;
|
|
||||||
app.can_open_multiple_files = FALSE;
|
|
||||||
app.expects_uris = FALSE;
|
|
||||||
app.supported_uri_schemes = NULL;
|
|
||||||
app.requires_terminal = category->needs_terminal;
|
|
||||||
|
|
||||||
gnome_vfs_application_registry_save_mime_application (&app);
|
|
||||||
gnome_vfs_application_registry_sync ();
|
|
||||||
|
|
||||||
gconf_client_set_string (gconf_client_get_default (),
|
|
||||||
tmp, app.id, NULL);
|
|
||||||
g_free (app.name);
|
|
||||||
app_id = app_uuid_str;
|
|
||||||
} else {
|
} else {
|
||||||
app_id = NULL;
|
gconf_client_unset (gconf_client_get_default (), tmp, NULL);
|
||||||
|
set_ids = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
@ -469,8 +484,8 @@ mime_category_info_save (MimeCategoryInfo *category)
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
g_free (tmp1);
|
g_free (tmp1);
|
||||||
|
|
||||||
if (app_id != NULL)
|
if (set_ids)
|
||||||
set_subcategory_ids (MODEL_ENTRY (category), category, app_id);
|
set_subcategory_ids (MODEL_ENTRY (category), category, category->default_action->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -487,15 +502,6 @@ update_subcategories (ModelEntry *entry, MimeCategoryInfo *category)
|
||||||
MIME_TYPE_INFO (entry)->default_action = NULL;
|
MIME_TYPE_INFO (entry)->default_action = NULL;
|
||||||
else
|
else
|
||||||
MIME_TYPE_INFO (entry)->default_action = gnome_vfs_mime_application_copy (category->default_action);
|
MIME_TYPE_INFO (entry)->default_action = gnome_vfs_mime_application_copy (category->default_action);
|
||||||
|
|
||||||
g_free (MIME_TYPE_INFO (entry)->custom_line);
|
|
||||||
|
|
||||||
if (category->custom_line == NULL)
|
|
||||||
MIME_TYPE_INFO (entry)->custom_line = NULL;
|
|
||||||
else
|
|
||||||
MIME_TYPE_INFO (entry)->custom_line = g_strdup (category->custom_line);
|
|
||||||
|
|
||||||
MIME_TYPE_INFO (entry)->needs_terminal = category->needs_terminal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,8 +58,6 @@ struct _MimeTypeInfo
|
||||||
|
|
||||||
Bonobo_ServerInfo *default_component;
|
Bonobo_ServerInfo *default_component;
|
||||||
GnomeVFSMimeApplication *default_action;
|
GnomeVFSMimeApplication *default_action;
|
||||||
gchar *custom_line;
|
|
||||||
gboolean needs_terminal;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MimeCategoryInfo
|
struct _MimeCategoryInfo
|
||||||
|
@ -68,8 +66,6 @@ struct _MimeCategoryInfo
|
||||||
|
|
||||||
gchar *name;
|
gchar *name;
|
||||||
GnomeVFSMimeApplication *default_action;
|
GnomeVFSMimeApplication *default_action;
|
||||||
gchar *custom_line;
|
|
||||||
gboolean needs_terminal;
|
|
||||||
|
|
||||||
gboolean use_parent_category;
|
gboolean use_parent_category;
|
||||||
gboolean use_parent_cat_loaded;
|
gboolean use_parent_cat_loaded;
|
||||||
|
@ -94,6 +90,8 @@ gchar *mime_type_info_get_file_extensions_pretty_string
|
||||||
(MimeTypeInfo *info);
|
(MimeTypeInfo *info);
|
||||||
gchar *mime_type_info_get_category_name (const MimeTypeInfo *info);
|
gchar *mime_type_info_get_category_name (const MimeTypeInfo *info);
|
||||||
|
|
||||||
|
gboolean mime_type_info_using_custom_app (const MimeTypeInfo *info);
|
||||||
|
|
||||||
void mime_type_info_set_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);
|
GtkTreeModel *model);
|
||||||
|
@ -104,6 +102,7 @@ MimeCategoryInfo *mime_category_info_new (MimeCategoryInfo *parent,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GtkTreeModel *model);
|
GtkTreeModel *model);
|
||||||
void mime_category_info_load_all (MimeCategoryInfo *category);
|
void mime_category_info_load_all (MimeCategoryInfo *category);
|
||||||
|
gboolean mime_category_info_using_custom_app (const MimeCategoryInfo *category);
|
||||||
void mime_category_info_save (MimeCategoryInfo *category);
|
void mime_category_info_save (MimeCategoryInfo *category);
|
||||||
void mime_category_info_update (MimeCategoryInfo *info);
|
void mime_category_info_update (MimeCategoryInfo *info);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue