diff src/gtk/options_dialog.c @ 227:a85a097bbb02

2003-7-20 Brian Masney <masneyb@gftp.org> * lib/config_file.c lib/gftp.h - added compare_function to gftp_config_vars structure. (gftp_set_global_option) use the compare function to see if the value was actually changed, and if so set the gftp_configuration_changed variable * lib/misc.c lib/gftp.h - For glib 1.2, added my version of g_build_path() since it's not there * lib/misc.c - GLIB/GTK+ 1.2 fixes * lib/protocols.c (gftp_fd_open) - cleaned up some * lib/rfc959.c (rfc959_init) - if the email address is blank, get the users address here instead of in register_module. It was being blanked out when the config file was being read * lib/options.h lib/rfc2068.c lib/rfc959.c lib/sshv2.c - mark the config variables that can show up in the bookmarks editor * src/text/gftp-text.c src/gtk/options_dialog.c - use gftp_set_global_option() to set the new configuration values * src/gtk/bookmarks.c - fixed crash in bookmarks dialog. Added notebook widget to the dialog as well. The options that can be edited for this site will show up in other tabs * src/gtk/gftp-gtk.c - fixes to the calls to gftp_set_global_option() * src/gtk/options_dialog.c - added gftp_gtk_setup_bookmark_options() to display all the editable options for this bookmark
author masneyb
date Mon, 21 Jul 2003 00:26:43 +0000
parents b9584a877daf
children 35ae2e80962e
line wrap: on
line diff
--- a/src/gtk/options_dialog.c	Mon Jul 21 00:22:46 2003 +0000
+++ b/src/gtk/options_dialog.c	Mon Jul 21 00:26:43 2003 +0000
@@ -25,8 +25,6 @@
                  * netmask3, * netmask4, * domain_active;
 static GList * new_proxy_hosts;
 
-/* FIXME - use cancel function */
-
 static void
 _setup_option (gftp_option_type_enum otype,
                gftp_options_dialog_data * option_data, 
@@ -123,11 +121,7 @@
   option_data = user_data;
   tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data));
 
-  if (cv->flags & GFTP_CVARS_FLAGS_DYNMEM)
-    g_free (cv->value);
-
-  cv->value = g_strdup (tempstr);
-  cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
+  gftp_set_global_option (cv->key, tempstr);
 }
 
 
@@ -206,25 +200,12 @@
 {
   gftp_options_dialog_data * option_data;
   const char *tempstr;
-  char **clist;
-  int i;
 
   option_data = user_data;
 
   tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (cv->user_data)->entry));
 
-  if (cv->listdata != NULL && tempstr != NULL)
-    {
-      clist = cv->listdata;
-      for (i=0; clist[i] != NULL; i++)
-        {
-          if (strcasecmp (tempstr, clist[i]) == 0)
-            {
-              cv->value = clist[i];
-              break;
-            }
-        }
-    }
+  gftp_set_global_option (cv->key, tempstr);
 }
 
 
@@ -545,7 +526,8 @@
 
   option_data = user_data;
   tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data));
-  cv->value = GINT_TO_POINTER(strtol (tempstr, NULL, 10));
+
+  gftp_set_global_option (cv->key, GINT_TO_POINTER(strtol (tempstr, NULL, 10)));
 }
 
 
@@ -596,7 +578,7 @@
   gftp_options_dialog_data * option_data;
 
   option_data = user_data;
-  cv->value = GINT_TO_POINTER (GTK_TOGGLE_BUTTON (cv->user_data)->active);
+  gftp_set_global_option (cv->key, GINT_TO_POINTER (GTK_TOGGLE_BUTTON (cv->user_data)->active));
 }
 
 
@@ -623,12 +605,14 @@
 {
   gftp_options_dialog_data * option_data;
   const char *tempstr;
+  void *val;
   float f;
 
   option_data = user_data;
   tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data));
   f = strtod (tempstr, NULL);
-  memcpy (&cv->value, &f, sizeof (cv->value));
+  memcpy (&val, &f, sizeof (val));
+  gftp_set_global_option (cv->key, val);
 }
 
 
@@ -861,6 +845,8 @@
   GList *templist;
   int num;
 
+  gftp_configuration_changed = 1; /* FIXME */
+
   if ((templist = GTK_CLIST (proxy_list)->selection) == NULL)
     return;
   num = GPOINTER_TO_INT (templist->data);
@@ -878,6 +864,8 @@
   char *tempstr, *title;
   GList *templist;
 
+  gftp_configuration_changed = 1; /* FIXME */
+
   if (data)
     {
       if ((templist = GTK_CLIST (proxy_list)->selection) == NULL)
@@ -1175,6 +1163,33 @@
 }
 
 
+static void
+_init_option_data (gftp_options_dialog_data * option_data)
+{
+  memset (option_data, 0, sizeof (*option_data));
+
+  _setup_option (gftp_option_type_text, option_data, 
+                 _print_option_type_text, _save_option_type_text, NULL);
+  _setup_option (gftp_option_type_textcombo, option_data, 
+                 _print_option_type_textcombo, _save_option_type_textcombo, 
+                 NULL);
+  _setup_option (gftp_option_type_textcomboedt, option_data, 
+                 _print_option_type_textcomboedt, 
+                 _save_option_type_textcomboedt,
+                 _cancel_option_type_textcomboedt);
+  _setup_option (gftp_option_type_hidetext, option_data, 
+                 _print_option_type_hidetext, _save_option_type_text, NULL);
+  _setup_option (gftp_option_type_int, option_data, 
+                 _print_option_type_int, _save_option_type_int, NULL);
+  _setup_option (gftp_option_type_checkbox, option_data, 
+                 _print_option_type_checkbox, _save_option_type_checkbox, NULL);
+  _setup_option (gftp_option_type_float, option_data, 
+                 _print_option_type_float, _save_option_type_float, NULL);
+  _setup_option (gftp_option_type_notebook, option_data, 
+                 _print_option_type_notebook, NULL, NULL);
+}
+
+
 void
 options_dialog (gpointer data)
 {
@@ -1186,26 +1201,7 @@
   GtkWidget * tempwid;
 #endif
 
-  memset (&option_data, 0, sizeof (option_data));
-  _setup_option (gftp_option_type_text, &option_data, 
-                 _print_option_type_text, _save_option_type_text, NULL);
-  _setup_option (gftp_option_type_textcombo, &option_data, 
-                 _print_option_type_textcombo, _save_option_type_textcombo, 
-                 NULL);
-  _setup_option (gftp_option_type_textcomboedt, &option_data, 
-                 _print_option_type_textcomboedt, 
-                 _save_option_type_textcomboedt,
-                 _cancel_option_type_textcomboedt);
-  _setup_option (gftp_option_type_hidetext, &option_data, 
-                 _print_option_type_hidetext, _save_option_type_text, NULL);
-  _setup_option (gftp_option_type_int, &option_data, 
-                 _print_option_type_int, _save_option_type_int, NULL);
-  _setup_option (gftp_option_type_checkbox, &option_data, 
-                 _print_option_type_checkbox, _save_option_type_checkbox, NULL);
-  _setup_option (gftp_option_type_float, &option_data, 
-                 _print_option_type_float, _save_option_type_float, NULL);
-  _setup_option (gftp_option_type_notebook, &option_data, 
-                 _print_option_type_notebook, NULL, NULL);
+  _init_option_data (&option_data);
 
 #if GTK_MAJOR_VERSION == 1
   option_data.dialog = gtk_dialog_new ();
@@ -1304,3 +1300,67 @@
   gtk_widget_show (option_data.dialog);
 }
 
+
+void
+gftp_gtk_setup_bookmark_options (GtkWidget * notebook)
+{
+  gftp_options_dialog_data option_data;
+  gftp_config_vars * cv;
+  GList * templist;
+  int i;
+
+  _init_option_data (&option_data);
+  option_data.notebook = notebook;
+
+  cv = gftp_options_list->data;
+  option_data.last_option = cv[0].otype;
+  for (templist = gftp_options_list; 
+       templist != NULL; 
+       templist = templist->next)
+    {
+      cv = templist->data;
+
+      for (i=0; cv[i].key != NULL; i++)
+        {
+          if (!(cv[i].flags & GFTP_CVARS_FLAGS_SHOW_BOOKMARK))
+            continue;
+
+          if (gftp_option_types[cv[i].otype].ui_print_function == NULL)
+            continue;
+
+          cv[i].user_data = gftp_option_types[cv[i].otype].ui_print_function (&cv[i], gftp_option_types[cv[i].otype].user_data);
+
+          option_data.last_option = cv[i].otype;
+        }
+    }
+}
+
+
+void
+gftp_gtk_save_bookmark_options (GtkWidget * widget, gpointer data)
+{
+/* FIXME  - implement
+  gftp_config_vars * cv;
+  GList * templist;
+  int i;
+
+  for (templist = gftp_options_list;
+       templist != NULL;
+       templist = templist->next)
+    {
+      cv = templist->data;
+
+      for (i=0; cv[i].key != NULL; i++)
+        {
+          if (!(cv[i].flags & GFTP_CVARS_FLAGS_SHOW_BOOKMARK))
+            continue;
+
+          if (gftp_option_types[cv[i].otype].ui_save_function == NULL)
+            continue;
+
+          gftp_option_types[cv[i].otype].ui_save_function (&cv[i], gftp_option_types[cv[i].otype].user_data);
+        }
+    }
+*/
+}
+