[patch] Exclude db in backup capplet
- From: Carlos Morgado <chbm chbm nu>
- To: gnome-pilot-list gnome org
- Subject: [patch] Exclude db in backup capplet
- Date: Sun, 26 Mar 2000 00:41:42 +0000
this does:
+ exclude_list_to_string and exclude_string_to_list aux functions. this are
called way too much. maybe we should keep exclude_string along with
exclude_files. otoh converting back and forth may assure stuff is sane
(opinions ?)
+ adds a textbox to configure exclude_files
needs:
+ tips about format of string
patch attached.
cheers
--
Carlos Morgado - chbm(at)chbm(dot)nu - http://chbm.nu/ -- gpgkey: 0x1FC57F0A
http://wwwkeys.pgp.net/ FP:0A27 35D3 C448 3641 0573 6876 2A37 4BB2 1FC5 7F0A
Shaw's Principle:
Build a system that even a fool can use, and only a fool will
want to use it.
Index: backup-conduit-control-applet.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/conduits/backup/backup-conduit-control-applet.c,v
retrieving revision 1.23
diff -u -r1.23 backup-conduit-control-applet.c
--- backup-conduit-control-applet.c 2000/03/12 02:17:52 1.23
+++ backup-conduit-control-applet.c 2000/03/26 00:38:27
@@ -55,13 +55,51 @@
CORBA_Environment ev;
+static GList *
+exclude_string_to_list( gchar *exclude )
+{
+ gchar **excs;
+ guint i;
+ GList *list = NULL;
+
+ if(exclude == NULL)
+ return(NULL);
+
+ excs = g_strsplit( exclude, ",", 0 );
+ for( i = 0; excs[i] != NULL ; i++ ) {
+ list = g_list_insert_sorted( list , g_strdup(excs[i]),
+ (GCompareFunc)g_strcasecmp);
+ }
+ g_strfreev(excs);
+ return(list);
+}
+
+static gchar *
+exclude_list_to_string(GList *list)
+{
+ gchar *str;
+ GList *iterator;
+ gchar **exclude;
+ guint i;
+
+ iterator = list;
+ exclude = g_malloc( sizeof(char *) * (g_list_length(iterator)+1) );
+ for( i=0 ; iterator != NULL ; iterator = iterator->next, i++ ) {
+ exclude[i] = iterator->data;
+ }
+ exclude[i] = NULL;
+ str = g_strjoinv( ",", exclude);
+ g_free(exclude);
+
+ return(str);
+}
+
+
static void
load_configuration(ConduitCfg **c,guint32 pilotId)
{
gchar *prefix;
gchar *exclude;
- gchar **excs;
- guint i;
*c = g_new0(ConduitCfg,1);
(*c)->child = -1;
@@ -73,16 +111,7 @@
(*c)->updated_only = gnome_config_get_bool("updated_only=TRUE");
(*c)->remove_deleted = gnome_config_get_bool("remove_deleted=FALSE");
exclude = gnome_config_get_string("exclude_files");
- if(exclude != NULL) {
- (*c)->exclude_files = NULL;
- excs = g_strsplit( exclude, ",", 0 );
- for( i = 0; excs[i] != NULL ; i++ ) {
- (*c)->exclude_files = g_list_insert_sorted( (*c)->exclude_files ,
- g_strdup(excs[i]),
- (GCompareFunc)g_strcasecmp);
- }
- g_strfreev(excs);
- }
+ (*c)->exclude_files = exclude_string_to_list(exclude);
gnome_config_pop_prefix();
(*c)->files_in_backup = NULL;
@@ -106,29 +135,23 @@
g_free(prefix);
}
+
static void
save_configuration(ConduitCfg *c)
{
gchar *prefix;
- gchar **exclude;
gchar *exc=NULL;
- GList *iterator;
- guint i;
g_return_if_fail(c!=NULL);
prefix= g_strdup_printf("/gnome-pilot.d/backup-conduit/Pilot_%u/",c->pilotId);
if( c->exclude_files != NULL ) {
- iterator = c->exclude_files;
- exclude = g_malloc( sizeof(char *) * (g_list_length(iterator)+1) );
- for( i=0 ; iterator != NULL ; iterator = iterator->next, i++ ) {
- exclude[i] = iterator->data;
- }
- exclude[i] = NULL;
- exc = g_strjoinv( ",", exclude);
- g_free(exclude);
+ exc = exclude_list_to_string(c->exclude_files);
+ } else {
+ exc = g_strdup("");
}
+
gnome_config_push_prefix(prefix);
gnome_config_set_string("backup_dir",c->backup_dir);
gnome_config_set_bool("updated_only",c->updated_only);
@@ -356,7 +379,7 @@
vbox = gtk_vbox_new(FALSE, GNOME_PAD);
- table = gtk_table_new(2, 3, FALSE);
+ table = gtk_table_new(2, 4, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table), 4);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
@@ -377,22 +400,39 @@
GTK_SIGNAL_FUNC(statechange_cb),
NULL);
+ label = gtk_label_new(_("Exclude dbs"));
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
+
+ entry = gtk_entry_new_with_max_length(128);
+ gtk_object_set_data(GTK_OBJECT(vbox), "exclude_files", entry);
+ gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 1, 2);
+ gtk_signal_connect(GTK_OBJECT(entry), "insert_text",
+ GTK_SIGNAL_FUNC(insert_dir_callback),
+ NULL);
+ gtk_signal_connect_after(GTK_OBJECT(entry), "insert_text",
+ GTK_SIGNAL_FUNC(statechange_cb),
+ NULL);
+ gtk_signal_connect_after(GTK_OBJECT(entry), "delete_text",
+ GTK_SIGNAL_FUNC(statechange_cb),
+ NULL);
+
+
label = gtk_label_new(_("Only backup changed bases"));
- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1,2);
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
button = gtk_check_button_new();
gtk_object_set_data(GTK_OBJECT(vbox), "only_changed", button);
- gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1,2);
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2, 3);
gtk_signal_connect(GTK_OBJECT(button), "toggled",
GTK_SIGNAL_FUNC(button_toggled_cb),
NULL);
label = gtk_label_new(_("Remove local base if deleted on pilot"));
- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2,3);
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
button = gtk_check_button_new();
gtk_object_set_data(GTK_OBJECT(vbox), "remove_local", button);
- gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2,3);
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 3, 4);
gtk_signal_connect(GTK_OBJECT(button), "toggled",
GTK_SIGNAL_FUNC(button_toggled_cb),
NULL);
@@ -404,19 +444,22 @@
static void
setOptionsCfg(GtkWidget *pilotcfg, ConduitCfg *state)
{
- GtkWidget *dir,*updated_only,*remove_deleted;
+ GtkWidget *dir,*exclude_files,*updated_only,*remove_deleted;
dir = gtk_object_get_data(GTK_OBJECT(pilotcfg), "dir");
+ exclude_files = gtk_object_get_data(GTK_OBJECT(pilotcfg), "exclude_files");
updated_only = gtk_object_get_data(GTK_OBJECT(pilotcfg), "only_changed");
remove_deleted = gtk_object_get_data(GTK_OBJECT(pilotcfg), "remove_local");
g_assert(dir!=NULL);
+ g_assert(exclude_files!=NULL);
g_assert(updated_only!=NULL);
g_assert(remove_deleted!=NULL);
ignore_changes = TRUE;
gtk_entry_set_text(GTK_ENTRY(dir), state->backup_dir);
+ gtk_entry_set_text(GTK_ENTRY(exclude_files), exclude_list_to_string(state->exclude_files));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(updated_only), state->updated_only);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remove_deleted), state->remove_deleted);
@@ -427,13 +470,15 @@
static void
readOptionsCfg(GtkWidget *pilotcfg, ConduitCfg *state)
{
- GtkWidget *dir,*updated_only,*remove_deleted;
+ GtkWidget *dir,*exclude_files,*updated_only,*remove_deleted;
dir = gtk_object_get_data(GTK_OBJECT(pilotcfg), "dir");
+ exclude_files = gtk_object_get_data(GTK_OBJECT(pilotcfg), "exclude_files");
updated_only = gtk_object_get_data(GTK_OBJECT(pilotcfg), "only_changed");
remove_deleted = gtk_object_get_data(GTK_OBJECT(pilotcfg), "remove_local");
state->backup_dir = g_strdup(gtk_entry_get_text(GTK_ENTRY(dir)));
+ state->exclude_files = exclude_string_to_list(gtk_entry_get_text(GTK_ENTRY(exclude_files)));
state->updated_only = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(updated_only));
state->remove_deleted = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remove_deleted));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]