menu-properties.c 17.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * GNOME panel menu-properties module.
 * (C) 1997 The Free Software Foundation
 *
 * Authors: Miguel de Icaza
 *          Federico Mena
 */

#include <config.h>
#include <ctype.h>
#include <stdio.h>
12
#include <sys/types.h>
13 14 15 16 17 18 19 20
#include <sys/stat.h>
#include <sys/wait.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <errno.h>

21
#include <libgnomeui/libgnomeui.h>
Mark McLoughlin's avatar
Mark McLoughlin committed
22
#include <libgnome/libgnome.h>
23

Mark McLoughlin's avatar
Mark McLoughlin committed
24 25
#include "gnome-desktop-item.h"

26 27
#include "quick-desktop-reader.h"
#include "panel-util.h"
28
#include "xstuff.h"
29

Mark McLoughlin's avatar
Mark McLoughlin committed
30 31
#include "menu-properties.h"

32
#undef MENU_PROPERTIES_DEBUG
33

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
struct _MenuDialogInfo {
	GtkWidget *main_menu;
	GtkWidget *global_main;
	GtkWidget *system;
	GtkWidget *system_sub;
	GtkWidget *applets;
	GtkWidget *applets_sub;
	GtkWidget *distribution;
	GtkWidget *distribution_sub;
 	GtkWidget *kde;
 	GtkWidget *kde_sub;
	GtkWidget *panel;
	GtkWidget *panel_sub;
	GtkWidget *desktop;
	GtkWidget *desktop_sub;
	GtkWidget *pathentry;
	GtkWidget *custom_icon;
	GtkWidget *custom_icon_entry;

	GtkWidget *main_frame;
	GtkWidget *normal_frame;
};

57
char *
58
get_real_menu_path (const char *arguments, gboolean main_menu)
59
{
60
	if (main_menu)
61
		return g_strdup ("applications:");
62
	
63
	else if (*arguments == '~')
64
		/* FIXME: this needs to be a URI */
65
		return g_build_filename (g_get_home_dir(),
66
					      &arguments[1], NULL);
67
	else
68
		return g_strdup (arguments);
69 70 71
}

char *
72
get_pixmap (const char *menudir, gboolean main_menu)
73
{
74
	char *pixmap_name = NULL;
75

76
	if (main_menu) {
77 78
		pixmap_name = panel_pixmap_discovery ("gnome-logo-icon-transparent.png",
						      TRUE /* fallback */);
79 80
	} else {
		char *dentry_name;
81 82 83 84 85 86 87 88 89
		QuickDesktopItem *qitem;

		dentry_name = g_build_path ("/",
					    menudir,
					    ".directory",
					    NULL);
		qitem = quick_desktop_item_load_uri (dentry_name,
						     NULL /* expected_type */,
						     FALSE /* run_tryexec */);
90 91
		g_free (dentry_name);

92 93
		if (qitem != NULL)
			pixmap_name = quick_desktop_item_find_icon (qitem->icon);
94

95
		if (pixmap_name == NULL)
96 97
			pixmap_name = panel_pixmap_discovery ("gnome-folder.png",
							      TRUE /* fallback */);
98

99 100
		if (qitem != NULL)
			quick_desktop_item_destroy (qitem);
101 102 103 104 105
	}
	return pixmap_name;
}

static void
106
properties_apply_callback (Menu *menu)
107 108
{
	char *s;
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
	gboolean bool;
	gboolean change_icon = FALSE;
	gboolean need_reload = FALSE;
	char *old_path;
	gboolean old_global_main;
	int old_main_menu_flags;
	gboolean need_edit_menus, got_edit_menus;

	/* Store some old config */
	old_path = g_strdup (menu->path);
	old_global_main = menu->global_main;
	old_main_menu_flags = menu->main_menu_flags;


	/* Start with the icon stuff */
	bool = GTK_TOGGLE_BUTTON (menu->dialog_info->custom_icon)->active;
	if (( ! menu->custom_icon && bool) ||
	    (menu->custom_icon && ! bool)) {
		menu->custom_icon = bool;
		change_icon = TRUE;
	}
130

131
	s = gnome_icon_entry_get_filename (GNOME_ICON_ENTRY(menu->dialog_info->custom_icon_entry));
132 133 134 135 136 137 138 139 140
	if (menu->custom_icon_file == NULL ||
	    s == NULL ||
	    strcmp (menu->custom_icon_file, s) != 0) {
		g_free (menu->custom_icon_file);
		menu->custom_icon_file = s;
		change_icon = TRUE;
	} else {
		g_free (s);
	}
141

142
	need_edit_menus = FALSE;
143 144 145 146

	/* default to non-main-menu */
	menu->main_menu = FALSE;

147 148
	if (GTK_TOGGLE_BUTTON (menu->dialog_info->main_menu)->active ||
	    GTK_TOGGLE_BUTTON (menu->dialog_info->global_main)->active) {
149
		menu->main_menu = TRUE;
150

151
		need_edit_menus = TRUE;
152
	} else {
153 154
		s = gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (menu->dialog_info->pathentry),
						    TRUE);
155
		if(s == NULL) {
156
			g_warning (_("Can't open directory, using main menu!"));
157
			menu->main_menu = TRUE;
158
		} else if (*s == '\0') {
159
			menu->main_menu = TRUE;
160
		} else {
161
			g_free (menu->path);
162 163
			menu->path = g_strdup (s);
		}
164
	}
165

166
	/* Setup the edit_menus callback */
167
	if (panel_applet_get_callback (menu->info->user_menu, "edit_menus"))
168 169 170 171 172
		got_edit_menus = TRUE;
	else
		got_edit_menus = FALSE;

	if (need_edit_menus && ! got_edit_menus)
173 174 175 176 177 178 179
		panel_applet_add_callback (menu->info,
					   "edit_menus",
					   NULL,
					   _("Edit menus..."));

	else if (!need_edit_menus && got_edit_menus)
		panel_applet_remove_callback (menu->info, "edit_menus");
180 181 182



183
	if (GTK_TOGGLE_BUTTON(menu->dialog_info->global_main)->active)
184 185 186 187
		 menu->global_main = TRUE;
	else
		 menu->global_main = FALSE;

188
	menu->main_menu_flags = 0;
189
	if (GTK_TOGGLE_BUTTON(menu->dialog_info->system_sub)->active)
190
		menu->main_menu_flags |= MAIN_MENU_SYSTEM_SUB;
191
	else if (GTK_TOGGLE_BUTTON(menu->dialog_info->system)->active)
192
		menu->main_menu_flags |= MAIN_MENU_SYSTEM;
193

194
	if(GTK_TOGGLE_BUTTON(menu->dialog_info->applets_sub)->active)
195
		menu->main_menu_flags |= MAIN_MENU_APPLETS_SUB;
196
	else if (GTK_TOGGLE_BUTTON (menu->dialog_info->applets)->active)
197
		menu->main_menu_flags |= MAIN_MENU_APPLETS;
198

199
	if(GTK_TOGGLE_BUTTON(menu->dialog_info->distribution_sub)->active)
200
		menu->main_menu_flags |= MAIN_MENU_DISTRIBUTION_SUB;
201
	else if (GTK_TOGGLE_BUTTON (menu->dialog_info->distribution)->active)
202
		menu->main_menu_flags |= MAIN_MENU_DISTRIBUTION;
203

204
	if(GTK_TOGGLE_BUTTON(menu->dialog_info->kde_sub)->active)
205
		menu->main_menu_flags |= MAIN_MENU_KDE_SUB;
206
	else if (GTK_TOGGLE_BUTTON (menu->dialog_info->kde)->active)
207
		menu->main_menu_flags |= MAIN_MENU_KDE;
208

209
	if(GTK_TOGGLE_BUTTON(menu->dialog_info->panel_sub)->active)
210
		menu->main_menu_flags |= MAIN_MENU_PANEL_SUB;
211
	else if (GTK_TOGGLE_BUTTON(menu->dialog_info->panel)->active)
212 213
		menu->main_menu_flags |= MAIN_MENU_PANEL;

214
	if(GTK_TOGGLE_BUTTON(menu->dialog_info->desktop_sub)->active)
215
		menu->main_menu_flags |= MAIN_MENU_DESKTOP_SUB;
216
	else if (GTK_TOGGLE_BUTTON(menu->dialog_info->desktop)->active)
217
		menu->main_menu_flags |= MAIN_MENU_DESKTOP;
218

219 220 221 222 223 224 225 226 227 228 229 230 231
	if (strcmp (old_path, menu->path) != 0) {
		need_reload = TRUE;
		change_icon = TRUE;
	}

	if (old_main_menu_flags != menu->main_menu_flags ||
	    ( ! menu->global_main && old_global_main) ||
	    (menu->global_main && ! old_global_main)) {
		need_reload = TRUE;
	}

	g_free (old_path);

232 233

	/* Apply menu changes */
234
	if (need_reload) {
235
		char *this_menu = get_real_menu_path (menu->path, menu->main_menu);
236
		GSList *list = g_slist_append (NULL, this_menu);
237
		
238
		add_menu_widget (menu, PANEL_WIDGET (menu->button->parent),
239
				 list, TRUE);
240
		
241
		g_free (this_menu);
242

243
		g_slist_free (list);
244
	}
245 246

	/* Apply icon changes */
247
	if (change_icon) {
248 249
		char *this_menu = get_real_menu_path (menu->path,
						      menu->main_menu);
250 251 252 253
		char *pixmap_name;

		if (menu->custom_icon &&
		    menu->custom_icon_file != NULL &&
254
		    g_file_test (menu->custom_icon_file, G_FILE_TEST_EXISTS))
255 256
			pixmap_name = g_strdup (menu->custom_icon_file);
		else
257
			pixmap_name = get_pixmap (this_menu, menu->main_menu);
258 259 260
		button_widget_set_pixmap(BUTTON_WIDGET(menu->button),
					 pixmap_name, -1);
	}
261 262 263 264 265 266
}

static void
properties_close_callback(GtkWidget *widget, gpointer data)
{
	Menu *menu = data;
267 268 269 270 271

	menu->prop_dialog = NULL;

	g_free (menu->dialog_info);
	menu->dialog_info = NULL;
272 273 274 275 276
}

static void
toggle_prop(GtkWidget *widget, gpointer data)
{
277
	Menu *menu = data;
278 279

	if(GTK_TOGGLE_BUTTON(widget)->active)
280
		properties_apply_callback (menu);
281 282
}

283
static void
284
toggle_global_main (GtkWidget *widget, gpointer data)
285
{
286 287
	Menu *menu = data;

288
	if (GTK_TOGGLE_BUTTON (widget)->active) {
289 290 291 292
		gtk_widget_set_sensitive(menu->dialog_info->main_frame, FALSE);
		gtk_widget_set_sensitive(menu->dialog_info->normal_frame, FALSE);

		properties_apply_callback (menu);
293 294 295
	}
}

296 297 298
static void
toggle_main_menu(GtkWidget *widget, gpointer data)
{
299
	Menu *menu = data;
300

301
	if(GTK_TOGGLE_BUTTON(widget)->active) {
302 303 304 305
		gtk_widget_set_sensitive(menu->dialog_info->main_frame, TRUE);
		gtk_widget_set_sensitive(menu->dialog_info->normal_frame, FALSE);

		properties_apply_callback (menu);
306 307
	}
}
308

309 310 311
static void
toggle_custom_icon(GtkWidget *widget, gpointer data)
{
312
	Menu *menu = data;
313 314

	if(GTK_TOGGLE_BUTTON(widget)->active) {
315
		gtk_widget_set_sensitive(menu->dialog_info->custom_icon_entry, TRUE);
316
	} else {
317
		gtk_widget_set_sensitive(menu->dialog_info->custom_icon_entry, FALSE);
318 319
	}

320
	properties_apply_callback (menu);
321 322
}

323 324 325
static void
toggle_normal_menu(GtkWidget *widget, gpointer data)
{
326 327
	Menu *menu = data;

328
	if(GTK_TOGGLE_BUTTON(widget)->active) {
329 330 331 332
		gtk_widget_set_sensitive(menu->dialog_info->main_frame, FALSE);
		gtk_widget_set_sensitive(menu->dialog_info->normal_frame, TRUE);

		properties_apply_callback (menu);
333 334 335 336
	}
}

static void
337 338 339 340 341 342 343 344 345 346 347
textbox_changed (GtkWidget *widget, gpointer data)
{
	Menu *menu = data;

	properties_apply_callback (menu);
}

static void
add_menu_type_options(Menu *menu, GtkObject *dialog, GtkTable *table, int row,
		      char *title, GtkWidget **widget, GtkWidget **widget_sub,
		      gboolean on, gboolean sub)
348 349 350
{
	GtkWidget *w;
	GtkWidget *rb;
351

352 353 354 355 356
	w = gtk_label_new(title);
	gtk_table_attach_defaults(table,w,0,1,row,row+1);
	
	rb = w = gtk_radio_button_new_with_label (NULL, _("Off"));
	gtk_table_attach_defaults(table,w,3,4,row,row+1);
357

358
	if(!on && !sub)
359
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),TRUE);
360 361 362
	g_signal_connect (G_OBJECT (w), "toggled", 
			  G_CALLBACK (toggle_prop), 
			  menu);
363 364 365
	
	w = gtk_radio_button_new_with_label (gtk_radio_button_group(GTK_RADIO_BUTTON(rb)),
					     _("In a submenu"));
366 367 368 369 370
	gtk_table_attach_defaults(table, w, 2, 3, row, row+1);

	*widget_sub = w;

	if (sub)
371
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),TRUE);
372 373 374
	g_signal_connect (G_OBJECT (w), "toggled", 
			  G_CALLBACK (toggle_prop), 
			  menu);
375 376 377
	
	w = gtk_radio_button_new_with_label (gtk_radio_button_group(GTK_RADIO_BUTTON(rb)),
					     _("On the main menu"));
378 379 380
	*widget = w;
	gtk_table_attach_defaults(table, w, 1, 2, row, row+1);
	if (on)
381
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),TRUE);
382 383 384
	g_signal_connect (G_OBJECT (w), "toggled", 
			  G_CALLBACK (toggle_prop), 
			  menu);
385
}
Jacob Berkman's avatar
Jacob Berkman committed
386 387

static void
388
dialog_response (GtkWidget *dialog, int response, gpointer data)
Jacob Berkman's avatar
Jacob Berkman committed
389
{
390 391
	Menu *menu = data;

392
	if (response == GTK_RESPONSE_CLOSE) {
393
		gtk_widget_destroy (dialog);
394
	} else if (response == GTK_RESPONSE_HELP) {
395
		if (GTK_TOGGLE_BUTTON (menu->dialog_info->main_menu)->active)
396
			panel_show_help ("mainmenu", "MAINMENUCONFIG");
397
		else
398
			panel_show_help ("menus", NULL);
399 400
	}
}
401 402

static GtkWidget *
403
create_properties_dialog (Menu *menu)
404
{
405
	GtkWidget *dialog, *notebook;
406 407 408
	GtkWidget *vbox;
	GtkWidget *box;
	GtkWidget *table;
409
	GtkWidget *w, *w2;
410 411
	GtkWidget *f;
	GtkWidget *t;
412
	GtkWidget *main_menu, *global_main;
413

414 415 416 417
	dialog = gtk_dialog_new_with_buttons (_("Menu properties"),
					      NULL /* parent */,
					      0 /* flags */,
					      GTK_STOCK_HELP,
418 419 420
					      GTK_RESPONSE_HELP,
					      GTK_STOCK_CLOSE,
					      GTK_RESPONSE_CLOSE,
421
					      NULL);
422 423 424 425 426 427

	menu->prop_dialog = dialog;

	menu->dialog_info = g_new0 (MenuDialogInfo, 1);

	notebook = gtk_notebook_new ();
428
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
429 430
			    notebook, TRUE, TRUE, 0);

431
	gtk_window_set_wmclass(GTK_WINDOW(dialog),
432
			       "menu_properties", "Panel");
433 434 435 436 437 438 439 440 441 442 443 444 445
	/*gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);*/
	gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, TRUE);
	
	vbox = gtk_vbox_new(FALSE,GNOME_PAD_SMALL);
	gtk_container_set_border_width(GTK_CONTAINER(vbox),GNOME_PAD_SMALL);

	f = gtk_frame_new(_("Menu type"));
	gtk_box_pack_start(GTK_BOX(vbox),f,FALSE,FALSE,0);
	
	box = gtk_hbox_new(FALSE,GNOME_PAD_SMALL);
	gtk_container_set_border_width(GTK_CONTAINER(box),GNOME_PAD_SMALL);
	gtk_container_add(GTK_CONTAINER(f),box);
	
446 447
	w = gtk_radio_button_new_with_label (NULL, _("Global main menu"));
	global_main = w;
448
	menu->dialog_info->global_main = w;
449 450
	if (menu->main_menu &&
	    menu->global_main)
451
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
452 453 454
	g_signal_connect (G_OBJECT (w), "toggled", 
			  G_CALLBACK (toggle_global_main), 
			  menu);
455 456 457 458 459
	gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0);

	w = gtk_radio_button_new_with_label (
		  gtk_radio_button_group (GTK_RADIO_BUTTON (global_main)),
		  _("Main menu"));
460
	main_menu = w;
461
	menu->dialog_info->main_menu = w;
462 463
	if (menu->main_menu &&
	    ! menu->global_main)
464
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
465 466 467
	g_signal_connect (G_OBJECT (w), "toggled", 
			  G_CALLBACK (toggle_main_menu), 
			  menu);
468
	gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0);
469 470

	w2 = gtk_radio_button_new_with_label (
471 472
		  gtk_radio_button_group (GTK_RADIO_BUTTON (global_main)),
		  _("Normal menu"));
473
	if ( ! menu->main_menu)
474
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w2), TRUE);
475 476 477
	g_signal_connect (G_OBJECT (w2), "toggled", 
			  G_CALLBACK (toggle_normal_menu), 
			  menu);
478
	gtk_box_pack_start(GTK_BOX(box), w2, TRUE, TRUE, 0);
479 480

	f = gtk_frame_new(_("Main menu"));
481 482
	if ( ! menu->main_menu ||
	     menu->global_main)
483
		gtk_widget_set_sensitive(f, FALSE);
484
	menu->dialog_info->main_frame = f;
485
	gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 0);
486
	
487 488 489
	table = gtk_table_new(7, 4, FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(table), GNOME_PAD_SMALL);
	gtk_container_add(GTK_CONTAINER(f), table);
490

491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
	add_menu_type_options(menu,
			      GTK_OBJECT(dialog), GTK_TABLE(table),0,
			      _("Programs: "),
			      &menu->dialog_info->system,
			      &menu->dialog_info->system_sub,
			      menu->main_menu_flags & MAIN_MENU_SYSTEM,
			      menu->main_menu_flags & MAIN_MENU_SYSTEM_SUB);
	add_menu_type_options(menu,
			      GTK_OBJECT(dialog), GTK_TABLE(table),2,
			      _("Applets: "),
			      &menu->dialog_info->applets,
			      &menu->dialog_info->applets_sub,
			      menu->main_menu_flags & MAIN_MENU_APPLETS,
			      menu->main_menu_flags & MAIN_MENU_APPLETS_SUB);
	add_menu_type_options(menu,
			      GTK_OBJECT(dialog), GTK_TABLE(table),3,
			      _("Distribution menu (if found): "),
			      &menu->dialog_info->distribution,
			      &menu->dialog_info->distribution_sub,
			      menu->main_menu_flags & MAIN_MENU_DISTRIBUTION,
			      menu->main_menu_flags & MAIN_MENU_DISTRIBUTION_SUB);
 	add_menu_type_options(menu,
			      GTK_OBJECT(dialog), GTK_TABLE(table),4,
 			      _("KDE menu (if found): "),
			      &menu->dialog_info->kde,
			      &menu->dialog_info->kde_sub,
 			      menu->main_menu_flags & MAIN_MENU_KDE,
 			      menu->main_menu_flags & MAIN_MENU_KDE_SUB);
	add_menu_type_options(menu,
			      GTK_OBJECT(dialog), GTK_TABLE(table),6,
			      _("Panel menu: "),
			      &menu->dialog_info->panel,
			      &menu->dialog_info->panel_sub,
			      menu->main_menu_flags & MAIN_MENU_PANEL,
			      menu->main_menu_flags & MAIN_MENU_PANEL_SUB);
	add_menu_type_options(menu,
			      GTK_OBJECT(dialog), GTK_TABLE(table),7,
			      _("Desktop menu: "),
			      &menu->dialog_info->desktop,
			      &menu->dialog_info->desktop_sub,
			      menu->main_menu_flags & MAIN_MENU_DESKTOP,
			      menu->main_menu_flags & MAIN_MENU_DESKTOP_SUB);
533

534
	f = gtk_frame_new(_("Normal menu"));
535 536
	if ( ! menu->main_menu)
		gtk_widget_set_sensitive (f, FALSE);
537
	menu->dialog_info->normal_frame = f;
538
	gtk_box_pack_start (GTK_BOX (vbox), f, FALSE, FALSE, 0);
539
	
540 541 542
	box = gtk_hbox_new(FALSE, GNOME_PAD_SMALL);
	gtk_container_set_border_width(GTK_CONTAINER(box), GNOME_PAD_SMALL);
	gtk_container_add(GTK_CONTAINER(f), box);
543 544
	
	w = gtk_label_new(_("Menu path"));
545
	gtk_box_pack_start(GTK_BOX(box), w, FALSE, FALSE, 0);
546

547 548
	w = gnome_file_entry_new ("menu_path", _("Browse"));
	gnome_file_entry_set_directory_entry (GNOME_FILE_ENTRY (w), TRUE);
549 550

	t = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (w));
551
	menu->dialog_info->pathentry = w;
552
	if (menu->path) {
553
		char *s = get_real_menu_path (menu->path, menu->main_menu);
554 555 556
		gtk_entry_set_text(GTK_ENTRY(t), s);
		g_free(s);
	}
557
	gtk_box_pack_start(GTK_BOX(box),w,TRUE,TRUE,0);
558 559 560
	g_signal_connect (G_OBJECT (t), "changed",
			  G_CALLBACK (textbox_changed),
			  menu);
561
	
562
	gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
563
				  vbox, gtk_label_new (_("Menu")));
564 565 566 567 568 569 570 571 572 573 574 575

	vbox = gtk_vbox_new(FALSE, GNOME_PAD_SMALL);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), GNOME_PAD_SMALL);

	f = gtk_frame_new(_("Icon"));
	gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 0);
	
	box = gtk_vbox_new(FALSE, GNOME_PAD_SMALL);
	gtk_container_set_border_width(GTK_CONTAINER(box), GNOME_PAD_SMALL);
	gtk_container_add(GTK_CONTAINER(f), box);

	w = gtk_check_button_new_with_label (_("Use custom icon for panel button"));
576
	menu->dialog_info->custom_icon = w;
577 578 579
	if(menu->custom_icon &&
	   menu->custom_icon_file != NULL)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
580 581 582
	g_signal_connect (G_OBJECT (w), "toggled", 
			  G_CALLBACK (toggle_custom_icon), 
			  menu);
583 584 585
	gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0);

	w = gnome_icon_entry_new("icon", _("Browse"));
586
	menu->dialog_info->custom_icon_entry = w;
587
	if (menu->custom_icon_file != NULL) {
588 589
		gnome_icon_entry_set_filename (GNOME_ICON_ENTRY (w),
					       menu->custom_icon_file);
590 591 592 593 594
	}
	if ( ! menu->custom_icon) {
		gtk_widget_set_sensitive (w, FALSE);
	}
	gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 0);
595 596 597
	g_signal_connect (G_OBJECT (w), "changed",
			  G_CALLBACK (textbox_changed),
			  menu);
598

599 600
	gtk_widget_grab_focus (global_main);

601
	gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
602
				  vbox, gtk_label_new (_("Icon")));
603
	
604 605 606
	g_signal_connect (G_OBJECT(dialog), "destroy",
			  G_CALLBACK (properties_close_callback),
			  menu);
607

608 609 610
	g_signal_connect (G_OBJECT (dialog), "response",
			  G_CALLBACK (dialog_response),
			  menu);
611 612 613 614 615

	return dialog;
}

void
616
menu_properties (Menu *menu)
617 618 619
{
	GtkWidget *dialog;

620 621 622
	g_return_if_fail (menu != NULL);

	if (menu->prop_dialog != NULL) {
623
		xstuff_window_raise_on_current_wspace (menu->prop_dialog);
624 625 626
		return;
	}

627
	dialog = create_properties_dialog (menu);
628 629
	gtk_widget_show_all (dialog);
}