~ubuntu-branches/ubuntu/raring/nautilus/raring

« back to all changes in this revision

Viewing changes to libnautilus-private/nautilus-file-changes-queue.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Jeremy Bicha
  • Date: 2012-01-31 13:45:01 UTC
  • mfrom: (1.17.25)
  • Revision ID: package-import@ubuntu.com-20120131134501-yn7mqny7fgzx9fao
Tags: 1:3.3.4-0ubuntu1
* New upstream version which fixes:
  - "Opening Popupmenu in Context of Folder with List-View impossible?"
    (lp: #126540)
  - "'Create folder in here' context menu option for nautilus" (lp: #61786)
  - the file count and the size count change in opposite direction.
    (lp: #503330)
  - the mounts in the place menu should have a properties entry.
    (lp: #846289)
  - add command line option to select file (lp: #575719)
  - Media in 'Places' side bar should have same context menu as in 
    'Computer' (lp: #230098)
* debian/nautilus-data.install:
  - updated, ui and icons have been moved into gresources
* debian/patches/05_desktop_menu_export.patch:
   - updated to correctly include the gresources desktop definition

[ Jeremy Bicha ]
* New upstream release.
* debian/control.in:
  - Bump minimum GTK and glib
* Refreshed patches
* Dropped upstream patches:
  - 17_dont_allow_new_tab_on_desktop.patch
  - 18_fix_crash_in_get_current_uri.patch
  - 19_lazily_initialize_notification_service.patch
  - git_sideplace_sorting.patch
  - git_next_row.patch
  - git_dont_document_browser_option.patch
  - git_browser_compat.patch
  - git_bookmarks_reordering.patch
  - git_listview_context_menus.patch
  - git_use_gtk_grid.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include "nautilus-directory-notify.h"
27
27
 
28
 
#ifdef G_THREADS_ENABLED
29
 
#define MUTEX_LOCK(a)   if ((a) != NULL) g_mutex_lock (a)
30
 
#define MUTEX_UNLOCK(a) if ((a) != NULL) g_mutex_unlock (a)
31
 
#else
32
 
#define MUTEX_LOCK(a)
33
 
#define MUTEX_UNLOCK(a)
34
 
#endif
35
 
 
36
28
typedef enum {
37
29
        CHANGE_FILE_INITIAL,
38
30
        CHANGE_FILE_ADDED,
54
46
typedef struct {
55
47
        GList *head;
56
48
        GList *tail;
57
 
#ifdef G_THREADS_ENABLED
58
 
        GMutex *mutex;
59
 
#endif
 
49
        GMutex mutex;
60
50
} NautilusFileChangesQueue;
61
51
 
62
52
static NautilusFileChangesQueue *
65
55
        NautilusFileChangesQueue *result;
66
56
 
67
57
        result = g_new0 (NautilusFileChangesQueue, 1);
68
 
        
69
 
#ifdef G_THREADS_ENABLED
70
 
        result->mutex = g_mutex_new ();
71
 
#endif
 
58
        g_mutex_init (&result->mutex);
 
59
 
72
60
        return result;
73
61
}
74
62
 
84
72
        return file_changes_queue;
85
73
}
86
74
 
87
 
#if 0 /* no public free call yet */
88
 
 
89
 
static void
90
 
nautilus_file_change_free (NautilusFileChange *change)
91
 
{
92
 
        if (change->from) {
93
 
                g_object_unref (change->from);
94
 
        }
95
 
        if (change->to) {
96
 
                g_object_unref (change->to);
97
 
        }
98
 
}
99
 
 
100
 
void
101
 
nautilus_file_changes_queue_free (NautilusFileChangesQueue *queue)
102
 
{
103
 
        GList *p;
104
 
        if (queue == NULL) {
105
 
                return;
106
 
        }
107
 
        
108
 
#ifdef G_THREADS_ENABLED
109
 
        /* if lock on a defunct mutex were defined (returning a failure)
110
 
         * we would lock here 
111
 
         */
112
 
#endif
113
 
 
114
 
        for (p = queue->head; p != NULL; p = p->next) {
115
 
                nautilus_file_change_free (p->data);
116
 
        }
117
 
        g_list_free (queue->head);
118
 
 
119
 
#ifdef G_THREADS_ENABLED
120
 
        g_mutex_free (queue->mutex);
121
 
#endif
122
 
        g_free (queue);
123
 
}
124
 
 
125
 
#endif /* no public free call yet */
126
 
 
127
75
static void
128
76
nautilus_file_changes_queue_add_common (NautilusFileChangesQueue *queue, 
129
77
        NautilusFileChange *new_item)
130
78
{
131
79
        /* enqueue the new queue item while locking down the list */
132
 
        MUTEX_LOCK (queue->mutex);
 
80
        g_mutex_lock (&queue->mutex);
133
81
 
134
82
        queue->head = g_list_prepend (queue->head, new_item);
135
83
        if (queue->tail == NULL)
136
84
                queue->tail = queue->head;
137
85
 
138
 
        MUTEX_UNLOCK (queue->mutex);
 
86
        g_mutex_unlock (&queue->mutex);
139
87
}
140
88
 
141
89
void
237
185
        g_assert (queue != NULL);
238
186
        
239
187
        /* dequeue the tail item while locking down the list */
240
 
        MUTEX_LOCK (queue->mutex);
 
188
        g_mutex_lock (&queue->mutex);
241
189
 
242
190
        if (queue->tail == NULL) {
243
191
                result = NULL;
250
198
                queue->tail = new_tail;
251
199
        }
252
200
 
253
 
        MUTEX_UNLOCK (queue->mutex);
 
201
        g_mutex_unlock (&queue->mutex);
254
202
 
255
203
        return result;
256
204
}