Sat, 25 Nov 2017 21:42:28 +0800
jabber.c: fix #17270, ignore STARTTLS when using BOSH.
Pidgin wants to establish a TLS connection with a STARTTLS request, but
it doesn't make any sense, since the XMPP stream is proxied by the BOSH
connection, which is already encrypted by HTTPS. It is impossible to
STARTTLS with BOSH.
According to XEP-0206: The client SHOULD ignore any Transport Layer Security
(TLS) feature since BOSH channel encryption SHOULD be negotiated at the HTTP
layer.
Failing to do it causes Pidgin fails to create any connection with BOSH to any
XMPP server with STARTTLS enabled.
https://developer.pidgin.im/ticket/17270
|
17586
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
1 | /** |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
2 | * GNT - The GLib Ncurses Toolkit |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
3 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
4 | * GNT is the legal property of its developers, whose names are too numerous |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
6 | * source distribution. |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
7 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
8 | * This library is free software; you can redistribute it and/or modify |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
11 | * (at your option) any later version. |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
12 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
16 | * GNU General Public License for more details. |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
17 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19558
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
17586
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
21 | */ |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16264
diff
changeset
|
22 | |
|
24822
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
23 | #include "gntinternal.h" |
|
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
24 | #undef GNT_LOG_DOMAIN |
|
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
25 | #define GNT_LOG_DOMAIN "FileSel" |
|
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
26 | |
|
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
|
27 | #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
|
28 | #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
|
29 | #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
|
30 | #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
|
31 | #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
|
32 | #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
|
33 | #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
|
34 | |
|
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 | #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
|
36 | #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
|
37 | #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
|
38 | #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
|
39 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
40 | #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
|
41 | #include <glob.h> |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
42 | #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
|
43 | |
|
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 | 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
|
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 | 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
|
47 | 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
|
48 | }; |
|
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 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
|
51 | 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
|
52 | static void (*orig_map)(GntWidget *widget); |
|
18263
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
53 | static void (*orig_size_request)(GntWidget *widget); |
|
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
|
54 | |
|
18826
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
55 | static void select_activated_cb(GntWidget *button, GntFileSel *sel); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
56 | |
|
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
|
57 | 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
|
58 | 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
|
59 | { |
|
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 | 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
|
61 | g_free(sel->current); |
| 16000 | 62 | 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
|
63 | if (sel->tags) { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
64 | 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
|
65 | 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
|
66 | } |
|
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
|
67 | } |
|
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
|
68 | |
|
16053
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
69 | #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
|
70 | /* ripped from glib/gfileutils.c */ |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
71 | static gchar * |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
72 | 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
|
73 | gchar **str_array) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
74 | { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
75 | GString *result; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
76 | gint separator_len = strlen (separator); |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
77 | gboolean is_first = TRUE; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
78 | gboolean have_leading = FALSE; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
79 | const gchar *single_element = NULL; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
80 | const gchar *next_element; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
81 | const gchar *last_trailing = NULL; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
82 | gint i = 0; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
83 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
84 | result = g_string_new (NULL); |
|
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 | next_element = str_array[i++]; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
87 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
88 | while (TRUE) { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
89 | const gchar *element; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
90 | const gchar *start; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
91 | const gchar *end; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
92 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
93 | if (next_element) { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
94 | element = next_element; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
95 | next_element = str_array[i++]; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
96 | } else |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
97 | break; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
98 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
99 | /* Ignore empty elements */ |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
100 | if (!*element) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
101 | continue; |
|
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 | start = element; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
104 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
105 | if (separator_len) { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
106 | while (start && |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
107 | 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
|
108 | start += separator_len; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
109 | } |
|
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 | end = start + strlen (start); |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
112 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
113 | if (separator_len) { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
114 | while (end >= start + separator_len && |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
115 | 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
|
116 | end -= separator_len; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
117 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
118 | last_trailing = end; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
119 | 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
|
120 | 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
|
121 | last_trailing -= separator_len; |
|
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 | if (!have_leading) { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
124 | /* 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
|
125 | * 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
|
126 | */ |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
127 | if (last_trailing <= start) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
128 | single_element = element; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
129 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
130 | 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
|
131 | have_leading = TRUE; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
132 | } else |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
133 | single_element = NULL; |
|
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 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
136 | if (end == start) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
137 | continue; |
|
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 (!is_first) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
140 | g_string_append (result, separator); |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
141 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
142 | 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
|
143 | is_first = FALSE; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
144 | } |
|
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 | if (single_element) { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
147 | g_string_free (result, TRUE); |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
148 | return g_strdup (single_element); |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
149 | } else { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
150 | if (last_trailing) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
151 | 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
|
152 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
153 | 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
|
154 | } |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
155 | } |
|
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 | static gchar * |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
158 | 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
|
159 | gchar **args) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
160 | { |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
161 | if (!args) |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
162 | return NULL; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
163 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
164 | 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
|
165 | } |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
166 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
167 | #endif |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
168 | |
|
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
|
169 | 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
|
170 | 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
|
171 | { |
|
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 | 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
|
173 | 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
|
174 | 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
|
175 | |
|
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 | 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
|
177 | 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
|
178 | if (strcmp(splits[i], ".") == 0) { |
|
28630
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
179 | g_free(splits[i]); |
|
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
180 | splits[i] = 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
|
181 | } 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
|
182 | 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
|
183 | j--; |
|
28630
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
184 | g_free(splits[i]); |
|
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
185 | splits[i] = 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
|
186 | } 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
|
187 | 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
|
188 | 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
|
189 | 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
|
190 | 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
|
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 | 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
|
193 | } |
|
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 | } |
|
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 | 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
|
196 | 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
|
197 | 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
|
198 | 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
|
199 | 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
|
200 | 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
|
201 | 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
|
202 | } |
|
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 | 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
|
205 | 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
|
206 | { |
|
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
|
207 | 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
|
208 | const char *tmp; |
| 16000 | 209 | tmp = sel->suggest ? sel->suggest : |
| 210 | (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); | |
|
19558
3fcb1a404632
Fix #2599. (Sound File Change Crash)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19230
diff
changeset
|
211 | old = g_strdup_printf("%s%s%s", SAFE(sel->current), SAFE(sel->current)[1] ? G_DIR_SEPARATOR_S : "", tmp ? 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
|
212 | 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
|
213 | 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
|
214 | } |
|
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
|
215 | |
|
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
|
216 | static gboolean |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
217 | 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
|
218 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
219 | 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
|
220 | 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
|
221 | g_free(ret); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
222 | return find; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
223 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
224 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
225 | 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
|
226 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
227 | 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
|
228 | file->basename = g_strdup(name); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
229 | file->type = GNT_FILE_DIR; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
230 | return file; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
231 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
232 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
233 | 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
|
234 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
235 | 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
|
236 | file->basename = g_strdup(name); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
237 | file->type = GNT_FILE_REGULAR; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
238 | file->size = size; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
239 | return file; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
240 | } |
|
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 | static gboolean |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
243 | 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
|
244 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
245 | GDir *dir; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
246 | GntFile *file; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
247 | const char *str; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
248 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
249 | 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
|
250 | if (dir == NULL || (error && *error)) { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
251 | return FALSE; |
|
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 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
254 | *files = NULL; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
255 | 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
|
256 | file = gnt_file_new_dir(".."); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
257 | *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
|
258 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
259 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
260 | 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
|
261 | 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
|
262 | struct stat st; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
263 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
264 | if (stat(fp, &st)) { |
|
24822
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
265 | gnt_warning("Error stating location %s", fp); |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
266 | } else { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
267 | 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
|
268 | 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
|
269 | } else { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
270 | 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
|
271 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
272 | *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
|
273 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
274 | g_free(fp); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
275 | } |
|
20238
e4abd12fb7ec
applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
276 | g_dir_close(dir); |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
277 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
278 | *files = g_list_reverse(*files); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
279 | return TRUE; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
280 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
281 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
282 | static void |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
283 | gnt_file_free(GntFile *file) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
284 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
285 | g_free(file->fullpath); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
286 | g_free(file->basename); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
287 | g_free(file); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
288 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
289 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
290 | 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
|
291 | 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
|
292 | { |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
293 | GList *files, *iter; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
294 | 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
|
295 | |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
296 | if (!sel->dirs) |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
297 | return TRUE; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
298 | |
|
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
|
299 | gnt_tree_remove_all(GNT_TREE(sel->dirs)); |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
300 | if (sel->files) |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
301 | 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
|
302 | 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
|
303 | 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
|
304 | 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
|
305 | 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
|
306 | 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
|
307 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
308 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
309 | /* XXX:\ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
310 | * XXX: This is blocking. |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
311 | * XXX:/ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
312 | */ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
313 | files = NULL; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
314 | if (sel->read_fn) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
315 | 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
|
316 | else |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
317 | success = local_read_fn(sel->current, &files, err); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
318 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
319 | if (!success || *err) { |
|
24822
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
320 | gnt_warning("error opening location %s (%s)", |
|
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
|
321 | 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
|
322 | 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
|
323 | } |
|
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 | 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
|
326 | GntFile *file = iter->data; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
327 | char *str = file->basename; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
328 | 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
|
329 | 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
|
330 | 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
|
331 | 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
|
332 | 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
|
333 | } else if (!sel->dirsonly) { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
334 | char size[128]; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
335 | 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
|
336 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
337 | 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
|
338 | 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
|
339 | 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
|
340 | 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
|
341 | } |
|
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 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | 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
|
347 | 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
|
348 | } |
|
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
|
349 | |
|
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 | 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
|
351 | 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
|
352 | { |
|
22421
ccddf3ffaf41
'\n' (ctrl-j) should behave similar to '\r' (ctrl-m). Fixes #4833.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21453
diff
changeset
|
353 | if (strcmp(key, "\r") == 0 || strcmp(key, "\n") == 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
|
354 | 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
|
355 | char *path, *dir; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
356 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
357 | if (!str) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
358 | return TRUE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
359 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
360 | 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
|
361 | 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
|
362 | 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
|
363 | 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
|
364 | } 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
|
365 | 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
|
366 | } |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
367 | gnt_bindable_perform_action_named(GNT_BINDABLE(tree), "end-search", 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
|
368 | 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
|
369 | 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
|
370 | 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
|
371 | 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
|
372 | } |
|
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
|
373 | 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
|
374 | } |
|
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
|
375 | |
|
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 | 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
|
377 | 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
|
378 | { |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
379 | char *path; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
380 | char *str; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
381 | #if 0 |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
382 | int count; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
383 | glob_t gl; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
384 | struct stat st; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
385 | int glob_ret; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
386 | #endif |
|
22421
ccddf3ffaf41
'\n' (ctrl-j) should behave similar to '\r' (ctrl-m). Fixes #4833.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21453
diff
changeset
|
387 | if (strcmp(key, "\r") && strcmp(key, "\n")) |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
388 | 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
|
389 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
390 | 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
|
391 | if (*str == G_DIR_SEPARATOR) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
392 | path = g_strdup(str); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
393 | else |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
394 | 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
|
395 | str = process_path(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
396 | g_free(path); |
|
16053
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
397 | path = str; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
398 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
399 | 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
|
400 | goto success; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
401 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
402 | 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
|
403 | 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
|
404 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
405 | 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
|
406 | g_free(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
407 | return FALSE; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
408 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
409 | #if 0 |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
410 | /* 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
|
411 | * like the read_fn stuff. */ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
412 | 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
|
413 | 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
|
414 | 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
|
415 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
416 | 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
|
417 | 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
|
418 | g_free(loc); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
419 | 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
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | 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
|
424 | 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
|
425 | 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
|
426 | char size[128]; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
427 | 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
|
428 | 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
|
429 | 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
|
430 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
431 | g_free(loc); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
432 | 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
|
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 | 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
|
435 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
436 | } else if (sel->files) { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
437 | 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
|
438 | gnt_widget_draw(sel->files); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
439 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
440 | globfree(&gl); |
|
16053
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
441 | #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
|
442 | success: |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
443 | g_free(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
444 | 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
|
445 | } |
|
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 | |
|
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
|
447 | 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
|
448 | 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
|
449 | { |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
450 | 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
|
451 | g_free(sel->suggest); |
|
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
452 | sel->suggest = NULL; |
|
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
453 | update_location(sel); |
|
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
454 | } |
|
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
|
455 | } |
|
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
|
456 | |
|
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
|
457 | 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
|
458 | 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
|
459 | { |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
460 | GntFileSel *sel = GNT_FILE_SEL(widget); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
461 | GntWidget *hbox, *vbox; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
462 | |
| 18613 | 463 | if (sel->current == NULL) |
| 464 | gnt_file_sel_set_current_location(sel, g_get_home_dir()); | |
| 465 | ||
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
466 | vbox = gnt_vbox_new(FALSE); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
467 | 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
|
468 | 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
|
469 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
470 | /* The dir. and files list */ |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
471 | hbox = gnt_hbox_new(FALSE); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
472 | gnt_box_set_pad(GNT_BOX(hbox), 0); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
473 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
474 | gnt_box_add_widget(GNT_BOX(hbox), sel->dirs); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
475 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
476 | if (!sel->dirsonly) { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
477 | gnt_box_add_widget(GNT_BOX(hbox), sel->files); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
478 | } else { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
479 | 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
|
480 | } |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
481 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
482 | gnt_box_add_widget(GNT_BOX(vbox), hbox); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
483 | gnt_box_add_widget(GNT_BOX(vbox), sel->location); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
484 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
485 | /* The buttons */ |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
486 | hbox = gnt_hbox_new(FALSE); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
487 | gnt_box_add_widget(GNT_BOX(hbox), sel->cancel); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
488 | gnt_box_add_widget(GNT_BOX(hbox), sel->select); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
489 | gnt_box_add_widget(GNT_BOX(vbox), hbox); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
490 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
491 | 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
|
492 | orig_map(widget); |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
493 | 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
|
494 | } |
|
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
|
495 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
496 | static gboolean |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
497 | 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
|
498 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
499 | 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
|
500 | char *str; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
501 | GList *find; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
502 | char *file; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
503 | GntWidget *tree; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
504 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
505 | if (!sel->multiselect) |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
506 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
507 | tree = sel->dirsonly ? sel->dirs : sel->files; |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
508 | if (!gnt_widget_has_focus(tree) || |
|
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
509 | gnt_tree_is_searching(GNT_TREE(tree))) |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
510 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
511 | |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
512 | file = gnt_tree_get_selection_data(GNT_TREE(tree)); |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
513 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
514 | 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
|
515 | 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
|
516 | g_free(find->data); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
517 | 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
|
518 | 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
|
519 | g_free(str); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
520 | } else { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
521 | 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
|
522 | 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
|
523 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
524 | |
|
16011
8510d387d21b
move to the next entry after (un)tagging an item.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16000
diff
changeset
|
525 | 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
|
526 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
527 | return TRUE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
528 | } |
|
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 | static gboolean |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
531 | 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
|
532 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
533 | 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
|
534 | GntWidget *tree; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
535 | GList *iter; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
536 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
537 | if (!sel->multiselect) |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
538 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
539 | tree = sel->dirsonly ? sel->dirs : sel->files; |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
540 | if (!gnt_widget_has_focus(tree) || |
|
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
541 | gnt_tree_is_searching(GNT_TREE(tree))) |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
542 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
543 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
544 | 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
|
545 | 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
|
546 | sel->tags = NULL; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
547 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
548 | 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
|
549 | 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
|
550 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
551 | return TRUE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
552 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
553 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
554 | static gboolean |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
555 | 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
|
556 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
557 | char *path, *dir; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
558 | 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
|
559 | 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
|
560 | !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
|
561 | return FALSE; |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
562 | if (gnt_tree_is_searching(GNT_TREE(sel->dirs)) || |
|
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
563 | gnt_tree_is_searching(GNT_TREE(sel->files))) |
|
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
564 | return FALSE; |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
565 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
566 | 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
|
567 | 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
|
568 | 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
|
569 | 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
|
570 | g_free(dir); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
571 | g_free(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
572 | return TRUE; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
573 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
574 | |
|
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
|
575 | static void |
|
18263
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
576 | gnt_file_sel_size_request(GntWidget *widget) |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
577 | { |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
578 | GntFileSel *sel; |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
579 | if (widget->priv.height > 0) |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
580 | return; |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
581 | |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
582 | sel = GNT_FILE_SEL(widget); |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
583 | sel->dirs->priv.height = 16; |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
584 | sel->files->priv.height = 16; |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
585 | orig_size_request(widget); |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
586 | } |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
587 | |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
588 | static 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
|
589 | 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
|
590 | { |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
591 | 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
|
592 | 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
|
593 | 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
|
594 | 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
|
595 | 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
|
596 | kl->map = gnt_file_sel_map; |
|
18263
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
597 | orig_size_request = kl->size_request; |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
598 | kl->size_request = gnt_file_sel_size_request; |
|
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
|
599 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
600 | signals[SIG_FILE_SELECTED] = |
|
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
|
601 | 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
|
602 | 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
|
603 | 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
|
604 | 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
|
605 | 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
|
606 | gnt_closure_marshal_VOID__STRING_STRING, |
|
18635
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
607 | G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
608 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
609 | 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
|
610 | 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
|
611 | 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
|
612 | 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
|
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 | 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
|
615 | } |
|
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 | 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
|
618 | 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
|
619 | { |
|
18826
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
620 | GntFileSel *sel = GNT_FILE_SEL(instance); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
621 | |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
622 | sel->dirs = gnt_tree_new(); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
623 | gnt_tree_set_compare_func(GNT_TREE(sel->dirs), (GCompareFunc)g_utf8_collate); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
624 | gnt_tree_set_hash_fns(GNT_TREE(sel->dirs), g_str_hash, g_str_equal, g_free); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
625 | gnt_tree_set_column_titles(GNT_TREE(sel->dirs), "Directories"); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
626 | gnt_tree_set_show_title(GNT_TREE(sel->dirs), TRUE); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
627 | gnt_tree_set_col_width(GNT_TREE(sel->dirs), 0, 20); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
628 | g_signal_connect(G_OBJECT(sel->dirs), "key_pressed", G_CALLBACK(dir_key_pressed), sel); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
629 | |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
630 | sel->files = gnt_tree_new_with_columns(2); /* Name, Size */ |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
631 | gnt_tree_set_compare_func(GNT_TREE(sel->files), (GCompareFunc)g_utf8_collate); |
|
28630
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
632 | gnt_tree_set_hash_fns(GNT_TREE(sel->files), g_str_hash, g_str_equal, g_free); |
|
18826
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
633 | gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size"); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
634 | gnt_tree_set_show_title(GNT_TREE(sel->files), TRUE); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
635 | gnt_tree_set_col_width(GNT_TREE(sel->files), 0, 25); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
636 | gnt_tree_set_col_width(GNT_TREE(sel->files), 1, 10); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
637 | gnt_tree_set_column_is_right_aligned(GNT_TREE(sel->files), 1, TRUE); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
638 | g_signal_connect(G_OBJECT(sel->files), "selection_changed", G_CALLBACK(file_sel_changed), sel); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
639 | |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
640 | /* The location entry */ |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
641 | sel->location = gnt_entry_new(NULL); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
642 | g_signal_connect(G_OBJECT(sel->location), "key_pressed", G_CALLBACK(location_key_pressed), sel); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
643 | |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
644 | sel->cancel = gnt_button_new("Cancel"); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
645 | sel->select = gnt_button_new("Select"); |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
646 | |
|
21267
e3a6fdf2e009
Hitting enter on a file will trigger the 'select' button in the file selector dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21243
diff
changeset
|
647 | g_signal_connect_swapped(G_OBJECT(sel->files), "activate", G_CALLBACK(gnt_widget_activate), sel->select); |
|
18826
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18635
diff
changeset
|
648 | g_signal_connect(G_OBJECT(sel->select), "activate", G_CALLBACK(select_activated_cb), 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
|
649 | } |
|
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 | /****************************************************************************** |
|
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 | * 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
|
653 | *****************************************************************************/ |
|
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 | 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
|
655 | 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
|
656 | { |
|
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 | 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
|
658 | |
|
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 | 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
|
660 | { |
|
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 | 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
|
662 | 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
|
663 | 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
|
664 | 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
|
665 | (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
|
666 | 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
|
667 | 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
|
668 | 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
|
669 | 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
|
670 | 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
|
671 | 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
|
672 | }; |
|
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
|
673 | |
|
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
|
674 | 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
|
675 | "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
|
676 | &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
|
677 | } |
|
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
|
678 | |
|
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
|
679 | 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
|
680 | } |
|
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
|
681 | |
|
18635
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
682 | static void |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
683 | select_activated_cb(GntWidget *button, GntFileSel *sel) |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
684 | { |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
685 | char *path = gnt_file_sel_get_selected_file(sel); |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
686 | char *file = g_path_get_basename(path); |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
687 | g_signal_emit(sel, signals[SIG_FILE_SELECTED], 0, path, file); |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
688 | g_free(file); |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
689 | g_free(path); |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
690 | } |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
691 | |
|
15972
894a15d885ec
This was giving me a warning saying the function wasn't previously declared
Mark Doliner <markdoliner@pidgin.im>
parents:
15911
diff
changeset
|
692 | 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
|
693 | { |
|
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
|
694 | 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
|
695 | 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
|
696 | } |
|
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
|
697 | |
|
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
|
698 | 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
|
699 | { |
|
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
|
700 | 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
|
701 | 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
|
702 | 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
|
703 | |
|
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
|
704 | 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
|
705 | 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
|
706 | 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
|
707 | 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
|
708 | 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
|
709 | 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
|
710 | 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
|
711 | 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
|
712 | 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
|
713 | } 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
|
714 | 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
|
715 | |
|
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
|
716 | 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
|
717 | 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
|
718 | } |
|
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
|
719 | |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
720 | 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
|
721 | { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
722 | sel->dirsonly = dirs; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
723 | } |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
724 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
725 | gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel) |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
726 | { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
727 | return sel->dirsonly; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
728 | } |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
729 | |
| 16000 | 730 | void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest) |
| 731 | { | |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20238
diff
changeset
|
732 | g_free(sel->suggest); |
| 16000 | 733 | sel->suggest = g_strdup(suggest); |
| 734 | } | |
| 735 | ||
|
15912
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
736 | 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
|
737 | { |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
738 | char *ret; |
| 16000 | 739 | if (sel->dirsonly) { |
| 16025 | 740 | ret = g_path_get_dirname(gnt_entry_get_text(GNT_ENTRY(sel->location))); |
| 16000 | 741 | } else { |
| 742 | ret = g_strdup(gnt_entry_get_text(GNT_ENTRY(sel->location))); | |
| 743 | } | |
|
15912
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
744 | return ret; |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
745 | } |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
746 | |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
747 | 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
|
748 | { |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
749 | /*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
|
750 | sel->must_exist = must; |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
751 | } |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
752 | |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
753 | 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
|
754 | { |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
755 | return sel->must_exist; |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
756 | } |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
757 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
758 | 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
|
759 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
760 | sel->multiselect = set; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
761 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
762 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
763 | 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
|
764 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
765 | GList *list = NULL, *iter; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
766 | 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
|
767 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
768 | 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
|
769 | 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
|
770 | 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
|
771 | g_free(str); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
772 | str = NULL; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
773 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
774 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
775 | if (str) |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
776 | 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
|
777 | 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
|
778 | return list; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
779 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
780 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
781 | 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
|
782 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
783 | sel->read_fn = read_fn; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
784 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
785 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
786 |