]> git.0d.be Git - empathy.git/blobdiff - src/empathy-ft-manager.c
Merge branch 'gnome-3-8'
[empathy.git] / src / empathy-ft-manager.c
index abe7975c47f951c51c89cebcbe2c2f8c27f63e17..18e05dc1989d7188410294ba5bc7c1c1545fd720 100644 (file)
 /* The original file transfer manager code was copied from Epiphany */
 
 #include "config.h"
-
-#include <string.h>
+#include "empathy-ft-manager.h"
 
 #include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-
-#define DEBUG_FLAG EMPATHY_DEBUG_FT
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-tp-file.h>
-#include <libempathy/empathy-utils.h>
 
-#include <libempathy-gtk/empathy-ui-utils.h>
-#include <libempathy-gtk/empathy-geometry.h>
-#include <libempathy-gtk/empathy-images.h>
+#include "empathy-geometry.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 
-#include "empathy-ft-manager.h"
+#define DEBUG_FLAG EMPATHY_DEBUG_FT
+#include "empathy-debug.h"
 
 enum
 {
@@ -71,7 +64,8 @@ enum
 {
   RESPONSE_OPEN  = 1,
   RESPONSE_STOP  = 2,
-  RESPONSE_CLEAR = 3
+  RESPONSE_CLEAR = 3,
+  RESPONSE_CLOSE = 4
 };
 
 G_DEFINE_TYPE (EmpathyFTManager, empathy_ft_manager, G_TYPE_OBJECT);
@@ -261,11 +255,11 @@ ft_manager_format_progress_bytes_and_percentage (guint64 current,
   char *total_str, *current_str, *retval;
   char *speed_str = NULL;
 
-  total_str = g_format_size_for_display (total);
-  current_str = g_format_size_for_display (current);
+  total_str = g_format_size (total);
+  current_str = g_format_size (current);
 
   if (speed > 0)
-    speed_str = g_format_size_for_display ((goffset) speed);
+    speed_str = g_format_size ((goffset) speed);
 
   /* translators: first %s is the currently processed size, second %s is
    * the total file size */
@@ -517,7 +511,7 @@ do_real_transfer_done (EmpathyFTManager *manager,
 
 static void
 ft_handler_transfer_done_cb (EmpathyFTHandler *handler,
-                             EmpathyTpFile *tp_file,
+                             TpFileTransferChannel *channel,
                              EmpathyFTManager *manager)
 {
   if (empathy_ft_handler_is_incoming (handler) &&
@@ -573,7 +567,7 @@ ft_handler_transfer_progress_cb (EmpathyFTHandler *handler,
 
 static void
 ft_handler_transfer_started_cb (EmpathyFTHandler *handler,
-                                EmpathyTpFile *tp_file,
+                                TpFileTransferChannel *channel,
                                 EmpathyFTManager *manager)
 {
   guint64 transferred_bytes, total_bytes;
@@ -695,11 +689,8 @@ static void
 ft_manager_start_transfer (EmpathyFTManager *manager,
                            EmpathyFTHandler *handler)
 {
-  EmpathyFTManagerPriv *priv;
   gboolean is_outgoing;
 
-  priv = GET_PRIV (manager);
-
   is_outgoing = !empathy_ft_handler_is_incoming (handler);
 
   DEBUG ("Start transfer, is outgoing %s",
@@ -868,11 +859,34 @@ ft_manager_stop (EmpathyFTManager *manager)
   g_object_unref (handler);
 }
 
+static gboolean
+close_window (EmpathyFTManager *manager)
+{
+  EmpathyFTManagerPriv *priv = GET_PRIV (manager);
+
+  DEBUG ("%p", manager);
+
+  /* remove all the completed/cancelled/errored transfers */
+  ft_manager_clear (manager);
+
+  if (g_hash_table_size (priv->ft_handler_to_row_ref) > 0)
+    {
+      /* There is still FTs on flight, just hide the window */
+      DEBUG ("Hiding window");
+      gtk_widget_hide (priv->window);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 ft_manager_response_cb (GtkWidget *widget,
                         gint response,
                         EmpathyFTManager *manager)
 {
+  EmpathyFTManagerPriv *priv = GET_PRIV (manager);
+
   switch (response)
     {
       case RESPONSE_CLEAR:
@@ -884,6 +898,10 @@ ft_manager_response_cb (GtkWidget *widget,
       case RESPONSE_STOP:
         ft_manager_stop (manager);
         break;
+      case RESPONSE_CLOSE:
+        if (!close_window (manager))
+          gtk_widget_destroy (priv->window);
+        break;
       case GTK_RESPONSE_NONE:
       case GTK_RESPONSE_DELETE_EVENT:
         /* Do nothing */
@@ -898,22 +916,7 @@ ft_manager_delete_event_cb (GtkWidget *widget,
                             GdkEvent *event,
                             EmpathyFTManager *manager)
 {
-  EmpathyFTManagerPriv *priv = GET_PRIV (manager);
-
-  DEBUG ("%p", manager);
-
-  /* remove all the completed/cancelled/errored transfers */
-  ft_manager_clear (manager);
-
-  if (g_hash_table_size (priv->ft_handler_to_row_ref) > 0)
-    {
-      /* There is still FTs on flight, just hide the window */
-      DEBUG ("Hiding window");
-      gtk_widget_hide (widget);
-      return TRUE;
-    }
-
-  return FALSE;
+  return close_window (manager);
 }
 
 static void
@@ -1072,7 +1075,7 @@ empathy_ft_manager_finalize (GObject *object)
 
   DEBUG ("FT Manager %p", object);
 
-  g_hash_table_destroy (priv->ft_handler_to_row_ref);
+  g_hash_table_unref (priv->ft_handler_to_row_ref);
 
   G_OBJECT_CLASS (empathy_ft_manager_parent_class)->finalize (object);
 }