~ubuntu-branches/ubuntu/quantal/nautilus/quantal

« back to all changes in this revision

Viewing changes to libnautilus-private/nautilus-trash-monitor.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-07-24 13:00:13 UTC
  • mfrom: (299.1.1 quantal)
  • Revision ID: package-import@ubuntu.com-20120724130013-5qnys60ngsy3hom0
Tags: 1:3.5.4-0ubuntu2
* debian/patches/git_handle_space.patch:
  - "query-editor: make sure not to handle space if we're invisible"
* debian/patches/git_dont_grab_entry_focus.patch:
  - "Don't grab focus away from the search entry box"
* debian/patches/git_entry_grab_keys.patch:
  - "This fixes the search entry grabbing pasted URLs." (lp: #1026659)
* debian/patches/git_focus_on_down_key.patch:
  - "Change focus to the view on down arrow"
* debian/patches/git_desktop_dont_search_on_type.patch:
  - "Don't handle search for desktop windows" (lp: #1028028)

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
}
91
91
 
92
92
static void
93
 
update_info_cb (GObject *source_object,
94
 
                GAsyncResult *res,
95
 
                gpointer user_data)
96
 
{
97
 
        NautilusTrashMonitor *trash_monitor;
98
 
        GFileInfo *info;
99
 
        GIcon *icon;
100
 
        const char * const *names;
101
 
        gboolean empty;
102
 
        int i;
103
 
 
104
 
        trash_monitor = NAUTILUS_TRASH_MONITOR (user_data);
 
93
update_icon (NautilusTrashMonitor *trash_monitor)
 
94
{
 
95
        g_clear_object (&trash_monitor->details->icon);
 
96
 
 
97
        if (trash_monitor->details->empty) {
 
98
                trash_monitor->details->icon = g_themed_icon_new (NAUTILUS_ICON_TRASH);
 
99
        } else {
 
100
                trash_monitor->details->icon = g_themed_icon_new (NAUTILUS_ICON_TRASH_FULL);
 
101
        }
 
102
}
 
103
 
 
104
static void
 
105
update_empty_info (NautilusTrashMonitor *trash_monitor,
 
106
                   gboolean is_empty)
 
107
{
 
108
        if (trash_monitor->details->empty == is_empty) {
 
109
                return;
 
110
        }
105
111
        
106
 
        info = g_file_query_info_finish (G_FILE (source_object),
107
 
                                         res, NULL);
108
 
 
109
 
        if (info != NULL) {
110
 
                icon = g_file_info_get_icon (info);
111
 
 
112
 
                if (icon) {
113
 
                        g_object_unref (trash_monitor->details->icon);
114
 
                        trash_monitor->details->icon = g_object_ref (icon);
115
 
                        empty = TRUE;
116
 
                        if (G_IS_THEMED_ICON (icon)) {
117
 
                                names = g_themed_icon_get_names (G_THEMED_ICON (icon));
118
 
                                for (i = 0; names[i] != NULL; i++) {
119
 
                                        if (strcmp (names[i], NAUTILUS_ICON_TRASH_FULL) == 0) {
120
 
                                                empty = FALSE;
121
 
                                                break;
122
 
                                        }
123
 
                                }
124
 
                        }
125
 
                        if (trash_monitor->details->empty != empty) {
126
 
                                trash_monitor->details->empty = empty;
127
 
 
128
 
                                /* trash got empty or full, notify everyone who cares */
129
 
                                g_signal_emit (trash_monitor, 
130
 
                                               signals[TRASH_STATE_CHANGED], 0,
131
 
                                               trash_monitor->details->empty);
132
 
                        }
133
 
                }
134
 
                g_object_unref (info);
 
112
        trash_monitor->details->empty = is_empty;
 
113
        update_icon (trash_monitor);
 
114
 
 
115
        /* trash got empty or full, notify everyone who cares */
 
116
        g_signal_emit (trash_monitor,
 
117
                       signals[TRASH_STATE_CHANGED], 0,
 
118
                       trash_monitor->details->empty);
 
119
}
 
120
 
 
121
static void
 
122
enumerate_next_files_cb (GObject *source,
 
123
                         GAsyncResult *res,
 
124
                         gpointer user_data)
 
125
{
 
126
        NautilusTrashMonitor *trash_monitor = user_data;
 
127
        GList *infos;
 
128
 
 
129
        infos = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (source), res, NULL);
 
130
        if (!infos) {
 
131
                update_empty_info (trash_monitor, TRUE);
 
132
        } else {
 
133
                update_empty_info (trash_monitor, FALSE);
 
134
                g_list_free_full (infos, g_object_unref);
135
135
        }
136
136
 
137
137
        g_object_unref (trash_monitor);
138
138
}
139
139
 
140
140
static void
 
141
enumerate_children_cb (GObject *source,
 
142
                       GAsyncResult *res,
 
143
                       gpointer user_data)
 
144
{
 
145
        GFileEnumerator *enumerator;
 
146
        NautilusTrashMonitor *trash_monitor = user_data;
 
147
 
 
148
        enumerator = g_file_enumerate_children_finish (G_FILE (source), res, NULL);
 
149
        if (!enumerator) {
 
150
                update_empty_info (trash_monitor, TRUE);
 
151
                g_object_unref (trash_monitor);
 
152
                return;
 
153
        }
 
154
 
 
155
        g_file_enumerator_next_files_async (enumerator, 1,
 
156
                                            G_PRIORITY_DEFAULT, NULL,
 
157
                                            enumerate_next_files_cb, trash_monitor);
 
158
        g_object_unref (enumerator);
 
159
}
 
160
 
 
161
static void
141
162
schedule_update_info (NautilusTrashMonitor *trash_monitor)
142
163
{
143
164
        GFile *location;
144
165
 
145
166
        location = g_file_new_for_uri ("trash:///");
146
 
 
147
 
        g_file_query_info_async (location,
148
 
                                 G_FILE_ATTRIBUTE_STANDARD_ICON,
149
 
                                 0, 0, NULL,
150
 
                                 update_info_cb, g_object_ref (trash_monitor));
 
167
        g_file_enumerate_children_async (location,
 
168
                                         G_FILE_ATTRIBUTE_STANDARD_TYPE,
 
169
                                         G_FILE_QUERY_INFO_NONE,
 
170
                                         G_PRIORITY_DEFAULT, NULL,
 
171
                                         enumerate_children_cb, g_object_ref (trash_monitor));
151
172
        
152
173
        g_object_unref (location);
153
174
}
176
197
                                                              NautilusTrashMonitorDetails);
177
198
 
178
199
        trash_monitor->details->empty = TRUE;
179
 
        trash_monitor->details->icon = g_themed_icon_new (NAUTILUS_ICON_TRASH);
 
200
        update_icon (trash_monitor);
180
201
 
181
202
        location = g_file_new_for_uri ("trash:///");
182
203