Commit the changeset (main): Construct a changeset (edit_cb): Pass the

2002-01-11  Bradford Hovinen  <hovinen@ximian.com>

	* file-types-capplet.c (apply_cb): Commit the changeset
	(main): Construct a changeset
	(edit_cb): Pass the changeset to service_info_new

	* service-info.c (set_string): Don't set the value if it is NULL
	(service_info_load): Store changeset in info structure
	(service_info_save): Don't require a changeset; use the one stored
	in the structure
This commit is contained in:
Bradford Hovinen 2002-01-11 16:01:15 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent a53fac33f2
commit cd0aec7eaa
5 changed files with 28 additions and 16 deletions

View file

@ -1,6 +1,13 @@
2002-01-11 Bradford Hovinen <hovinen@ximian.com>
* file-types-capplet.c (apply_cb): Commit the changeset
(main): Construct a changeset
(edit_cb): Pass the changeset to service_info_new
* service-info.c (set_string): Don't set the value if it is NULL
(service_info_load): Store changeset in info structure
(service_info_save): Don't require a changeset; use the one stored
in the structure
* service-edit-dialog.c (store_data): Call service_info_save

View file

@ -33,6 +33,8 @@
#include <gnome.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include <gconf/gconf-changeset.h>
#include "mime-types-model.h"
#include "mime-edit-dialog.h"
@ -43,6 +45,7 @@
#define WID(x) (glade_xml_get_widget (dialog, x))
static GList *remove_list = NULL;
static GConfChangeSet *changeset = NULL;
static void
add_cb (GtkButton *button, GladeXML *dialog)
@ -67,7 +70,7 @@ edit_cb (GtkButton *button, GladeXML *dialog)
gtk_tree_selection_get_selected (selection, &model, &iter);
if (model_entry_is_protocol (model, &iter))
edit_dialog = service_edit_dialog_new (service_info_load (model, &iter, NULL));
edit_dialog = service_edit_dialog_new (service_info_load (model, &iter, changeset));
else
edit_dialog = mime_edit_dialog_new (mime_type_info_load (model, &iter));
}
@ -144,9 +147,6 @@ create_dialog (void)
return dialog;
}
/* Stupid gnome-vfs install bug */
void gnome_vfs_mime_registered_mime_type_delete (const gchar *mime_type);
static void
apply_cb (void)
{
@ -155,6 +155,8 @@ apply_cb (void)
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);
gconf_client_commit_change_set (gconf_client_get_default (), changeset, TRUE, NULL);
}
int
@ -168,6 +170,7 @@ main (int argc, char **argv)
gnome_program_init ("gnome-file-types-properties", VERSION, LIBGNOMEUI_MODULE, argc, argv, NULL);
changeset = gconf_change_set_new ();
dialog = create_dialog ();
g_signal_connect (G_OBJECT (WID ("main_apply_button")), "clicked", (GCallback) apply_cb, NULL);

View file

@ -303,7 +303,7 @@ store_data (ServiceEditDialog *dialog)
g_strdup (gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (WID ("custom_program_entry")), FALSE));
service_info_update (dialog->p->info);
service_info_save (dialog->p->info, NULL);
service_info_save (dialog->p->info);
}
static void

View file

@ -135,6 +135,7 @@ service_info_load (GtkTreeModel *model, GtkTreeIter *iter, GConfChangeSet *chang
info = g_new0 (ServiceInfo, 1);
info->model = model;
info->iter = gtk_tree_iter_copy (iter);
info->changeset = changeset;
info->protocol = g_value_dup_string (&protocol);
info->description = get_string (info, "description", changeset);
info->run_program = get_bool (info, "type", changeset);
@ -150,20 +151,20 @@ service_info_load (GtkTreeModel *model, GtkTreeIter *iter, GConfChangeSet *chang
}
void
service_info_save (const ServiceInfo *info, GConfChangeSet *changeset)
service_info_save (const ServiceInfo *info)
{
set_string (info, "description", info->description, changeset);
set_string (info, "description", info->description, info->changeset);
if (info->app == NULL) {
set_string (info, "command", info->custom_line, changeset);
set_string (info, "command-id", "", changeset);
set_string (info, "command", info->custom_line, info->changeset);
set_string (info, "command-id", "", info->changeset);
} else {
set_string (info, "command", info->app->command, changeset);
set_string (info, "command-id", info->app->id, changeset);
set_string (info, "command", info->app->command, info->changeset);
set_string (info, "command-id", info->app->id, info->changeset);
}
set_bool (info, "type", info->run_program, changeset);
set_bool (info, "need-terminal", info->need_terminal, changeset);
set_bool (info, "type", info->run_program, info->changeset);
set_bool (info, "need-terminal", info->need_terminal, info->changeset);
}
void

View file

@ -45,13 +45,14 @@ struct _ServiceInfo {
GnomeVFSMimeApplication *app;
gchar *custom_line;
gboolean need_terminal;
GConfChangeSet *changeset;
};
ServiceInfo *service_info_load (GtkTreeModel *model,
GtkTreeIter *iter,
GConfChangeSet *changeset);
void service_info_save (const ServiceInfo *info,
GConfChangeSet *changeset);
void service_info_save (const ServiceInfo *info);
void service_info_update (ServiceInfo *info);
void service_info_free (ServiceInfo *info);