~rye/ubuntuone-client/stop-killing-thumbnails

« back to all changes in this revision

Viewing changes to nautilus/ubuntuone-nautilus.c

  • Committer: Roman Yepishev
  • Date: 2009-12-17 21:41:14 UTC
  • Revision ID: roman.yepishev@gmail.com-20091217214114-wpm8k21nppw9kt7j
Removed emblem updating by utime

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include <string.h>
44
44
#include <sys/stat.h>
45
45
#include <sys/types.h>
46
 
#include <utime.h>
47
46
 
48
47
/* The header is generated from ubuntuone-marshallers.list */
49
48
#include "ubuntuone-marshallers.h"
80
79
  /* Lists of sync/unsync'd files */
81
80
  GHashTable * updated;
82
81
  GHashTable * needsupdating;
 
82
  /* List of files that are observed for changes */
 
83
  GHashTable * observed;
83
84
 
84
85
  /* Extra data we need to free on finalization */
85
86
  ShareCBData * share_cb_data;
94
95
static GType ubuntuone_nautilus_get_type (void);
95
96
static void ubuntuone_nautilus_register_type (GTypeModule * module);
96
97
 
 
98
/* Utility functions */
 
99
static void ubuntuone_nautilus_reset_emblem (UbuntuOneNautilus * uon,
 
100
                                             const char * path);
 
101
 
 
102
static void ubuntuone_nautilus_observed_file_unref (gpointer user_data,
 
103
                                                    GObject *where_the_object_was);
 
104
 
97
105
/* DBus signal and async method call handlers */
98
106
static void ubuntuone_nautilus_update_meta (DBusGProxy * proxy,
99
107
                                            DBusGProxyCall * call_id,
132
140
 
133
141
static GObjectClass * parent_class = NULL;
134
142
 
 
143
static void ubuntuone_nautilus_reset_emblem (UbuntuOneNautilus * uon,
 
144
                                             const char * path) {
 
145
 
 
146
  NautilusFileInfo *file = g_hash_table_lookup (uon->observed, path);
 
147
  if (file)
 
148
    nautilus_file_info_invalidate_extension_info (file);
 
149
}
 
150
 
 
151
/* Called when NautilusFileInfo is unreferenced */
 
152
static void ubuntuone_nautilus_observed_file_unref (gpointer user_data,
 
153
                                                    GObject *where_the_object_was) {
 
154
  UbuntuOneNautilus * uon;
 
155
  NautilusFileInfo * file;
 
156
  gchar * path = NULL;
 
157
 
 
158
  uon  = UBUNTUONE_NAUTILUS(user_data);
 
159
  file = NAUTILUS_FILE_INFO(where_the_object_was);
 
160
  path = g_filename_from_uri (nautilus_file_info_get_uri (file), NULL, NULL);
 
161
 
 
162
  if (g_hash_table_lookup (uon->observed, path ))
 
163
    g_hash_table_remove (uon->observed, path);
 
164
 
 
165
}
 
166
 
135
167
/* Are we in an Ubuntu One managed directory */
136
168
static gboolean ubuntuone_is_storagefs (UbuntuOneNautilus * uon,
137
169
                                        const char * path) {
171
203
  if (!path || !ubuntuone_is_storagefs (uon, path))
172
204
    goto updating_meta;
173
205
 
 
206
  g_hash_table_insert (uon->observed, g_strdup (path), file);
 
207
  g_object_weak_ref (G_OBJECT(file),
 
208
                     (GWeakNotify)ubuntuone_nautilus_observed_file_unref,
 
209
                     uon);
 
210
 
174
211
  if (!g_hash_table_lookup (uon->updated, path) &&
175
212
      !g_hash_table_lookup (uon->needsupdating, path)) {
176
213
    /* Add the synchronized emblem anyway, and update later */
566
603
  uon->shares = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
567
604
  uon->updated = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
568
605
  uon->needsupdating = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
606
  uon->observed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
569
607
 
570
608
  /* Magic bag of holding +10:
571
609
   * We store some button widgets in a hash table here, so that we can
733
771
  g_hash_table_destroy (uon->needsupdating);
734
772
  uon->needsupdating = NULL;
735
773
 
 
774
  g_hash_table_destroy (uon->observed);
 
775
  uon->observed = NULL;
 
776
 
736
777
  g_hash_table_destroy (uon->buttons);
737
778
  uon->buttons = NULL;
738
779
}
833
874
    g_hash_table_replace (uon->updated, new_path, new_path);
834
875
  else
835
876
    g_hash_table_replace (uon->needsupdating, new_path, new_path);
836
 
  utime (new_path, NULL);
 
877
  ubuntuone_nautilus_reset_emblem (uon, new_path);
837
878
}
838
879
 
839
880
static void ubuntuone_nautilus_state_toggled (DBusGProxy * proxy,
939
980
  if (!g_hash_table_lookup (uon->uploads, path)) {
940
981
    gchar *new_path = g_strdup (path);
941
982
    g_hash_table_insert (uon->uploads, new_path, new_path);
942
 
    utime (path, NULL);
 
983
    ubuntuone_nautilus_reset_emblem (uon, path);
943
984
  }
944
985
}
945
986
 
955
996
  new_path = g_strdup (path);
956
997
  g_hash_table_replace (uon->updated, new_path, new_path);
957
998
 
958
 
  utime (path, NULL);
 
999
  ubuntuone_nautilus_reset_emblem (uon, path);
959
1000
}
960
1001
 
961
1002
static void ubuntuone_nautilus_download_started (DBusGProxy * proxy,
966
1007
  if (!g_hash_table_lookup (uon->downloads, path)) {
967
1008
    gchar *new_path = g_strdup (path);
968
1009
    g_hash_table_insert (uon->downloads, new_path, new_path);
969
 
    utime (path, NULL);
 
1010
    ubuntuone_nautilus_reset_emblem (uon, path);
970
1011
  }
971
1012
}
972
1013
 
983
1024
  new_path = g_strdup (path);
984
1025
  g_hash_table_replace (uon->updated, new_path, new_path);
985
1026
 
986
 
  utime (path, NULL);
 
1027
  ubuntuone_nautilus_reset_emblem (uon, path);
987
1028
}
988
1029
 
989
1030
static void ubuntuone_nautilus_share_created (DBusGProxy * proxy,
996
1037
  if (!g_hash_table_lookup (uon->shares, path)) {
997
1038
    gchar *new_share = g_strdup (path);
998
1039
    g_hash_table_insert (uon->shares, new_share, new_share);
 
1040
    ubuntuone_nautilus_reset_emblem (uon, new_share);
999
1041
  }
1000
1042
}
1001
1043