示例#1
0
文件: listitem.c 项目: amery/clip-itk
/* Selects the item, by emitting the item's "select" signal.
 * Depending on the selection mode of the list, this may cause
 * other items to be deselected.*/
int
clip_GTK_LISTITEMSELECT(ClipMachine *cm)
{
	C_widget *clitm = _fetch_cw_arg(cm);
        CHECKCWID(clitm,GTK_IS_LIST_ITEM);
        gtk_list_item_select(GTK_LIST_ITEM(clitm->widget));
	return 0;
err:
	return 1;
}
示例#2
0
文件: scripts.c 项目: IR4T4/xqf
GtkWidget *scripts_config_page () {
	GtkWidget *page_vbox;
	GtkWidget *frame;
	GtkWidget *vbox;
	GtkWidget *button;
	GtkWidget *label;
	GtkWidget *gtklist=NULL;
	GtkWidget *scrollwin=NULL;
	GtkWidget *games_hbox;
	unsigned i = 0;
	GList* s;

	page_vbox = gtk_vbox_new (FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (page_vbox), 8);

	games_hbox = gtk_hbox_new (FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (games_hbox), 0);
	gtk_box_pack_start (GTK_BOX (page_vbox), games_hbox, TRUE, TRUE, 0);

	vbox = gtk_vbox_new (FALSE, 0);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);

	scrollwin = gtk_scrolled_window_new (NULL, NULL);

	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
			GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

	gtklist = gtk_list_new ();

	gtk_widget_set_usize (gtklist, 136, -1);

	//  gtk_container_add (GTK_CONTAINER (scrollwin), gtklist);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwin), gtklist);

	gtk_container_add (GTK_CONTAINER (frame), scrollwin);
	gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);

	button = gtk_button_new_with_label(_("Install ..."));
	gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

	gtk_signal_connect (GTK_OBJECT (button),
			"clicked", G_CALLBACK(install_button_callback), NULL);

#if have_time_to_implement_that
	button = gtk_button_new_with_label(_("Remove"));
	gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
#endif

	gtk_box_pack_start (GTK_BOX (games_hbox), vbox, FALSE, FALSE, 0);

	notebook = gtk_notebook_new ();
	// the tabs are hidden, so nobody will notice its a notebook
	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
	gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
	gtk_box_pack_start (GTK_BOX (games_hbox), notebook, FALSE, FALSE, 15);

	for (s = scripts; s; s = g_list_next(s), ++i) {
		const char* filename = s->data;
		GtkWidget *page;
		GtkWidget* item;
		Script* script;

		script = g_datalist_get_data(&scriptdata, filename);

		item = gtk_list_item_new();
		if (s == scripts) {
			gtk_list_item_select(GTK_LIST_ITEM(item));
		}

		gtk_container_add (GTK_CONTAINER (item), gtk_label_new(filename));

		gtk_signal_connect (GTK_OBJECT (item), "select",
				GTK_SIGNAL_FUNC(scripts_page_select_callback), GINT_TO_POINTER(i));

		gtk_widget_show_all(item);
		gtk_container_add (GTK_CONTAINER (gtklist), item);

		label = gtk_label_new (filename);

		if (script) {
			page = generic_script_frame(filename, script);

			gtk_object_set_data_full (GTK_OBJECT (notebook), filename, script,
					(GtkDestroyNotify) unref_option_widgets);
		}
		else {
			page = gtk_label_new(_("Invalid script"));
			gtk_widget_show(page);
		}

		gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
	}

	gtk_widget_show_all (page_vbox);

	return page_vbox;
}