Mercurial > pidgin.yaz
annotate finch/libgnt/gntfilesel.c @ 17973:acff371d7908
Fix crash when deleting buddies on Windows. This was done by
correctly printing null strings in MsimMessage debug messages, since _uid_before
had a NULL value when being sent to postprocessing.
Closes #2400.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sat, 04 Aug 2007 17:43:37 +0000 |
parents | 4f6a6443a1e3 |
children | 8410511f4dbb |
rev | line source |
---|---|
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntbutton.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include "gntentry.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 #include "gntfilesel.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 #include "gntlabel.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 #include "gntmarshal.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 #include "gntstyle.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 #include "gnttree.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 #include <string.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 #include <sys/types.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 #include <sys/stat.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 #include <unistd.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
14 #if 0 |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 #include <glob.h> |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
16 #endif |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 enum |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 SIG_FILE_SELECTED, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 SIGS |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 }; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 static GntWindowClass *parent_class = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 static guint signals[SIGS] = { 0 }; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 static void (*orig_map)(GntWidget *widget); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 gnt_file_sel_destroy(GntWidget *widget) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 GntFileSel *sel = GNT_FILE_SEL(widget); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 g_free(sel->current); |
15939 | 33 g_free(sel->suggest); |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
34 if (sel->tags) { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
35 g_list_foreach(sel->tags, (GFunc)g_free, NULL); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
36 g_list_free(sel->tags); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
37 } |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 |
15992
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
40 #if !GLIB_CHECK_VERSION(2,8,0) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
41 /* ripped from glib/gfileutils.c */ |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
42 static gchar * |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
43 g_build_path_va (const gchar *separator, |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
44 gchar **str_array) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
45 { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
46 GString *result; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
47 gint separator_len = strlen (separator); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
48 gboolean is_first = TRUE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
49 gboolean have_leading = FALSE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
50 const gchar *single_element = NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
51 const gchar *next_element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
52 const gchar *last_trailing = NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
53 gint i = 0; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
54 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
55 result = g_string_new (NULL); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
56 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
57 next_element = str_array[i++]; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
58 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
59 while (TRUE) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
60 const gchar *element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
61 const gchar *start; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
62 const gchar *end; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
63 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
64 if (next_element) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
65 element = next_element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
66 next_element = str_array[i++]; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
67 } else |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
68 break; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
69 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
70 /* Ignore empty elements */ |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
71 if (!*element) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
72 continue; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
73 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
74 start = element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
75 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
76 if (separator_len) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
77 while (start && |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
78 strncmp (start, separator, separator_len) == 0) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
79 start += separator_len; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
80 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
81 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
82 end = start + strlen (start); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
83 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
84 if (separator_len) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
85 while (end >= start + separator_len && |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
86 strncmp (end - separator_len, separator, separator_len) == 0) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
87 end -= separator_len; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
88 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
89 last_trailing = end; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
90 while (last_trailing >= element + separator_len && |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
91 strncmp (last_trailing - separator_len, separator, separator_len) == 0) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
92 last_trailing -= separator_len; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
93 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
94 if (!have_leading) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
95 /* If the leading and trailing separator strings are in the |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
96 * same element and overlap, the result is exactly that element |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
97 */ |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
98 if (last_trailing <= start) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
99 single_element = element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
100 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
101 g_string_append_len (result, element, start - element); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
102 have_leading = TRUE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
103 } else |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
104 single_element = NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
105 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
106 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
107 if (end == start) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
108 continue; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
109 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
110 if (!is_first) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
111 g_string_append (result, separator); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
112 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
113 g_string_append_len (result, start, end - start); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
114 is_first = FALSE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
115 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
116 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
117 if (single_element) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
118 g_string_free (result, TRUE); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
119 return g_strdup (single_element); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
120 } else { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
121 if (last_trailing) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
122 g_string_append (result, last_trailing); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
123 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
124 return g_string_free (result, FALSE); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
125 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
126 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
127 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
128 static gchar * |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
129 g_build_pathv (const gchar *separator, |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
130 gchar **args) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
131 { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
132 if (!args) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
133 return NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
134 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
135 return g_build_path_va (separator, args); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
136 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
137 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
138 #endif |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
139 |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 static char * |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 process_path(const char *path) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 char **splits = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 int i, j; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 char *str, *ret; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 splits = g_strsplit(path, G_DIR_SEPARATOR_S, -1); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 for (i = 0, j = 0; splits[i]; i++) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 if (strcmp(splits[i], ".") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 } else if (strcmp(splits[i], "..") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 if (j) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 j--; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 } else { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 if (i != j) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 g_free(splits[j]); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 splits[j] = splits[i]; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 splits[i] = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 j++; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 g_free(splits[j]); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
163 splits[j] = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
164 str = g_build_pathv(G_DIR_SEPARATOR_S, splits); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 ret = g_strdup_printf(G_DIR_SEPARATOR_S "%s", str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 g_free(str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 g_strfreev(splits); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 return ret; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
170 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
171 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 update_location(GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
173 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
174 char *old; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
175 const char *tmp; |
15939 | 176 tmp = sel->suggest ? sel->suggest : |
177 (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); | |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
178 old = g_strdup_printf("%s%s%s", sel->current, sel->current[1] ? G_DIR_SEPARATOR_S : "", tmp ? tmp : ""); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
179 gnt_entry_set_text(GNT_ENTRY(sel->location), old); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
180 g_free(old); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
181 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
182 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
183 static gboolean |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
184 is_tagged(GntFileSel *sel, const char *f) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
185 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
186 char *ret = g_strdup_printf("%s%s%s", sel->current, sel->current[1] ? G_DIR_SEPARATOR_S : "", f); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
187 gboolean find = g_list_find_custom(sel->tags, ret, (GCompareFunc)g_utf8_collate) != NULL; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
188 g_free(ret); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
189 return find; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
190 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
191 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
192 GntFile* gnt_file_new_dir(const char *name) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
193 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
194 GntFile *file = g_new0(GntFile, 1); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
195 file->basename = g_strdup(name); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
196 file->type = GNT_FILE_DIR; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
197 return file; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
198 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
199 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
200 GntFile* gnt_file_new(const char *name, unsigned long size) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
201 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
202 GntFile *file = g_new0(GntFile, 1); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
203 file->basename = g_strdup(name); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
204 file->type = GNT_FILE_REGULAR; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
205 file->size = size; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
206 return file; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
207 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
208 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
209 static gboolean |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
210 local_read_fn(const char *path, GList **files, GError **error) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
211 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
212 GDir *dir; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
213 GntFile *file; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
214 const char *str; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
215 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
216 dir = g_dir_open(path, 0, error); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
217 if (dir == NULL || (error && *error)) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
218 return FALSE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
219 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
220 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
221 *files = NULL; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
222 if (*path != '\0' && strcmp(path, G_DIR_SEPARATOR_S)) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
223 file = gnt_file_new_dir(".."); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
224 *files = g_list_prepend(*files, file); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
225 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
226 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
227 while ((str = g_dir_read_name(dir)) != NULL) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
228 char *fp = g_build_filename(path, str, NULL); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
229 struct stat st; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
230 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
231 if (stat(fp, &st)) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
232 g_printerr("Error stating location %s\n", fp); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
233 } else { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
234 if (S_ISDIR(st.st_mode)) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
235 file = gnt_file_new_dir(str); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
236 } else { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
237 file = gnt_file_new(str, (long)st.st_size); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
238 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
239 *files = g_list_prepend(*files, file); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
240 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
241 g_free(fp); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
242 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
243 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
244 *files = g_list_reverse(*files); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
245 return TRUE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
246 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
247 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
248 static void |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
249 gnt_file_free(GntFile *file) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
250 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
251 g_free(file->fullpath); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
252 g_free(file->basename); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
253 g_free(file); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
254 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
255 |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
256 static gboolean |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 location_changed(GntFileSel *sel, GError **err) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 { |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
259 GList *files, *iter; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
260 gboolean success; |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
262 if (!sel->dirs) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
263 return TRUE; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
264 |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 gnt_tree_remove_all(GNT_TREE(sel->dirs)); |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
266 if (sel->files) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
267 gnt_tree_remove_all(GNT_TREE(sel->files)); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
268 gnt_entry_set_text(GNT_ENTRY(sel->location), NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 if (sel->current == NULL) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(sel), GNT_WIDGET_MAPPED)) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 gnt_widget_draw(GNT_WIDGET(sel)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 return TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
274 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
275 /* XXX:\ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
276 * XXX: This is blocking. |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
277 * XXX:/ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
278 */ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
279 files = NULL; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
280 if (sel->read_fn) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
281 success = sel->read_fn(sel->current, &files, err); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
282 else |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
283 success = local_read_fn(sel->current, &files, err); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
284 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
285 if (!success || *err) { |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
286 g_printerr("GntFileSel: error opening location %s (%s)\n", |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
287 sel->current, *err ? (*err)->message : "reason unknown"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
288 return FALSE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
289 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
290 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
291 for (iter = files; iter; iter = iter->next) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
292 GntFile *file = iter->data; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
293 char *str = file->basename; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
294 if (file->type == GNT_FILE_DIR) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
295 gnt_tree_add_row_after(GNT_TREE(sel->dirs), g_strdup(str), |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
296 gnt_tree_create_row(GNT_TREE(sel->dirs), str), NULL, NULL); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
297 if (sel->multiselect && sel->dirsonly && is_tagged(sel, str)) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
298 gnt_tree_set_row_flags(GNT_TREE(sel->dirs), (gpointer)str, GNT_TEXT_FLAG_BOLD); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
299 } else if (!sel->dirsonly) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
300 char size[128]; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
301 snprintf(size, sizeof(size), "%ld", file->size); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
302 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
303 gnt_tree_add_row_after(GNT_TREE(sel->files), g_strdup(str), |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
304 gnt_tree_create_row(GNT_TREE(sel->files), str, size, ""), NULL, NULL); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
305 if (sel->multiselect && is_tagged(sel, str)) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
306 gnt_tree_set_row_flags(GNT_TREE(sel->files), (gpointer)str, GNT_TEXT_FLAG_BOLD); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
307 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
308 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
309 g_list_foreach(files, (GFunc)gnt_file_free, NULL); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
310 g_list_free(files); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
311 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(sel), GNT_WIDGET_MAPPED)) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
312 gnt_widget_draw(GNT_WIDGET(sel)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
313 return TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
314 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
316 static gboolean |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
317 dir_key_pressed(GntTree *tree, const char *key, GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
318 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
319 if (strcmp(key, "\r") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
320 char *str = g_strdup(gnt_tree_get_selection_data(tree)); |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
321 char *path, *dir; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
322 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
323 if (!str) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
324 return TRUE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
325 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
326 path = g_build_filename(sel->current, str, NULL); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
327 dir = g_path_get_basename(sel->current); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
328 if (!gnt_file_sel_set_current_location(sel, path)) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
329 gnt_tree_set_selected(tree, str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
330 } else if (strcmp(str, "..") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
331 gnt_tree_set_selected(tree, dir); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
332 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
333 g_free(dir); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
334 g_free(str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
335 g_free(path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
336 return TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
337 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
338 return FALSE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
339 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
340 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
341 static gboolean |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
342 location_key_pressed(GntTree *tree, const char *key, GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
343 { |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
344 char *path; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
345 char *str; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
346 #if 0 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
347 int count; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
348 glob_t gl; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
349 struct stat st; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
350 int glob_ret; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
351 #endif |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
352 if (strcmp(key, "\r")) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
353 return FALSE; |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
354 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
355 str = (char*)gnt_entry_get_text(GNT_ENTRY(sel->location)); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
356 if (*str == G_DIR_SEPARATOR) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
357 path = g_strdup(str); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
358 else |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
359 path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", sel->current, str); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
360 str = process_path(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
361 g_free(path); |
15992
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
362 path = str; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
363 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
364 if (gnt_file_sel_set_current_location(sel, path)) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
365 goto success; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
366 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
367 path = g_path_get_dirname(str); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
368 g_free(str); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
369 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
370 if (!gnt_file_sel_set_current_location(sel, path)) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
371 g_free(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
372 return FALSE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
373 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
374 #if 0 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
375 /* XXX: there needs to be a way to allow other methods for globbing, |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
376 * like the read_fn stuff. */ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
377 glob_ret = glob(path, GLOB_MARK, NULL, &gl); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
378 if (!glob_ret) { /* XXX: do something with the return value */ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
379 char *loc = g_path_get_dirname(gl.gl_pathv[0]); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
380 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
381 stat(gl.gl_pathv[0], &st); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
382 gnt_file_sel_set_current_location(sel, loc); /* XXX: check the return value */ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
383 g_free(loc); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
384 if (!S_ISDIR(st.st_mode) && !sel->dirsonly) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
385 gnt_tree_remove_all(GNT_TREE(sel->files)); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
386 for (count = 0; count < gl.gl_pathc; count++) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
387 char *tmp = process_path(gl.gl_pathv[count]); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
388 loc = g_path_get_dirname(tmp); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
389 if (g_utf8_collate(sel->current, loc) == 0) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
390 char *base = g_path_get_basename(tmp); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
391 char size[128]; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
392 snprintf(size, sizeof(size), "%ld", (long)st.st_size); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
393 gnt_tree_add_row_after(GNT_TREE(sel->files), base, |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
394 gnt_tree_create_row(GNT_TREE(sel->files), base, size, ""), NULL, NULL); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
395 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
396 g_free(loc); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
397 g_free(tmp); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
398 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
399 gnt_widget_draw(sel->files); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
400 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
401 } else if (sel->files) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
402 gnt_tree_remove_all(GNT_TREE(sel->files)); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
403 gnt_widget_draw(sel->files); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
404 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
405 globfree(&gl); |
15992
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
406 #endif |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
407 success: |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
408 g_free(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
409 return TRUE; |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
410 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
411 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
412 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
413 file_sel_changed(GntWidget *widget, gpointer old, gpointer current, GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
414 { |
16203
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
415 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_HAS_FOCUS)) { |
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
416 g_free(sel->suggest); |
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
417 sel->suggest = NULL; |
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
418 update_location(sel); |
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
419 } |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
420 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
421 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
422 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
423 gnt_file_sel_map(GntWidget *widget) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
424 { |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
425 GntFileSel *sel = GNT_FILE_SEL(widget); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
426 GntWidget *hbox, *vbox; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
427 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
428 vbox = gnt_vbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
429 gnt_box_set_pad(GNT_BOX(vbox), 0); |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
430 gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_MID); |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
431 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
432 /* The dir. and files list */ |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
433 hbox = gnt_hbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
434 gnt_box_set_pad(GNT_BOX(hbox), 0); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
435 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
436 gnt_box_add_widget(GNT_BOX(hbox), sel->dirs); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
437 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
438 if (!sel->dirsonly) { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
439 gnt_box_add_widget(GNT_BOX(hbox), sel->files); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
440 } else { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
441 g_signal_connect(G_OBJECT(sel->dirs), "selection_changed", G_CALLBACK(file_sel_changed), sel); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
442 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
443 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
444 gnt_box_add_widget(GNT_BOX(vbox), hbox); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
445 gnt_box_add_widget(GNT_BOX(vbox), sel->location); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
446 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
447 /* The buttons */ |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
448 hbox = gnt_hbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
449 gnt_box_add_widget(GNT_BOX(hbox), sel->cancel); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
450 gnt_box_add_widget(GNT_BOX(hbox), sel->select); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
451 gnt_box_add_widget(GNT_BOX(vbox), hbox); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
452 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
453 gnt_box_add_widget(GNT_BOX(sel), vbox); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
454 orig_map(widget); |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
455 update_location(sel); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
456 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
457 |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
458 static gboolean |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
459 toggle_tag_selection(GntBindable *bind, GList *null) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
460 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
461 GntFileSel *sel = GNT_FILE_SEL(bind); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
462 char *str; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
463 GList *find; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
464 char *file; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
465 GntWidget *tree; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
466 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
467 if (!sel->multiselect) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
468 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
469 tree = sel->dirsonly ? sel->dirs : sel->files; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
470 if (!gnt_widget_has_focus(tree)) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
471 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
472 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
473 file = gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
474 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
475 str = gnt_file_sel_get_selected_file(sel); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
476 if ((find = g_list_find_custom(sel->tags, str, (GCompareFunc)g_utf8_collate)) != NULL) { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
477 g_free(find->data); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
478 sel->tags = g_list_delete_link(sel->tags, find); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
479 gnt_tree_set_row_flags(GNT_TREE(tree), file, GNT_TEXT_FLAG_NORMAL); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
480 g_free(str); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
481 } else { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
482 sel->tags = g_list_prepend(sel->tags, str); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
483 gnt_tree_set_row_flags(GNT_TREE(tree), file, GNT_TEXT_FLAG_BOLD); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
484 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
485 |
15952
0ef26ac647ac
move to the next entry after (un)tagging an item.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15939
diff
changeset
|
486 gnt_bindable_perform_action_named(GNT_BINDABLE(tree), "move-down", NULL); |
0ef26ac647ac
move to the next entry after (un)tagging an item.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15939
diff
changeset
|
487 |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
488 return TRUE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
489 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
490 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
491 static gboolean |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
492 clear_tags(GntBindable *bind, GList *null) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
493 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
494 GntFileSel *sel = GNT_FILE_SEL(bind); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
495 GntWidget *tree; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
496 GList *iter; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
497 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
498 if (!sel->multiselect) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
499 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
500 tree = sel->dirsonly ? sel->dirs : sel->files; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
501 if (!gnt_widget_has_focus(tree)) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
502 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
503 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
504 g_list_foreach(sel->tags, (GFunc)g_free, NULL); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
505 g_list_free(sel->tags); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
506 sel->tags = NULL; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
507 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
508 for (iter = GNT_TREE(tree)->list; iter; iter = iter->next) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
509 gnt_tree_set_row_flags(GNT_TREE(tree), iter->data, GNT_TEXT_FLAG_NORMAL); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
510 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
511 return TRUE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
512 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
513 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
514 static gboolean |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
515 up_directory(GntBindable *bind, GList *null) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
516 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
517 char *path, *dir; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
518 GntFileSel *sel = GNT_FILE_SEL(bind); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
519 if (!gnt_widget_has_focus(sel->dirs) && |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
520 !gnt_widget_has_focus(sel->files)) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
521 return FALSE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
522 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
523 path = g_build_filename(sel->current, "..", NULL); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
524 dir = g_path_get_basename(sel->current); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
525 if (gnt_file_sel_set_current_location(sel, path)) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
526 gnt_tree_set_selected(GNT_TREE(sel->dirs), dir); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
527 g_free(dir); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
528 g_free(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
529 return TRUE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
530 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
531 |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
532 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
533 gnt_file_sel_class_init(GntFileSelClass *klass) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
534 { |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
535 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
536 GntWidgetClass *kl = GNT_WIDGET_CLASS(klass); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
537 parent_class = GNT_WINDOW_CLASS(klass); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
538 kl->destroy = gnt_file_sel_destroy; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
539 orig_map = kl->map; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
540 kl->map = gnt_file_sel_map; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
541 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
542 signals[SIG_FILE_SELECTED] = |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
543 g_signal_new("file_selected", |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
544 G_TYPE_FROM_CLASS(klass), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
545 G_SIGNAL_RUN_LAST, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
546 G_STRUCT_OFFSET(GntFileSelClass, file_selected), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
547 NULL, NULL, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
548 gnt_closure_marshal_VOID__STRING_STRING, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
549 G_TYPE_NONE, 0); |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
550 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
551 gnt_bindable_class_register_action(bindable, "toggle-tag", toggle_tag_selection, "t", NULL); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
552 gnt_bindable_class_register_action(bindable, "clear-tags", clear_tags, "c", NULL); |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
553 gnt_bindable_class_register_action(bindable, "up-directory", up_directory, GNT_KEY_BACKSPACE, NULL); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
554 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
555 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
556 GNTDEBUG; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
557 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
558 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
559 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
560 gnt_file_sel_init(GTypeInstance *instance, gpointer class) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
561 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
562 GNTDEBUG; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
563 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
564 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
565 /****************************************************************************** |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
566 * GntFileSel API |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
567 *****************************************************************************/ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
568 GType |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
569 gnt_file_sel_get_gtype(void) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
570 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
571 static GType type = 0; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
572 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
573 if(type == 0) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
574 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
575 static const GTypeInfo info = { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
576 sizeof(GntFileSelClass), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
577 NULL, /* base_init */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
578 NULL, /* base_finalize */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
579 (GClassInitFunc)gnt_file_sel_class_init, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
580 NULL, /* class_finalize */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
581 NULL, /* class_data */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
582 sizeof(GntFileSel), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
583 0, /* n_preallocs */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
584 gnt_file_sel_init, /* instance_init */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
585 NULL |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
586 }; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
587 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
588 type = g_type_register_static(GNT_TYPE_WINDOW, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
589 "GntFileSel", |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
590 &info, 0); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
591 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
592 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
593 return type; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
594 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
595 |
15911
0592a7b4db86
This was giving me a warning saying the function wasn't previously declared
Mark Doliner <mark@kingant.net>
parents:
15849
diff
changeset
|
596 GntWidget *gnt_file_sel_new(void) |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
597 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
598 GntWidget *widget = g_object_new(GNT_TYPE_FILE_SEL, NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
599 GntFileSel *sel = GNT_FILE_SEL(widget); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
600 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
601 sel->dirs = gnt_tree_new(); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
602 gnt_tree_set_compare_func(GNT_TREE(sel->dirs), (GCompareFunc)g_utf8_collate); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
603 gnt_tree_set_hash_fns(GNT_TREE(sel->dirs), g_str_hash, g_str_equal, g_free); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
604 gnt_tree_set_column_titles(GNT_TREE(sel->dirs), "Directories"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
605 gnt_tree_set_show_title(GNT_TREE(sel->dirs), TRUE); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
606 gnt_tree_set_col_width(GNT_TREE(sel->dirs), 0, 20); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
607 g_signal_connect(G_OBJECT(sel->dirs), "key_pressed", G_CALLBACK(dir_key_pressed), sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
608 |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
609 sel->files = gnt_tree_new_with_columns(2); /* Name, Size */ |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
610 gnt_tree_set_compare_func(GNT_TREE(sel->files), (GCompareFunc)g_utf8_collate); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
611 gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
612 gnt_tree_set_show_title(GNT_TREE(sel->files), TRUE); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
613 gnt_tree_set_col_width(GNT_TREE(sel->files), 0, 25); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
614 gnt_tree_set_col_width(GNT_TREE(sel->files), 1, 10); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
615 g_signal_connect(G_OBJECT(sel->files), "selection_changed", G_CALLBACK(file_sel_changed), sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
616 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
617 /* The location entry */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
618 sel->location = gnt_entry_new(NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
619 g_signal_connect(G_OBJECT(sel->location), "key_pressed", G_CALLBACK(location_key_pressed), sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
620 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
621 sel->cancel = gnt_button_new("Cancel"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
622 sel->select = gnt_button_new("Select"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
623 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
624 return widget; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
625 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
626 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
627 gboolean gnt_file_sel_set_current_location(GntFileSel *sel, const char *path) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
628 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
629 char *old; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
630 GError *error = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
631 gboolean ret = TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
632 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
633 old = sel->current; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
634 sel->current = process_path(path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
635 if (!location_changed(sel, &error)) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
636 g_error_free(error); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
637 error = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
638 g_free(sel->current); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
639 sel->current = old; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
640 location_changed(sel, &error); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
641 ret = FALSE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
642 } else |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
643 g_free(old); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
644 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
645 update_location(sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
646 return ret; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
647 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
648 |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
649 void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
650 { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
651 sel->dirsonly = dirs; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
652 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
653 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
654 gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
655 { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
656 return sel->dirsonly; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
657 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
658 |
15939 | 659 void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest) |
660 { | |
661 sel->suggest = g_strdup(suggest); | |
662 } | |
663 | |
15850
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
664 char *gnt_file_sel_get_selected_file(GntFileSel *sel) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
665 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
666 char *ret; |
15939 | 667 if (sel->dirsonly) { |
15964 | 668 ret = g_path_get_dirname(gnt_entry_get_text(GNT_ENTRY(sel->location))); |
15939 | 669 } else { |
670 ret = g_strdup(gnt_entry_get_text(GNT_ENTRY(sel->location))); | |
671 } | |
15850
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
672 return ret; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
673 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
674 |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
675 void gnt_file_sel_set_must_exist(GntFileSel *sel, gboolean must) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
676 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
677 /*XXX: What do I do with this? */ |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
678 sel->must_exist = must; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
679 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
680 |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
681 gboolean gnt_file_sel_get_must_exist(GntFileSel *sel) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
682 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
683 return sel->must_exist; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
684 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
685 |
15925
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
686 void gnt_file_sel_set_multi_select(GntFileSel *sel, gboolean set) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
687 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
688 sel->multiselect = set; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
689 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
690 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
691 GList *gnt_file_sel_get_selected_multi_files(GntFileSel *sel) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
692 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
693 GList *list = NULL, *iter; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
694 char *str = gnt_file_sel_get_selected_file(sel); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
695 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
696 for (iter = sel->tags; iter; iter = iter->next) { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
697 list = g_list_prepend(list, g_strdup(iter->data)); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
698 if (g_utf8_collate(str, iter->data)) { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
699 g_free(str); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
700 str = NULL; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
701 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
702 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
703 if (str) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
704 list = g_list_prepend(list, str); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
705 list = g_list_reverse(list); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
706 return list; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
707 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
708 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
709 void gnt_file_sel_set_read_fn(GntFileSel *sel, gboolean (*read_fn)(const char *path, GList **files, GError **error)) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
710 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
711 sel->read_fn = read_fn; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
712 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
713 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
714 |