Mercurial > pidgin.yaz
annotate finch/libgnt/gntfilesel.c @ 15850:65b45106bfbb
Use the file selector for request-file.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 20 Mar 2007 11:52:46 +0000 |
parents | 3da9d5da9054 |
children | f771cdcc551a b4086a92568f |
rev | line source |
---|---|
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntbutton.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include "gntentry.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 #include "gntfilesel.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 #include "gntlabel.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 #include "gntmarshal.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 #include "gntstyle.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 #include "gnttree.h" |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 #include <string.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 #include <sys/types.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 #include <sys/stat.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 #include <unistd.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 #include <glob.h> |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 enum |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 SIG_FILE_SELECTED, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 SIGS |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 }; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 static GntWindowClass *parent_class = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 static guint signals[SIGS] = { 0 }; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 static void (*orig_map)(GntWidget *widget); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 gnt_file_sel_destroy(GntWidget *widget) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 GntFileSel *sel = GNT_FILE_SEL(widget); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 g_free(sel->current); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 static char * |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 process_path(const char *path) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 char **splits = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 int i, j; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 char *str, *ret; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 splits = g_strsplit(path, G_DIR_SEPARATOR_S, -1); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 for (i = 0, j = 0; splits[i]; i++) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 if (strcmp(splits[i], ".") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 } else if (strcmp(splits[i], "..") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 if (j) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 j--; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 } else { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 if (i != j) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 g_free(splits[j]); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 splits[j] = splits[i]; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 splits[i] = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 j++; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 g_free(splits[j]); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 splits[j] = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 str = g_build_pathv(G_DIR_SEPARATOR_S, splits); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 ret = g_strdup_printf(G_DIR_SEPARATOR_S "%s", str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 g_free(str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 g_strfreev(splits); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 return ret; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 update_location(GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 char *old; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 const char *tmp; |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
69 tmp = (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 old = g_strdup_printf("%s%s%s", sel->current, sel->current[1] ? G_DIR_SEPARATOR_S : "", tmp ? tmp : ""); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 gnt_entry_set_text(GNT_ENTRY(sel->location), old); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 g_free(old); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 static gboolean |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 location_changed(GntFileSel *sel, GError **err) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 GDir *dir; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 const char *str; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
81 if (!sel->dirs) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
82 return TRUE; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
83 |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 gnt_tree_remove_all(GNT_TREE(sel->dirs)); |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
85 if (sel->files) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
86 gnt_tree_remove_all(GNT_TREE(sel->files)); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 gnt_entry_set_text(GNT_ENTRY(sel->location), NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
88 if (sel->current == NULL) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(sel), GNT_WIDGET_MAPPED)) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 gnt_widget_draw(GNT_WIDGET(sel)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 return TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 dir = g_dir_open(sel->current, 0, err); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 if (dir == NULL || *err) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 g_printerr("GntFileSel: error opening location %s (%s)\n", |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 sel->current, *err ? (*err)->message : "reason unknown"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 return FALSE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 if (*sel->current != '\0' && strcmp(sel->current, G_DIR_SEPARATOR_S)) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 gnt_tree_add_row_after(GNT_TREE(sel->dirs), g_strdup(".."), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 gnt_tree_create_row(GNT_TREE(sel->dirs), ".."), NULL, NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 while ((str = g_dir_read_name(dir)) != NULL) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 char *fp = g_build_filename(sel->current, str, NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 struct stat st; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 if (stat(fp, &st)) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 g_printerr("Error stating location %s\n", fp); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 } else { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 if (S_ISDIR(st.st_mode)) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 gnt_tree_add_row_after(GNT_TREE(sel->dirs), g_strdup(str), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 gnt_tree_create_row(GNT_TREE(sel->dirs), str), NULL, NULL); |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
115 else if (!sel->dirsonly) { |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 char size[128]; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 snprintf(size, sizeof(size), "%ld", (long)st.st_size); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 gnt_tree_add_row_after(GNT_TREE(sel->files), g_strdup(str), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 gnt_tree_create_row(GNT_TREE(sel->files), str, size, ""), NULL, NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 g_free(fp); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(sel), GNT_WIDGET_MAPPED)) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 gnt_widget_draw(GNT_WIDGET(sel)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 return TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 static gboolean |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 dir_key_pressed(GntTree *tree, const char *key, GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 if (strcmp(key, "\r") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 /* XXX: if we are moving up the tree, make sure the current node is selected after the redraw */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 char *str = g_strdup(gnt_tree_get_selection_data(tree)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 char *path = g_build_filename(sel->current, str, NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 char *dir = g_path_get_basename(sel->current); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 if (!gnt_file_sel_set_current_location(sel, path)) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 gnt_tree_set_selected(tree, str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 } else if (strcmp(str, "..") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 gnt_tree_set_selected(tree, dir); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 g_free(dir); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 g_free(str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 g_free(path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 return TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 return FALSE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 static gboolean |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 location_key_pressed(GntTree *tree, const char *key, GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 if (strcmp(key, "\r") == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 int count; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 glob_t gl; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 char *path; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 char *str; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 struct stat st; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 int glob_ret; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 str = (char*)gnt_entry_get_text(GNT_ENTRY(sel->location)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
163 if (*str == G_DIR_SEPARATOR) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
164 path = g_strdup(str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 else |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", sel->current, str); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 str = process_path(path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 g_free(path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 path = str; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
170 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
171 if (!stat(path, &st)) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 if (S_ISDIR(st.st_mode)) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
173 gnt_file_sel_set_current_location(sel, path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
174 goto success; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
175 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
176 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
177 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
178 glob_ret = glob(path, GLOB_MARK, NULL, &gl); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
179 if (!glob_ret) { /* XXX: do something with the return value */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
180 char *loc = g_path_get_dirname(gl.gl_pathv[0]); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
181 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
182 stat(gl.gl_pathv[0], &st); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
183 gnt_file_sel_set_current_location(sel, loc); /* XXX: check the return value */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
184 g_free(loc); |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
185 if (!S_ISDIR(st.st_mode) && !sel->dirsonly) { |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 gnt_tree_remove_all(GNT_TREE(sel->files)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 for (count = 0; count < gl.gl_pathc; count++) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
188 char *tmp = process_path(gl.gl_pathv[count]); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
189 loc = g_path_get_dirname(tmp); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 if (g_utf8_collate(sel->current, loc) == 0) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
191 char *base = g_path_get_basename(tmp); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 char size[128]; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 snprintf(size, sizeof(size), "%ld", (long)st.st_size); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 gnt_tree_add_row_after(GNT_TREE(sel->files), base, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
195 gnt_tree_create_row(GNT_TREE(sel->files), base, size, ""), NULL, NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
197 g_free(loc); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 g_free(tmp); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 gnt_widget_draw(sel->files); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
201 } |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
202 } else if (sel->files) { |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
203 gnt_tree_remove_all(GNT_TREE(sel->files)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
204 gnt_widget_draw(sel->files); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
205 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
206 globfree(&gl); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
207 success: |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 g_free(path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 return TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 return FALSE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
212 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
213 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 file_sel_changed(GntWidget *widget, gpointer old, gpointer current, GntFileSel *sel) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 update_location(sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
219 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 gnt_file_sel_map(GntWidget *widget) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 { |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
223 GntFileSel *sel = GNT_FILE_SEL(widget); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
224 GntWidget *hbox, *vbox; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
225 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
226 vbox = gnt_vbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
227 gnt_box_set_pad(GNT_BOX(vbox), 0); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
228 gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
229 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
230 /* The dir. and files list */ |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
231 hbox = gnt_hbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
232 gnt_box_set_pad(GNT_BOX(hbox), 0); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
233 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
234 gnt_box_add_widget(GNT_BOX(hbox), sel->dirs); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
235 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
236 if (!sel->dirsonly) { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
237 gnt_box_add_widget(GNT_BOX(hbox), sel->files); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
238 } else { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
239 g_signal_connect(G_OBJECT(sel->dirs), "selection_changed", G_CALLBACK(file_sel_changed), sel); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
240 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
241 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
242 gnt_box_add_widget(GNT_BOX(vbox), hbox); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
243 gnt_box_add_widget(GNT_BOX(vbox), sel->location); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
244 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
245 /* The buttons */ |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
246 hbox = gnt_hbox_new(FALSE); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
247 gnt_box_add_widget(GNT_BOX(hbox), sel->cancel); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
248 gnt_box_add_widget(GNT_BOX(hbox), sel->select); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
249 gnt_box_add_widget(GNT_BOX(vbox), hbox); |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
250 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
251 gnt_box_add_widget(GNT_BOX(sel), vbox); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 orig_map(widget); |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
253 update_location(sel); |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 gnt_file_sel_class_init(GntFileSelClass *klass) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 GntWidgetClass *kl = GNT_WIDGET_CLASS(klass); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
260 parent_class = GNT_WINDOW_CLASS(klass); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 kl->destroy = gnt_file_sel_destroy; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 orig_map = kl->map; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
263 kl->map = gnt_file_sel_map; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 signals[SIG_FILE_SELECTED] = |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
266 g_signal_new("file_selected", |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
267 G_TYPE_FROM_CLASS(klass), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
268 G_SIGNAL_RUN_LAST, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 G_STRUCT_OFFSET(GntFileSelClass, file_selected), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 NULL, NULL, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 gnt_closure_marshal_VOID__STRING_STRING, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 G_TYPE_NONE, 0); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
274 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
275 GNTDEBUG; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
276 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
277 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
278 static void |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
279 gnt_file_sel_init(GTypeInstance *instance, gpointer class) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
280 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
281 GNTDEBUG; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
282 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
283 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
284 /****************************************************************************** |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
285 * GntFileSel API |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
286 *****************************************************************************/ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
287 GType |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
288 gnt_file_sel_get_gtype(void) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
289 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
290 static GType type = 0; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
291 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
292 if(type == 0) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
293 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
294 static const GTypeInfo info = { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
295 sizeof(GntFileSelClass), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
296 NULL, /* base_init */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
297 NULL, /* base_finalize */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
298 (GClassInitFunc)gnt_file_sel_class_init, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
299 NULL, /* class_finalize */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
300 NULL, /* class_data */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
301 sizeof(GntFileSel), |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
302 0, /* n_preallocs */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
303 gnt_file_sel_init, /* instance_init */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
304 NULL |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
305 }; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
306 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
307 type = g_type_register_static(GNT_TYPE_WINDOW, |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
308 "GntFileSel", |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
309 &info, 0); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
310 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
311 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
312 return type; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
313 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
314 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 GntWidget *gnt_file_sel_new() |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
316 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
317 GntWidget *widget = g_object_new(GNT_TYPE_FILE_SEL, NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
318 GntFileSel *sel = GNT_FILE_SEL(widget); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
319 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
320 sel->dirs = gnt_tree_new(); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
321 gnt_tree_set_compare_func(GNT_TREE(sel->dirs), (GCompareFunc)g_utf8_collate); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
322 gnt_tree_set_hash_fns(GNT_TREE(sel->dirs), g_str_hash, g_str_equal, g_free); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
323 gnt_tree_set_column_titles(GNT_TREE(sel->dirs), "Directories"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
324 gnt_tree_set_show_title(GNT_TREE(sel->dirs), TRUE); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
325 gnt_tree_set_col_width(GNT_TREE(sel->dirs), 0, 20); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
326 g_signal_connect(G_OBJECT(sel->dirs), "key_pressed", G_CALLBACK(dir_key_pressed), sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
327 |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
328 sel->files = gnt_tree_new_with_columns(2); /* Name, Size */ |
15847
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
329 gnt_tree_set_compare_func(GNT_TREE(sel->files), (GCompareFunc)g_utf8_collate); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
330 gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
331 gnt_tree_set_show_title(GNT_TREE(sel->files), TRUE); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
332 gnt_tree_set_col_width(GNT_TREE(sel->files), 0, 25); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
333 gnt_tree_set_col_width(GNT_TREE(sel->files), 1, 10); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
334 g_signal_connect(G_OBJECT(sel->files), "selection_changed", G_CALLBACK(file_sel_changed), sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
335 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
336 /* The location entry */ |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
337 sel->location = gnt_entry_new(NULL); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
338 g_signal_connect(G_OBJECT(sel->location), "key_pressed", G_CALLBACK(location_key_pressed), sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
339 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
340 sel->cancel = gnt_button_new("Cancel"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
341 sel->select = gnt_button_new("Select"); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
342 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
343 return widget; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
344 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
345 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
346 gboolean gnt_file_sel_set_current_location(GntFileSel *sel, const char *path) |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
347 { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
348 char *old; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
349 GError *error = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
350 gboolean ret = TRUE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
351 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
352 old = sel->current; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
353 sel->current = process_path(path); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
354 if (!location_changed(sel, &error)) { |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
355 g_error_free(error); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
356 error = NULL; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
357 g_free(sel->current); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
358 sel->current = old; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
359 location_changed(sel, &error); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
360 ret = FALSE; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
361 } else |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
362 g_free(old); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
363 |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
364 update_location(sel); |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
365 return ret; |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
366 } |
a2ab257116ce
File selector dialog. Still in an experimental state. When properly complete, this can be used for file/folder-request etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
367 |
15849
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
368 void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
369 { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
370 sel->dirsonly = dirs; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
371 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
372 |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
373 gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel) |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
374 { |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
375 return sel->dirsonly; |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
376 } |
3da9d5da9054
Directory only selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15847
diff
changeset
|
377 |
15850
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
378 char *gnt_file_sel_get_selected_file(GntFileSel *sel) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
379 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
380 char *ret; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
381 const char *tmp; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
382 tmp = (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
383 ret = g_strdup_printf("%s%s%s", sel->current, sel->current[1] ? G_DIR_SEPARATOR_S : "", tmp ? tmp : ""); |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
384 return ret; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
385 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
386 |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
387 void gnt_file_sel_set_must_exist(GntFileSel *sel, gboolean must) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
388 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
389 /*XXX: What do I do with this? */ |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
390 sel->must_exist = must; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
391 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
392 |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
393 gboolean gnt_file_sel_get_must_exist(GntFileSel *sel) |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
394 { |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
395 return sel->must_exist; |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
396 } |
65b45106bfbb
Use the file selector for request-file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15849
diff
changeset
|
397 |