"Fossies" - the Fresh Open Source Software Archive

Member "sitecopy-0.16.6/gnome/changes.c" (24 Apr 2005, 9186 Bytes) of archive /linux/www/sitecopy-0.16.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "changes.c" see the Fossies "Dox" file reference documentation.

    1 /* 
    2  *      XSitecopy, for managing remote web sites with a GNOME interface.
    3  *      Copyright (C) 2000, Lee Mallabone <lee@fonicmonkey.net>
    4  *                                                                        
    5  *      This program is free software; you can redistribute it and/or modify
    6  *      it under the terms of the GNU General Public License as published by
    7  *      the Free Software Foundation; either version 2 of the License, or
    8  *      (at your option) any later version.
    9  *     
   10  *      This program is distributed in the hope that it will be useful,
   11  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  *      GNU General Public License for more details.
   14  *     
   15  *      You should have received a copy of the GNU General Public License
   16  *      along with this program; if not, write to the Free Software
   17  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   18  *  
   19  */
   20 #include <ne_utils.h>
   21 
   22 #include "changes.h"
   23 
   24 /* Throughout this file, strdup is used, and not the preferable g_strdup.
   25  * This is because many of the fields are allocated in the core of
   26  * sitecopy, and g_free and free are not compatible. I didn't fancy my
   27  * chances of getting the core of sitecopy dependant upon glib, so only
   28  * strdup & free are used in this file.
   29  */
   30 
   31 extern struct site *selected_site;
   32 extern gboolean rcfile_saved;
   33 extern GtkWidget *sitecopy;
   34 
   35 extern GtkWidget *nooverwrite, *sym_maintain, *perms_exec, *perms_all;
   36 extern GtkWidget *perms_ignore, *sym_ignore, *port, *ftp_mode;
   37 
   38 void change_detection_mode(GtkWidget *button, gpointer data)
   39 {
   40     if ( selected_site->remote_is_different)
   41       {
   42       gnome_error_dialog_parented("Your local site must be in sync with the remote site\nbefore change-detection mode can be changed.", 
   43                       GTK_WINDOW(sitecopy));
   44           return;
   45       }
   46 
   47     if (selected_site->state_method == state_checksum)
   48       selected_site->state_method = state_timesize;
   49     else
   50       selected_site->state_method = state_checksum;
   51     
   52     /* Restore file info */
   53     site_readfiles(selected_site);
   54     NE_DEBUG (DEBUG_GNOME, "**************\nReadfiles done.\n*************");
   55     site_catchup(selected_site);
   56     NE_DEBUG (DEBUG_GNOME, "**************\nCatchup done.\n*************");
   57     site_write_stored_state(selected_site);
   58     NE_DEBUG (DEBUG_GNOME, "**************\nStored state written.\n*************");
   59     rescan_selected(TRUE);
   60 }
   61 
   62 void change_port(GtkWidget * spinbutton, gpointer data)
   63 {
   64     int p = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton));
   65     selected_site->server.port = p;
   66 }
   67 
   68 void change_lowercase(GtkWidget * checkbutton, gpointer data)
   69 {
   70     selected_site->lowercase = GTK_TOGGLE_BUTTON(checkbutton)->active;
   71 }
   72 
   73 void change_safemode(GtkWidget * checkbutton, gpointer data)
   74 {
   75     /* This makes the nooverwrite checkbutton insensitive,
   76        * as it can't be used with safe mode.
   77      */
   78     gboolean active = GTK_TOGGLE_BUTTON(checkbutton)->active;
   79     g_assert(nooverwrite != NULL);
   80 
   81     if (active)
   82     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nooverwrite), FALSE);
   83 
   84     gtk_widget_set_sensitive(nooverwrite, !active);
   85     selected_site->safemode = active;
   86 }
   87 
   88 void change_host_name(GtkWidget * entry, gpointer data)
   89 {
   90     char *new_hostname = strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
   91 
   92     xsc_replace_string(&(selected_site->server.hostname), new_hostname);
   93     
   94     rcfile_saved = FALSE;
   95 }
   96 
   97 void change_protocol(GtkWidget * menu_item, gpointer proto)
   98 {
   99     gchar *protoc;
  100     extern struct proto_driver ftp_driver;
  101 #ifdef USE_DAV
  102     extern struct proto_driver dav_driver;
  103 #endif
  104 
  105     protoc = (gchar *) proto;
  106     if (strcmp(protoc, "ftp") == 0) {
  107     selected_site->protocol = siteproto_ftp;
  108     /* Change protocol to ftp */
  109     selected_site->driver = &ftp_driver;
  110     /* We can't do sym links with ftp */
  111     gtk_widget_set_sensitive(sym_maintain, FALSE);
  112     /* So make sure we ignore them */
  113     if (selected_site->symlinks == sitesym_maintain)
  114         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sym_ignore), TRUE);
  115     /* Let's set an appropriate default port */
  116     gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), 21);
  117 #ifdef USE_DAV
  118     /* If using DAV caused the passive FTP checkbox to get de-sensitived,
  119      * then make sure it's now sensitive.
  120      */
  121 
  122     g_assert(ftp_mode != NULL);
  123     g_assert(perms_exec != NULL);
  124     g_assert(perms_all != NULL);
  125     g_assert(perms_ignore != NULL);
  126     g_assert(sym_maintain != NULL);
  127     
  128     gtk_widget_set_sensitive(ftp_mode, TRUE);
  129     gtk_widget_set_sensitive(perms_exec, TRUE);
  130     gtk_widget_set_sensitive(perms_all, TRUE);
  131 
  132     } else if (strcmp(protoc, "dav") == 0) {
  133     selected_site->protocol = siteproto_dav;
  134     /* DAV */
  135     selected_site->driver = &dav_driver;
  136     gtk_widget_set_sensitive(GTK_WIDGET(ftp_mode),
  137                  FALSE);
  138     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ftp_mode),
  139                      FALSE);
  140     /* Set an appropriate port */
  141     gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), 80);
  142 
  143     gtk_widget_set_sensitive(sym_maintain, TRUE);
  144     gtk_widget_set_sensitive(perms_exec, FALSE);
  145     gtk_widget_set_sensitive(perms_all, FALSE);
  146     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(perms_ignore), TRUE);
  147 #endif
  148     }
  149     rcfile_saved = FALSE;
  150 }
  151 
  152 void change_username(GtkWidget * entry, gpointer data)
  153 {
  154     gchar *username;
  155 
  156     username = strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
  157     xsc_replace_string(&(selected_site->server.username), username);
  158 
  159     rcfile_saved = FALSE;
  160 }
  161 
  162 void change_password(GtkWidget * entry, gpointer data)
  163 {
  164     gchar *new_password = strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
  165     xsc_replace_string(&(selected_site->server.password), new_password);
  166     
  167     rcfile_saved = FALSE;
  168 }
  169 
  170 void change_passive_ftp(GtkWidget * toggle, gpointer data)
  171 {
  172     selected_site->ftp_pasv_mode = GTK_TOGGLE_BUTTON(toggle)->active;
  173     rcfile_saved = FALSE;
  174 }
  175 
  176 void change_nooverwrite(GtkWidget * toggle, gpointer data)
  177 {
  178     selected_site->nooverwrite = GTK_TOGGLE_BUTTON(toggle)->active;
  179     rcfile_saved = FALSE;
  180 }
  181 
  182 void change_delete(GtkWidget * toggle, gpointer data)
  183 {
  184     if (GTK_TOGGLE_BUTTON(toggle)->active) {
  185     selected_site->nodelete = FALSE;
  186     } else {
  187     selected_site->nodelete = TRUE;
  188     }
  189     rcfile_saved = FALSE;
  190 }
  191 
  192 void change_move_status(GtkWidget * toggle, gpointer data)
  193 {
  194     selected_site->checkmoved = GTK_TOGGLE_BUTTON(toggle)->active;
  195     rcfile_saved = FALSE;
  196 }
  197 
  198 void change_http_expect(GtkWidget * toggle, gpointer data)
  199 {
  200     selected_site->http_use_expect = GTK_TOGGLE_BUTTON(toggle)->active;
  201     rcfile_saved = FALSE;
  202 }
  203 
  204 void change_http_limit(GtkWidget * toggle, gpointer data)
  205 {
  206     selected_site->http_limit = GTK_TOGGLE_BUTTON(toggle)->active;
  207     rcfile_saved = FALSE;
  208 }
  209 
  210 void change_perms(GtkWidget * menu_item, gpointer perm_data)
  211 {
  212     gchar *perm_set;
  213 
  214     perm_set = (gchar *) perm_data;
  215     if (strcmp(perm_set, "ignore") == 0) {
  216     selected_site->perms = sitep_ignore;
  217     } else if (strcmp(perm_set, "exec") == 0) {
  218     selected_site->perms = sitep_exec;
  219     } else if (strcmp(perm_set, "all") == 0) {
  220     selected_site->perms = sitep_all;
  221     }
  222     rcfile_saved = FALSE;
  223 }
  224 
  225 void change_sym_mode(GtkWidget * menu_item, gpointer sym_data)
  226 {
  227     gchar *sym_info;
  228 
  229     sym_info = (gchar *) sym_data;
  230     if (strcmp(sym_info, "ignore") == 0) {
  231     selected_site->symlinks = sitesym_ignore;
  232     } else if (strcmp(sym_info, "follow") == 0) {
  233     selected_site->symlinks = sitesym_follow;
  234     } else if (strcmp(sym_info, "maintain") == 0) {
  235     selected_site->symlinks = sitesym_maintain;
  236     }
  237     rcfile_saved = FALSE;
  238 }
  239 
  240 /* This is for the 'change' event. */
  241 
  242 void set_local_dir(GtkWidget * entry, gpointer data)
  243 {
  244     gchar *new_local_dir = strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
  245     
  246     xsc_replace_string(&(selected_site->local_root_user), new_local_dir);
  247     
  248     if (*selected_site->local_root_user == '~')
  249     selected_site->local_isrel = TRUE;
  250     else
  251     selected_site->local_isrel = FALSE;
  252 
  253     rcfile_saved = FALSE;
  254 }
  255 
  256 
  257 /** FIXME: Sort this, and make sure the event it's connected to is right.
  258  * Currently connected to the focus-out-event.
  259  */
  260 void change_local_dir(GtkWidget * entry, gpointer data)
  261 {
  262     set_local_dir(entry, data);
  263     rescan_selected(FALSE);
  264 }
  265 
  266 void change_remote_dir(GtkWidget * entry)
  267 {
  268     gchar *new_remote_dir = strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
  269     
  270     xsc_replace_string(&(selected_site->remote_root_user), new_remote_dir);
  271 
  272     if (*new_remote_dir == '~') {
  273     selected_site->remote_isrel = TRUE;
  274     } else {
  275     selected_site->remote_isrel = FALSE;
  276     }
  277 
  278     if (verifysite_gnome(selected_site) != 0) {
  279     NE_DEBUG(DEBUG_GNOME, "site did not verify correctly.");
  280     return;
  281     }
  282     if ((*new_remote_dir != '~') && (*new_remote_dir != '/')) {
  283     gfe_status("Warning! The remote directory must begin with either a '/' or a '~/'.\n Use ~/ to denote a directory relative to your logon directory");
  284     return;
  285     }
  286     /* Do we want to enquire about a site_fetch_list if this changes? */
  287     rcfile_saved = FALSE;
  288 }
  289 
  290 void change_url(GtkWidget * entry, gpointer data)
  291 {
  292     char *new_url= strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
  293     
  294     xsc_replace_string(&(selected_site->url), new_url);
  295     rcfile_saved = FALSE;
  296 }