Mercurial > pidgin
annotate finch/libgnt/gntfilesel.c @ 18362:65ed0916d3bc
Allowing specifying different styles for different applications.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 30 Jun 2007 00:53:24 +0000 |
parents | 4ea95c55e771 |
children | 2bf8792760fe |
rev | line source |
---|---|
18049
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
1 /** |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
3 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
6 * source distribution. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
7 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
11 * (at your option) any later version. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
12 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
16 * GNU General Public License for more details. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
17 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
21 */ |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16203
diff
changeset
|
22 |
15846
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 #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
|
24 #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
|
25 #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
|
26 #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
|
27 #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
|
28 #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
|
29 #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
|
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 #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
|
32 #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
|
33 #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
|
34 #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
|
35 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
36 #if 0 |
15846
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
|
37 #include <glob.h> |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
38 #endif |
15846
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 |
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
|
40 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
|
41 { |
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
|
42 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
|
43 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
|
44 }; |
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
|
45 |
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
|
46 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
|
47 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
|
48 static void (*orig_map)(GntWidget *widget); |
18200
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
49 static void (*orig_size_request)(GntWidget *widget); |
15846
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
|
50 |
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
|
51 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
|
52 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
|
53 { |
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
|
54 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
|
55 g_free(sel->current); |
15936 | 56 g_free(sel->suggest); |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
57 if (sel->tags) { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
58 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:
15922
diff
changeset
|
59 g_list_free(sel->tags); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
60 } |
15846
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
|
61 } |
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
|
62 |
15992
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
63 #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
|
64 /* ripped from glib/gfileutils.c */ |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
65 static gchar * |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
66 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
|
67 gchar **str_array) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
68 { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
69 GString *result; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
70 gint separator_len = strlen (separator); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
71 gboolean is_first = TRUE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
72 gboolean have_leading = FALSE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
73 const gchar *single_element = NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
74 const gchar *next_element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
75 const gchar *last_trailing = NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
76 gint i = 0; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
77 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
78 result = g_string_new (NULL); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
79 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
80 next_element = str_array[i++]; |
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 while (TRUE) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
83 const gchar *element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
84 const gchar *start; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
85 const gchar *end; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
86 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
87 if (next_element) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
88 element = next_element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
89 next_element = str_array[i++]; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
90 } else |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
91 break; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
92 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
93 /* Ignore empty elements */ |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
94 if (!*element) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
95 continue; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
96 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
97 start = element; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
98 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
99 if (separator_len) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
100 while (start && |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
101 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
|
102 start += separator_len; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
103 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
104 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
105 end = start + strlen (start); |
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 (separator_len) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
108 while (end >= start + separator_len && |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
109 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
|
110 end -= separator_len; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
111 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
112 last_trailing = end; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
113 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
|
114 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
|
115 last_trailing -= separator_len; |
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 (!have_leading) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
118 /* 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
|
119 * 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
|
120 */ |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
121 if (last_trailing <= start) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
122 single_element = element; |
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 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
|
125 have_leading = TRUE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
126 } else |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
127 single_element = NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
128 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
129 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
130 if (end == start) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
131 continue; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
132 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
133 if (!is_first) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
134 g_string_append (result, separator); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
135 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
136 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
|
137 is_first = FALSE; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
138 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
139 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
140 if (single_element) { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
141 g_string_free (result, TRUE); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
142 return g_strdup (single_element); |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
143 } else { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
144 if (last_trailing) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
145 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
|
146 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
147 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
|
148 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
149 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
150 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
151 static gchar * |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
152 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
|
153 gchar **args) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
154 { |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
155 if (!args) |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
156 return NULL; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
157 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
158 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
|
159 } |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
160 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
161 #endif |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
162 |
15846
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 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
|
164 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
|
165 { |
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 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
|
167 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
|
168 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
|
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 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
|
171 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
|
172 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
|
173 } 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
|
174 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
|
175 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
|
176 } 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
|
177 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
|
178 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
|
179 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
|
180 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
|
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 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
|
183 } |
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
|
184 } |
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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 } |
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
|
193 |
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
|
194 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
|
195 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
|
196 { |
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
|
197 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
|
198 const char *tmp; |
15936 | 199 tmp = sel->suggest ? sel->suggest : |
200 (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); | |
15846
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
|
201 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
|
202 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
|
203 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
|
204 } |
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
|
205 |
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
|
206 static gboolean |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
207 is_tagged(GntFileSel *sel, const char *f) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
208 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
209 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:
15922
diff
changeset
|
210 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:
15922
diff
changeset
|
211 g_free(ret); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
212 return find; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
213 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
214 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
215 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
|
216 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
217 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
|
218 file->basename = g_strdup(name); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
219 file->type = GNT_FILE_DIR; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
220 return file; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
221 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
222 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
223 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
|
224 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
225 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
|
226 file->basename = g_strdup(name); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
227 file->type = GNT_FILE_REGULAR; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
228 file->size = size; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
229 return file; |
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 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
232 static gboolean |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
233 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
|
234 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
235 GDir *dir; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
236 GntFile *file; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
237 const char *str; |
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 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
|
240 if (dir == NULL || (error && *error)) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
241 return FALSE; |
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 = NULL; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
245 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
|
246 file = gnt_file_new_dir(".."); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
247 *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
|
248 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
249 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
250 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
|
251 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
|
252 struct stat st; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
253 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
254 if (stat(fp, &st)) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
255 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
|
256 } else { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
257 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
|
258 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
|
259 } else { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
260 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
|
261 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
262 *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
|
263 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
264 g_free(fp); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
265 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
266 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
267 *files = g_list_reverse(*files); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
268 return TRUE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
269 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
270 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
271 static void |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
272 gnt_file_free(GntFile *file) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
273 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
274 g_free(file->fullpath); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
275 g_free(file->basename); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
276 g_free(file); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
277 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
278 |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
279 static gboolean |
15846
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
|
280 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
|
281 { |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
282 GList *files, *iter; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
283 gboolean success; |
15846
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 |
15848
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
285 if (!sel->dirs) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
286 return TRUE; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
287 |
15846
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 gnt_tree_remove_all(GNT_TREE(sel->dirs)); |
15848
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
289 if (sel->files) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
290 gnt_tree_remove_all(GNT_TREE(sel->files)); |
15846
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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
297 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
298 /* XXX:\ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
299 * XXX: This is blocking. |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
300 * XXX:/ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
301 */ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
302 files = NULL; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
303 if (sel->read_fn) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
304 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
|
305 else |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
306 success = local_read_fn(sel->current, &files, err); |
15846
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 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
308 if (!success || *err) { |
15846
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
|
309 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
|
310 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
|
311 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
|
312 } |
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 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
314 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
|
315 GntFile *file = iter->data; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
316 char *str = file->basename; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 } else if (!sel->dirsonly) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
323 char size[128]; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
324 snprintf(size, sizeof(size), "%ld", file->size); |
15846
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
|
325 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 gnt_tree_set_row_flags(GNT_TREE(sel->files), (gpointer)str, GNT_TEXT_FLAG_BOLD); |
15846
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 } |
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 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
332 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
|
333 g_list_free(files); |
15846
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 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
|
335 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
|
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 |
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 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
|
340 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
|
341 { |
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 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
|
343 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
|
344 char *path, *dir; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
345 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
346 if (!str) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
347 return TRUE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
348 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
349 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
|
350 dir = g_path_get_basename(sel->current); |
15846
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
|
351 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
|
352 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
|
353 } 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
|
354 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
|
355 } |
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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 } |
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
|
361 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
|
362 } |
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
|
363 |
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
|
364 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
|
365 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
|
366 { |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
367 char *path; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
368 char *str; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
369 #if 0 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
370 int count; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
371 glob_t gl; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
372 struct stat st; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
373 int glob_ret; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
374 #endif |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
375 if (strcmp(key, "\r")) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
376 return FALSE; |
15846
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
|
377 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
378 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
|
379 if (*str == G_DIR_SEPARATOR) |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
380 path = g_strdup(str); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
381 else |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
382 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
|
383 str = process_path(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
384 g_free(path); |
15992
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
385 path = str; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
386 |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
387 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
|
388 goto success; |
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
389 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
390 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
|
391 g_free(str); |
15846
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
|
392 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
393 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
|
394 g_free(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
395 return FALSE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
396 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
397 #if 0 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
398 /* 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
|
399 * like the read_fn stuff. */ |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
400 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
|
401 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
|
402 char *loc = g_path_get_dirname(gl.gl_pathv[0]); |
15846
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
|
403 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
404 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
|
405 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
|
406 g_free(loc); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
407 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
|
408 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
|
409 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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 char size[128]; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
415 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
|
416 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
|
417 gnt_tree_create_row(GNT_TREE(sel->files), base, size, ""), NULL, NULL); |
15846
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
|
418 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
419 g_free(loc); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
420 g_free(tmp); |
15846
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 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
|
423 } |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
424 } else if (sel->files) { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
425 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
|
426 gnt_widget_draw(sel->files); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
427 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
428 globfree(&gl); |
15992
e78b15c2c60f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15988
diff
changeset
|
429 #endif |
15846
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
|
430 success: |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
431 g_free(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
432 return TRUE; |
15846
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
|
433 } |
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
|
434 |
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
|
435 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
|
436 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
|
437 { |
16203
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
438 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
|
439 g_free(sel->suggest); |
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
440 sel->suggest = NULL; |
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
441 update_location(sel); |
4f6a6443a1e3
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
15992
diff
changeset
|
442 } |
15846
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
|
443 } |
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
|
444 |
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
|
445 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
|
446 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
|
447 { |
15848
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
448 GntFileSel *sel = GNT_FILE_SEL(widget); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
449 GntWidget *hbox, *vbox; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
450 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
451 vbox = gnt_vbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
452 gnt_box_set_pad(GNT_BOX(vbox), 0); |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
453 gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_MID); |
15848
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
454 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
455 /* The dir. and files list */ |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
456 hbox = gnt_hbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
457 gnt_box_set_pad(GNT_BOX(hbox), 0); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
458 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
459 gnt_box_add_widget(GNT_BOX(hbox), sel->dirs); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
460 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
461 if (!sel->dirsonly) { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
462 gnt_box_add_widget(GNT_BOX(hbox), sel->files); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
463 } else { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
464 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:
15846
diff
changeset
|
465 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
466 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
467 gnt_box_add_widget(GNT_BOX(vbox), hbox); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
468 gnt_box_add_widget(GNT_BOX(vbox), sel->location); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
469 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
470 /* The buttons */ |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
471 hbox = gnt_hbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
472 gnt_box_add_widget(GNT_BOX(hbox), sel->cancel); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
473 gnt_box_add_widget(GNT_BOX(hbox), sel->select); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
474 gnt_box_add_widget(GNT_BOX(vbox), hbox); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
475 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
476 gnt_box_add_widget(GNT_BOX(sel), vbox); |
15846
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
|
477 orig_map(widget); |
15848
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
478 update_location(sel); |
15846
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
|
479 } |
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
|
480 |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
481 static gboolean |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
482 toggle_tag_selection(GntBindable *bind, GList *null) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
483 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
484 GntFileSel *sel = GNT_FILE_SEL(bind); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
485 char *str; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
486 GList *find; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
487 char *file; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
488 GntWidget *tree; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
489 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
490 if (!sel->multiselect) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
491 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
492 tree = sel->dirsonly ? sel->dirs : sel->files; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
493 if (!gnt_widget_has_focus(tree)) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
494 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
495 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
496 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:
15922
diff
changeset
|
497 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
498 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:
15922
diff
changeset
|
499 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:
15922
diff
changeset
|
500 g_free(find->data); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
501 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:
15922
diff
changeset
|
502 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:
15922
diff
changeset
|
503 g_free(str); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
504 } else { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
505 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:
15922
diff
changeset
|
506 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:
15922
diff
changeset
|
507 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
508 |
15952
0ef26ac647ac
move to the next entry after (un)tagging an item.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15936
diff
changeset
|
509 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:
15936
diff
changeset
|
510 |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
511 return TRUE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
512 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
513 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
514 static gboolean |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
515 clear_tags(GntBindable *bind, GList *null) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
516 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
517 GntFileSel *sel = GNT_FILE_SEL(bind); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
518 GntWidget *tree; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
519 GList *iter; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
520 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
521 if (!sel->multiselect) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
522 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
523 tree = sel->dirsonly ? sel->dirs : sel->files; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
524 if (!gnt_widget_has_focus(tree)) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
525 return FALSE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
526 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
527 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:
15922
diff
changeset
|
528 g_list_free(sel->tags); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
529 sel->tags = NULL; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
530 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
531 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:
15922
diff
changeset
|
532 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:
15922
diff
changeset
|
533 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
534 return TRUE; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
535 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
536 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
537 static gboolean |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
538 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
|
539 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
540 char *path, *dir; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
541 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
|
542 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
|
543 !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
|
544 return FALSE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
545 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
546 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
|
547 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
|
548 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
|
549 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
|
550 g_free(dir); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
551 g_free(path); |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
552 return TRUE; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
553 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
554 |
15846
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 static void |
18200
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
556 gnt_file_sel_size_request(GntWidget *widget) |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
557 { |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
558 GntFileSel *sel; |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
559 if (widget->priv.height > 0) |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
560 return; |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
561 |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
562 sel = GNT_FILE_SEL(widget); |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
563 sel->dirs->priv.height = 16; |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
564 sel->files->priv.height = 16; |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
565 orig_size_request(widget); |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
566 } |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
567 |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
568 static void |
15846
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_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
|
570 { |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
571 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); |
15846
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 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
|
573 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
|
574 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
|
575 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
|
576 kl->map = gnt_file_sel_map; |
18200
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
577 orig_size_request = kl->size_request; |
4ea95c55e771
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
578 kl->size_request = gnt_file_sel_size_request; |
15846
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 |
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 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
|
581 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
|
582 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
|
583 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
|
584 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
|
585 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
|
586 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
|
587 G_TYPE_NONE, 0); |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
588 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
589 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:
15922
diff
changeset
|
590 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
|
591 gnt_bindable_class_register_action(bindable, "up-directory", up_directory, GNT_KEY_BACKSPACE, NULL); |
15846
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 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
|
593 |
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 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
|
595 } |
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
|
596 |
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 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
|
598 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
|
599 { |
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 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
|
601 } |
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 |
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 /****************************************************************************** |
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 * 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
|
605 *****************************************************************************/ |
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 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
|
607 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
|
608 { |
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
|
609 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
|
610 |
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 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
|
612 { |
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 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
|
614 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
|
615 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
|
616 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
|
617 (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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 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
|
624 }; |
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 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
|
627 "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
|
628 &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
|
629 } |
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 |
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 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
|
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 |
15909
0592a7b4db86
This was giving me a warning saying the function wasn't previously declared
Mark Doliner <mark@kingant.net>
parents:
15848
diff
changeset
|
634 GntWidget *gnt_file_sel_new(void) |
15846
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 { |
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 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
|
637 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
|
638 |
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->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
|
640 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
|
641 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
|
642 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
|
643 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
|
644 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
|
645 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
|
646 |
15848
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
647 sel->files = gnt_tree_new_with_columns(2); /* Name, Size */ |
15846
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 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
|
649 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
|
650 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
|
651 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
|
652 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
|
653 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
|
654 |
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
|
655 /* 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
|
656 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
|
657 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
|
658 |
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
|
659 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
|
660 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
|
661 |
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
|
662 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
|
663 } |
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
|
664 |
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
|
665 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
|
666 { |
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
|
667 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
|
668 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
|
669 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
|
670 |
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
|
671 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
|
672 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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 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
|
680 } 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
|
681 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
|
682 |
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
|
683 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
|
684 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
|
685 } |
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
|
686 |
15848
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
687 void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
688 { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
689 sel->dirsonly = dirs; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
690 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
691 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
692 gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
693 { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
694 return sel->dirsonly; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
695 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15846
diff
changeset
|
696 |
15936 | 697 void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest) |
698 { | |
699 sel->suggest = g_strdup(suggest); | |
700 } | |
701 | |
15849
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
702 char *gnt_file_sel_get_selected_file(GntFileSel *sel) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
703 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
704 char *ret; |
15936 | 705 if (sel->dirsonly) { |
15964 | 706 ret = g_path_get_dirname(gnt_entry_get_text(GNT_ENTRY(sel->location))); |
15936 | 707 } else { |
708 ret = g_strdup(gnt_entry_get_text(GNT_ENTRY(sel->location))); | |
709 } | |
15849
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
710 return ret; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
711 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
712 |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
713 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:
15848
diff
changeset
|
714 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
715 /*XXX: What do I do with this? */ |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
716 sel->must_exist = must; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
717 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
718 |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
719 gboolean gnt_file_sel_get_must_exist(GntFileSel *sel) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
720 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
721 return sel->must_exist; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
722 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15848
diff
changeset
|
723 |
15923
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
724 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:
15922
diff
changeset
|
725 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
726 sel->multiselect = set; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
727 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
728 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
729 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:
15922
diff
changeset
|
730 { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
731 GList *list = NULL, *iter; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
732 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:
15922
diff
changeset
|
733 |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
734 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:
15922
diff
changeset
|
735 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:
15922
diff
changeset
|
736 if (g_utf8_collate(str, iter->data)) { |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
737 g_free(str); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
738 str = NULL; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
739 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
740 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
741 if (str) |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
742 list = g_list_prepend(list, str); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
743 list = g_list_reverse(list); |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
744 return list; |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
745 } |
f8c16848b76d
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15922
diff
changeset
|
746 |
15988
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
747 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
|
748 { |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
749 sel->read_fn = read_fn; |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
750 } |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
751 |
e05e5b148723
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
752 |