changeset 320:853981bbd4d7

2003-11-30 Brian Masney <masneyb@gftp.org> * src/gtk/transfer.c - shows status information in title bar. (patch from Jamil Geor <jamil_geor@yahoo.co.nz>, cleaned up by me some) * lib/options.h - added show_trans_in_title option. 2003-11-25 Brian Masney <masneyb@gftp.org> * lib/misc.c (gftp_locale_init) - call bindtextdomain() so that the directory is setup properly * lib/misc.c lib/gftp.h lib/config_file.c - move copyfile() to config_file.c and declare it to be static. On the destination file, set the flag O_EXCL
author masneyb
date Sun, 30 Nov 2003 19:35:24 +0000
parents 2ad0b9a00fdd
children 3e6d0c26e37b
files ChangeLog lib/config_file.c lib/gftp.h lib/misc.c lib/options.h src/gtk/transfer.c
diffstat 6 files changed, 87 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Nov 23 15:52:22 2003 +0000
+++ b/ChangeLog	Sun Nov 30 19:35:24 2003 +0000
@@ -1,3 +1,17 @@
+2003-11-30 Brian Masney <masneyb@gftp.org>
+	* src/gtk/transfer.c - shows status information in title bar. (patch
+	from Jamil Geor <jamil_geor@yahoo.co.nz>, cleaned up by me some)
+
+	* lib/options.h - added show_trans_in_title option.
+	
+2003-11-25 Brian Masney <masneyb@gftp.org>
+	* lib/misc.c (gftp_locale_init) - call bindtextdomain() so that the
+	directory is setup properly
+
+	* lib/misc.c lib/gftp.h lib/config_file.c - move copyfile() to 
+	config_file.c and declare it to be static. On the destination file,
+	set the flag O_EXCL
+
 2003-11-23 Brian Masney <masneyb@gftp.org>
 	* src/gtk/transfer.c - when transfering a file, if the file being
 	transfered is greater in the destination than in the source, overwrite
@@ -1762,7 +1776,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.174 2003/11/23 15:52:19 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.175 2003/11/30 19:35:16 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/config_file.c	Sun Nov 23 15:52:22 2003 +0000
+++ b/lib/config_file.c	Sun Nov 30 19:35:24 2003 +0000
@@ -105,6 +105,60 @@
 }
 
 
+static int
+copyfile (char *source, char *dest)
+{
+  int srcfd, destfd;
+  char buf[8192];
+  ssize_t n;
+
+  if ((srcfd = gftp_fd_open (NULL, source, O_RDONLY, 0)) == -1)
+    {
+      printf (_("Error: Cannot open local file %s: %s\n"),
+              source, g_strerror (errno));
+      exit (1);
+    }
+
+  if ((destfd = gftp_fd_open (NULL, dest, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) == -1)
+    {
+      printf (_("Error: Cannot open local file %s: %s\n"),
+              dest, g_strerror (errno));
+      close (srcfd);
+      exit (1);
+    }
+
+  while ((n = read (srcfd, buf, sizeof (buf))) > 0)
+    {
+      if (write (destfd, buf, n) == -1)
+        {
+          printf (_("Error: Could not write to socket: %s\n"), 
+                  g_strerror (errno));
+          exit (1);
+        }
+    }
+
+  if (n == -1)
+    {
+      printf (_("Error: Could not read from socket: %s\n"), g_strerror (errno));
+      exit (1);
+    }
+
+  if (close (srcfd) == -1)
+    {
+      printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
+      exit (1);
+    }
+
+  if (close (destfd) == -1)
+    {
+      printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
+      exit (1);
+    }
+
+  return (1);
+}
+
+
 static void
 gftp_read_bookmarks (char *global_data_path)
 {
--- a/lib/gftp.h	Sun Nov 23 15:52:22 2003 +0000
+++ b/lib/gftp.h	Sun Nov 30 19:35:24 2003 +0000
@@ -656,9 +656,6 @@
 
 void make_nonnull 			( char **str );
 
-int copyfile				( char *source,
-					  char *dest );
-
 int gftp_match_filespec 		( char *filename, 
 					  char *filespec );
 
--- a/lib/misc.c	Sun Nov 23 15:52:22 2003 +0000
+++ b/lib/misc.c	Sun Nov 30 19:35:24 2003 +0000
@@ -260,60 +260,6 @@
 }
 
 
-int
-copyfile (char *source, char *dest)
-{
-  int srcfd, destfd;
-  char buf[8192];
-  ssize_t n;
-
-  if ((srcfd = gftp_fd_open (NULL, source, O_RDONLY, 0)) == -1)
-    {
-      printf (_("Error: Cannot open local file %s: %s\n"),
-              source, g_strerror (errno));
-      exit (1);
-    }
-
-  if ((destfd = gftp_fd_open (NULL, dest, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) == -1)
-    {
-      printf (_("Error: Cannot open local file %s: %s\n"),
-              dest, g_strerror (errno));
-      close (srcfd);
-      exit (1);
-    }
-
-  while ((n = read (srcfd, buf, sizeof (buf))) > 0)
-    {
-      if (write (destfd, buf, n) == -1)
-        {
-          printf (_("Error: Could not write to socket: %s\n"), 
-                  g_strerror (errno));
-          exit (1);
-        }
-    }
-
-  if (n == -1)
-    {
-      printf (_("Error: Could not read from socket: %s\n"), g_strerror (errno));
-      exit (1);
-    }
-
-  if (close (srcfd) == -1)
-    {
-      printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
-      exit (1);
-    }
-
-  if (close (destfd) == -1)
-    {
-      printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
-      exit (1);
-    }
-
-  return (1);
-}
-
-
 /* FIXME - is there a replacement for this */
 int
 gftp_match_filespec (char *filename, char *filespec)
@@ -1281,13 +1227,12 @@
 
   setlocale (LC_ALL, "");
   textdomain ("gftp");
+  bindtextdomain ("gftp", LOCALE_DIR);
 
 #if GLIB_MAJOR_VERSION > 1
   bind_textdomain_codeset ("gftp", "UTF-8");
 #endif
 
-  textdomain ("gftp");
-
-#endif
+#endif /* HAVE_GETTEXT */
 }
 
--- a/lib/options.h	Sun Nov 23 15:52:22 2003 +0000
+++ b/lib/options.h	Sun Nov 30 19:35:24 2003 +0000
@@ -85,6 +85,9 @@
    gftp_option_type_checkbox, GINT_TO_POINTER(1), NULL, 
    GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
    N_("Show hidden files in the listboxes"), GFTP_PORT_ALL, NULL},
+  {"show_trans_in_title", N_("Show transfer status in title"), 
+   gftp_option_type_checkbox, GINT_TO_POINTER(1), NULL, 0,
+   N_("Show the file transfer status in the titlebar"), GFTP_PORT_GTK, NULL},
 
   {"", N_("Network"), gftp_option_type_notebook, NULL, NULL, 
    GFTP_CVARS_FLAGS_SHOW_BOOKMARK, NULL, GFTP_PORT_GTK, NULL},
--- a/src/gtk/transfer.c	Sun Nov 23 15:52:22 2003 +0000
+++ b/src/gtk/transfer.c	Sun Nov 30 19:35:24 2003 +0000
@@ -1275,6 +1275,8 @@
 
   pthread_mutex_lock (&transfer_mutex);
   gftp_file_transfers = g_list_remove_link (gftp_file_transfers, node);
+  gdk_window_set_title (gtk_widget_get_parent_window (GTK_WIDGET(dlwdw)),
+                        gftp_version);
   pthread_mutex_unlock (&transfer_mutex);
 
   free_tdata (tdata);
@@ -1317,12 +1319,12 @@
 static void
 update_file_status (gftp_transfer * tdata)
 {
-  char totstr[100], dlstr[100], gotstr[50], ofstr[50];
-  int hours, mins, secs, pcent, st;
+  char totstr[100], dlstr[100], winstr[150], gotstr[50], ofstr[50];
+  int hours, mins, secs, pcent, st, show_trans_in_title;
   unsigned long remaining_secs, lkbs;
   gftp_file * tempfle;
   struct timeval tv;
-
+  
   g_static_mutex_lock (&tdata->statmutex);
   tempfle = tdata->curfle->data;
 
@@ -1399,6 +1401,14 @@
   g_static_mutex_unlock (&tdata->statmutex);
 
   gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->user_data, 1, totstr);
+  
+  gftp_lookup_global_option ("show_trans_in_title", &show_trans_in_title);
+  if (gftp_file_transfers->data == tdata && show_trans_in_title)
+    {
+      g_snprintf (winstr, sizeof(winstr),  "%s: %s", gftp_version, totstr);
+      gdk_window_set_title (gtk_widget_get_parent_window (GTK_WIDGET(dlwdw)),
+                            winstr);
+    }
 
   if (*dlstr != '\0')
     gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1, dlstr);