~noskcaj/ubuntu/vivid/thunar/1.6.4

« back to all changes in this revision

Viewing changes to plugins/thunar-uca/thunar-uca-editor.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2010-12-04 16:46:20 UTC
  • mto: (2.1.3 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: james.westby@ubuntu.com-20101204164620-h7p4t2e9z6hfhz6l
Tags: upstream-1.1.4
ImportĀ upstreamĀ versionĀ 1.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
 
37
37
 
38
 
static void           thunar_uca_editor_class_init      (ThunarUcaEditorClass   *klass);
39
 
static void           thunar_uca_editor_init            (ThunarUcaEditor        *uca_editor);
40
 
static void           thunar_uca_editor_finalize        (GObject                *object);
41
38
static const gchar   *thunar_uca_editor_get_icon_name   (const ThunarUcaEditor  *uca_editor);
42
39
static void           thunar_uca_editor_set_icon_name   (ThunarUcaEditor        *uca_editor,
43
40
                                                         const gchar            *icon_name);
58
55
{
59
56
  GtkDialog __parent__;
60
57
 
61
 
  GtkTooltips *tooltips;
62
 
 
63
58
  GtkWidget   *name_entry;
64
59
  GtkWidget   *description_entry;
65
60
  GtkWidget   *icon_button;
66
61
  GtkWidget   *command_entry;
 
62
  GtkWidget   *sn_button;
67
63
  GtkWidget   *parameter_entry;
68
64
  GtkWidget   *patterns_entry;
69
65
  GtkWidget   *directories_button;
83
79
static void
84
80
thunar_uca_editor_class_init (ThunarUcaEditorClass *klass)
85
81
{
86
 
  GObjectClass *gobject_class;
87
 
 
88
 
  gobject_class = G_OBJECT_CLASS (klass);
89
 
  gobject_class->finalize = thunar_uca_editor_finalize;
90
82
}
91
83
 
92
84
 
119
111
  gtk_window_set_destroy_with_parent (GTK_WINDOW (uca_editor), TRUE);
120
112
  gtk_window_set_resizable (GTK_WINDOW (uca_editor), FALSE);
121
113
 
122
 
  /* allocate shared tooltips object */
123
 
  uca_editor->tooltips = gtk_tooltips_new ();
124
 
  g_object_ref (G_OBJECT (uca_editor->tooltips));
125
 
  gtk_object_sink (GTK_OBJECT (uca_editor->tooltips));
126
 
 
127
114
  notebook = gtk_notebook_new ();
128
115
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
129
116
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (uca_editor)->vbox), notebook, TRUE, TRUE, 0);
133
120
     Basic
134
121
   */
135
122
  label = gtk_label_new (_("Basic"));
136
 
  table = gtk_table_new (6, 2, FALSE);
 
123
  table = gtk_table_new (7, 2, FALSE);
137
124
  gtk_table_set_col_spacings (GTK_TABLE (table), 12);
138
125
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
139
126
  gtk_container_set_border_width (GTK_CONTAINER (table), 12);
146
133
  gtk_widget_show (label);
147
134
 
148
135
  uca_editor->name_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, NULL);
149
 
  gtk_tooltips_set_tip (uca_editor->tooltips, uca_editor->name_entry, _("The name of the action that will be displayed in the context menu."), NULL);
 
136
  gtk_widget_set_tooltip_text (uca_editor->name_entry, _("The name of the action that will be displayed in the context menu."));
150
137
  gtk_table_attach (GTK_TABLE (table), uca_editor->name_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
151
138
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->name_entry);
152
139
  gtk_widget_grab_focus (uca_editor->name_entry);
164
151
  gtk_widget_show (label);
165
152
 
166
153
  uca_editor->description_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, NULL);
167
 
  gtk_tooltips_set_tip (uca_editor->tooltips, uca_editor->description_entry, _("The description of the action that will be displayed as tooltip "
168
 
                                                                               "in the statusbar when selecting the item from the context menu."), NULL);
 
154
  gtk_widget_set_tooltip_text (uca_editor->description_entry, _("The description of the action that will be displayed as tooltip "
 
155
                                                                "in the statusbar when selecting the item from the context menu."));
169
156
  gtk_table_attach (GTK_TABLE (table), uca_editor->description_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
170
157
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->description_entry);
171
158
  gtk_widget_show (uca_editor->description_entry);
186
173
  gtk_widget_show (hbox);
187
174
 
188
175
  uca_editor->command_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, NULL);
189
 
  gtk_tooltips_set_tip (uca_editor->tooltips, uca_editor->command_entry, _("The command (including the necessary parameters) to perform the action. "
190
 
                                                                           "See the command parameter legend below for a list of supported parameter "
191
 
                                                                           "variables, which will be substituted when launching the command. When "
192
 
                                                                           "upper-case letters (e.g. %F, %D, %N) are used, the action will be applicable "
193
 
                                                                           "even if more than one item is selected. Else the action will only be "
194
 
                                                                           "applicable if exactly one item is selected."), NULL);
 
176
  gtk_widget_set_tooltip_text (uca_editor->command_entry, _("The command (including the necessary parameters) to perform the action. "
 
177
                                                            "See the command parameter legend below for a list of supported parameter "
 
178
                                                            "variables, which will be substituted when launching the command. When "
 
179
                                                            "upper-case letters (e.g. %F, %D, %N) are used, the action will be applicable "
 
180
                                                            "even if more than one item is selected. Else the action will only be "
 
181
                                                            "applicable if exactly one item is selected."));
195
182
  gtk_box_pack_start (GTK_BOX (hbox), uca_editor->command_entry, TRUE, TRUE, 0);
196
183
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->command_entry);
197
184
  gtk_widget_show (uca_editor->command_entry);
198
185
 
199
186
  button = gtk_button_new ();
200
 
  gtk_tooltips_set_tip (uca_editor->tooltips, button, _("Browse the file system to select an application to use for this action."), NULL);
 
187
  gtk_widget_set_tooltip_text (button, _("Browse the file system to select an application to use for this action."));
201
188
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
202
189
  g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (thunar_uca_editor_command_clicked), uca_editor);
203
190
  gtk_widget_show (button);
213
200
  atk_relation_set_add (relations, relation);
214
201
  g_object_unref (G_OBJECT (relation));
215
202
 
 
203
  uca_editor->sn_button = gtk_check_button_new_with_label (_("Use Startup Notification"));
 
204
  gtk_widget_set_tooltip_text (uca_editor->sn_button, _("Enable this option if you want a waiting cursor to be shown while the "
 
205
                                                        "action is launched. This is also highly recommended if you have focus "
 
206
                                                        "stealing prevention enabled in your window manager."));
 
207
  gtk_table_attach (GTK_TABLE (table), uca_editor->sn_button, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
 
208
  gtk_widget_show (uca_editor->sn_button);
 
209
 
216
210
  label = g_object_new (GTK_TYPE_LABEL, "label", _("_Icon:"), "use-underline", TRUE, "xalign", 0.0f, NULL);
217
 
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
 
211
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
218
212
  gtk_widget_show (label);
219
213
 
220
214
  align = gtk_alignment_new (0.0f, 0.5f, 0.0f, 0.0f);
221
 
  gtk_table_attach (GTK_TABLE (table), align, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
 
215
  gtk_table_attach (GTK_TABLE (table), align, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
222
216
  gtk_widget_show (align);
223
217
 
224
218
  uca_editor->icon_button = gtk_button_new_with_label (_("No icon"));
225
 
  gtk_tooltips_set_tip (uca_editor->tooltips, uca_editor->icon_button, _("Click this button to select an icon file that will be displayed "
226
 
                                                                         "in the context menu in addition to the action name chosen above."), NULL);
 
219
  gtk_widget_set_tooltip_text (uca_editor->icon_button, _("Click this button to select an icon file that will be displayed "
 
220
                                                          "in the context menu in addition to the action name chosen above."));
227
221
  gtk_container_add (GTK_CONTAINER (align), uca_editor->icon_button);
228
222
  g_signal_connect_swapped (G_OBJECT (uca_editor->icon_button), "clicked", G_CALLBACK (thunar_uca_editor_icon_clicked), uca_editor);
229
223
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->icon_button);
237
231
  g_object_unref (G_OBJECT (relation));
238
232
 
239
233
  align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 12, NULL);
240
 
  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
 
234
  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
241
235
  gtk_widget_show (align);
242
236
 
243
237
  hbox = gtk_hbox_new (FALSE, 6);
244
 
  gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
 
238
  gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
245
239
  gtk_widget_show (hbox);
246
240
 
247
241
  image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DND);
378
372
  gtk_widget_show (label);
379
373
 
380
374
  uca_editor->patterns_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, "text", "*", NULL);
381
 
  gtk_tooltips_set_tip (uca_editor->tooltips, uca_editor->patterns_entry, _("Enter a list of patterns that will be used to determine "
382
 
                                                                            "whether this action should be displayed for a selected "
383
 
                                                                            "file. If you specify more than one pattern here, the list "
384
 
                                                                            "items must be separated with semicolons (e.g. *.txt;*.doc)."), NULL);
 
375
  gtk_widget_set_tooltip_text (uca_editor->patterns_entry, _("Enter a list of patterns that will be used to determine "
 
376
                                                             "whether this action should be displayed for a selected "
 
377
                                                             "file. If you specify more than one pattern here, the list "
 
378
                                                             "items must be separated with semicolons (e.g. *.txt;*.doc)."));
385
379
  gtk_table_attach (GTK_TABLE (table), uca_editor->patterns_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
386
380
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->patterns_entry);
387
381
  gtk_widget_show (uca_editor->patterns_entry);
465
459
 
466
460
 
467
461
static void
468
 
thunar_uca_editor_finalize (GObject *object)
469
 
{
470
 
  ThunarUcaEditor *uca_editor = THUNAR_UCA_EDITOR (object);
471
 
 
472
 
  /* release the tooltips */
473
 
  g_object_unref (G_OBJECT (uca_editor->tooltips));
474
 
 
475
 
  (*G_OBJECT_CLASS (thunar_uca_editor_parent_class)->finalize) (object);
476
 
}
477
 
 
478
 
 
479
 
 
480
 
static void
481
462
thunar_uca_editor_command_clicked (ThunarUcaEditor *uca_editor)
482
463
{
483
464
  GtkFileFilter *filter;
790
771
  gchar         *command;
791
772
  gchar         *icon;
792
773
  gchar         *name;
 
774
  gboolean       startup_notify;
793
775
 
794
776
  g_return_if_fail (THUNAR_UCA_IS_EDITOR (uca_editor));
795
777
  g_return_if_fail (THUNAR_UCA_IS_MODEL (uca_model));
803
785
                      THUNAR_UCA_MODEL_COLUMN_TYPES, &types,
804
786
                      THUNAR_UCA_MODEL_COLUMN_ICON, &icon,
805
787
                      THUNAR_UCA_MODEL_COLUMN_NAME, &name,
 
788
                      THUNAR_UCA_MODEL_COLUMN_STARTUP_NOTIFY, &startup_notify,
806
789
                      -1);
807
790
 
808
791
  /* setup the new selection */
816
799
  gtk_entry_set_text (GTK_ENTRY (uca_editor->patterns_entry), (patterns != NULL) ? patterns : "");
817
800
  gtk_entry_set_text (GTK_ENTRY (uca_editor->command_entry), (command != NULL) ? command : "");
818
801
  gtk_entry_set_text (GTK_ENTRY (uca_editor->name_entry), (name != NULL) ? name : "");
 
802
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (uca_editor->sn_button), startup_notify);
819
803
 
820
804
  /* cleanup */
821
805
  g_free (description);
850
834
                           gtk_entry_get_text (GTK_ENTRY (uca_editor->description_entry)),
851
835
                           thunar_uca_editor_get_icon_name (uca_editor),
852
836
                           gtk_entry_get_text (GTK_ENTRY (uca_editor->command_entry)),
 
837
                           gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (uca_editor->sn_button)),
853
838
                           gtk_entry_get_text (GTK_ENTRY (uca_editor->patterns_entry)),
854
839
                           thunar_uca_editor_get_types (uca_editor));
855
840
}