~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimppatheditor.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include "gimpwidgetstypes.h"
32
32
 
 
33
#undef GIMP_DISABLE_DEPRECATED
 
34
#include "gimpfileentry.h"
 
35
 
33
36
#include "gimppatheditor.h"
34
 
#include "gimpfileentry.h"
35
37
 
36
38
#include "libgimp/libgimp-intl.h"
37
39
 
52
54
};
53
55
 
54
56
 
55
 
static void     gimp_path_editor_class_init         (GimpPathEditorClass *klass);
56
 
static void     gimp_path_editor_init               (GimpPathEditor      *editor);
57
 
 
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,
69
 
                                                     gchar               *path_str,
70
 
                                                     GimpPathEditor      *editor);
71
 
 
 
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,
 
68
                                                   gchar               *path_str,
 
69
                                                   GimpPathEditor      *editor);
 
70
 
 
71
 
 
72
G_DEFINE_TYPE (GimpPathEditor, gimp_path_editor, GTK_TYPE_VBOX)
 
73
 
 
74
#define parent_class gimp_path_editor_parent_class
72
75
 
73
76
static guint gimp_path_editor_signals[LAST_SIGNAL] = { 0 };
74
77
 
75
 
static GtkVBoxClass *parent_class = NULL;
76
 
 
77
 
 
78
 
GType
79
 
gimp_path_editor_get_type (void)
80
 
{
81
 
  static GType type = 0;
82
 
 
83
 
  if (! type)
84
 
    {
85
 
      static const GTypeInfo info =
86
 
      {
87
 
        sizeof (GimpPathEditorClass),
88
 
        (GBaseInitFunc) NULL,
89
 
        (GBaseFinalizeFunc) NULL,
90
 
        (GClassInitFunc) gimp_path_editor_class_init,
91
 
        NULL,           /* class_finalize */
92
 
        NULL,           /* class_data     */
93
 
        sizeof (GimpPathEditor),
94
 
        0,              /* n_preallocs    */
95
 
        (GInstanceInitFunc) gimp_path_editor_init,
96
 
      };
97
 
 
98
 
      type = g_type_register_static (GTK_TYPE_VBOX,
99
 
                                     "GimpPathEditor",
100
 
                                     &info, 0);
101
 
    }
102
 
 
103
 
  return type;
104
 
}
105
78
 
106
79
static void
107
80
gimp_path_editor_class_init (GimpPathEditorClass *klass)
108
81
{
109
 
  parent_class = g_type_class_peek_parent (klass);
110
 
 
111
82
  /**
112
83
   * GimpPathEditor::path-changed:
113
84
   *
115
86
   * or reorders an element of the search path.
116
87
   **/
117
88
  gimp_path_editor_signals[PATH_CHANGED] =
118
 
    g_signal_new ("path_changed",
119
 
                  G_TYPE_FROM_CLASS (klass),
120
 
                  G_SIGNAL_RUN_FIRST,
121
 
                  G_STRUCT_OFFSET (GimpPathEditorClass, path_changed),
122
 
                  NULL, NULL,
123
 
                  g_cclosure_marshal_VOID__VOID,
124
 
                  G_TYPE_NONE, 0);
 
89
    g_signal_new ("path-changed",
 
90
                  G_TYPE_FROM_CLASS (klass),
 
91
                  G_SIGNAL_RUN_FIRST,
 
92
                  G_STRUCT_OFFSET (GimpPathEditorClass, path_changed),
 
93
                  NULL, NULL,
 
94
                  g_cclosure_marshal_VOID__VOID,
 
95
                  G_TYPE_NONE, 0);
125
96
 
126
97
  /**
127
98
   * GimpPathEditor::writable-changed:
131
102
   * gimp_path_editor_set_dir_writable().
132
103
   **/
133
104
  gimp_path_editor_signals[WRITABLE_CHANGED] =
134
 
    g_signal_new ("writable_changed",
135
 
                  G_TYPE_FROM_CLASS (klass),
136
 
                  G_SIGNAL_RUN_FIRST,
137
 
                  G_STRUCT_OFFSET (GimpPathEditorClass, writable_changed),
138
 
                  NULL, NULL,
139
 
                  g_cclosure_marshal_VOID__VOID,
140
 
                  G_TYPE_NONE, 0);
 
105
    g_signal_new ("writable-changed",
 
106
                  G_TYPE_FROM_CLASS (klass),
 
107
                  G_SIGNAL_RUN_FIRST,
 
108
                  G_STRUCT_OFFSET (GimpPathEditorClass, writable_changed),
 
109
                  NULL, NULL,
 
110
                  g_cclosure_marshal_VOID__VOID,
 
111
                  G_TYPE_NONE, 0);
141
112
 
142
113
  klass->path_changed     = NULL;
143
114
  klass->writable_changed = NULL;
176
147
 
177
148
  g_signal_connect (button, "clicked",
178
149
                    G_CALLBACK (gimp_path_editor_new_clicked),
179
 
                    editor);
 
150
                    editor);
180
151
 
181
152
  editor->up_button = button = gtk_button_new ();
182
153
  gtk_widget_set_sensitive (button, FALSE);
189
160
 
190
161
  g_signal_connect (button, "clicked",
191
162
                    G_CALLBACK (gimp_path_editor_move_clicked),
192
 
                    editor);
 
163
                    editor);
193
164
 
194
165
  editor->down_button = button = gtk_button_new ();
195
166
  gtk_widget_set_sensitive (button, FALSE);
202
173
 
203
174
  g_signal_connect (button, "clicked",
204
175
                    G_CALLBACK (gimp_path_editor_move_clicked),
205
 
                    editor);
 
176
                    editor);
206
177
 
207
178
  editor->delete_button = button = gtk_button_new ();
208
179
  gtk_widget_set_sensitive (button, FALSE);
215
186
 
216
187
  g_signal_connect (button, "clicked",
217
188
                    G_CALLBACK (gimp_path_editor_delete_clicked),
218
 
                    editor);
 
189
                    editor);
219
190
 
220
191
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
221
192
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
222
 
                                       GTK_SHADOW_IN);
 
193
                                       GTK_SHADOW_IN);
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);
250
221
 
251
222
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv),
252
 
                                               -1, _("Folder"),
253
 
                                               gtk_cell_renderer_text_new (),
254
 
                                               "text", COLUMN_UTF8,
255
 
                                               NULL);
 
223
                                               -1, _("Folder"),
 
224
                                               gtk_cell_renderer_text_new (),
 
225
                                               "text", COLUMN_UTF8,
 
226
                                               NULL);
256
227
 
257
228
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv), TRUE);
258
229
 
261
232
 
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),
265
 
                    editor);
 
235
                    G_CALLBACK (gimp_path_editor_selection_changed),
 
236
                    editor);
266
237
}
267
238
 
268
239
/**
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.
273
243
 *
274
244
 * Creates a new #GimpPathEditor widget.
275
245
 *
279
249
 * Returns: A pointer to the new #GimpPathEditor widget.
280
250
 **/
281
251
GtkWidget *
282
 
gimp_path_editor_new (const gchar *filesel_title,
283
 
                      const gchar *path)
 
252
gimp_path_editor_new (const gchar *title,
 
253
                      const gchar *path)
284
254
{
285
255
  GimpPathEditor *editor;
286
256
 
287
 
  g_return_val_if_fail (filesel_title != NULL, NULL);
 
257
  g_return_val_if_fail (title != NULL, NULL);
288
258
 
289
259
  editor = g_object_new (GIMP_TYPE_PATH_EDITOR, NULL);
290
260
 
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,
294
264
                      TRUE, TRUE, 0);
295
265
  gtk_widget_show (editor->file_entry);
296
266
 
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),
299
 
                    editor);
 
269
                    editor);
300
270
 
301
271
  if (path)
302
272
    gimp_path_editor_set_path (editor, path);
370
340
 
371
341
  old_path = gimp_path_editor_get_path (editor);
372
342
 
373
 
  if (old_path == path || (old_path && path && ! strcmp (old_path, path)))
 
343
  if (old_path && path && strcmp (old_path, path) == 0)
374
344
    {
375
345
      g_free (old_path);
376
346
      return;
377
347
    }
378
348
 
 
349
  g_free (old_path);
 
350
 
379
351
  path_list = gimp_path_parse (path, 16, TRUE, NULL);
380
352
 
381
353
  gtk_list_store_clear (editor->dir_list);
587
559
  if (editor->sel_path)
588
560
    {
589
561
      g_signal_handlers_block_by_func (editor->sel,
590
 
                                       gimp_path_editor_selection_changed,
 
562
                                       gimp_path_editor_selection_changed,
591
563
                                       editor);
592
564
 
593
565
      gtk_tree_selection_unselect_path (editor->sel, editor->sel_path);
594
566
 
595
567
      g_signal_handlers_unblock_by_func (editor->sel,
596
 
                                         gimp_path_editor_selection_changed,
 
568
                                         gimp_path_editor_selection_changed,
597
569
                                         editor);
598
570
 
599
571
      gtk_tree_path_free (editor->sel_path);
681
653
    return;
682
654
 
683
655
  gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter,
684
 
                           editor->sel_path);
 
656
                           editor->sel_path);
685
657
 
686
658
  gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
687
659
                      COLUMN_WRITABLE, &dir_writable,
743
715
      return;
744
716
    }
745
717
 
746
 
  utf8 = g_filename_to_utf8 (dir, -1, NULL, NULL, NULL);
 
718
  utf8 = g_filename_display_name (dir);
747
719
 
748
720
  if (editor->sel_path == NULL)
749
721
    {
760
732
  else
761
733
    {
762
734
      gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter,
763
 
                               editor->sel_path);
 
735
                               editor->sel_path);
764
736
      gtk_list_store_set (editor->dir_list, &iter,
765
737
                          COLUMN_UTF8,      utf8,
766
738
                          COLUMN_DIRECTORY, dir,
801
773
      g_free (directory);
802
774
 
803
775
      if (editor->sel_path)
804
 
        gtk_tree_path_free (editor->sel_path);
 
776
        gtk_tree_path_free (editor->sel_path);
805
777
 
806
778
      editor->sel_path =
807
779
        gtk_tree_model_get_path (GTK_TREE_MODEL (editor->dir_list), &iter);