1 | /* |
---|
2 | * GNOME panel menu-properties module. |
---|
3 | * (C) 1997 The Free Software Foundation |
---|
4 | * |
---|
5 | * Authors: Miguel de Icaza |
---|
6 | * Federico Mena |
---|
7 | */ |
---|
8 | |
---|
9 | #include <config.h> |
---|
10 | #include <ctype.h> |
---|
11 | #include <stdio.h> |
---|
12 | #include <sys/types.h> |
---|
13 | #include <sys/stat.h> |
---|
14 | #include <sys/wait.h> |
---|
15 | #include <dirent.h> |
---|
16 | #include <unistd.h> |
---|
17 | #include <string.h> |
---|
18 | #include <limits.h> |
---|
19 | #include <errno.h> |
---|
20 | #include <gnome.h> |
---|
21 | |
---|
22 | #include "panel-include.h" |
---|
23 | |
---|
24 | #include "icon-entry-hack.h" |
---|
25 | |
---|
26 | /*#define PANEL_DEBUG 1*/ |
---|
27 | |
---|
28 | extern GlobalConfig global_config; |
---|
29 | |
---|
30 | extern int config_sync_timeout; |
---|
31 | extern int panels_to_sync; |
---|
32 | extern int applets_to_sync; |
---|
33 | extern int need_complete_save; |
---|
34 | |
---|
35 | |
---|
36 | struct _MenuDialogInfo { |
---|
37 | GtkWidget *main_menu; |
---|
38 | GtkWidget *global_main; |
---|
39 | GtkWidget *system; |
---|
40 | GtkWidget *system_sub; |
---|
41 | GtkWidget *user; |
---|
42 | GtkWidget *user_sub; |
---|
43 | GtkWidget *applets; |
---|
44 | GtkWidget *applets_sub; |
---|
45 | GtkWidget *distribution; |
---|
46 | GtkWidget *distribution_sub; |
---|
47 | GtkWidget *kde; |
---|
48 | GtkWidget *kde_sub; |
---|
49 | GtkWidget *panel; |
---|
50 | GtkWidget *panel_sub; |
---|
51 | GtkWidget *desktop; |
---|
52 | GtkWidget *desktop_sub; |
---|
53 | GtkWidget *pathentry; |
---|
54 | GtkWidget *custom_icon; |
---|
55 | GtkWidget *custom_icon_entry; |
---|
56 | |
---|
57 | GtkWidget *main_frame; |
---|
58 | GtkWidget *normal_frame; |
---|
59 | }; |
---|
60 | |
---|
61 | char * |
---|
62 | get_real_menu_path(const char *arguments) |
---|
63 | { |
---|
64 | char *this_menu; |
---|
65 | |
---|
66 | /*if null, let's put the main menu up*/ |
---|
67 | if (string_empty (arguments)) |
---|
68 | arguments = "."; |
---|
69 | |
---|
70 | if(strcmp(arguments, ".") == 0) |
---|
71 | this_menu = gnome_unconditional_datadir_file ("gnome/apps"); |
---|
72 | else if (*arguments == '/') |
---|
73 | this_menu = g_strdup (arguments); |
---|
74 | else if (*arguments == '~') |
---|
75 | this_menu = g_concat_dir_and_file (g_get_home_dir(), |
---|
76 | &arguments[1]); |
---|
77 | else |
---|
78 | this_menu = gnome_unconditional_datadir_file (arguments); |
---|
79 | |
---|
80 | if (!panel_file_exists (this_menu)) { |
---|
81 | g_warning("menu %s does not exist " |
---|
82 | "(arguments are %s)", |
---|
83 | this_menu, arguments); |
---|
84 | g_free (this_menu); |
---|
85 | return NULL; |
---|
86 | } |
---|
87 | return this_menu; |
---|
88 | } |
---|
89 | |
---|
90 | char * |
---|
91 | get_pixmap(const char *menudir, gboolean main_menu) |
---|
92 | { |
---|
93 | char *pixmap_name = NULL; |
---|
94 | if (main_menu) { |
---|
95 | pixmap_name = gnome_datadir_file("gnome/athena/menu-icon"); |
---|
96 | } else { |
---|
97 | char *dentry_name; |
---|
98 | GnomeDesktopEntry *item_info; |
---|
99 | |
---|
100 | dentry_name = g_concat_dir_and_file (menudir, |
---|
101 | ".directory"); |
---|
102 | item_info = gnome_desktop_entry_load (dentry_name); |
---|
103 | g_free (dentry_name); |
---|
104 | |
---|
105 | if(item_info && item_info->icon) |
---|
106 | pixmap_name = g_strdup(item_info->icon); |
---|
107 | else |
---|
108 | pixmap_name = |
---|
109 | gnome_unconditional_pixmap_file ("gnome-folder.png"); |
---|
110 | |
---|
111 | if (item_info) |
---|
112 | gnome_desktop_entry_free(item_info); |
---|
113 | } |
---|
114 | return pixmap_name; |
---|
115 | } |
---|
116 | |
---|
117 | /* Cache this, we don't want to check in the path all the time */ |
---|
118 | static gboolean |
---|
119 | got_gmenu (void) |
---|
120 | { |
---|
121 | static gboolean checked = FALSE; |
---|
122 | static gboolean got_it = FALSE; |
---|
123 | char *tmp; |
---|
124 | |
---|
125 | if (checked) |
---|
126 | return got_it; |
---|
127 | |
---|
128 | tmp = panel_is_program_in_path ("gmenu"); |
---|
129 | if (tmp != NULL) |
---|
130 | got_it = TRUE; |
---|
131 | else |
---|
132 | got_it = FALSE; |
---|
133 | |
---|
134 | g_free (tmp); |
---|
135 | |
---|
136 | checked = TRUE; |
---|
137 | |
---|
138 | return got_it; |
---|
139 | } |
---|
140 | |
---|
141 | static void |
---|
142 | properties_apply_callback (Menu *menu) |
---|
143 | { |
---|
144 | char *s; |
---|
145 | gboolean bool; |
---|
146 | gboolean change_icon = FALSE; |
---|
147 | gboolean need_reload = FALSE; |
---|
148 | char *old_path; |
---|
149 | gboolean old_global_main; |
---|
150 | int old_main_menu_flags; |
---|
151 | gboolean need_edit_menus, got_edit_menus; |
---|
152 | |
---|
153 | /* Store some old config */ |
---|
154 | old_path = g_strdup (menu->path); |
---|
155 | old_global_main = menu->global_main; |
---|
156 | old_main_menu_flags = menu->main_menu_flags; |
---|
157 | |
---|
158 | |
---|
159 | /* Start with the icon stuff */ |
---|
160 | bool = GTK_TOGGLE_BUTTON (menu->dialog_info->custom_icon)->active; |
---|
161 | if (( ! menu->custom_icon && bool) || |
---|
162 | (menu->custom_icon && ! bool)) { |
---|
163 | menu->custom_icon = bool; |
---|
164 | change_icon = TRUE; |
---|
165 | } |
---|
166 | |
---|
167 | s = hack_icon_entry_get_icon (GNOME_ICON_ENTRY(menu->dialog_info->custom_icon_entry)); |
---|
168 | if (menu->custom_icon_file == NULL || |
---|
169 | s == NULL || |
---|
170 | strcmp (menu->custom_icon_file, s) != 0) { |
---|
171 | g_free (menu->custom_icon_file); |
---|
172 | menu->custom_icon_file = s; |
---|
173 | change_icon = TRUE; |
---|
174 | } else { |
---|
175 | g_free (s); |
---|
176 | } |
---|
177 | |
---|
178 | need_edit_menus = FALSE; |
---|
179 | if (GTK_TOGGLE_BUTTON (menu->dialog_info->main_menu)->active || |
---|
180 | GTK_TOGGLE_BUTTON (menu->dialog_info->global_main)->active) { |
---|
181 | g_free (menu->path); |
---|
182 | menu->path = g_strdup ("."); |
---|
183 | |
---|
184 | if (got_gmenu ()) { |
---|
185 | need_edit_menus = TRUE; |
---|
186 | } |
---|
187 | } else { |
---|
188 | g_free (menu->path); |
---|
189 | s = gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (menu->dialog_info->pathentry), |
---|
190 | TRUE); |
---|
191 | if(s == NULL) { |
---|
192 | g_warning (_("Can't open directory, using main menu!")); |
---|
193 | menu->path = g_strdup ("."); |
---|
194 | } else if (*s == '\0') { |
---|
195 | menu->path = g_strdup ("."); |
---|
196 | } else { |
---|
197 | menu->path = g_strdup (s); |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | |
---|
202 | /* Setup the edit_menus callback */ |
---|
203 | if (applet_get_callback (menu->info->user_menu, "edit_menus") != NULL) |
---|
204 | got_edit_menus = TRUE; |
---|
205 | else |
---|
206 | got_edit_menus = FALSE; |
---|
207 | |
---|
208 | if (need_edit_menus && ! got_edit_menus) |
---|
209 | applet_add_callback (menu->info, "edit_menus", |
---|
210 | NULL, |
---|
211 | _("Edit menus...")); |
---|
212 | else if ( ! need_edit_menus && got_edit_menus) |
---|
213 | applet_remove_callback (menu->info, "edit_menus"); |
---|
214 | |
---|
215 | |
---|
216 | |
---|
217 | if (GTK_TOGGLE_BUTTON(menu->dialog_info->global_main)->active) |
---|
218 | menu->global_main = TRUE; |
---|
219 | else |
---|
220 | menu->global_main = FALSE; |
---|
221 | |
---|
222 | menu->main_menu_flags = 0; |
---|
223 | if (GTK_TOGGLE_BUTTON(menu->dialog_info->system_sub)->active) |
---|
224 | menu->main_menu_flags |= MAIN_MENU_SYSTEM_SUB; |
---|
225 | else if (GTK_TOGGLE_BUTTON(menu->dialog_info->system)->active) |
---|
226 | menu->main_menu_flags |= MAIN_MENU_SYSTEM; |
---|
227 | |
---|
228 | if(GTK_TOGGLE_BUTTON(menu->dialog_info->user_sub)->active) |
---|
229 | menu->main_menu_flags |= MAIN_MENU_USER_SUB; |
---|
230 | else if (GTK_TOGGLE_BUTTON (menu->dialog_info->user)->active) |
---|
231 | menu->main_menu_flags |= MAIN_MENU_USER; |
---|
232 | |
---|
233 | if(GTK_TOGGLE_BUTTON(menu->dialog_info->applets_sub)->active) |
---|
234 | menu->main_menu_flags |= MAIN_MENU_APPLETS_SUB; |
---|
235 | else if (GTK_TOGGLE_BUTTON (menu->dialog_info->applets)->active) |
---|
236 | menu->main_menu_flags |= MAIN_MENU_APPLETS; |
---|
237 | |
---|
238 | if(GTK_TOGGLE_BUTTON(menu->dialog_info->distribution_sub)->active) |
---|
239 | menu->main_menu_flags |= MAIN_MENU_DISTRIBUTION_SUB; |
---|
240 | else if (GTK_TOGGLE_BUTTON (menu->dialog_info->distribution)->active) |
---|
241 | menu->main_menu_flags |= MAIN_MENU_DISTRIBUTION; |
---|
242 | |
---|
243 | if(GTK_TOGGLE_BUTTON(menu->dialog_info->kde_sub)->active) |
---|
244 | menu->main_menu_flags |= MAIN_MENU_KDE_SUB; |
---|
245 | else if (GTK_TOGGLE_BUTTON (menu->dialog_info->kde)->active) |
---|
246 | menu->main_menu_flags |= MAIN_MENU_KDE; |
---|
247 | |
---|
248 | if(GTK_TOGGLE_BUTTON(menu->dialog_info->panel_sub)->active) |
---|
249 | menu->main_menu_flags |= MAIN_MENU_PANEL_SUB; |
---|
250 | else if (GTK_TOGGLE_BUTTON(menu->dialog_info->panel)->active) |
---|
251 | menu->main_menu_flags |= MAIN_MENU_PANEL; |
---|
252 | |
---|
253 | if(GTK_TOGGLE_BUTTON(menu->dialog_info->desktop_sub)->active) |
---|
254 | menu->main_menu_flags |= MAIN_MENU_DESKTOP_SUB; |
---|
255 | else if (GTK_TOGGLE_BUTTON(menu->dialog_info->desktop)->active) |
---|
256 | menu->main_menu_flags |= MAIN_MENU_DESKTOP; |
---|
257 | |
---|
258 | if (strcmp (old_path, menu->path) != 0) { |
---|
259 | need_reload = TRUE; |
---|
260 | change_icon = TRUE; |
---|
261 | } |
---|
262 | |
---|
263 | if (old_main_menu_flags != menu->main_menu_flags || |
---|
264 | ( ! menu->global_main && old_global_main) || |
---|
265 | (menu->global_main && ! old_global_main)) { |
---|
266 | need_reload = TRUE; |
---|
267 | } |
---|
268 | |
---|
269 | g_free (old_path); |
---|
270 | |
---|
271 | |
---|
272 | /* Apply menu changes */ |
---|
273 | if (need_reload) { |
---|
274 | char *this_menu = get_real_menu_path (menu->path); |
---|
275 | GSList *list = g_slist_append (NULL, this_menu); |
---|
276 | gboolean main_menu = strcmp (menu->path, ".") == 0; |
---|
277 | |
---|
278 | add_menu_widget (menu, PANEL_WIDGET (menu->button->parent), |
---|
279 | list, main_menu, TRUE); |
---|
280 | |
---|
281 | g_free (this_menu); |
---|
282 | |
---|
283 | g_slist_free (list); |
---|
284 | } |
---|
285 | |
---|
286 | /* Apply icon changes */ |
---|
287 | if (change_icon) { |
---|
288 | char *this_menu = get_real_menu_path(menu->path); |
---|
289 | char *pixmap_name; |
---|
290 | |
---|
291 | if (menu->custom_icon && |
---|
292 | menu->custom_icon_file != NULL && |
---|
293 | panel_file_exists (menu->custom_icon_file)) |
---|
294 | pixmap_name = g_strdup (menu->custom_icon_file); |
---|
295 | else |
---|
296 | pixmap_name = get_pixmap(this_menu, (strcmp (menu->path, ".") == 0)); |
---|
297 | button_widget_set_pixmap(BUTTON_WIDGET(menu->button), |
---|
298 | pixmap_name, -1); |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | static void |
---|
303 | properties_close_callback(GtkWidget *widget, gpointer data) |
---|
304 | { |
---|
305 | Menu *menu = data; |
---|
306 | |
---|
307 | menu->prop_dialog = NULL; |
---|
308 | |
---|
309 | g_free (menu->dialog_info); |
---|
310 | menu->dialog_info = NULL; |
---|
311 | } |
---|
312 | |
---|
313 | static void |
---|
314 | toggle_prop(GtkWidget *widget, gpointer data) |
---|
315 | { |
---|
316 | Menu *menu = data; |
---|
317 | |
---|
318 | if(GTK_TOGGLE_BUTTON(widget)->active) |
---|
319 | properties_apply_callback (menu); |
---|
320 | } |
---|
321 | |
---|
322 | static void |
---|
323 | toggle_global_main(GtkWidget *widget, gpointer data) |
---|
324 | { |
---|
325 | Menu *menu = data; |
---|
326 | |
---|
327 | if(GTK_TOGGLE_BUTTON(widget)->active) { |
---|
328 | gtk_widget_set_sensitive(menu->dialog_info->main_frame, FALSE); |
---|
329 | gtk_widget_set_sensitive(menu->dialog_info->normal_frame, FALSE); |
---|
330 | |
---|
331 | properties_apply_callback (menu); |
---|
332 | } |
---|
333 | } |
---|
334 | |
---|
335 | static void |
---|
336 | toggle_main_menu(GtkWidget *widget, gpointer data) |
---|
337 | { |
---|
338 | Menu *menu = data; |
---|
339 | |
---|
340 | if(GTK_TOGGLE_BUTTON(widget)->active) { |
---|
341 | gtk_widget_set_sensitive(menu->dialog_info->main_frame, TRUE); |
---|
342 | gtk_widget_set_sensitive(menu->dialog_info->normal_frame, FALSE); |
---|
343 | |
---|
344 | properties_apply_callback (menu); |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | static void |
---|
349 | toggle_custom_icon(GtkWidget *widget, gpointer data) |
---|
350 | { |
---|
351 | Menu *menu = data; |
---|
352 | |
---|
353 | if(GTK_TOGGLE_BUTTON(widget)->active) { |
---|
354 | gtk_widget_set_sensitive(menu->dialog_info->custom_icon_entry, TRUE); |
---|
355 | } else { |
---|
356 | gtk_widget_set_sensitive(menu->dialog_info->custom_icon_entry, FALSE); |
---|
357 | } |
---|
358 | |
---|
359 | properties_apply_callback (menu); |
---|
360 | } |
---|
361 | |
---|
362 | static void |
---|
363 | toggle_normal_menu(GtkWidget *widget, gpointer data) |
---|
364 | { |
---|
365 | Menu *menu = data; |
---|
366 | |
---|
367 | if(GTK_TOGGLE_BUTTON(widget)->active) { |
---|
368 | gtk_widget_set_sensitive(menu->dialog_info->main_frame, FALSE); |
---|
369 | gtk_widget_set_sensitive(menu->dialog_info->normal_frame, TRUE); |
---|
370 | |
---|
371 | properties_apply_callback (menu); |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | static void |
---|
376 | textbox_changed (GtkWidget *widget, gpointer data) |
---|
377 | { |
---|
378 | Menu *menu = data; |
---|
379 | |
---|
380 | properties_apply_callback (menu); |
---|
381 | } |
---|
382 | |
---|
383 | static void |
---|
384 | add_menu_type_options(Menu *menu, GtkObject *dialog, GtkTable *table, int row, |
---|
385 | char *title, GtkWidget **widget, GtkWidget **widget_sub, |
---|
386 | gboolean on, gboolean sub) |
---|
387 | { |
---|
388 | GtkWidget *w; |
---|
389 | GtkWidget *rb; |
---|
390 | |
---|
391 | w = gtk_label_new(title); |
---|
392 | gtk_table_attach_defaults(table,w,0,1,row,row+1); |
---|
393 | |
---|
394 | rb = w = gtk_radio_button_new_with_label (NULL, _("Off")); |
---|
395 | gtk_table_attach_defaults(table,w,3,4,row,row+1); |
---|
396 | |
---|
397 | if(!on && !sub) |
---|
398 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),TRUE); |
---|
399 | gtk_signal_connect (GTK_OBJECT (w), "toggled", |
---|
400 | GTK_SIGNAL_FUNC (toggle_prop), |
---|
401 | menu); |
---|
402 | |
---|
403 | w = gtk_radio_button_new_with_label (gtk_radio_button_group(GTK_RADIO_BUTTON(rb)), |
---|
404 | _("In a submenu")); |
---|
405 | gtk_table_attach_defaults(table, w, 2, 3, row, row+1); |
---|
406 | |
---|
407 | *widget_sub = w; |
---|
408 | |
---|
409 | if (sub) |
---|
410 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),TRUE); |
---|
411 | gtk_signal_connect (GTK_OBJECT (w), "toggled", |
---|
412 | GTK_SIGNAL_FUNC (toggle_prop), |
---|
413 | menu); |
---|
414 | |
---|
415 | w = gtk_radio_button_new_with_label (gtk_radio_button_group(GTK_RADIO_BUTTON(rb)), |
---|
416 | _("On the main menu")); |
---|
417 | *widget = w; |
---|
418 | gtk_table_attach_defaults(table, w, 1, 2, row, row+1); |
---|
419 | if (on) |
---|
420 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),TRUE); |
---|
421 | gtk_signal_connect (GTK_OBJECT (w), "toggled", |
---|
422 | GTK_SIGNAL_FUNC (toggle_prop), |
---|
423 | menu); |
---|
424 | } |
---|
425 | |
---|
426 | static void |
---|
427 | dialog_clicked (GtkWidget *widget, int button, gpointer data) |
---|
428 | { |
---|
429 | Menu *menu = data; |
---|
430 | |
---|
431 | if (button == 0 /* close */) { |
---|
432 | gnome_dialog_close (GNOME_DIALOG (widget)); |
---|
433 | } else if (button == 1 /* help */) { |
---|
434 | if (GTK_TOGGLE_BUTTON (menu->dialog_info->main_menu)->active) |
---|
435 | panel_show_help ("mainmenu.html#MAINMENUCONFIG"); |
---|
436 | else |
---|
437 | panel_show_help ("menus.html"); |
---|
438 | } |
---|
439 | } |
---|
440 | |
---|
441 | static GtkWidget * |
---|
442 | create_properties_dialog(Menu *menu) |
---|
443 | { |
---|
444 | GtkWidget *dialog, *notebook; |
---|
445 | GtkWidget *vbox; |
---|
446 | GtkWidget *box; |
---|
447 | GtkWidget *table; |
---|
448 | GtkWidget *w, *w2; |
---|
449 | GtkWidget *f; |
---|
450 | GtkWidget *t; |
---|
451 | GtkWidget *main_menu, *global_main; |
---|
452 | |
---|
453 | dialog = gnome_dialog_new (_("Menu properties"), |
---|
454 | GNOME_STOCK_BUTTON_CLOSE, |
---|
455 | GNOME_STOCK_BUTTON_HELP, |
---|
456 | NULL); |
---|
457 | gnome_dialog_set_close (GNOME_DIALOG (dialog), |
---|
458 | FALSE /* click_closes */); |
---|
459 | |
---|
460 | menu->prop_dialog = dialog; |
---|
461 | |
---|
462 | menu->dialog_info = g_new0 (MenuDialogInfo, 1); |
---|
463 | |
---|
464 | notebook = gtk_notebook_new (); |
---|
465 | gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), |
---|
466 | notebook, TRUE, TRUE, 0); |
---|
467 | |
---|
468 | gtk_window_set_wmclass(GTK_WINDOW(dialog), |
---|
469 | "menu_properties", "Panel"); |
---|
470 | gtk_window_set_title(GTK_WINDOW(dialog), _("Menu properties")); |
---|
471 | /*gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);*/ |
---|
472 | gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, TRUE); |
---|
473 | |
---|
474 | vbox = gtk_vbox_new(FALSE,GNOME_PAD_SMALL); |
---|
475 | gtk_container_set_border_width(GTK_CONTAINER(vbox),GNOME_PAD_SMALL); |
---|
476 | |
---|
477 | f = gtk_frame_new(_("Menu type")); |
---|
478 | gtk_box_pack_start(GTK_BOX(vbox),f,FALSE,FALSE,0); |
---|
479 | |
---|
480 | box = gtk_hbox_new(FALSE,GNOME_PAD_SMALL); |
---|
481 | gtk_container_set_border_width(GTK_CONTAINER(box),GNOME_PAD_SMALL); |
---|
482 | gtk_container_add(GTK_CONTAINER(f),box); |
---|
483 | |
---|
484 | w = gtk_radio_button_new_with_label (NULL, _("Panel context menu")); |
---|
485 | global_main = w; |
---|
486 | menu->dialog_info->global_main = w; |
---|
487 | if((menu->path == NULL || |
---|
488 | strcmp(menu->path, ".") == 0) && |
---|
489 | menu->global_main) |
---|
490 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE); |
---|
491 | gtk_signal_connect (GTK_OBJECT (w), "toggled", |
---|
492 | GTK_SIGNAL_FUNC (toggle_global_main), |
---|
493 | menu); |
---|
494 | gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0); |
---|
495 | |
---|
496 | w = gtk_radio_button_new_with_label ( |
---|
497 | gtk_radio_button_group (GTK_RADIO_BUTTON (global_main)), |
---|
498 | _("Main menu")); |
---|
499 | main_menu = w; |
---|
500 | menu->dialog_info->main_menu = w; |
---|
501 | if((menu->path == NULL || |
---|
502 | strcmp(menu->path, ".") == 0) && |
---|
503 | ! menu->global_main) |
---|
504 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE); |
---|
505 | gtk_signal_connect (GTK_OBJECT (w), "toggled", |
---|
506 | GTK_SIGNAL_FUNC (toggle_main_menu), |
---|
507 | menu); |
---|
508 | gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0); |
---|
509 | |
---|
510 | w2 = gtk_radio_button_new_with_label ( |
---|
511 | gtk_radio_button_group (GTK_RADIO_BUTTON (global_main)), |
---|
512 | _("Normal menu")); |
---|
513 | if(menu->path && strcmp(menu->path, ".") != 0) |
---|
514 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w2), TRUE); |
---|
515 | gtk_signal_connect (GTK_OBJECT (w2), "toggled", |
---|
516 | GTK_SIGNAL_FUNC (toggle_normal_menu), |
---|
517 | menu); |
---|
518 | gtk_box_pack_start(GTK_BOX(box), w2, TRUE, TRUE, 0); |
---|
519 | |
---|
520 | f = gtk_frame_new(_("Main menu")); |
---|
521 | if((menu->path && |
---|
522 | strcmp(menu->path, ".") != 0) || |
---|
523 | menu->global_main) |
---|
524 | gtk_widget_set_sensitive(f, FALSE); |
---|
525 | menu->dialog_info->main_frame = f; |
---|
526 | gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 0); |
---|
527 | |
---|
528 | table = gtk_table_new(7, 4, FALSE); |
---|
529 | gtk_container_set_border_width(GTK_CONTAINER(table), GNOME_PAD_SMALL); |
---|
530 | gtk_container_add(GTK_CONTAINER(f), table); |
---|
531 | |
---|
532 | add_menu_type_options(menu, |
---|
533 | GTK_OBJECT(dialog), GTK_TABLE(table),0, |
---|
534 | _("Programs: "), |
---|
535 | &menu->dialog_info->system, |
---|
536 | &menu->dialog_info->system_sub, |
---|
537 | menu->main_menu_flags & MAIN_MENU_SYSTEM, |
---|
538 | menu->main_menu_flags & MAIN_MENU_SYSTEM_SUB); |
---|
539 | add_menu_type_options(menu, |
---|
540 | GTK_OBJECT(dialog), GTK_TABLE(table),1, |
---|
541 | _("Favorites: "), |
---|
542 | &menu->dialog_info->user, |
---|
543 | &menu->dialog_info->user_sub, |
---|
544 | menu->main_menu_flags & MAIN_MENU_USER, |
---|
545 | menu->main_menu_flags & MAIN_MENU_USER_SUB); |
---|
546 | add_menu_type_options(menu, |
---|
547 | GTK_OBJECT(dialog), GTK_TABLE(table),2, |
---|
548 | _("Applets: "), |
---|
549 | &menu->dialog_info->applets, |
---|
550 | &menu->dialog_info->applets_sub, |
---|
551 | menu->main_menu_flags & MAIN_MENU_APPLETS, |
---|
552 | menu->main_menu_flags & MAIN_MENU_APPLETS_SUB); |
---|
553 | add_menu_type_options(menu, |
---|
554 | GTK_OBJECT(dialog), GTK_TABLE(table),3, |
---|
555 | _("Distribution menu (if found): "), |
---|
556 | &menu->dialog_info->distribution, |
---|
557 | &menu->dialog_info->distribution_sub, |
---|
558 | menu->main_menu_flags & MAIN_MENU_DISTRIBUTION, |
---|
559 | menu->main_menu_flags & MAIN_MENU_DISTRIBUTION_SUB); |
---|
560 | add_menu_type_options(menu, |
---|
561 | GTK_OBJECT(dialog), GTK_TABLE(table),4, |
---|
562 | _("KDE menu (if found): "), |
---|
563 | &menu->dialog_info->kde, |
---|
564 | &menu->dialog_info->kde_sub, |
---|
565 | menu->main_menu_flags & MAIN_MENU_KDE, |
---|
566 | menu->main_menu_flags & MAIN_MENU_KDE_SUB); |
---|
567 | add_menu_type_options(menu, |
---|
568 | GTK_OBJECT(dialog), GTK_TABLE(table),6, |
---|
569 | _("Panel menu: "), |
---|
570 | &menu->dialog_info->panel, |
---|
571 | &menu->dialog_info->panel_sub, |
---|
572 | menu->main_menu_flags & MAIN_MENU_PANEL, |
---|
573 | menu->main_menu_flags & MAIN_MENU_PANEL_SUB); |
---|
574 | add_menu_type_options(menu, |
---|
575 | GTK_OBJECT(dialog), GTK_TABLE(table),7, |
---|
576 | _("Desktop menu: "), |
---|
577 | &menu->dialog_info->desktop, |
---|
578 | &menu->dialog_info->desktop_sub, |
---|
579 | menu->main_menu_flags & MAIN_MENU_DESKTOP, |
---|
580 | menu->main_menu_flags & MAIN_MENU_DESKTOP_SUB); |
---|
581 | |
---|
582 | f = gtk_frame_new(_("Normal menu")); |
---|
583 | if(menu->path == NULL || |
---|
584 | strcmp(menu->path, ".") == 0) |
---|
585 | gtk_widget_set_sensitive(f, FALSE); |
---|
586 | menu->dialog_info->normal_frame = f; |
---|
587 | gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 0); |
---|
588 | |
---|
589 | box = gtk_hbox_new(FALSE, GNOME_PAD_SMALL); |
---|
590 | gtk_container_set_border_width(GTK_CONTAINER(box), GNOME_PAD_SMALL); |
---|
591 | gtk_container_add(GTK_CONTAINER(f), box); |
---|
592 | |
---|
593 | w = gtk_label_new(_("Menu path")); |
---|
594 | gtk_box_pack_start(GTK_BOX(box), w, FALSE, FALSE, 0); |
---|
595 | |
---|
596 | w = gnome_file_entry_new("menu_path",_("Browse")); |
---|
597 | gnome_file_entry_set_directory(GNOME_FILE_ENTRY(w), TRUE); |
---|
598 | |
---|
599 | t = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (w)); |
---|
600 | menu->dialog_info->pathentry = w; |
---|
601 | if (menu->path) { |
---|
602 | char *s = get_real_menu_path(menu->path); |
---|
603 | gtk_entry_set_text(GTK_ENTRY(t), s); |
---|
604 | g_free(s); |
---|
605 | } |
---|
606 | gtk_box_pack_start(GTK_BOX(box),w,TRUE,TRUE,0); |
---|
607 | gtk_signal_connect (GTK_OBJECT (t), "changed", |
---|
608 | GTK_SIGNAL_FUNC (textbox_changed), |
---|
609 | menu); |
---|
610 | |
---|
611 | gtk_notebook_append_page (GTK_NOTEBOOK(notebook), |
---|
612 | vbox, gtk_label_new (_("Menu"))); |
---|
613 | |
---|
614 | vbox = gtk_vbox_new(FALSE, GNOME_PAD_SMALL); |
---|
615 | gtk_container_set_border_width(GTK_CONTAINER(vbox), GNOME_PAD_SMALL); |
---|
616 | |
---|
617 | f = gtk_frame_new(_("Icon")); |
---|
618 | gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 0); |
---|
619 | |
---|
620 | box = gtk_vbox_new(FALSE, GNOME_PAD_SMALL); |
---|
621 | gtk_container_set_border_width(GTK_CONTAINER(box), GNOME_PAD_SMALL); |
---|
622 | gtk_container_add(GTK_CONTAINER(f), box); |
---|
623 | |
---|
624 | w = gtk_check_button_new_with_label (_("Use custom icon for panel button")); |
---|
625 | menu->dialog_info->custom_icon = w; |
---|
626 | if(menu->custom_icon && |
---|
627 | menu->custom_icon_file != NULL) |
---|
628 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE); |
---|
629 | gtk_signal_connect (GTK_OBJECT (w), "toggled", |
---|
630 | GTK_SIGNAL_FUNC (toggle_custom_icon), |
---|
631 | menu); |
---|
632 | gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0); |
---|
633 | |
---|
634 | w = gnome_icon_entry_new("icon", _("Browse")); |
---|
635 | hack_icon_entry (GNOME_ICON_ENTRY (w)); |
---|
636 | menu->dialog_info->custom_icon_entry = w; |
---|
637 | if (menu->custom_icon_file != NULL) { |
---|
638 | hack_icon_entry_set_icon(GNOME_ICON_ENTRY(w), |
---|
639 | menu->custom_icon_file); |
---|
640 | } |
---|
641 | if ( ! menu->custom_icon) { |
---|
642 | gtk_widget_set_sensitive (w, FALSE); |
---|
643 | } |
---|
644 | gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0); |
---|
645 | t = gnome_icon_entry_gtk_entry (GNOME_ICON_ENTRY (w)); |
---|
646 | gtk_signal_connect (GTK_OBJECT (t), "changed", |
---|
647 | GTK_SIGNAL_FUNC (textbox_changed), |
---|
648 | menu); |
---|
649 | |
---|
650 | gtk_widget_grab_focus (global_main); |
---|
651 | |
---|
652 | gtk_notebook_append_page (GTK_NOTEBOOK(notebook), |
---|
653 | vbox, gtk_label_new (_("Icon"))); |
---|
654 | |
---|
655 | gtk_signal_connect (GTK_OBJECT(dialog), "destroy", |
---|
656 | GTK_SIGNAL_FUNC (properties_close_callback), |
---|
657 | menu); |
---|
658 | |
---|
659 | gtk_signal_connect (GTK_OBJECT (dialog), "clicked", |
---|
660 | GTK_SIGNAL_FUNC (dialog_clicked), |
---|
661 | menu); |
---|
662 | |
---|
663 | return dialog; |
---|
664 | } |
---|
665 | |
---|
666 | void |
---|
667 | menu_properties (Menu *menu) |
---|
668 | { |
---|
669 | GtkWidget *dialog; |
---|
670 | |
---|
671 | g_return_if_fail (menu != NULL); |
---|
672 | |
---|
673 | if (menu->prop_dialog != NULL) { |
---|
674 | gtk_widget_show_now (menu->prop_dialog); |
---|
675 | gdk_window_raise (menu->prop_dialog->window); |
---|
676 | return; |
---|
677 | } |
---|
678 | |
---|
679 | dialog = create_properties_dialog (menu); |
---|
680 | gtk_widget_show_all (dialog); |
---|
681 | } |
---|