31
31
#include "gimpwidgetstypes.h"
33
#undef GIMP_DISABLE_DEPRECATED
34
#include "gimpfileentry.h"
33
36
#include "gimppatheditor.h"
34
#include "gimpfileentry.h"
36
38
#include "libgimp/libgimp-intl.h"
55
static void gimp_path_editor_class_init (GimpPathEditorClass *klass);
56
static void gimp_path_editor_init (GimpPathEditor *editor);
58
static void gimp_path_editor_new_clicked (GtkWidget *widget,
59
GimpPathEditor *editor);
60
static void gimp_path_editor_move_clicked (GtkWidget *widget,
61
GimpPathEditor *editor);
62
static void gimp_path_editor_delete_clicked (GtkWidget *widget,
63
GimpPathEditor *editor);
64
static void gimp_path_editor_file_entry_changed (GtkWidget *widget,
65
GimpPathEditor *editor);
66
static void gimp_path_editor_selection_changed (GtkTreeSelection *sel,
67
GimpPathEditor *editor);
68
static void gimp_path_editor_writable_toggled (GtkCellRendererToggle *toggle,
70
GimpPathEditor *editor);
57
static void gimp_path_editor_new_clicked (GtkWidget *widget,
58
GimpPathEditor *editor);
59
static void gimp_path_editor_move_clicked (GtkWidget *widget,
60
GimpPathEditor *editor);
61
static void gimp_path_editor_delete_clicked (GtkWidget *widget,
62
GimpPathEditor *editor);
63
static void gimp_path_editor_file_entry_changed (GtkWidget *widget,
64
GimpPathEditor *editor);
65
static void gimp_path_editor_selection_changed (GtkTreeSelection *sel,
66
GimpPathEditor *editor);
67
static void gimp_path_editor_writable_toggled (GtkCellRendererToggle *toggle,
69
GimpPathEditor *editor);
72
G_DEFINE_TYPE (GimpPathEditor, gimp_path_editor, GTK_TYPE_VBOX)
74
#define parent_class gimp_path_editor_parent_class
73
76
static guint gimp_path_editor_signals[LAST_SIGNAL] = { 0 };
75
static GtkVBoxClass *parent_class = NULL;
79
gimp_path_editor_get_type (void)
81
static GType type = 0;
85
static const GTypeInfo info =
87
sizeof (GimpPathEditorClass),
89
(GBaseFinalizeFunc) NULL,
90
(GClassInitFunc) gimp_path_editor_class_init,
91
NULL, /* class_finalize */
92
NULL, /* class_data */
93
sizeof (GimpPathEditor),
95
(GInstanceInitFunc) gimp_path_editor_init,
98
type = g_type_register_static (GTK_TYPE_VBOX,
107
80
gimp_path_editor_class_init (GimpPathEditorClass *klass)
109
parent_class = g_type_class_peek_parent (klass);
112
83
* GimpPathEditor::path-changed:
115
86
* or reorders an element of the search path.
117
88
gimp_path_editor_signals[PATH_CHANGED] =
118
g_signal_new ("path_changed",
119
G_TYPE_FROM_CLASS (klass),
121
G_STRUCT_OFFSET (GimpPathEditorClass, path_changed),
123
g_cclosure_marshal_VOID__VOID,
89
g_signal_new ("path-changed",
90
G_TYPE_FROM_CLASS (klass),
92
G_STRUCT_OFFSET (GimpPathEditorClass, path_changed),
94
g_cclosure_marshal_VOID__VOID,
127
98
* GimpPathEditor::writable-changed:
131
102
* gimp_path_editor_set_dir_writable().
133
104
gimp_path_editor_signals[WRITABLE_CHANGED] =
134
g_signal_new ("writable_changed",
135
G_TYPE_FROM_CLASS (klass),
137
G_STRUCT_OFFSET (GimpPathEditorClass, writable_changed),
139
g_cclosure_marshal_VOID__VOID,
105
g_signal_new ("writable-changed",
106
G_TYPE_FROM_CLASS (klass),
108
G_STRUCT_OFFSET (GimpPathEditorClass, writable_changed),
110
g_cclosure_marshal_VOID__VOID,
142
113
klass->path_changed = NULL;
143
114
klass->writable_changed = NULL;
177
148
g_signal_connect (button, "clicked",
178
149
G_CALLBACK (gimp_path_editor_new_clicked),
181
152
editor->up_button = button = gtk_button_new ();
182
153
gtk_widget_set_sensitive (button, FALSE);
190
161
g_signal_connect (button, "clicked",
191
162
G_CALLBACK (gimp_path_editor_move_clicked),
194
165
editor->down_button = button = gtk_button_new ();
195
166
gtk_widget_set_sensitive (button, FALSE);
203
174
g_signal_connect (button, "clicked",
204
175
G_CALLBACK (gimp_path_editor_move_clicked),
207
178
editor->delete_button = button = gtk_button_new ();
208
179
gtk_widget_set_sensitive (button, FALSE);
216
187
g_signal_connect (button, "clicked",
217
188
G_CALLBACK (gimp_path_editor_delete_clicked),
220
191
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
221
192
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
223
194
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
224
195
GTK_POLICY_AUTOMATIC,
225
196
GTK_POLICY_ALWAYS);
249
220
gtk_tree_view_column_set_visible (col, FALSE);
251
222
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv),
253
gtk_cell_renderer_text_new (),
224
gtk_cell_renderer_text_new (),
257
228
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv), TRUE);
262
233
editor->sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
263
234
g_signal_connect (editor->sel, "changed",
264
G_CALLBACK (gimp_path_editor_selection_changed),
235
G_CALLBACK (gimp_path_editor_selection_changed),
269
240
* gimp_path_editor_new:
270
* @filesel_title: The title of the #GtkFileSelection dialog which can be
271
* popped up by the attached #GimpFileSelection.
272
* @path: The initial search path.
241
* @title: The title of the #GtkFileChooser dialog which can be popped up.
242
* @path: The initial search path.
274
244
* Creates a new #GimpPathEditor widget.
279
249
* Returns: A pointer to the new #GimpPathEditor widget.
282
gimp_path_editor_new (const gchar *filesel_title,
252
gimp_path_editor_new (const gchar *title,
285
255
GimpPathEditor *editor;
287
g_return_val_if_fail (filesel_title != NULL, NULL);
257
g_return_val_if_fail (title != NULL, NULL);
289
259
editor = g_object_new (GIMP_TYPE_PATH_EDITOR, NULL);
291
editor->file_entry = gimp_file_entry_new (filesel_title, "", TRUE, TRUE);
261
editor->file_entry = gimp_file_entry_new (title, "", TRUE, TRUE);
292
262
gtk_widget_set_sensitive (editor->file_entry, FALSE);
293
263
gtk_box_pack_start (GTK_BOX (editor->upper_hbox), editor->file_entry,
295
265
gtk_widget_show (editor->file_entry);
297
g_signal_connect (editor->file_entry, "filename_changed",
267
g_signal_connect (editor->file_entry, "filename-changed",
298
268
G_CALLBACK (gimp_path_editor_file_entry_changed),
302
272
gimp_path_editor_set_path (editor, path);
371
341
old_path = gimp_path_editor_get_path (editor);
373
if (old_path == path || (old_path && path && ! strcmp (old_path, path)))
343
if (old_path && path && strcmp (old_path, path) == 0)
375
345
g_free (old_path);
379
351
path_list = gimp_path_parse (path, 16, TRUE, NULL);
381
353
gtk_list_store_clear (editor->dir_list);
587
559
if (editor->sel_path)
589
561
g_signal_handlers_block_by_func (editor->sel,
590
gimp_path_editor_selection_changed,
562
gimp_path_editor_selection_changed,
593
565
gtk_tree_selection_unselect_path (editor->sel, editor->sel_path);
595
567
g_signal_handlers_unblock_by_func (editor->sel,
596
gimp_path_editor_selection_changed,
568
gimp_path_editor_selection_changed,
599
571
gtk_tree_path_free (editor->sel_path);
683
655
gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter,
686
658
gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
687
659
COLUMN_WRITABLE, &dir_writable,
746
utf8 = g_filename_to_utf8 (dir, -1, NULL, NULL, NULL);
718
utf8 = g_filename_display_name (dir);
748
720
if (editor->sel_path == NULL)