1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* fm-empty-view.c - implementation of empty view of directory.
Copyright (C) 2006 Free Software Foundation, Inc.
The Mate Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Mate Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Mate Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
Authors: Christian Neumair <chris@mate-de.org>
*/
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-vfs-extensions.h>
#include <libcaja-private/caja-file-utilities.h>
#include <libcaja-private/caja-view.h>
#include <libcaja-private/caja-view-factory.h>
#include "fm-empty-view.h"
struct FMEmptyViewDetails
{
int number_of_files;
};
static GList *fm_empty_view_get_selection (FMDirectoryView *view);
static GList *fm_empty_view_get_selection_for_file_transfer (FMDirectoryView *view);
static void fm_empty_view_scroll_to_file (CajaView *view,
const char *uri);
static void fm_empty_view_iface_init (CajaViewIface *iface);
G_DEFINE_TYPE_WITH_CODE (FMEmptyView, fm_empty_view, FM_TYPE_DIRECTORY_VIEW,
G_IMPLEMENT_INTERFACE (CAJA_TYPE_VIEW,
fm_empty_view_iface_init));
/* for EEL_CALL_PARENT */
#define parent_class fm_empty_view_parent_class
static void
fm_empty_view_add_file (FMDirectoryView *view, CajaFile *file, CajaDirectory *directory)
{
static GTimer *timer = NULL;
static gdouble cumu = 0, elaps;
FM_EMPTY_VIEW (view)->details->number_of_files++;
cairo_surface_t *icon;
if (!timer) timer = g_timer_new ();
g_timer_start (timer);
icon = caja_file_get_icon_surface (file, caja_get_icon_size_for_zoom_level (CAJA_ZOOM_LEVEL_STANDARD),
TRUE, gtk_widget_get_scale_factor (GTK_WIDGET(view)), 0);
elaps = g_timer_elapsed (timer, NULL);
g_timer_stop (timer);
cairo_surface_destroy (icon);
cumu += elaps;
g_message ("entire loading: %.3f, cumulative %.3f", elaps, cumu);
}
static void
fm_empty_view_begin_loading (FMDirectoryView *view)
{
}
static void
fm_empty_view_clear (FMDirectoryView *view)
{
}
static void
fm_empty_view_file_changed (FMDirectoryView *view, CajaFile *file, CajaDirectory *directory)
{
}
static GtkWidget *
fm_empty_view_get_background_widget (FMDirectoryView *view)
{
return GTK_WIDGET (view);
}
static GList *
fm_empty_view_get_selection (FMDirectoryView *view)
{
return NULL;
}
static GList *
fm_empty_view_get_selection_for_file_transfer (FMDirectoryView *view)
{
return NULL;
}
static guint
fm_empty_view_get_item_count (FMDirectoryView *view)
{
return FM_EMPTY_VIEW (view)->details->number_of_files;
}
static gboolean
fm_empty_view_is_empty (FMDirectoryView *view)
{
return FM_EMPTY_VIEW (view)->details->number_of_files == 0;
}
static void
fm_empty_view_end_file_changes (FMDirectoryView *view)
{
}
static void
fm_empty_view_remove_file (FMDirectoryView *view, CajaFile *file, CajaDirectory *directory)
{
FM_EMPTY_VIEW (view)->details->number_of_files--;
g_assert (FM_EMPTY_VIEW (view)->details->number_of_files >= 0);
}
static void
fm_empty_view_set_selection (FMDirectoryView *view, GList *selection)
{
fm_directory_view_notify_selection_changed (view);
}
static void
fm_empty_view_select_all (FMDirectoryView *view)
{
}
static void
fm_empty_view_reveal_selection (FMDirectoryView *view)
{
}
static void
fm_empty_view_merge_menus (FMDirectoryView *view)
{
EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, merge_menus, (view));
}
static void
fm_empty_view_update_menus (FMDirectoryView *view)
{
EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, update_menus, (view));
}
/* Reset sort criteria and zoom level to match defaults */
static void
fm_empty_view_reset_to_defaults (FMDirectoryView *view)
{
}
static void
fm_empty_view_bump_zoom_level (FMDirectoryView *view, int zoom_increment)
{
}
static CajaZoomLevel
fm_empty_view_get_zoom_level (FMDirectoryView *view)
{
return CAJA_ZOOM_LEVEL_STANDARD;
}
static void
fm_empty_view_zoom_to_level (FMDirectoryView *view,
CajaZoomLevel zoom_level)
{
}
static void
fm_empty_view_restore_default_zoom_level (FMDirectoryView *view)
{
}
static gboolean
fm_empty_view_can_zoom_in (FMDirectoryView *view)
{
return FALSE;
}
static gboolean
fm_empty_view_can_zoom_out (FMDirectoryView *view)
{
return FALSE;
}
static void
fm_empty_view_start_renaming_file (FMDirectoryView *view,
CajaFile *file,
gboolean select_all)
{
}
static void
fm_empty_view_click_policy_changed (FMDirectoryView *directory_view)
{
}
static int
fm_empty_view_compare_files (FMDirectoryView *view, CajaFile *file1, CajaFile *file2)
{
if (file1 < file2)
{
return -1;
}
if (file1 > file2)
{
return +1;
}
return 0;
}
static gboolean
fm_empty_view_using_manual_layout (FMDirectoryView *view)
{
return FALSE;
}
static void
fm_empty_view_end_loading (FMDirectoryView *view,
gboolean all_files_seen)
{
}
static void
fm_empty_view_finalize (GObject *object)
{
FMEmptyView *empty_view;
empty_view = FM_EMPTY_VIEW (object);
g_free (empty_view->details);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
fm_empty_view_emblems_changed (FMDirectoryView *directory_view)
{
}
static char *
fm_empty_view_get_first_visible_file (CajaView *view)
{
return NULL;
}
static void
fm_empty_view_scroll_to_file (CajaView *view,
const char *uri)
{
}
static void
fm_empty_view_grab_focus (CajaView *view)
{
gtk_widget_grab_focus (GTK_WIDGET (view));
}
static void
fm_empty_view_sort_directories_first_changed (FMDirectoryView *view)
{
}
static void
fm_empty_view_class_init (FMEmptyViewClass *class)
{
FMDirectoryViewClass *fm_directory_view_class;
fm_directory_view_class = FM_DIRECTORY_VIEW_CLASS (class);
G_OBJECT_CLASS (class)->finalize = fm_empty_view_finalize;
fm_directory_view_class->add_file = fm_empty_view_add_file;
fm_directory_view_class->begin_loading = fm_empty_view_begin_loading;
fm_directory_view_class->bump_zoom_level = fm_empty_view_bump_zoom_level;
fm_directory_view_class->can_zoom_in = fm_empty_view_can_zoom_in;
fm_directory_view_class->can_zoom_out = fm_empty_view_can_zoom_out;
fm_directory_view_class->click_policy_changed = fm_empty_view_click_policy_changed;
fm_directory_view_class->clear = fm_empty_view_clear;
fm_directory_view_class->file_changed = fm_empty_view_file_changed;
fm_directory_view_class->get_background_widget = fm_empty_view_get_background_widget;
fm_directory_view_class->get_selection = fm_empty_view_get_selection;
fm_directory_view_class->get_selection_for_file_transfer = fm_empty_view_get_selection_for_file_transfer;
fm_directory_view_class->get_item_count = fm_empty_view_get_item_count;
fm_directory_view_class->is_empty = fm_empty_view_is_empty;
fm_directory_view_class->remove_file = fm_empty_view_remove_file;
fm_directory_view_class->merge_menus = fm_empty_view_merge_menus;
fm_directory_view_class->update_menus = fm_empty_view_update_menus;
fm_directory_view_class->reset_to_defaults = fm_empty_view_reset_to_defaults;
fm_directory_view_class->restore_default_zoom_level = fm_empty_view_restore_default_zoom_level;
fm_directory_view_class->reveal_selection = fm_empty_view_reveal_selection;
fm_directory_view_class->select_all = fm_empty_view_select_all;
fm_directory_view_class->set_selection = fm_empty_view_set_selection;
fm_directory_view_class->compare_files = fm_empty_view_compare_files;
fm_directory_view_class->sort_directories_first_changed = fm_empty_view_sort_directories_first_changed;
fm_directory_view_class->start_renaming_file = fm_empty_view_start_renaming_file;
fm_directory_view_class->get_zoom_level = fm_empty_view_get_zoom_level;
fm_directory_view_class->zoom_to_level = fm_empty_view_zoom_to_level;
fm_directory_view_class->emblems_changed = fm_empty_view_emblems_changed;
fm_directory_view_class->end_file_changes = fm_empty_view_end_file_changes;
fm_directory_view_class->using_manual_layout = fm_empty_view_using_manual_layout;
fm_directory_view_class->end_loading = fm_empty_view_end_loading;
}
static const char *
fm_empty_view_get_id (CajaView *view)
{
return FM_EMPTY_VIEW_ID;
}
static void
fm_empty_view_iface_init (CajaViewIface *iface)
{
fm_directory_view_init_view_iface (iface);
iface->get_view_id = fm_empty_view_get_id;
iface->get_first_visible_file = fm_empty_view_get_first_visible_file;
iface->scroll_to_file = fm_empty_view_scroll_to_file;
iface->get_title = NULL;
iface->grab_focus = fm_empty_view_grab_focus;
}
static void
fm_empty_view_init (FMEmptyView *empty_view)
{
empty_view->details = g_new0 (FMEmptyViewDetails, 1);
}
static CajaView *
fm_empty_view_create (CajaWindowSlotInfo *slot)
{
FMEmptyView *view;
g_assert (CAJA_IS_WINDOW_SLOT_INFO (slot));
view = g_object_new (FM_TYPE_EMPTY_VIEW,
"window-slot", slot,
NULL);
return CAJA_VIEW (view);
}
static gboolean
fm_empty_view_supports_uri (const char *uri,
GFileType file_type,
const char *mime_type)
{
if (file_type == G_FILE_TYPE_DIRECTORY)
{
return TRUE;
}
if (strcmp (mime_type, CAJA_SAVED_SEARCH_MIMETYPE) == 0)
{
return TRUE;
}
if (g_str_has_prefix (uri, "trash:"))
{
return TRUE;
}
if (g_str_has_prefix (uri, EEL_SEARCH_URI))
{
return TRUE;
}
return FALSE;
}
static CajaViewInfo fm_empty_view =
{
.id = FM_EMPTY_VIEW_ID,
.view_combo_label = N_("Empty View"),
.view_menu_label_with_mnemonic = N_("_Empty"),
.error_label = N_("Empty View"),
.startup_error_label = N_("The empty view encountered an error."),
.display_location_label = N_("Display this location with the empty view."),
.create = fm_empty_view_create,
.supports_uri =fm_empty_view_supports_uri
};
void
fm_empty_view_register (void)
{
fm_empty_view.id = fm_empty_view.id;
fm_empty_view.view_combo_label = fm_empty_view.view_combo_label;
fm_empty_view.view_menu_label_with_mnemonic = fm_empty_view.view_menu_label_with_mnemonic;
fm_empty_view.error_label = fm_empty_view.error_label;
fm_empty_view.display_location_label = fm_empty_view.display_location_label;
caja_view_factory_register (&fm_empty_view);
}
|