Bug Summary

File:plugins/filebrowser/lapiz-file-browser-view.c
Warning:line 632, column 2
Value stored to 'handled' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name lapiz-file-browser-view.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/plugins/filebrowser -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I /usr/include/libxml2 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/local/include/ctksourceview-4 -I /usr/local/include/libbean-1.0 -I /usr/include/gobject-introspection-1.0 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/plugins/filebrowser -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-05-135312-33852-1 -x c lapiz-file-browser-view.c
1/*
2 * lapiz-file-browser-view.c - Lapiz plugin providing easy file access
3 * from the sidepanel
4 *
5 * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <string.h>
23#include <gio/gio.h>
24#include <ctk/ctk.h>
25#include <cdk/cdkkeysyms.h>
26
27#include "lapiz-file-browser-store.h"
28#include "lapiz-file-bookmarks-store.h"
29#include "lapiz-file-browser-view.h"
30#include "lapiz-file-browser-marshal.h"
31#include "lapiz-file-browser-enum-types.h"
32
33struct _LapizFileBrowserViewPrivate
34{
35 CtkTreeViewColumn *column;
36 CtkCellRenderer *pixbuf_renderer;
37 CtkCellRenderer *text_renderer;
38
39 CtkTreeModel *model;
40 CtkTreeRowReference *editable;
41
42 CdkCursor *busy_cursor;
43
44 /* CLick policy */
45 LapizFileBrowserViewClickPolicy click_policy;
46 CtkTreePath *double_click_path[2]; /* Both clicks in a double click need to be on the same row */
47 CtkTreePath *hover_path;
48 CdkCursor *hand_cursor;
49 gboolean ignore_release;
50 gboolean selected_on_button_down;
51 gint drag_button;
52 gboolean drag_started;
53
54 gboolean restore_expand_state;
55 gboolean is_refresh;
56 GHashTable * expand_state;
57};
58
59/* Properties */
60enum
61{
62 PROP_0,
63
64 PROP_CLICK_POLICY,
65 PROP_RESTORE_EXPAND_STATE
66};
67
68/* Signals */
69enum
70{
71 ERROR,
72 FILE_ACTIVATED,
73 DIRECTORY_ACTIVATED,
74 BOOKMARK_ACTIVATED,
75 NUM_SIGNALS
76};
77
78static guint signals[NUM_SIGNALS] = { 0 };
79
80static const CtkTargetEntry drag_source_targets[] = {
81 { "text/uri-list", 0, 0 }
82};
83
84G_DEFINE_DYNAMIC_TYPE_EXTENDED (LapizFileBrowserView,static void lapiz_file_browser_view_init (LapizFileBrowserView
*self); static void lapiz_file_browser_view_class_init (LapizFileBrowserViewClass
*klass); static void lapiz_file_browser_view_class_finalize (
LapizFileBrowserViewClass *klass); static gpointer lapiz_file_browser_view_parent_class
= ((void*)0); static GType lapiz_file_browser_view_type_id =
0; static gint LapizFileBrowserView_private_offset; static void
lapiz_file_browser_view_class_intern_init (gpointer klass) {
lapiz_file_browser_view_parent_class = g_type_class_peek_parent
(klass); if (LapizFileBrowserView_private_offset != 0) g_type_class_adjust_private_offset
(klass, &LapizFileBrowserView_private_offset); lapiz_file_browser_view_class_init
((LapizFileBrowserViewClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer lapiz_file_browser_view_get_instance_private
(LapizFileBrowserView *self) { return (((gpointer) ((guint8*
) (self) + (glong) (LapizFileBrowserView_private_offset)))); }
GType lapiz_file_browser_view_get_type (void) { return lapiz_file_browser_view_type_id
; } static void lapiz_file_browser_view_register_type (GTypeModule
*type_module) { GType g_define_type_id __attribute__ ((__unused__
)); const GTypeInfo g_define_type_info = { sizeof (LapizFileBrowserViewClass
), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc) ((void*)0)
, (GClassInitFunc)(void (*)(void)) lapiz_file_browser_view_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) lapiz_file_browser_view_class_finalize
, ((void*)0), sizeof (LapizFileBrowserView), 0, (GInstanceInitFunc
)(void (*)(void)) lapiz_file_browser_view_init, ((void*)0) };
lapiz_file_browser_view_type_id = g_type_module_register_type
(type_module, (ctk_tree_view_get_type ()), "LapizFileBrowserView"
, &g_define_type_info, (GTypeFlags) 0); g_define_type_id =
lapiz_file_browser_view_type_id; { { LapizFileBrowserView_private_offset
= sizeof (LapizFileBrowserViewPrivate); } ; } }
85 lapiz_file_browser_view,static void lapiz_file_browser_view_init (LapizFileBrowserView
*self); static void lapiz_file_browser_view_class_init (LapizFileBrowserViewClass
*klass); static void lapiz_file_browser_view_class_finalize (
LapizFileBrowserViewClass *klass); static gpointer lapiz_file_browser_view_parent_class
= ((void*)0); static GType lapiz_file_browser_view_type_id =
0; static gint LapizFileBrowserView_private_offset; static void
lapiz_file_browser_view_class_intern_init (gpointer klass) {
lapiz_file_browser_view_parent_class = g_type_class_peek_parent
(klass); if (LapizFileBrowserView_private_offset != 0) g_type_class_adjust_private_offset
(klass, &LapizFileBrowserView_private_offset); lapiz_file_browser_view_class_init
((LapizFileBrowserViewClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer lapiz_file_browser_view_get_instance_private
(LapizFileBrowserView *self) { return (((gpointer) ((guint8*
) (self) + (glong) (LapizFileBrowserView_private_offset)))); }
GType lapiz_file_browser_view_get_type (void) { return lapiz_file_browser_view_type_id
; } static void lapiz_file_browser_view_register_type (GTypeModule
*type_module) { GType g_define_type_id __attribute__ ((__unused__
)); const GTypeInfo g_define_type_info = { sizeof (LapizFileBrowserViewClass
), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc) ((void*)0)
, (GClassInitFunc)(void (*)(void)) lapiz_file_browser_view_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) lapiz_file_browser_view_class_finalize
, ((void*)0), sizeof (LapizFileBrowserView), 0, (GInstanceInitFunc
)(void (*)(void)) lapiz_file_browser_view_init, ((void*)0) };
lapiz_file_browser_view_type_id = g_type_module_register_type
(type_module, (ctk_tree_view_get_type ()), "LapizFileBrowserView"
, &g_define_type_info, (GTypeFlags) 0); g_define_type_id =
lapiz_file_browser_view_type_id; { { LapizFileBrowserView_private_offset
= sizeof (LapizFileBrowserViewPrivate); } ; } }
86 CTK_TYPE_TREE_VIEW,static void lapiz_file_browser_view_init (LapizFileBrowserView
*self); static void lapiz_file_browser_view_class_init (LapizFileBrowserViewClass
*klass); static void lapiz_file_browser_view_class_finalize (
LapizFileBrowserViewClass *klass); static gpointer lapiz_file_browser_view_parent_class
= ((void*)0); static GType lapiz_file_browser_view_type_id =
0; static gint LapizFileBrowserView_private_offset; static void
lapiz_file_browser_view_class_intern_init (gpointer klass) {
lapiz_file_browser_view_parent_class = g_type_class_peek_parent
(klass); if (LapizFileBrowserView_private_offset != 0) g_type_class_adjust_private_offset
(klass, &LapizFileBrowserView_private_offset); lapiz_file_browser_view_class_init
((LapizFileBrowserViewClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer lapiz_file_browser_view_get_instance_private
(LapizFileBrowserView *self) { return (((gpointer) ((guint8*
) (self) + (glong) (LapizFileBrowserView_private_offset)))); }
GType lapiz_file_browser_view_get_type (void) { return lapiz_file_browser_view_type_id
; } static void lapiz_file_browser_view_register_type (GTypeModule
*type_module) { GType g_define_type_id __attribute__ ((__unused__
)); const GTypeInfo g_define_type_info = { sizeof (LapizFileBrowserViewClass
), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc) ((void*)0)
, (GClassInitFunc)(void (*)(void)) lapiz_file_browser_view_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) lapiz_file_browser_view_class_finalize
, ((void*)0), sizeof (LapizFileBrowserView), 0, (GInstanceInitFunc
)(void (*)(void)) lapiz_file_browser_view_init, ((void*)0) };
lapiz_file_browser_view_type_id = g_type_module_register_type
(type_module, (ctk_tree_view_get_type ()), "LapizFileBrowserView"
, &g_define_type_info, (GTypeFlags) 0); g_define_type_id =
lapiz_file_browser_view_type_id; { { LapizFileBrowserView_private_offset
= sizeof (LapizFileBrowserViewPrivate); } ; } }
87 0,static void lapiz_file_browser_view_init (LapizFileBrowserView
*self); static void lapiz_file_browser_view_class_init (LapizFileBrowserViewClass
*klass); static void lapiz_file_browser_view_class_finalize (
LapizFileBrowserViewClass *klass); static gpointer lapiz_file_browser_view_parent_class
= ((void*)0); static GType lapiz_file_browser_view_type_id =
0; static gint LapizFileBrowserView_private_offset; static void
lapiz_file_browser_view_class_intern_init (gpointer klass) {
lapiz_file_browser_view_parent_class = g_type_class_peek_parent
(klass); if (LapizFileBrowserView_private_offset != 0) g_type_class_adjust_private_offset
(klass, &LapizFileBrowserView_private_offset); lapiz_file_browser_view_class_init
((LapizFileBrowserViewClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer lapiz_file_browser_view_get_instance_private
(LapizFileBrowserView *self) { return (((gpointer) ((guint8*
) (self) + (glong) (LapizFileBrowserView_private_offset)))); }
GType lapiz_file_browser_view_get_type (void) { return lapiz_file_browser_view_type_id
; } static void lapiz_file_browser_view_register_type (GTypeModule
*type_module) { GType g_define_type_id __attribute__ ((__unused__
)); const GTypeInfo g_define_type_info = { sizeof (LapizFileBrowserViewClass
), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc) ((void*)0)
, (GClassInitFunc)(void (*)(void)) lapiz_file_browser_view_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) lapiz_file_browser_view_class_finalize
, ((void*)0), sizeof (LapizFileBrowserView), 0, (GInstanceInitFunc
)(void (*)(void)) lapiz_file_browser_view_init, ((void*)0) };
lapiz_file_browser_view_type_id = g_type_module_register_type
(type_module, (ctk_tree_view_get_type ()), "LapizFileBrowserView"
, &g_define_type_info, (GTypeFlags) 0); g_define_type_id =
lapiz_file_browser_view_type_id; { { LapizFileBrowserView_private_offset
= sizeof (LapizFileBrowserViewPrivate); } ; } }
88 G_ADD_PRIVATE_DYNAMIC (LapizFileBrowserView))static void lapiz_file_browser_view_init (LapizFileBrowserView
*self); static void lapiz_file_browser_view_class_init (LapizFileBrowserViewClass
*klass); static void lapiz_file_browser_view_class_finalize (
LapizFileBrowserViewClass *klass); static gpointer lapiz_file_browser_view_parent_class
= ((void*)0); static GType lapiz_file_browser_view_type_id =
0; static gint LapizFileBrowserView_private_offset; static void
lapiz_file_browser_view_class_intern_init (gpointer klass) {
lapiz_file_browser_view_parent_class = g_type_class_peek_parent
(klass); if (LapizFileBrowserView_private_offset != 0) g_type_class_adjust_private_offset
(klass, &LapizFileBrowserView_private_offset); lapiz_file_browser_view_class_init
((LapizFileBrowserViewClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer lapiz_file_browser_view_get_instance_private
(LapizFileBrowserView *self) { return (((gpointer) ((guint8*
) (self) + (glong) (LapizFileBrowserView_private_offset)))); }
GType lapiz_file_browser_view_get_type (void) { return lapiz_file_browser_view_type_id
; } static void lapiz_file_browser_view_register_type (GTypeModule
*type_module) { GType g_define_type_id __attribute__ ((__unused__
)); const GTypeInfo g_define_type_info = { sizeof (LapizFileBrowserViewClass
), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc) ((void*)0)
, (GClassInitFunc)(void (*)(void)) lapiz_file_browser_view_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) lapiz_file_browser_view_class_finalize
, ((void*)0), sizeof (LapizFileBrowserView), 0, (GInstanceInitFunc
)(void (*)(void)) lapiz_file_browser_view_init, ((void*)0) };
lapiz_file_browser_view_type_id = g_type_module_register_type
(type_module, (ctk_tree_view_get_type ()), "LapizFileBrowserView"
, &g_define_type_info, (GTypeFlags) 0); g_define_type_id =
lapiz_file_browser_view_type_id; { { LapizFileBrowserView_private_offset
= sizeof (LapizFileBrowserViewPrivate); } ; } }
89
90static void on_cell_edited (CtkCellRendererText * cell,
91 gchar * path,
92 gchar * new_text,
93 LapizFileBrowserView * tree_view);
94
95static void on_begin_refresh (LapizFileBrowserStore * model,
96 LapizFileBrowserView * view);
97static void on_end_refresh (LapizFileBrowserStore * model,
98 LapizFileBrowserView * view);
99
100static void on_unload (LapizFileBrowserStore * model,
101 gchar const * uri,
102 LapizFileBrowserView * view);
103
104static void on_row_inserted (LapizFileBrowserStore * model,
105 CtkTreePath * path,
106 CtkTreeIter * iter,
107 LapizFileBrowserView * view);
108
109static void
110lapiz_file_browser_view_finalize (GObject * object)
111{
112 LapizFileBrowserView *obj = LAPIZ_FILE_BROWSER_VIEW(object)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((object)), ((lapiz_file_browser_view_get_type
()))))))
;
113
114 if (obj->priv->hand_cursor)
115 g_object_unref (obj->priv->hand_cursor);
116
117 if (obj->priv->hover_path)
118 ctk_tree_path_free (obj->priv->hover_path);
119
120 if (obj->priv->expand_state)
121 {
122 g_hash_table_destroy (obj->priv->expand_state);
123 obj->priv->expand_state = NULL((void*)0);
124 }
125
126 g_object_unref (obj->priv->busy_cursor);
127
128 G_OBJECT_CLASS (lapiz_file_browser_view_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), (((GType) ((20) <<
(2))))))))
->
129 finalize (object);
130}
131
132static void
133add_expand_state (LapizFileBrowserView * view,
134 gchar const * uri)
135{
136 GFile * file;
137
138 if (!uri)
139 return;
140
141 file = g_file_new_for_uri (uri);
142
143 if (view->priv->expand_state)
144 g_hash_table_insert (view->priv->expand_state, file, file);
145 else
146 g_object_unref (file);
147}
148
149static void
150remove_expand_state (LapizFileBrowserView * view,
151 gchar const * uri)
152{
153 GFile * file;
154
155 if (!uri)
156 return;
157
158 file = g_file_new_for_uri (uri);
159
160 if (view->priv->expand_state)
161 g_hash_table_remove (view->priv->expand_state, file);
162
163 g_object_unref (file);
164}
165
166static void
167row_expanded (CtkTreeView * tree_view,
168 CtkTreeIter * iter,
169 CtkTreePath * path)
170{
171 LapizFileBrowserView *view = LAPIZ_FILE_BROWSER_VIEW (tree_view)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((tree_view)), ((lapiz_file_browser_view_get_type
()))))))
;
172 gchar * uri;
173
174 if (CTK_TREE_VIEW_CLASS (lapiz_file_browser_view_parent_class)((((CtkTreeViewClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_tree_view_get_type
()))))))
->row_expanded)
175 CTK_TREE_VIEW_CLASS (lapiz_file_browser_view_parent_class)((((CtkTreeViewClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_tree_view_get_type
()))))))
->row_expanded (tree_view, iter, path);
176
177 if (!LAPIZ_IS_FILE_BROWSER_STORE (view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
178 return;
179
180 if (view->priv->restore_expand_state)
181 {
182 ctk_tree_model_get (view->priv->model,
183 iter,
184 LAPIZ_FILE_BROWSER_STORE_COLUMN_URI,
185 &uri,
186 -1);
187
188 add_expand_state (view, uri);
189 g_free (uri);
190 }
191
192 _lapiz_file_browser_store_iter_expanded (LAPIZ_FILE_BROWSER_STORE (view->priv->model)((((LapizFileBrowserStore*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view->priv->model)), ((lapiz_file_browser_store_get_type
()))))))
,
193 iter);
194}
195
196static void
197row_collapsed (CtkTreeView * tree_view,
198 CtkTreeIter * iter,
199 CtkTreePath * path)
200{
201 LapizFileBrowserView *view = LAPIZ_FILE_BROWSER_VIEW (tree_view)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((tree_view)), ((lapiz_file_browser_view_get_type
()))))))
;
202 gchar * uri;
203
204 if (CTK_TREE_VIEW_CLASS (lapiz_file_browser_view_parent_class)((((CtkTreeViewClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_tree_view_get_type
()))))))
->row_collapsed)
205 CTK_TREE_VIEW_CLASS (lapiz_file_browser_view_parent_class)((((CtkTreeViewClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_tree_view_get_type
()))))))
->row_collapsed (tree_view, iter, path);
206
207 if (!LAPIZ_IS_FILE_BROWSER_STORE (view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
208 return;
209
210 if (view->priv->restore_expand_state)
211 {
212 ctk_tree_model_get (view->priv->model,
213 iter,
214 LAPIZ_FILE_BROWSER_STORE_COLUMN_URI,
215 &uri,
216 -1);
217
218 remove_expand_state (view, uri);
219 g_free (uri);
220 }
221
222 _lapiz_file_browser_store_iter_collapsed (LAPIZ_FILE_BROWSER_STORE (view->priv->model)((((LapizFileBrowserStore*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view->priv->model)), ((lapiz_file_browser_store_get_type
()))))))
,
223 iter);
224}
225
226static gboolean
227leave_notify_event (CtkWidget *widget,
228 CdkEventCrossing *event)
229{
230 LapizFileBrowserView *view = LAPIZ_FILE_BROWSER_VIEW (widget)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((lapiz_file_browser_view_get_type
()))))))
;
231
232 if (view->priv->click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
233 view->priv->hover_path != NULL((void*)0)) {
234 ctk_tree_path_free (view->priv->hover_path);
235 view->priv->hover_path = NULL((void*)0);
236 }
237
238 // Chainup
239 return CTK_WIDGET_CLASS (lapiz_file_browser_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_widget_get_type
()))))))
->leave_notify_event (widget, event);
240}
241
242static gboolean
243enter_notify_event (CtkWidget *widget,
244 CdkEventCrossing *event)
245{
246 LapizFileBrowserView *view = LAPIZ_FILE_BROWSER_VIEW (widget)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((lapiz_file_browser_view_get_type
()))))))
;
247
248 if (view->priv->click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
249 if (view->priv->hover_path != NULL((void*)0))
250 ctk_tree_path_free (view->priv->hover_path);
251
252 ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_tree_view_get_type ()))))))
,
253 event->x, event->y,
254 &view->priv->hover_path,
255 NULL((void*)0), NULL((void*)0), NULL((void*)0));
256
257 if (view->priv->hover_path != NULL((void*)0))
258 cdk_window_set_cursor (ctk_widget_get_window (widget),
259 view->priv->hand_cursor);
260 }
261
262 // Chainup
263 return CTK_WIDGET_CLASS (lapiz_file_browser_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_widget_get_type
()))))))
->enter_notify_event (widget, event);
264}
265
266static gboolean
267motion_notify_event (CtkWidget * widget,
268 CdkEventMotion * event)
269{
270 CtkTreePath *old_hover_path;
271 LapizFileBrowserView *view = LAPIZ_FILE_BROWSER_VIEW (widget)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((lapiz_file_browser_view_get_type
()))))))
;
272
273 if (view->priv->click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
274 old_hover_path = view->priv->hover_path;
275 ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_tree_view_get_type ()))))))
,
276 event->x, event->y,
277 &view->priv->hover_path,
278 NULL((void*)0), NULL((void*)0), NULL((void*)0));
279
280 if ((old_hover_path != NULL((void*)0)) != (view->priv->hover_path != NULL((void*)0))) {
281 if (view->priv->hover_path != NULL((void*)0))
282 cdk_window_set_cursor (ctk_widget_get_window (widget),
283 view->priv->hand_cursor);
284 else
285 cdk_window_set_cursor (ctk_widget_get_window (widget),
286 NULL((void*)0));
287 }
288
289 if (old_hover_path != NULL((void*)0))
290 ctk_tree_path_free (old_hover_path);
291 }
292
293 // Chainup
294 return CTK_WIDGET_CLASS (lapiz_file_browser_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_widget_get_type
()))))))
->motion_notify_event (widget, event);
295}
296
297static void
298set_click_policy_property (LapizFileBrowserView *obj,
299 LapizFileBrowserViewClickPolicy click_policy)
300{
301 CtkTreeIter iter;
302 CdkDisplay *display;
303 CdkWindow *win;
304
305 display = ctk_widget_get_display (CTK_WIDGET (obj)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_widget_get_type ()))))))
);
306
307 obj->priv->click_policy = click_policy;
308
309 if (click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
310 if (obj->priv->hand_cursor == NULL((void*)0))
311 obj->priv->hand_cursor = cdk_cursor_new_for_display (display, CDK_HAND2);
312 } else if (click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE) {
313 if (obj->priv->hover_path != NULL((void*)0)) {
314 if (ctk_tree_model_get_iter (CTK_TREE_MODEL (obj->priv->model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj->priv->model)), ((ctk_tree_model_get_type ()))
))))
,
315 &iter, obj->priv->hover_path))
316 ctk_tree_model_row_changed (CTK_TREE_MODEL (obj->priv->model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj->priv->model)), ((ctk_tree_model_get_type ()))
))))
,
317 obj->priv->hover_path, &iter);
318
319 ctk_tree_path_free (obj->priv->hover_path);
320 obj->priv->hover_path = NULL((void*)0);
321 }
322
323 if (ctk_widget_get_realized (CTK_WIDGET (obj)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_widget_get_type ()))))))
)) {
324 win = ctk_widget_get_window (CTK_WIDGET (obj)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_widget_get_type ()))))))
);
325 cdk_window_set_cursor (win, NULL((void*)0));
326
327 display = ctk_widget_get_display (CTK_WIDGET (obj)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_widget_get_type ()))))))
);
328
329 if (display != NULL((void*)0))
330 cdk_display_flush (display);
331 }
332
333 if (obj->priv->hand_cursor) {
334 g_object_unref (obj->priv->hand_cursor);
335 obj->priv->hand_cursor = NULL((void*)0);
336 }
337 }
338}
339
340static void
341directory_activated (LapizFileBrowserView *view,
342 CtkTreeIter *iter)
343{
344 lapiz_file_browser_store_set_virtual_root (LAPIZ_FILE_BROWSER_STORE (view->priv->model)((((LapizFileBrowserStore*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view->priv->model)), ((lapiz_file_browser_store_get_type
()))))))
, iter);
345}
346
347static void
348activate_selected_files (LapizFileBrowserView *view) {
349 CtkTreeView *tree_view = CTK_TREE_VIEW (view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_tree_view_get_type ()))))))
;
350 CtkTreeSelection *selection = ctk_tree_view_get_selection (tree_view);
351 GList *rows, *row;
352 CtkTreePath *directory = NULL((void*)0);
353 CtkTreePath *path;
354 CtkTreeIter iter;
355 LapizFileBrowserStoreFlag flags;
356
357 rows = ctk_tree_selection_get_selected_rows (selection, &view->priv->model);
358
359 for (row = rows; row; row = row->next) {
360 path = (CtkTreePath *)(row->data);
361
362 /* Get iter from path */
363 if (!ctk_tree_model_get_iter (view->priv->model, &iter, path))
364 continue;
365
366 ctk_tree_model_get (view->priv->model, &iter, LAPIZ_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1);
367
368 if (FILE_IS_DIR (flags)(flags & LAPIZ_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY)) {
369 if (directory == NULL((void*)0))
370 directory = path;
371
372 } else if (!FILE_IS_DUMMY (flags)(flags & LAPIZ_FILE_BROWSER_STORE_FLAG_IS_DUMMY)) {
373 g_signal_emit (view, signals[FILE_ACTIVATED], 0, &iter);
374 }
375 }
376
377 if (directory != NULL((void*)0)) {
378 if (ctk_tree_model_get_iter (view->priv->model, &iter, directory))
379 g_signal_emit (view, signals[DIRECTORY_ACTIVATED], 0, &iter);
380 }
381
382 g_list_foreach (rows, (GFunc)ctk_tree_path_free, NULL((void*)0));
383 g_list_free (rows);
384}
385
386static void
387activate_selected_bookmark (LapizFileBrowserView *view) {
388 CtkTreeView *tree_view = CTK_TREE_VIEW (view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_tree_view_get_type ()))))))
;
389 CtkTreeSelection *selection = ctk_tree_view_get_selection (tree_view);
390 CtkTreeIter iter;
391
392 if (ctk_tree_selection_get_selected (selection, &view->priv->model, &iter))
393 g_signal_emit (view, signals[BOOKMARK_ACTIVATED], 0, &iter);
394}
395
396static void
397activate_selected_items (LapizFileBrowserView *view)
398{
399 if (LAPIZ_IS_FILE_BROWSER_STORE (view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
400 activate_selected_files (view);
401 else if (LAPIZ_IS_FILE_BOOKMARKS_STORE (view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(view->priv->model)); GType __t = ((lapiz_file_bookmarks_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
402 activate_selected_bookmark (view);
403}
404
405static void
406toggle_hidden_filter (LapizFileBrowserView *view)
407{
408 LapizFileBrowserStoreFilterMode mode;
409
410 if (LAPIZ_IS_FILE_BROWSER_STORE (view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
411 {
412 mode = lapiz_file_browser_store_get_filter_mode
413 (LAPIZ_FILE_BROWSER_STORE (view->priv->model)((((LapizFileBrowserStore*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view->priv->model)), ((lapiz_file_browser_store_get_type
()))))))
);
414 mode ^= LAPIZ_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN;
415 lapiz_file_browser_store_set_filter_mode
416 (LAPIZ_FILE_BROWSER_STORE (view->priv->model)((((LapizFileBrowserStore*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view->priv->model)), ((lapiz_file_browser_store_get_type
()))))))
, mode);
417 }
418}
419
420static gboolean
421button_event_modifies_selection (CdkEventButton *event)
422{
423 return (event->state & (CDK_CONTROL_MASK | CDK_SHIFT_MASK)) != 0;
424}
425
426static void
427drag_begin (CtkWidget *widget,
428 CdkDragContext *context)
429{
430 LapizFileBrowserView *view = LAPIZ_FILE_BROWSER_VIEW (widget)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((lapiz_file_browser_view_get_type
()))))))
;
431
432 view->priv->drag_button = 0;
433 view->priv->drag_started = TRUE(!(0));
434
435 /* Chain up */
436 CTK_WIDGET_CLASS (lapiz_file_browser_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_widget_get_type
()))))))
->drag_begin (widget, context);
437}
438
439static void
440did_not_drag (LapizFileBrowserView *view,
441 CdkEventButton *event)
442{
443 CtkTreeView *tree_view;
444 CtkTreeSelection *selection;
445 CtkTreePath *path;
446
447 tree_view = CTK_TREE_VIEW (view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_tree_view_get_type ()))))))
;
448 selection = ctk_tree_view_get_selection (tree_view);
449
450 if (ctk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
451 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
452 if ((view->priv->click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
453 && !button_event_modifies_selection(event)
454 && (event->button == 1 || event->button == 2)) {
455 /* Activate all selected items, and leave them selected */
456 activate_selected_items (view);
457 } else if ((event->button == 1 || event->button == 2)
458 && ((event->state & CDK_CONTROL_MASK) != 0 ||
459 (event->state & CDK_SHIFT_MASK) == 0)
460 && view->priv->selected_on_button_down) {
461 if (!button_event_modifies_selection (event)) {
462 ctk_tree_selection_unselect_all (selection);
463 ctk_tree_selection_select_path (selection, path);
464 } else {
465 ctk_tree_selection_unselect_path (selection, path);
466 }
467 }
468
469 ctk_tree_path_free (path);
470 }
471}
472
473static gboolean
474button_release_event (CtkWidget *widget,
475 CdkEventButton *event)
476{
477 LapizFileBrowserView *view = LAPIZ_FILE_BROWSER_VIEW (widget)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((lapiz_file_browser_view_get_type
()))))))
;
478
479 if (event->button == view->priv->drag_button) {
480 view->priv->drag_button = 0;
481
482 if (!view->priv->drag_started &&
483 !view->priv->ignore_release)
484 did_not_drag (view, event);
485 }
486
487 /* Chain up */
488 return CTK_WIDGET_CLASS (lapiz_file_browser_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_widget_get_type
()))))))
->button_release_event (widget, event);
489}
490
491static gboolean
492button_press_event (CtkWidget *widget,
493 CdkEventButton *event)
494{
495 int double_click_time;
496 static int click_count = 0;
497 static guint32 last_click_time = 0;
498 LapizFileBrowserView *view;
499 CtkTreeView *tree_view;
500 CtkTreeSelection *selection;
501 CtkTreePath *path;
502 int expander_size;
503 int horizontal_separator;
504 gboolean on_expander;
505 gboolean call_parent;
506 gboolean selected;
507 CtkWidgetClass *widget_parent = CTK_WIDGET_CLASS(lapiz_file_browser_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_widget_get_type
()))))))
;
508
509 tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_tree_view_get_type ()))))))
;
510 view = LAPIZ_FILE_BROWSER_VIEW (widget)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((lapiz_file_browser_view_get_type
()))))))
;
511 selection = ctk_tree_view_get_selection (tree_view);
512
513 /* Get double click time */
514 g_object_get (G_OBJECT (ctk_widget_get_settings (widget))((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_widget_get_settings (widget))), (((GType) ((20) <<
(2))))))))
,
515 "ctk-double-click-time", &double_click_time,
516 NULL((void*)0));
517
518 /* Determine click count */
519 if (event->time - last_click_time < double_click_time)
520 click_count++;
521 else
522 click_count = 0;
523
524 last_click_time = event->time;
525
526 /* Ignore double click if we are in single click mode */
527 if (view->priv->click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
528 click_count >= 2) {
529 return TRUE(!(0));
530 }
531
532 view->priv->ignore_release = FALSE(0);
533 call_parent = TRUE(!(0));
534
535 if (ctk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
536 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
537 /* Keep track of path of last click so double clicks only happen
538 * on the same item */
539 if ((event->button == 1 || event->button == 2) &&
540 event->type == CDK_BUTTON_PRESS) {
541 if (view->priv->double_click_path[1])
542 ctk_tree_path_free (view->priv->double_click_path[1]);
543
544 view->priv->double_click_path[1] = view->priv->double_click_path[0];
545 view->priv->double_click_path[0] = ctk_tree_path_copy (path);
546 }
547
548 if (event->type == CDK_2BUTTON_PRESS) {
549 if (view->priv->double_click_path[1] &&
550 ctk_tree_path_compare (view->priv->double_click_path[0], view->priv->double_click_path[1]) == 0)
551 activate_selected_items (view);
552
553 /* Chain up */
554 widget_parent->button_press_event (widget, event);
555 } else {
556 /* We're going to filter out some situations where
557 * we can't let the default code run because all
558 * but one row would be would be deselected. We don't
559 * want that; we want the right click menu or single
560 * click to apply to everything that's currently selected. */
561 selected = ctk_tree_selection_path_is_selected (selection, path);
562
563 if (event->button == 3 && selected)
564 call_parent = FALSE(0);
565
566 if ((event->button == 1 || event->button == 2) &&
567 ((event->state & CDK_CONTROL_MASK) != 0 ||
568 (event->state & CDK_SHIFT_MASK) == 0)) {
569 ctk_widget_style_get (widget,
570 "expander-size", &expander_size,
571 "horizontal-separator", &horizontal_separator,
572 NULL((void*)0));
573 on_expander = (event->x <= horizontal_separator / 2 +
574 ctk_tree_path_get_depth (path) * expander_size);
575
576 view->priv->selected_on_button_down = selected;
577
578 if (selected) {
579 call_parent = on_expander || ctk_tree_selection_count_selected_rows (selection) == 1;
580 view->priv->ignore_release = call_parent && view->priv->click_policy != LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE;
581 } else if ((event->state & CDK_CONTROL_MASK) != 0) {
582 call_parent = FALSE(0);
583 ctk_tree_selection_select_path (selection, path);
584 } else {
585 view->priv->ignore_release = on_expander;
586 }
587 }
588
589 if (call_parent) {
590 /* Chain up */
591 widget_parent->button_press_event (widget, event);
592 } else if (selected) {
593 ctk_widget_grab_focus (widget);
594 }
595
596 if ((event->button == 1 || event->button == 2) &&
597 event->type == CDK_BUTTON_PRESS) {
598 view->priv->drag_started = FALSE(0);
599 view->priv->drag_button = event->button;
600 }
601 }
602
603 ctk_tree_path_free (path);
604 } else {
605 if ((event->button == 1 || event->button == 2) &&
606 event->type == CDK_BUTTON_PRESS) {
607 if (view->priv->double_click_path[1])
608 ctk_tree_path_free (view->priv->double_click_path[1]);
609
610 view->priv->double_click_path[1] = view->priv->double_click_path[0];
611 view->priv->double_click_path[0] = NULL((void*)0);
612 }
613
614 ctk_tree_selection_unselect_all (selection);
615 /* Chain up */
616 widget_parent->button_press_event (widget, event);
617 }
618
619 /* We already chained up if nescessary, so just return TRUE */
620 return TRUE(!(0));
621}
622
623static gboolean
624key_press_event (CtkWidget *widget,
625 CdkEventKey *event)
626{
627 LapizFileBrowserView *view;
628 guint modifiers;
629 gboolean handled;
630
631 view = LAPIZ_FILE_BROWSER_VIEW (widget)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((lapiz_file_browser_view_get_type
()))))))
;
632 handled = FALSE(0);
Value stored to 'handled' is never read
633
634 modifiers = ctk_accelerator_get_default_mod_mask ();
635
636 switch (event->keyval) {
637 case CDK_KEY_space0x020:
638 if (event->state & CDK_CONTROL_MASK) {
639 handled = FALSE(0);
640 break;
641 }
642 if (!ctk_widget_has_focus (widget)) {
643 handled = FALSE(0);
644 break;
645 }
646
647 activate_selected_items (view);
648 handled = TRUE(!(0));
649 break;
650
651 case CDK_KEY_Return0xff0d:
652 case CDK_KEY_KP_Enter0xff8d:
653 activate_selected_items (view);
654 handled = TRUE(!(0));
655 break;
656
657 case CDK_KEY_h0x068:
658 if ((event->state & modifiers) == CDK_CONTROL_MASK) {
659 toggle_hidden_filter (view);
660 handled = TRUE(!(0));
661 break;
662 }
663
664 default:
665 handled = FALSE(0);
666 }
667
668 /* Chain up */
669 if (!handled)
670 return CTK_WIDGET_CLASS (lapiz_file_browser_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_file_browser_view_parent_class)), ((ctk_widget_get_type
()))))))
->key_press_event (widget, event);
671
672 return TRUE(!(0));
673}
674
675static void
676fill_expand_state (LapizFileBrowserView * view, CtkTreeIter * iter)
677{
678 CtkTreePath * path;
679 CtkTreeIter child;
680 gchar * uri;
681
682 if (!ctk_tree_model_iter_has_child (view->priv->model, iter))
683 return;
684
685 path = ctk_tree_model_get_path (view->priv->model, iter);
686
687 if (ctk_tree_view_row_expanded (CTK_TREE_VIEW (view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_tree_view_get_type ()))))))
, path))
688 {
689 ctk_tree_model_get (view->priv->model,
690 iter,
691 LAPIZ_FILE_BROWSER_STORE_COLUMN_URI,
692 &uri,
693 -1);
694
695 add_expand_state (view, uri);
696 g_free (uri);
697 }
698
699 if (ctk_tree_model_iter_children (view->priv->model, &child, iter))
700 {
701 do {
702 fill_expand_state (view, &child);
703 } while (ctk_tree_model_iter_next (view->priv->model, &child));
704 }
705
706 ctk_tree_path_free (path);
707}
708
709static void
710uninstall_restore_signals (LapizFileBrowserView * tree_view,
711 CtkTreeModel * model)
712{
713 g_signal_handlers_disconnect_by_func (model,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_begin_refresh), (tree_view))
714 on_begin_refresh,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_begin_refresh), (tree_view))
715 tree_view)g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_begin_refresh), (tree_view))
;
716
717 g_signal_handlers_disconnect_by_func (model,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_end_refresh), (tree_view))
718 on_end_refresh,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_end_refresh), (tree_view))
719 tree_view)g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_end_refresh), (tree_view))
;
720
721 g_signal_handlers_disconnect_by_func (model,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_unload), (tree_view))
722 on_unload,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_unload), (tree_view))
723 tree_view)g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_unload), (tree_view))
;
724
725 g_signal_handlers_disconnect_by_func (model,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_row_inserted), (tree_view))
726 on_row_inserted,g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_row_inserted), (tree_view))
727 tree_view)g_signal_handlers_disconnect_matched ((model), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_row_inserted), (tree_view))
;
728}
729
730static void
731install_restore_signals (LapizFileBrowserView * tree_view,
732 CtkTreeModel * model)
733{
734 g_signal_connect (model,g_signal_connect_data ((model), ("begin-refresh"), (((GCallback
) (on_begin_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
735 "begin-refresh",g_signal_connect_data ((model), ("begin-refresh"), (((GCallback
) (on_begin_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
736 G_CALLBACK (on_begin_refresh),g_signal_connect_data ((model), ("begin-refresh"), (((GCallback
) (on_begin_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
737 tree_view)g_signal_connect_data ((model), ("begin-refresh"), (((GCallback
) (on_begin_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
;
738
739 g_signal_connect (model,g_signal_connect_data ((model), ("end-refresh"), (((GCallback
) (on_end_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
740 "end-refresh",g_signal_connect_data ((model), ("end-refresh"), (((GCallback
) (on_end_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
741 G_CALLBACK (on_end_refresh),g_signal_connect_data ((model), ("end-refresh"), (((GCallback
) (on_end_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
742 tree_view)g_signal_connect_data ((model), ("end-refresh"), (((GCallback
) (on_end_refresh))), (tree_view), ((void*)0), (GConnectFlags
) 0)
;
743
744 g_signal_connect (model,g_signal_connect_data ((model), ("unload"), (((GCallback) (on_unload
))), (tree_view), ((void*)0), (GConnectFlags) 0)
745 "unload",g_signal_connect_data ((model), ("unload"), (((GCallback) (on_unload
))), (tree_view), ((void*)0), (GConnectFlags) 0)
746 G_CALLBACK (on_unload),g_signal_connect_data ((model), ("unload"), (((GCallback) (on_unload
))), (tree_view), ((void*)0), (GConnectFlags) 0)
747 tree_view)g_signal_connect_data ((model), ("unload"), (((GCallback) (on_unload
))), (tree_view), ((void*)0), (GConnectFlags) 0)
;
748
749 g_signal_connect_after (model,g_signal_connect_data ((model), ("row-inserted"), (((GCallback
) (on_row_inserted))), (tree_view), ((void*)0), G_CONNECT_AFTER
)
750 "row-inserted",g_signal_connect_data ((model), ("row-inserted"), (((GCallback
) (on_row_inserted))), (tree_view), ((void*)0), G_CONNECT_AFTER
)
751 G_CALLBACK (on_row_inserted),g_signal_connect_data ((model), ("row-inserted"), (((GCallback
) (on_row_inserted))), (tree_view), ((void*)0), G_CONNECT_AFTER
)
752 tree_view)g_signal_connect_data ((model), ("row-inserted"), (((GCallback
) (on_row_inserted))), (tree_view), ((void*)0), G_CONNECT_AFTER
)
;
753}
754
755static void
756set_restore_expand_state (LapizFileBrowserView * view,
757 gboolean state)
758{
759 if (state == view->priv->restore_expand_state)
760 return;
761
762 if (view->priv->expand_state)
763 {
764 g_hash_table_destroy (view->priv->expand_state);
765 view->priv->expand_state = NULL((void*)0);
766 }
767
768 if (state)
769 {
770 view->priv->expand_state = g_hash_table_new_full (g_file_hash,
771 (GEqualFunc)g_file_equal,
772 g_object_unref,
773 NULL((void*)0));
774
775 if (view->priv->model && LAPIZ_IS_FILE_BROWSER_STORE (view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
776 {
777 fill_expand_state (view, NULL((void*)0));
778
779 install_restore_signals (view, view->priv->model);
780 }
781 }
782 else if (view->priv->model && LAPIZ_IS_FILE_BROWSER_STORE (view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
783 {
784 uninstall_restore_signals (view, view->priv->model);
785 }
786
787 view->priv->restore_expand_state = state;
788}
789
790static void
791get_property (GObject *object,
792 guint prop_id,
793 GValue *value,
794 GParamSpec *pspec)
795{
796 LapizFileBrowserView *obj = LAPIZ_FILE_BROWSER_VIEW (object)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((object)), ((lapiz_file_browser_view_get_type
()))))))
;
797
798 switch (prop_id)
799 {
800 case PROP_CLICK_POLICY:
801 g_value_set_enum (value, obj->priv->click_policy);
802 break;
803 case PROP_RESTORE_EXPAND_STATE:
804 g_value_set_boolean (value, obj->priv->restore_expand_state);
805 break;
806 default:
807 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "lapiz-file-browser-view.c", 807, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
808 break;
809 }
810}
811
812static void
813set_property (GObject *object,
814 guint prop_id,
815 const GValue *value,
816 GParamSpec *pspec)
817{
818 LapizFileBrowserView *obj = LAPIZ_FILE_BROWSER_VIEW (object)((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((object)), ((lapiz_file_browser_view_get_type
()))))))
;
819
820 switch (prop_id)
821 {
822 case PROP_CLICK_POLICY:
823 set_click_policy_property (obj, g_value_get_enum (value));
824 break;
825 case PROP_RESTORE_EXPAND_STATE:
826 set_restore_expand_state (obj, g_value_get_boolean (value));
827 break;
828 default:
829 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "lapiz-file-browser-view.c", 829, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
830 break;
831 }
832}
833
834static void
835lapiz_file_browser_view_class_init (LapizFileBrowserViewClass * klass)
836{
837 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
838 CtkTreeViewClass *tree_view_class = CTK_TREE_VIEW_CLASS (klass)((((CtkTreeViewClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_tree_view_get_type ()))))))
;
839 CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_widget_get_type ()))))))
;
840
841 object_class->finalize = lapiz_file_browser_view_finalize;
842 object_class->get_property = get_property;
843 object_class->set_property = set_property;
844
845 /* Event handlers */
846 widget_class->motion_notify_event = motion_notify_event;
847 widget_class->enter_notify_event = enter_notify_event;
848 widget_class->leave_notify_event = leave_notify_event;
849 widget_class->button_press_event = button_press_event;
850 widget_class->button_release_event = button_release_event;
851 widget_class->drag_begin = drag_begin;
852 widget_class->key_press_event = key_press_event;
853
854 /* Tree view handlers */
855 tree_view_class->row_expanded = row_expanded;
856 tree_view_class->row_collapsed = row_collapsed;
857
858 /* Default handlers */
859 klass->directory_activated = directory_activated;
860
861 g_object_class_install_property (object_class, PROP_CLICK_POLICY,
862 g_param_spec_enum ("click-policy",
863 "Click Policy",
864 "The click policy",
865 LAPIZ_TYPE_FILE_BROWSER_VIEW_CLICK_POLICY(lapiz_file_browser_view_click_policy_get_type()),
866 LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
867 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
868
869 g_object_class_install_property (object_class, PROP_RESTORE_EXPAND_STATE,
870 g_param_spec_boolean ("restore-expand-state",
871 "Restore Expand State",
872 "Restore expanded state of loaded directories",
873 FALSE(0),
874 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
875
876 signals[ERROR] =
877 g_signal_new ("error",
878 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
879 G_SIGNAL_RUN_LAST,
880 G_STRUCT_OFFSET (LapizFileBrowserViewClass,((glong) __builtin_offsetof(LapizFileBrowserViewClass, error)
)
881 error)((glong) __builtin_offsetof(LapizFileBrowserViewClass, error)
)
, NULL((void*)0), NULL((void*)0),
882 lapiz_file_browser_marshal_VOID__UINT_STRING,
883 G_TYPE_NONE((GType) ((1) << (2))), 2, G_TYPE_UINT((GType) ((7) << (2))), G_TYPE_STRING((GType) ((16) << (2))));
884 signals[FILE_ACTIVATED] =
885 g_signal_new ("file-activated",
886 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
887 G_SIGNAL_RUN_LAST,
888 G_STRUCT_OFFSET (LapizFileBrowserViewClass,((glong) __builtin_offsetof(LapizFileBrowserViewClass, file_activated
))
889 file_activated)((glong) __builtin_offsetof(LapizFileBrowserViewClass, file_activated
))
, NULL((void*)0), NULL((void*)0),
890 g_cclosure_marshal_VOID__BOXED,
891 G_TYPE_NONE((GType) ((1) << (2))), 1, CTK_TYPE_TREE_ITER(ctk_tree_iter_get_type ()));
892 signals[DIRECTORY_ACTIVATED] =
893 g_signal_new ("directory-activated",
894 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
895 G_SIGNAL_RUN_LAST,
896 G_STRUCT_OFFSET (LapizFileBrowserViewClass,((glong) __builtin_offsetof(LapizFileBrowserViewClass, directory_activated
))
897 directory_activated)((glong) __builtin_offsetof(LapizFileBrowserViewClass, directory_activated
))
, NULL((void*)0), NULL((void*)0),
898 g_cclosure_marshal_VOID__BOXED,
899 G_TYPE_NONE((GType) ((1) << (2))), 1, CTK_TYPE_TREE_ITER(ctk_tree_iter_get_type ()));
900 signals[BOOKMARK_ACTIVATED] =
901 g_signal_new ("bookmark-activated",
902 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
903 G_SIGNAL_RUN_LAST,
904 G_STRUCT_OFFSET (LapizFileBrowserViewClass,((glong) __builtin_offsetof(LapizFileBrowserViewClass, bookmark_activated
))
905 bookmark_activated)((glong) __builtin_offsetof(LapizFileBrowserViewClass, bookmark_activated
))
, NULL((void*)0), NULL((void*)0),
906 g_cclosure_marshal_VOID__BOXED,
907 G_TYPE_NONE((GType) ((1) << (2))), 1, CTK_TYPE_TREE_ITER(ctk_tree_iter_get_type ()));
908}
909
910static void
911lapiz_file_browser_view_class_finalize (LapizFileBrowserViewClass *klass G_GNUC_UNUSED__attribute__ ((__unused__)))
912{
913 /* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
914}
915
916static void
917cell_data_cb (CtkTreeViewColumn *tree_column G_GNUC_UNUSED__attribute__ ((__unused__)),
918 CtkCellRenderer *cell,
919 CtkTreeModel *tree_model,
920 CtkTreeIter *iter,
921 LapizFileBrowserView *obj)
922{
923 CtkTreePath *path;
924 PangoUnderline underline = PANGO_UNDERLINE_NONE;
925 gboolean editable = FALSE(0);
926
927 path = ctk_tree_model_get_path (tree_model, iter);
928
929 if (obj->priv->click_policy == LAPIZ_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
930 if (obj->priv->hover_path != NULL((void*)0) &&
931 ctk_tree_path_compare (path, obj->priv->hover_path) == 0)
932 underline = PANGO_UNDERLINE_SINGLE;
933 }
934
935 if (LAPIZ_IS_FILE_BROWSER_STORE (tree_model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tree_model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
936 {
937 if (obj->priv->editable != NULL((void*)0) &&
938 ctk_tree_row_reference_valid (obj->priv->editable))
939 {
940 CtkTreePath *edpath = ctk_tree_row_reference_get_path (obj->priv->editable);
941
942 editable = edpath && ctk_tree_path_compare (path, edpath) == 0;
943 }
944 }
945
946 ctk_tree_path_free (path);
947 g_object_set (cell, "editable", editable, "underline", underline, NULL((void*)0));
948}
949
950static void
951lapiz_file_browser_view_init (LapizFileBrowserView * obj)
952{
953 CdkDisplay *display;
954
955 obj->priv = lapiz_file_browser_view_get_instance_private (obj);
956
957 obj->priv->column = ctk_tree_view_column_new ();
958
959 obj->priv->pixbuf_renderer = ctk_cell_renderer_pixbuf_new ();
960 ctk_tree_view_column_pack_start (obj->priv->column,
961 obj->priv->pixbuf_renderer,
962 FALSE(0));
963 ctk_tree_view_column_add_attribute (obj->priv->column,
964 obj->priv->pixbuf_renderer,
965 "pixbuf",
966 LAPIZ_FILE_BROWSER_STORE_COLUMN_ICON);
967
968 obj->priv->text_renderer = ctk_cell_renderer_text_new ();
969 ctk_tree_view_column_pack_start (obj->priv->column,
970 obj->priv->text_renderer, TRUE(!(0)));
971 ctk_tree_view_column_add_attribute (obj->priv->column,
972 obj->priv->text_renderer,
973 "text",
974 LAPIZ_FILE_BROWSER_STORE_COLUMN_NAME);
975
976 g_signal_connect (obj->priv->text_renderer, "edited",g_signal_connect_data ((obj->priv->text_renderer), ("edited"
), (((GCallback) (on_cell_edited))), (obj), ((void*)0), (GConnectFlags
) 0)
977 G_CALLBACK (on_cell_edited), obj)g_signal_connect_data ((obj->priv->text_renderer), ("edited"
), (((GCallback) (on_cell_edited))), (obj), ((void*)0), (GConnectFlags
) 0)
;
978
979 ctk_tree_view_append_column (CTK_TREE_VIEW (obj)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_tree_view_get_type ()))))))
,
980 obj->priv->column);
981 ctk_tree_view_set_headers_visible (CTK_TREE_VIEW (obj)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_tree_view_get_type ()))))))
, FALSE(0));
982
983 ctk_tree_view_enable_model_drag_source (CTK_TREE_VIEW (obj)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_tree_view_get_type ()))))))
,
984 CDK_BUTTON1_MASK,
985 drag_source_targets,
986 G_N_ELEMENTS (drag_source_targets)(sizeof (drag_source_targets) / sizeof ((drag_source_targets)
[0]))
,
987 CDK_ACTION_COPY);
988
989 display = ctk_widget_get_display (CTK_WIDGET (obj)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_widget_get_type ()))))))
);
990 obj->priv->busy_cursor = cdk_cursor_new_for_display (display, CDK_WATCH);
991}
992
993static gboolean
994bookmarks_separator_func (CtkTreeModel *model,
995 CtkTreeIter *iter,
996 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
997{
998 guint flags;
999
1000 ctk_tree_model_get (model, iter,
1001 LAPIZ_FILE_BOOKMARKS_STORE_COLUMN_FLAGS,
1002 &flags, -1);
1003
1004 return (flags & LAPIZ_FILE_BOOKMARKS_STORE_IS_SEPARATOR);
1005}
1006
1007/* Public */
1008CtkWidget *
1009lapiz_file_browser_view_new (void)
1010{
1011 LapizFileBrowserView *obj =
1012 LAPIZ_FILE_BROWSER_VIEW (g_object_new((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((g_object_new ((lapiz_file_browser_view_get_type
()), ((void*)0)))), ((lapiz_file_browser_view_get_type ())))
)))
1013 (LAPIZ_TYPE_FILE_BROWSER_VIEW, NULL))((((LapizFileBrowserView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((g_object_new ((lapiz_file_browser_view_get_type
()), ((void*)0)))), ((lapiz_file_browser_view_get_type ())))
)))
;
1014
1015 return CTK_WIDGET (obj)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_widget_get_type ()))))))
;
1016}
1017
1018void
1019lapiz_file_browser_view_set_model (LapizFileBrowserView * tree_view,
1020 CtkTreeModel * model)
1021{
1022 CtkTreeSelection *selection;
1023
1024 if (tree_view->priv->model == model)
1025 return;
1026
1027 selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
);
1028
1029 if (LAPIZ_IS_FILE_BOOKMARKS_STORE (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(model)); GType __t = ((lapiz_file_bookmarks_store_get_type (
))); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1030 ctk_tree_selection_set_mode (selection, CTK_SELECTION_BROWSE);
1031 ctk_tree_view_set_row_separator_func (CTK_TREE_VIEW((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
1032 (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
,
1033 bookmarks_separator_func,
1034 NULL((void*)0), NULL((void*)0));
1035 ctk_tree_view_column_set_cell_data_func (tree_view->priv->
1036 column,
1037 tree_view->priv->
1038 text_renderer,
1039 (CtkTreeCellDataFunc)
1040 cell_data_cb,
1041 tree_view, NULL((void*)0));
1042 } else {
1043 ctk_tree_selection_set_mode (selection, CTK_SELECTION_MULTIPLE);
1044 ctk_tree_view_set_row_separator_func (CTK_TREE_VIEW((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
1045 (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
, NULL((void*)0),
1046 NULL((void*)0), NULL((void*)0));
1047 ctk_tree_view_column_set_cell_data_func (tree_view->priv->
1048 column,
1049 tree_view->priv->
1050 text_renderer,
1051 (CtkTreeCellDataFunc)
1052 cell_data_cb,
1053 tree_view, NULL((void*)0));
1054
1055 if (tree_view->priv->restore_expand_state)
1056 install_restore_signals (tree_view, model);
1057
1058 }
1059
1060 if (tree_view->priv->hover_path != NULL((void*)0)) {
1061 ctk_tree_path_free (tree_view->priv->hover_path);
1062 tree_view->priv->hover_path = NULL((void*)0);
1063 }
1064
1065 if (LAPIZ_IS_FILE_BROWSER_STORE (tree_view->priv->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tree_view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1066 if (tree_view->priv->restore_expand_state)
1067 uninstall_restore_signals (tree_view,
1068 tree_view->priv->model);
1069 }
1070
1071 tree_view->priv->model = model;
1072 ctk_tree_view_set_model (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
, model);
1073}
1074
1075void
1076lapiz_file_browser_view_start_rename (LapizFileBrowserView * tree_view,
1077 CtkTreeIter * iter)
1078{
1079 guint flags;
1080 CtkTreeRowReference *rowref;
1081 CtkTreePath *path;
1082
1083 g_return_if_fail (LAPIZ_IS_FILE_BROWSER_VIEW (tree_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((tree_view)); GType __t = ((lapiz_file_browser_view_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_FILE_BROWSER_VIEW (tree_view)"
); return; } } while (0)
;
1084 g_return_if_fail (LAPIZ_IS_FILE_BROWSER_STOREdo { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((tree_view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_FILE_BROWSER_STORE (tree_view->priv->model)"
); return; } } while (0)
1085 (tree_view->priv->model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((tree_view->priv->model)); GType __t = ((lapiz_file_browser_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_FILE_BROWSER_STORE (tree_view->priv->model)"
); return; } } while (0)
;
1086 g_return_if_fail (iter != NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "iter != NULL"); return
; } } while (0)
;
1087
1088 ctk_tree_model_get (tree_view->priv->model, iter,
1089 LAPIZ_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
1090 -1);
1091
1092 if (!(FILE_IS_DIR (flags)(flags & LAPIZ_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY) || !FILE_IS_DUMMY (flags)(flags & LAPIZ_FILE_BROWSER_STORE_FLAG_IS_DUMMY)))
1093 return;
1094
1095 path = ctk_tree_model_get_path (tree_view->priv->model, iter);
1096 rowref = ctk_tree_row_reference_new (tree_view->priv->model, path);
1097
1098 /* Start editing */
1099 ctk_widget_grab_focus (CTK_WIDGET (tree_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_widget_get_type ()))))))
);
1100
1101 if (ctk_tree_path_up (path))
1102 ctk_tree_view_expand_to_path (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
,
1103 path);
1104
1105 ctk_tree_path_free (path);
1106 tree_view->priv->editable = rowref;
1107
1108 ctk_tree_view_set_cursor (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
,
1109 ctk_tree_row_reference_get_path (tree_view->priv->editable),
1110 tree_view->priv->column, TRUE(!(0)));
1111
1112 ctk_tree_view_scroll_to_cell (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
,
1113 ctk_tree_row_reference_get_path (tree_view->priv->editable),
1114 tree_view->priv->column,
1115 FALSE(0), 0.0, 0.0);
1116}
1117
1118void
1119lapiz_file_browser_view_set_click_policy (LapizFileBrowserView *tree_view,
1120 LapizFileBrowserViewClickPolicy policy)
1121{
1122 g_return_if_fail (LAPIZ_IS_FILE_BROWSER_VIEW (tree_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((tree_view)); GType __t = ((lapiz_file_browser_view_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_FILE_BROWSER_VIEW (tree_view)"
); return; } } while (0)
;
1123
1124 set_click_policy_property (tree_view, policy);
1125
1126 g_object_notify (G_OBJECT (tree_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), (((GType) ((20) << (2))))))))
, "click-policy");
1127}
1128
1129void
1130lapiz_file_browser_view_set_restore_expand_state (LapizFileBrowserView * tree_view,
1131 gboolean restore_expand_state)
1132{
1133 g_return_if_fail (LAPIZ_IS_FILE_BROWSER_VIEW (tree_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((tree_view)); GType __t = ((lapiz_file_browser_view_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_FILE_BROWSER_VIEW (tree_view)"
); return; } } while (0)
;
1134
1135 set_restore_expand_state (tree_view, restore_expand_state);
1136 g_object_notify (G_OBJECT (tree_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), (((GType) ((20) << (2))))))))
, "restore-expand-state");
1137}
1138
1139/* Signal handlers */
1140static void
1141on_cell_edited (CtkCellRendererText *cell G_GNUC_UNUSED__attribute__ ((__unused__)),
1142 gchar *path,
1143 gchar *new_text,
1144 LapizFileBrowserView *tree_view)
1145{
1146 CtkTreePath * treepath;
1147 CtkTreeIter iter;
1148 gboolean ret;
1149 GError * error = NULL((void*)0);
1150
1151 ctk_tree_row_reference_free (tree_view->priv->editable);
1152 tree_view->priv->editable = NULL((void*)0);
1153
1154 if (new_text == NULL((void*)0) || *new_text == '\0')
1155 return;
1156
1157 treepath = ctk_tree_path_new_from_string (path);
1158 ret = ctk_tree_model_get_iter (CTK_TREE_MODEL (tree_view->priv->model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view->priv->model)), ((ctk_tree_model_get_type
()))))))
, &iter, treepath);
1159 ctk_tree_path_free (treepath);
1160
1161 if (ret) {
1162 if (lapiz_file_browser_store_rename (LAPIZ_FILE_BROWSER_STORE (tree_view->priv->model)((((LapizFileBrowserStore*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((tree_view->priv->model)), ((lapiz_file_browser_store_get_type
()))))))
,
1163 &iter, new_text, &error)) {
1164 treepath = ctk_tree_model_get_path (CTK_TREE_MODEL (tree_view->priv->model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view->priv->model)), ((ctk_tree_model_get_type
()))))))
, &iter);
1165 ctk_tree_view_scroll_to_cell (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((ctk_tree_view_get_type ()))))))
,
1166 treepath, NULL((void*)0),
1167 FALSE(0), 0.0, 0.0);
1168 ctk_tree_path_free (treepath);
1169 }
1170 else {
1171 if (error) {
1172 g_signal_emit (tree_view, signals[ERROR], 0,
1173 error->code, error->message);
1174 g_error_free (error);
1175 }
1176 }
1177 }
1178}
1179
1180static void
1181on_begin_refresh (LapizFileBrowserStore *model G_GNUC_UNUSED__attribute__ ((__unused__)),
1182 LapizFileBrowserView *view)
1183{
1184 /* Store the refresh state, so we can handle unloading of nodes while
1185 refreshing properly */
1186 view->priv->is_refresh = TRUE(!(0));
1187}
1188
1189static void
1190on_end_refresh (LapizFileBrowserStore *model G_GNUC_UNUSED__attribute__ ((__unused__)),
1191 LapizFileBrowserView *view)
1192{
1193 /* Store the refresh state, so we can handle unloading of nodes while
1194 refreshing properly */
1195 view->priv->is_refresh = FALSE(0);
1196}
1197
1198static void
1199on_unload (LapizFileBrowserStore *model G_GNUC_UNUSED__attribute__ ((__unused__)),
1200 gchar const *uri,
1201 LapizFileBrowserView *view)
1202{
1203 /* Don't remove the expand state if we are refreshing */
1204 if (!view->priv->restore_expand_state || view->priv->is_refresh)
1205 return;
1206
1207 remove_expand_state (view, uri);
1208}
1209
1210static void
1211restore_expand_state (LapizFileBrowserView * view,
1212 LapizFileBrowserStore * model,
1213 CtkTreeIter * iter)
1214{
1215 gchar * uri;
1216 GFile * file;
1217 CtkTreePath * path;
1218
1219 ctk_tree_model_get (CTK_TREE_MODEL (model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_tree_model_get_type ()))))))
,
1220 iter,
1221 LAPIZ_FILE_BROWSER_STORE_COLUMN_URI,
1222 &uri,
1223 -1);
1224
1225 if (!uri)
1226 return;
1227
1228 file = g_file_new_for_uri (uri);
1229 path = ctk_tree_model_get_path (CTK_TREE_MODEL (model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_tree_model_get_type ()))))))
, iter);
1230
1231 if (g_hash_table_lookup (view->priv->expand_state, file))
1232 {
1233 ctk_tree_view_expand_row (CTK_TREE_VIEW (view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_tree_view_get_type ()))))))
,
1234 path,
1235 FALSE(0));
1236 }
1237
1238 ctk_tree_path_free (path);
1239
1240 g_object_unref (file);
1241 g_free (uri);
1242}
1243
1244static void
1245on_row_inserted (LapizFileBrowserStore * model,
1246 CtkTreePath * path,
1247 CtkTreeIter * iter,
1248 LapizFileBrowserView * view)
1249{
1250 CtkTreeIter parent;
1251 CtkTreePath * copy;
1252
1253 if (ctk_tree_model_iter_has_child (CTK_TREE_MODEL (model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_tree_model_get_type ()))))))
, iter))
1254 restore_expand_state (view, model, iter);
1255
1256 copy = ctk_tree_path_copy (path);
1257
1258 if (ctk_tree_path_up (copy) &&
1259 (ctk_tree_path_get_depth (copy) != 0) &&
1260 ctk_tree_model_get_iter (CTK_TREE_MODEL (model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_tree_model_get_type ()))))))
, &parent, copy))
1261 {
1262 restore_expand_state (view, model, &parent);
1263 }
1264
1265 ctk_tree_path_free (copy);
1266}
1267
1268void
1269_lapiz_file_browser_view_register_type (GTypeModule *type_module)
1270{
1271 lapiz_file_browser_view_register_type (type_module);
1272}
1273
1274// ex:ts=8:noet: