コード例 #1
0
ファイル: monopoly.c プロジェクト: jquick/pioneers
void monopoly_create_dlg(void)
{
	GtkWidget *dlg_vbox;
	GtkWidget *vbox;
	GtkWidget *lbl;
	GSList *monop_grp = NULL;

	if (monop_dlg != NULL) {
		gtk_window_present(GTK_WINDOW(monop_dlg));
		return;
	};

	/* Dialog caption */
	monop_dlg = gtk_dialog_new_with_buttons(_("Monopoly"),
						GTK_WINDOW(app_window),
						GTK_DIALOG_DESTROY_WITH_PARENT,
						GTK_STOCK_OK,
						GTK_RESPONSE_OK, NULL);
	g_signal_connect(G_OBJECT(monop_dlg), "destroy",
			 G_CALLBACK(gtk_widget_destroyed), &monop_dlg);
	gtk_widget_realize(monop_dlg);
	/* Disable close */
	gdk_window_set_functions(monop_dlg->window,
				 GDK_FUNC_ALL | GDK_FUNC_CLOSE);

	dlg_vbox = GTK_DIALOG(monop_dlg)->vbox;
	gtk_widget_show(dlg_vbox);

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(dlg_vbox), vbox, FALSE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);

	/* Label */
	lbl = gtk_label_new(_("Select the resource you wish to "
			      "monopolize."));
	gtk_widget_show(lbl);
	gtk_box_pack_start(GTK_BOX(vbox), lbl, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(lbl), 0, 0.5);

	monop_grp = add_resource_btn(vbox, monop_grp, BRICK_RESOURCE);
	monop_grp = add_resource_btn(vbox, monop_grp, GRAIN_RESOURCE);
	monop_grp = add_resource_btn(vbox, monop_grp, ORE_RESOURCE);
	monop_grp = add_resource_btn(vbox, monop_grp, WOOL_RESOURCE);
	monop_grp = add_resource_btn(vbox, monop_grp, LUMBER_RESOURCE);

	frontend_gui_register(gui_get_dialog_button
			      (GTK_DIALOG(monop_dlg), 0), GUI_MONOPOLY,
			      "clicked");
	gtk_dialog_set_default_response(GTK_DIALOG(monop_dlg),
					GTK_RESPONSE_OK);
	/* This _must_ be after frontend_gui_register, otherwise the
	 * regeneration of the button happens before the destruction, which
	 * results in an incorrectly sensitive OK button. */
	g_signal_connect(gui_get_dialog_button(GTK_DIALOG(monop_dlg), 0),
			 "destroy", G_CALLBACK(monopoly_destroyed), NULL);
	gtk_widget_show(monop_dlg);
	frontend_gui_update();
}
コード例 #2
0
ファイル: discard.c プロジェクト: jquick/pioneers
static GtkWidget *discard_create_dlg(gint num)
{
	GtkWidget *dlg_vbox;
	GtkWidget *vbox;
	gchar *text;

	discard.dlg = gtk_dialog_new_with_buttons(
							 /* Dialog caption */
							 _(""
							   "Discard Resources"),
							 GTK_WINDOW
							 (app_window),
							 GTK_DIALOG_DESTROY_WITH_PARENT,
							 GTK_STOCK_OK,
							 GTK_RESPONSE_OK,
							 NULL);
	g_signal_connect(G_OBJECT(discard.dlg), "destroy",
			 G_CALLBACK(gtk_widget_destroyed), &discard.dlg);
	gtk_widget_realize(discard.dlg);
	/* Disable close */
	gdk_window_set_functions(discard.dlg->window,
				 GDK_FUNC_ALL | GDK_FUNC_CLOSE);

	dlg_vbox = GTK_DIALOG(discard.dlg)->vbox;
	gtk_widget_show(dlg_vbox);

	vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(dlg_vbox), vbox, FALSE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);

	text = g_strdup_printf(ngettext("You must discard %d resource",
					"You must discard %d resources",
					num), num);
	discard.resource_widget =
	    resource_table_new(text, RESOURCE_TABLE_LESS_IN_HAND, FALSE,
			       TRUE);
	g_free(text);
	resource_table_set_total(RESOURCETABLE(discard.resource_widget),
				 /* Label */
				 _("Total discards"), num);
	gtk_widget_show(discard.resource_widget);
	gtk_box_pack_start(GTK_BOX(vbox), discard.resource_widget, FALSE,
			   TRUE, 0);
	g_signal_connect(G_OBJECT(discard.resource_widget), "change",
			 G_CALLBACK(amount_changed_cb), NULL);

	frontend_gui_register(gui_get_dialog_button
			      (GTK_DIALOG(discard.dlg), 0), GUI_DISCARD,
			      "clicked");
	/* This _must_ be after frontend_gui_register, otherwise the
	 * regeneration of the button happens before the destruction, which
	 * results in an incorrectly sensitive OK button. */
	g_signal_connect(gui_get_dialog_button(GTK_DIALOG(discard.dlg), 0),
			 "destroy", G_CALLBACK(button_destroyed),
			 GINT_TO_POINTER(num));
	gtk_widget_show(discard.dlg);
	frontend_gui_update();

	return discard.dlg;
}
コード例 #3
0
ファイル: plenty.c プロジェクト: Alex-Sjoberg/Pioneers
void plenty_create_dlg(const gint * bank)
{
	GtkWidget *dlg_vbox;
	GtkWidget *vbox;
	const char *str;
	gint r;
	gint total;

	plenty.dlg = gtk_dialog_new_with_buttons(_("Year of Plenty"),
						 GTK_WINDOW(app_window),
						 GTK_DIALOG_DESTROY_WITH_PARENT,
						 GTK_STOCK_OK,
						 GTK_RESPONSE_OK, NULL);
	g_signal_connect(GTK_OBJECT(plenty.dlg), "destroy",
			 G_CALLBACK(gtk_widget_destroyed), &plenty.dlg);
	gtk_widget_realize(plenty.dlg);
	/* Disable close */
	gdk_window_set_functions(plenty.dlg->window,
				 GDK_FUNC_ALL | GDK_FUNC_CLOSE);

	dlg_vbox = GTK_DIALOG(plenty.dlg)->vbox;
	gtk_widget_show(dlg_vbox);

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(dlg_vbox), vbox, FALSE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);

	total = 0;
	if (bank != NULL)
		for (r = 0; r < NO_RESOURCE; ++r) {
			plenty.bank[r] = bank[r];
			total += bank[r];
		}
	if (total == 1)
		str = _("Please choose one resource from the bank");
	else if (total >= 2) {
		total = 2;
		str = _("Please choose two resources from the bank");
	} else
		str = _("The bank is empty");
	plenty.resource_widget =
	    resource_table_new(str, RESOURCE_TABLE_MORE_IN_HAND, TRUE,
			       TRUE);
	resource_table_set_total(RESOURCETABLE(plenty.resource_widget),
				 /* Text for total in year of plenty dialog */
				 _("Total resources"), total);
	resource_table_limit_bank(RESOURCETABLE(plenty.resource_widget),
				  TRUE);
	resource_table_set_bank(RESOURCETABLE(plenty.resource_widget),
				plenty.bank);

	gtk_widget_show(plenty.resource_widget);
	gtk_box_pack_start(GTK_BOX(vbox), plenty.resource_widget, FALSE,
			   TRUE, 0);
	g_signal_connect(G_OBJECT(plenty.resource_widget), "change",
			 G_CALLBACK(amount_changed_cb), NULL);

	frontend_gui_register(gui_get_dialog_button
			      (GTK_DIALOG(plenty.dlg), 0), GUI_PLENTY,
			      "clicked");
	/* This _must_ be after frontend_gui_register, otherwise the
	 * regeneration of the button happens before the destruction, which
	 * results in an incorrectly sensitive OK button. */
	g_signal_connect(gui_get_dialog_button(GTK_DIALOG(plenty.dlg), 0),
			 "destroy", G_CALLBACK(plenty_destroyed), NULL);
	gtk_widget_show(plenty.dlg);
	frontend_gui_update();
}