finch/libgnt/gntfilesel.c

Wed, 06 Jun 2007 15:42:29 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Wed, 06 Jun 2007 15:42:29 +0000
branch
release-2.1.0
changeset 18114
adb3cfadc125
parent 16264
03aaf9aae68b
child 18263
d422d19f11fa
permissions
-rw-r--r--

Doxygen skeleton and license info for gnt files.

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

mercurial