/* 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
{
{
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);
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 */
static void
ft_handler_transfer_done_cb (EmpathyFTHandler *handler,
- EmpathyTpFile *tp_file,
+ TpFileTransferChannel *channel,
EmpathyFTManager *manager)
{
if (empathy_ft_handler_is_incoming (handler) &&
static void
ft_handler_transfer_started_cb (EmpathyFTHandler *handler,
- EmpathyTpFile *tp_file,
+ TpFileTransferChannel *channel,
EmpathyFTManager *manager)
{
guint64 transferred_bytes, total_bytes;
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",
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:
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 */
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
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);
}