~bcurtiswx/ubuntu/natty/empathy/empathy-2.34.0-0ubuntu2

« back to all changes in this revision

Viewing changes to debian/patches/41_unity_launcher_progress.patch

  • Committer: Ken VanDine
  • Date: 2011-02-16 21:59:22 UTC
  • Revision ID: ken.vandine@canonical.com-20110216215922-kgxs0pk30upf7ygp
* debian/patches/41_unity_launcher_progress.patch
  - Added support for file transfer progress in the unity launcher
* debian/patches/40_unity_launcher_count.patch
  - renamed for consistency and clarity

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=== modified file 'src/empathy-ft-manager.c'
 
2
--- old/src/empathy-ft-manager.c        2011-02-15 17:11:00 +0000
 
3
+++ new/src/empathy-ft-manager.c        2011-02-16 21:48:36 +0000
 
4
@@ -46,6 +46,8 @@
 
5
 
 
6
 #include "empathy-ft-manager.h"
 
7
 
 
8
+#include <unity.h>
 
9
+
 
10
 enum
 
11
 {
 
12
   COL_PERCENT,
 
13
@@ -65,6 +67,7 @@
 
14
   GtkWidget *open_button;
 
15
   GtkWidget *abort_button;
 
16
   GtkWidget *clear_button;
 
17
+  UnityLauncherEntry *launcher;
 
18
 } EmpathyFTManagerPriv;
 
19
 
 
20
 enum
 
21
@@ -83,6 +86,53 @@
 
22
 static void ft_handler_hashing_started_cb (EmpathyFTHandler *handler,
 
23
     EmpathyFTManager *manager);
 
24
 
 
25
+static gchar * ft_manager_format_progress_bytes_and_percentage (
 
26
+                                                 guint64 current,
 
27
+                                                 guint64 total,
 
28
+                                                 gdouble speed,
 
29
+                                                 int *percentage);
 
30
+
 
31
+static void
 
32
+ft_update_unity_launcher (EmpathyFTManager *manager)
 
33
+{
 
34
+  EmpathyFTManagerPriv *priv;
 
35
+
 
36
+  priv = GET_PRIV (manager);
 
37
+  g_return_if_fail (priv->launcher != NULL);
 
38
+
 
39
+  guint64 current_bytes = 0;
 
40
+  guint64 total_bytes = 0;
 
41
+  int percentage;
 
42
+  gdouble progress;
 
43
+  GHashTableIter iter;
 
44
+  gpointer handler;
 
45
+
 
46
+  g_hash_table_iter_init (&iter, priv->ft_handler_to_row_ref);
 
47
+  while (g_hash_table_iter_next (&iter, &handler, NULL)) 
 
48
+  {
 
49
+      if (!empathy_ft_handler_is_completed (handler) &&
 
50
+          !empathy_ft_handler_is_cancelled (handler))
 
51
+      {
 
52
+          current_bytes = current_bytes + empathy_ft_handler_get_transferred_bytes (handler);
 
53
+          total_bytes = total_bytes + empathy_ft_handler_get_total_bytes (handler);
 
54
+      }
 
55
+  }
 
56
+  ft_manager_format_progress_bytes_and_percentage (current_bytes, total_bytes, -1, &percentage);
 
57
+
 
58
+  progress = percentage;
 
59
+  progress = progress / 100;
 
60
+
 
61
+  unity_launcher_entry_set_progress (priv->launcher, progress);
 
62
+  if (progress > 0 && progress < 100)
 
63
+  {
 
64
+    unity_launcher_entry_set_progress_visible (priv->launcher, TRUE);
 
65
+  } 
 
66
+  else 
 
67
+  {
 
68
+    unity_launcher_entry_set_progress_visible (priv->launcher, FALSE);
 
69
+  }
 
70
+}
 
71
+
 
72
 static gchar *
 
73
 ft_manager_format_interval (guint interval)
 
74
 {
 
75
@@ -392,6 +442,8 @@
 
76
       COL_PERCENT, percentage,
 
77
       -1);
 
78
 
 
79
+  ft_update_unity_launcher (manager);
 
80
+
 
81
   gtk_tree_path_free (path);
 
82
 
 
83
 }
 
84
@@ -458,6 +510,8 @@
 
85
   ft_manager_clear_handler_time (manager, row_ref);
 
86
   ft_manager_update_buttons (manager);
 
87
 
 
88
+  ft_update_unity_launcher (manager);
 
89
+
 
90
   g_free (message);
 
91
 }
 
92
 
 
93
@@ -465,6 +519,7 @@
 
94
 do_real_transfer_done (EmpathyFTManager *manager,
 
95
                        EmpathyFTHandler *handler)
 
96
 {
 
97
+  EmpathyFTManagerPriv *priv;
 
98
   const char *contact_name;
 
99
   const char *filename;
 
100
   char *first_line, *second_line, *message;
 
101
@@ -474,6 +529,8 @@
 
102
   GtkRecentManager *recent_manager;
 
103
   GFile *file;
 
104
 
 
105
+  priv = GET_PRIV (manager); 
 
106
+
 
107
   row_ref = ft_manager_get_row_from_handler (manager, handler);
 
108
   g_return_if_fail (row_ref != NULL);
 
109
 
 
110
@@ -499,6 +556,8 @@
 
111
   ft_manager_update_handler_message (manager, row_ref, message);
 
112
   ft_manager_clear_handler_time (manager, row_ref);
 
113
 
 
114
+  ft_update_unity_launcher (manager);
 
115
+
 
116
   /* update buttons */
 
117
   ft_manager_update_buttons (manager);
 
118
 
 
119
@@ -535,6 +594,8 @@
 
120
   DEBUG ("Transfer done, no hashing");
 
121
 
 
122
   do_real_transfer_done (manager, handler);
 
123
+
 
124
+  ft_update_unity_launcher (manager);
 
125
 }
 
126
 
 
127
 static void
 
128
@@ -576,6 +637,8 @@
 
129
                                 EmpathyTpFile *tp_file,
 
130
                                 EmpathyFTManager *manager)
 
131
 {
 
132
+  EmpathyFTManagerPriv *priv;
 
133
+  priv = GET_PRIV (manager);
 
134
   guint64 transferred_bytes, total_bytes;
 
135
 
 
136
   DEBUG ("Transfer started");
 
137
@@ -1054,6 +1117,12 @@
 
138
 
 
139
   g_hash_table_destroy (priv->ft_handler_to_row_ref);
 
140
 
 
141
+  if (priv->launcher != NULL)
 
142
+  {
 
143
+    g_object_unref(priv->launcher);
 
144
+    priv->launcher = NULL;
 
145
+  }
 
146
 
147
   G_OBJECT_CLASS (empathy_ft_manager_parent_class)->finalize (object);
 
148
 }
 
149
 
 
150
@@ -1071,6 +1140,8 @@
 
151
       g_direct_equal, (GDestroyNotify) g_object_unref,
 
152
       (GDestroyNotify) gtk_tree_row_reference_free);
 
153
 
 
154
+  priv->launcher = unity_launcher_entry_get_for_desktop_id ("empathy.desktop");
 
155
+
 
156
   ft_manager_build_ui (manager);
 
157
 }
 
158
 
 
159