Fri, 07 Feb 2014 01:19:18 +0530
Merge gtkdoc-conversion
|
35456
821aa4bcb6fa
Fix a bunch of gtk-doc warnings in finch
Ankit Vani <a@nevitus.org>
parents:
35191
diff
changeset
|
1 | /* |
|
17586
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 | |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33649
diff
changeset
|
40 | #include <glib/gstdio.h> |
|
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33649
diff
changeset
|
41 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
42 | #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
|
43 | #include <glob.h> |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
44 | #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
|
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 | 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
|
47 | { |
|
b2dad43782a1
File selector dialog. Still in 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 | 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
|
49 | 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
|
50 | }; |
|
b2dad43782a1
File selector dialog. Still in 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 | |
|
b2dad43782a1
File selector dialog. Still in 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 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
|
53 | 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
|
54 | 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
|
55 | 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
|
56 | |
|
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
|
57 | 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
|
58 | |
|
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
|
59 | 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
|
60 | 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
|
61 | { |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
62 | 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
|
63 | g_free(sel->current); |
| 16000 | 64 | 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
|
65 | if (sel->tags) { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
66 | 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
|
67 | 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
|
68 | } |
|
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
|
69 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
70 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
71 | 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
|
72 | 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
|
73 | { |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
74 | 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
|
75 | 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
|
76 | 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
|
77 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
78 | 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
|
79 | 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
|
80 | if (strcmp(splits[i], ".") == 0) { |
|
28630
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
81 | g_free(splits[i]); |
|
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
82 | 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
|
83 | } 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
|
84 | 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
|
85 | j--; |
|
28630
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
86 | g_free(splits[i]); |
|
8e98598f5948
Plug leaks in the file-selector code.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24822
diff
changeset
|
87 | 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
|
88 | } 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
|
89 | 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
|
90 | 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
|
91 | 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
|
92 | 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
|
93 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
94 | 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
|
95 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
96 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
97 | 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
|
98 | 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
|
99 | 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
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
105 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
106 | 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
|
107 | 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
|
108 | { |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
109 | 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
|
110 | const char *tmp; |
| 16000 | 111 | tmp = sel->suggest ? sel->suggest : |
| 112 | (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
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
117 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
118 | static gboolean |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
119 | 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
|
120 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
121 | 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
|
122 | 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
|
123 | g_free(ret); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
124 | return find; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
125 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
126 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
127 | 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
|
128 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
129 | 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
|
130 | file->basename = g_strdup(name); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
131 | file->type = GNT_FILE_DIR; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
132 | return file; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
133 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
134 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
135 | 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
|
136 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
137 | 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
|
138 | file->basename = g_strdup(name); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
139 | file->type = GNT_FILE_REGULAR; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
140 | file->size = size; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
141 | return file; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
142 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
143 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
144 | static gboolean |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
145 | 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
|
146 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
147 | GDir *dir; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
148 | GntFile *file; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
149 | const char *str; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
150 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
151 | 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
|
152 | if (dir == NULL || (error && *error)) { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
153 | return FALSE; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
154 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
155 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
156 | *files = NULL; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
157 | 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
|
158 | file = gnt_file_new_dir(".."); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
159 | *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
|
160 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
161 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
162 | 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
|
163 | char *fp = g_build_filename(path, str, NULL); |
|
35191
e884b8670dc2
finch: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents:
33940
diff
changeset
|
164 | struct stat st; |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
165 | |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33649
diff
changeset
|
166 | if (g_stat(fp, &st)) { |
|
24822
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
167 | 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
|
168 | } else { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
169 | 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
|
170 | 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
|
171 | } else { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
172 | 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
|
173 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
174 | *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
|
175 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
176 | g_free(fp); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
177 | } |
|
20238
e4abd12fb7ec
applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
178 | g_dir_close(dir); |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
179 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
180 | *files = g_list_reverse(*files); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
181 | return TRUE; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
182 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
183 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
184 | static void |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
185 | gnt_file_free(GntFile *file) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
186 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
187 | g_free(file->fullpath); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
188 | g_free(file->basename); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
189 | g_free(file); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
190 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
191 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
192 | 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
|
193 | 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
|
194 | { |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
195 | GList *files, *iter; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
196 | 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
|
197 | |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
198 | if (!sel->dirs) |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
199 | return TRUE; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
200 | |
|
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
|
201 | gnt_tree_remove_all(GNT_TREE(sel->dirs)); |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
202 | if (sel->files) |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
203 | 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
|
204 | 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
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | 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
|
209 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
210 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
211 | /* XXX:\ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
212 | * XXX: This is blocking. |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
213 | * XXX:/ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
214 | */ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
215 | files = NULL; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
216 | if (sel->read_fn) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
217 | 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
|
218 | else |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
219 | success = local_read_fn(sel->current, &files, err); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
220 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
221 | if (!success || *err) { |
|
24822
d7774462f2ba
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
222 | 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
|
223 | 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
|
224 | 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
|
225 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
226 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
227 | 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
|
228 | GntFile *file = iter->data; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
229 | char *str = file->basename; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
230 | 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
|
231 | 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
|
232 | 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
|
233 | 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
|
234 | 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
|
235 | } else if (!sel->dirsonly) { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
236 | char size[128]; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
237 | 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
|
238 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
239 | 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
|
240 | 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
|
241 | 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
|
242 | 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
|
243 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
244 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | 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
|
250 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
251 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
252 | 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
|
253 | 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
|
254 | { |
|
22421
ccddf3ffaf41
'\n' (ctrl-j) should behave similar to '\r' (ctrl-m). Fixes #4833.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21453
diff
changeset
|
255 | 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
|
256 | 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
|
257 | char *path, *dir; |
|
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 | if (!str) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
260 | return TRUE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
261 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | } 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
|
267 | 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
|
268 | } |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
269 | 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
|
270 | 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
|
271 | 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
|
272 | 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
|
273 | 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
|
274 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
275 | 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
|
276 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
277 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
278 | 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
|
279 | 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
|
280 | { |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
281 | char *path; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
282 | char *str; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
283 | #if 0 |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
284 | int count; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
285 | glob_t gl; |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33649
diff
changeset
|
286 | GStatBuf st; |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
287 | int glob_ret; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
288 | #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
|
289 | 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
|
290 | 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
|
291 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
292 | 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
|
293 | if (*str == G_DIR_SEPARATOR) |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
294 | path = g_strdup(str); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
295 | else |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
296 | 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
|
297 | str = process_path(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
298 | g_free(path); |
|
16053
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
299 | path = str; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
300 | |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
301 | 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
|
302 | goto success; |
|
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
303 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
304 | 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
|
305 | 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
|
306 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
307 | 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
|
308 | g_free(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
309 | return FALSE; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
310 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
311 | #if 0 |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
312 | /* 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
|
313 | * like the read_fn stuff. */ |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
314 | 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
|
315 | 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
|
316 | 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
|
317 | |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33649
diff
changeset
|
318 | g_stat(gl.gl_pathv[0], &st); |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
319 | 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
|
320 | g_free(loc); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
321 | 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
|
322 | 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
|
323 | 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
|
324 | 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
|
325 | 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
|
326 | 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
|
327 | 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
|
328 | char size[128]; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
329 | 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
|
330 | 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
|
331 | 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
|
332 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
333 | g_free(loc); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
334 | 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
|
335 | } |
|
b2dad43782a1
File selector dialog. Still in 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 | 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
|
337 | } |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
338 | } else if (sel->files) { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
339 | 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
|
340 | gnt_widget_draw(sel->files); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
341 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
342 | globfree(&gl); |
|
16053
8049570feb1f
"elb: g_build_pathv is Glib 2.8"
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16049
diff
changeset
|
343 | #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
|
344 | success: |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
345 | g_free(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
346 | 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
|
347 | } |
|
b2dad43782a1
File selector dialog. Still in 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 | 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
|
350 | 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
|
351 | { |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
352 | 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
|
353 | g_free(sel->suggest); |
|
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
354 | sel->suggest = NULL; |
|
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
355 | update_location(sel); |
|
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16053
diff
changeset
|
356 | } |
|
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
|
357 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
358 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
359 | 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
|
360 | 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
|
361 | { |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
362 | GntFileSel *sel = GNT_FILE_SEL(widget); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
363 | GntWidget *hbox, *vbox; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
364 | |
| 18613 | 365 | if (sel->current == NULL) |
| 366 | gnt_file_sel_set_current_location(sel, g_get_home_dir()); | |
| 367 | ||
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
368 | vbox = gnt_vbox_new(FALSE); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
369 | 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
|
370 | 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
|
371 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
372 | /* The dir. and files list */ |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
373 | hbox = gnt_hbox_new(FALSE); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
374 | gnt_box_set_pad(GNT_BOX(hbox), 0); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
375 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
376 | gnt_box_add_widget(GNT_BOX(hbox), sel->dirs); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
377 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
378 | if (!sel->dirsonly) { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
379 | gnt_box_add_widget(GNT_BOX(hbox), sel->files); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
380 | } else { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
381 | 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
|
382 | } |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
383 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
384 | gnt_box_add_widget(GNT_BOX(vbox), hbox); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
385 | gnt_box_add_widget(GNT_BOX(vbox), sel->location); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
386 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
387 | /* The buttons */ |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
388 | hbox = gnt_hbox_new(FALSE); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
389 | gnt_box_add_widget(GNT_BOX(hbox), sel->cancel); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
390 | gnt_box_add_widget(GNT_BOX(hbox), sel->select); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
391 | gnt_box_add_widget(GNT_BOX(vbox), hbox); |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
392 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
393 | 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
|
394 | orig_map(widget); |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
395 | 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
|
396 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
397 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
398 | static gboolean |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
399 | 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
|
400 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
401 | 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
|
402 | char *str; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
403 | GList *find; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
404 | char *file; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
405 | GntWidget *tree; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
406 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
407 | if (!sel->multiselect) |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
408 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
409 | 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
|
410 | if (!gnt_widget_has_focus(tree) || |
|
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
411 | 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
|
412 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
413 | |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
414 | 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
|
415 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
416 | 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
|
417 | 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
|
418 | g_free(find->data); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
419 | 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
|
420 | 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
|
421 | g_free(str); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
422 | } else { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
423 | 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
|
424 | 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
|
425 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
426 | |
|
16011
8510d387d21b
move to the next entry after (un)tagging an item.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16000
diff
changeset
|
427 | 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
|
428 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
429 | return TRUE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
430 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
431 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
432 | static gboolean |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
433 | 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
|
434 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
435 | 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
|
436 | GntWidget *tree; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
437 | GList *iter; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
438 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
439 | if (!sel->multiselect) |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
440 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
441 | 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
|
442 | if (!gnt_widget_has_focus(tree) || |
|
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
443 | 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
|
444 | return FALSE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
445 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
446 | 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
|
447 | 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
|
448 | sel->tags = NULL; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
449 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
450 | 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
|
451 | 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
|
452 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
453 | return TRUE; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
454 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
455 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
456 | static gboolean |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
457 | 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
|
458 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
459 | char *path, *dir; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
460 | 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
|
461 | 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
|
462 | !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
|
463 | return FALSE; |
|
19230
4262d79182b8
Fix typeahead searching in the file-dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
464 | 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
|
465 | 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
|
466 | return FALSE; |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
467 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
468 | 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
|
469 | 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
|
470 | 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
|
471 | 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
|
472 | g_free(dir); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
473 | g_free(path); |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
474 | return TRUE; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
475 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
476 | |
|
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
|
477 | static void |
|
18263
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
478 | 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
|
479 | { |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
480 | GntFileSel *sel; |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
481 | 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
|
482 | return; |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
483 | |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
484 | 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
|
485 | 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
|
486 | 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
|
487 | orig_size_request(widget); |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
488 | } |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
489 | |
|
d422d19f11fa
The file-selector needs to be a bit taller.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17586
diff
changeset
|
490 | 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
|
491 | 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
|
492 | { |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
493 | 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
|
494 | 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
|
495 | 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
|
496 | 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
|
497 | 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
|
498 | 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
|
499 | 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
|
500 | 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
|
501 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
28630
diff
changeset
|
502 | 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
|
503 | 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
|
504 | 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
|
505 | 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
|
506 | 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
|
507 | 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
|
508 | 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
|
509 | 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
|
510 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
511 | 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
|
512 | 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
|
513 | 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
|
514 | 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
|
515 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
516 | 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
|
517 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
518 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
519 | 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
|
520 | 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
|
521 | { |
|
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
|
522 | 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
|
523 | |
|
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
|
524 | 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
|
525 | 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
|
526 | 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
|
527 | 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
|
528 | 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
|
529 | 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
|
530 | 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
|
531 | |
|
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
|
532 | 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
|
533 | 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
|
534 | 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
|
535 | 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
|
536 | 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
|
537 | 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
|
538 | 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
|
539 | 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
|
540 | 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
|
541 | |
|
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
|
542 | /* 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
|
543 | 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
|
544 | 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
|
545 | |
|
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
|
546 | 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
|
547 | 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
|
548 | |
|
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
|
549 | 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
|
550 | 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
|
551 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
552 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
553 | /****************************************************************************** |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
554 | * 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
|
555 | *****************************************************************************/ |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
556 | GType |
|
35379
ea1a0327001e
Rename _get_gtype() functions in libgnt to _get_type()
Ankit Vani <a@nevitus.org>
parents:
35191
diff
changeset
|
557 | gnt_file_sel_get_type(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
|
558 | { |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
559 | 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
|
560 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
561 | 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
|
562 | { |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
563 | 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
|
564 | 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
|
565 | 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
|
566 | 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
|
567 | (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
|
568 | 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
|
569 | 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
|
570 | 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
|
571 | 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
|
572 | 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
|
573 | 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
|
574 | }; |
|
b2dad43782a1
File selector dialog. Still in 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 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
576 | 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
|
577 | "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
|
578 | &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
|
579 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
580 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
581 | 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
|
582 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
583 | |
|
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
|
584 | 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
|
585 | 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
|
586 | { |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
587 | 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
|
588 | 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
|
589 | 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
|
590 | 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
|
591 | 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
|
592 | } |
|
0226ffea1a95
Since we have the file-selected signal, we might as well emit it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
593 | |
|
15972
894a15d885ec
This was giving me a warning saying the function wasn't previously declared
Mark Doliner <markdoliner@pidgin.im>
parents:
15911
diff
changeset
|
594 | 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
|
595 | { |
|
b2dad43782a1
File selector dialog. Still in 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 | 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
|
597 | 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
|
598 | } |
|
b2dad43782a1
File selector dialog. Still in 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 | |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
600 | 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
|
601 | { |
|
b2dad43782a1
File selector dialog. Still in 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 | 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
|
603 | 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
|
604 | 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
|
605 | |
|
b2dad43782a1
File selector dialog. Still in 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 | 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
|
607 | 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
|
608 | 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
|
609 | 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
|
610 | 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
|
611 | 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
|
612 | 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
|
613 | 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
|
614 | 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
|
615 | } 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
|
616 | 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
|
617 | |
|
b2dad43782a1
File selector dialog. Still in 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 | 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
|
619 | 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
|
620 | } |
|
b2dad43782a1
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
621 | |
|
15911
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
622 | 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
|
623 | { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
624 | sel->dirsonly = dirs; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
625 | } |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
626 | |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
627 | gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel) |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
628 | { |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
629 | return sel->dirsonly; |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
630 | } |
|
942565fe33f0
Directory only selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15902
diff
changeset
|
631 | |
| 16000 | 632 | void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest) |
| 633 | { | |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20238
diff
changeset
|
634 | g_free(sel->suggest); |
| 16000 | 635 | sel->suggest = g_strdup(suggest); |
| 636 | } | |
| 637 | ||
|
15912
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
638 | 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
|
639 | { |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
640 | char *ret; |
| 16000 | 641 | if (sel->dirsonly) { |
| 16025 | 642 | ret = g_path_get_dirname(gnt_entry_get_text(GNT_ENTRY(sel->location))); |
| 16000 | 643 | } else { |
| 644 | ret = g_strdup(gnt_entry_get_text(GNT_ENTRY(sel->location))); | |
| 645 | } | |
|
15912
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
646 | return ret; |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
647 | } |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
648 | |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
649 | 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
|
650 | { |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
651 | /*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
|
652 | sel->must_exist = must; |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
653 | } |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
654 | |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
655 | 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
|
656 | { |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
657 | return sel->must_exist; |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
658 | } |
|
7401338df45b
Use the file selector for request-file.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15911
diff
changeset
|
659 | |
|
15986
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
660 | 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
|
661 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
662 | sel->multiselect = set; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
663 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
664 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
665 | 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
|
666 | { |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
667 | GList *list = NULL, *iter; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
668 | 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
|
669 | |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
670 | 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
|
671 | 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
|
672 | 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
|
673 | g_free(str); |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
674 | str = NULL; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
675 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
676 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
677 | if (str) |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
678 | 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
|
679 | 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
|
680 | return list; |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
681 | } |
|
49c0e6c8c116
Allow selecting multiple files from the file-select dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15985
diff
changeset
|
682 | |
|
16049
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
683 | 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
|
684 | { |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
685 | sel->read_fn = read_fn; |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
686 | } |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
687 | |
|
0118c8161389
Allow using different methods for reading directory entries.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16025
diff
changeset
|
688 |