Ejemplo n.º 1
0
static GtkWidget*
make_view(DraftStoreUI *dsui) {
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	
	dsui->view = 
		gtk_tree_view_new_with_model(GTK_TREE_MODEL(dsui->store));
	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dsui->view), TRUE);
	g_object_unref(G_OBJECT(dsui->store));
	g_signal_connect(G_OBJECT(dsui->view), "row-activated",
			G_CALLBACK(row_activated_cb), dsui);

	/*renderer = gtk_cell_renderer_pixbuf_new();
	column = gtk_tree_view_column_new_with_attributes(_("Security"), renderer,
			"pixbuf", COL_SECURITY,
			NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(dsui->view), column);*/

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
			"text", COL_DATE,
			NULL);
	gtk_tree_view_column_set_sort_column_id(column, COL_DATE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(dsui->view), column);

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes(_("Subject"), renderer,
			"text", COL_SUBJECT,
			NULL);
	gtk_tree_view_column_set_sort_column_id(column, COL_SUBJECT);
	gtk_tree_view_append_column(GTK_TREE_VIEW(dsui->view), column);

	return scroll_wrap(dsui->view);
}
Ejemplo n.º 2
0
static void
pollmultidlg_init(PollMultiDlg *pmdlg, GtkWindow *parent) {
	GtkWidget *mainbox, *vbox, *paned;
	GtkWidget *menu, *label;

	pmdlg->dlg = gtk_dialog_new_with_buttons(_("Multi Poll Question"),
			parent, GTK_DIALOG_MODAL,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OK, GTK_RESPONSE_OK,
			NULL);
	jam_win_set_size(GTK_WINDOW(pmdlg->dlg), 500, -1);

	mainbox = gtk_vbox_new(FALSE, 12);

	menu = gtk_menu_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),
		gtk_menu_item_new_with_mnemonic(_("Choose best answer (_radio buttons)")));
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),
		gtk_menu_item_new_with_mnemonic(_("Choose best answer (_drop-down menu)")));
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),
		gtk_menu_item_new_with_mnemonic(_("Select _all that apply (checkboxes)")));

	pmdlg->typemenu = gtk_option_menu_new();
	gtk_option_menu_set_menu(GTK_OPTION_MENU(pmdlg->typemenu), menu);
	gtk_box_pack_start(GTK_BOX(mainbox),
			labelled_box_new_expand(_("Choice _Type:"), pmdlg->typemenu, TRUE),
			FALSE, FALSE, 0);

	paned = gtk_hpaned_new();
	gtk_box_pack_start(GTK_BOX(mainbox), paned, TRUE, TRUE, 0);

	vbox = gtk_vbox_new(FALSE, 6);
	label = gtk_label_new_with_mnemonic(_("_Question:"));
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	pmdlg->question = gtk_text_view_new();
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(pmdlg->question), GTK_WRAP_WORD);
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), pmdlg->question);
	gtk_box_pack_start(GTK_BOX(vbox),
			scroll_wrap(pmdlg->question),
			TRUE, TRUE, 0);

	gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, FALSE);

	vbox = gtk_vbox_new(FALSE, 6);
	pollmulti_make_list(pmdlg);
	label = gtk_label_new_with_mnemonic(_("O_ptions:"));
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), pmdlg->answers.view);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), pmdlg->answers.box, TRUE, TRUE, 0);

	gtk_paned_pack2(GTK_PANED(paned), vbox, TRUE, FALSE);

	jam_dialog_set_contents(GTK_DIALOG(pmdlg->dlg), mainbox);
}
Ejemplo n.º 3
0
static void
pollscaledlg_init(PollScaleDlg *psdlg, GtkWindow *parent) {
	GtkWidget *mainbox, *vbox;
	GtkWidget *label;
	GtkSizeGroup *sizegroup;

	GtkAdjustment *adj1 = (GtkAdjustment*)gtk_adjustment_new(
			1.0,  -32000.0, 32000.0, 1.0, 5.0, 0);
	GtkAdjustment *adj2 = (GtkAdjustment*)gtk_adjustment_new(
			10.0, -32000.0, 32000.0, 1.0, 5.0, 0);
	GtkAdjustment *adj3 = (GtkAdjustment*)gtk_adjustment_new(
			1.0,  -32000.0, 32000.0, 1.0, 5.0, 0);

	psdlg->dlg = gtk_dialog_new_with_buttons(_("Scale Poll Question"),
			parent, GTK_DIALOG_MODAL,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OK, GTK_RESPONSE_OK,
			NULL);
	jam_win_set_size(GTK_WINDOW(psdlg->dlg), 400, -1);

	mainbox = gtk_hbox_new(FALSE, 12);

	vbox = gtk_vbox_new(FALSE, 6);
	label = gtk_label_new_with_mnemonic(_("_Question:"));
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	psdlg->question = gtk_text_view_new();
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(psdlg->question), GTK_WRAP_WORD);
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), psdlg->question);
	gtk_box_pack_start(GTK_BOX(vbox),
			scroll_wrap(psdlg->question),
			TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(mainbox), vbox, TRUE, TRUE, 0);

	vbox = gtk_vbox_new(FALSE, 6);
	sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

	psdlg->from = gtk_spin_button_new(adj1, 1.0, 0);
	gtk_box_pack_start(GTK_BOX(vbox),
			labelled_box_new_sg(_("_From:"), psdlg->from, sizegroup),
			FALSE, FALSE, 0);
	psdlg->to = gtk_spin_button_new(adj2, 1.0, 0);
	gtk_box_pack_start(GTK_BOX(vbox),
			labelled_box_new_sg(_("_To:"), psdlg->to, sizegroup),
			FALSE, FALSE, 0);
	psdlg->by = gtk_spin_button_new(adj3, 1.0, 0);
	gtk_box_pack_start(GTK_BOX(vbox),
			labelled_box_new_sg(_("_By:"), psdlg->by, sizegroup),
			FALSE, FALSE, 0);

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

	jam_dialog_set_contents(GTK_DIALOG(psdlg->dlg), mainbox);
}
Ejemplo n.º 4
0
static void
polltextdlg_init(PollTextDlg *ptdlg, GtkWindow *parent) {
	GtkWidget *mainbox, *vbox;
	GtkWidget *label, *view;

	ptdlg->dlg = gtk_dialog_new_with_buttons(_("Text Poll Question"),
			parent, GTK_DIALOG_MODAL,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OK, GTK_RESPONSE_OK,
			NULL);

	mainbox = gtk_vbox_new(FALSE, 12);

	vbox = gtk_vbox_new(FALSE, 6);

	label = gtk_label_new_with_mnemonic(_("_Question:"));
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	ptdlg->question = view = gtk_text_view_new();
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), view);
	gtk_box_pack_start(GTK_BOX(vbox), scroll_wrap(view), TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(mainbox), vbox, TRUE, TRUE, 0);

	vbox = gtk_vbox_new(FALSE, 6);

	ptdlg->size = gtk_entry_new();
	gtk_entry_set_width_chars(GTK_ENTRY(ptdlg->size), 4);
	ptdlg->width = gtk_entry_new();
	gtk_entry_set_width_chars(GTK_ENTRY(ptdlg->width), 4);

	gtk_box_pack_start(GTK_BOX(vbox),
			labelled_box_new(_("_Text field size (optional): "),
				ptdlg->size),
			FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox),
			labelled_box_new(_("_Maximum text length (optional): "),
				ptdlg->width),
			FALSE, FALSE, 0);

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

	jam_dialog_set_contents(GTK_DIALOG(ptdlg->dlg), mainbox);
}
Ejemplo n.º 5
0
static void
jam_view_init(JamView *view) {
	gtk_box_set_spacing(GTK_BOX(view), 6);

	view->entry = gtk_text_view_new();
	view->undomgr = UNDOMGR(undomgr_new());

	gtk_text_view_set_editable(GTK_TEXT_VIEW(view->entry), TRUE);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view->entry), GTK_WRAP_WORD);
	g_signal_connect(G_OBJECT(view->entry), "populate-popup",
		G_CALLBACK(populate_entry_popup), view);
	if (conf.uifont)
		jam_widget_set_font(view->entry, conf.uifont);

	undomgr_attach(UNDOMGR(view->undomgr), view->entry);

	view->sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

	subject_add(view);
	jam_view_load_conf(view);
	gtk_box_pack_start(GTK_BOX(view), scroll_wrap(view->entry),
			TRUE, TRUE, 0);
}
Ejemplo n.º 6
0
static char*
pollmultidlg_option(GtkWindow *parent, const char *current) {
	GtkWidget *dlg, *vbox, *label, *view;
	GtkTextBuffer *buffer;
	char *newtext = NULL;

	dlg = gtk_dialog_new_with_buttons(_("Multi Poll Option"),
			parent, GTK_DIALOG_MODAL,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OK, GTK_RESPONSE_OK,
			NULL);
	jam_win_set_size(GTK_WINDOW(dlg), 300, -1);

	vbox = gtk_vbox_new(FALSE, 6);

	label = gtk_label_new_with_mnemonic(_("O_ption:"));
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	view = gtk_text_view_new();
	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
	if (current)
		gtk_text_buffer_insert_at_cursor(buffer, current, -1);
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), view);
	gtk_box_pack_start(GTK_BOX(vbox), scroll_wrap(view), TRUE, TRUE, 0);

	jam_dialog_set_contents(GTK_DIALOG(dlg), vbox);

	if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK) {
		GtkTextIter start, end;
		gtk_text_buffer_get_bounds(buffer, &start, &end);
		newtext = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
	}
	gtk_widget_destroy(dlg);
	return newtext;
}
Ejemplo n.º 7
0
void
console_dialog_run(GtkWindow *parent, JamAccountLJ *acc) {
	ConsoleUI *cui;
	GtkWidget *vbox, *hbox, *button;
	GtkTextBuffer *buffer;
	GtkTextIter end;

	cui = g_new0(ConsoleUI, 1);
	cui->account = acc;
	cui->win = gtk_dialog_new_with_buttons(_("LiveJournal Console"),
			parent, GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
			NULL);
	jam_win_set_size(GTK_WINDOW(cui->win), 500, 400);
	g_signal_connect_swapped(G_OBJECT(cui->win), "response",
			G_CALLBACK(gtk_widget_destroy), cui->win);
	g_signal_connect_swapped(G_OBJECT(cui->win), "destroy",
			G_CALLBACK(g_free), cui);
	geometry_tie(cui->win, GEOM_CONSOLE);

	vbox = gtk_vbox_new(FALSE, 5);

	hbox = gtk_hbox_new(FALSE, 5);
	cui->entry = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(hbox), cui->entry, TRUE, TRUE, 0);

	button = gtk_button_new_with_mnemonic(_(" _Submit "));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	g_signal_connect(G_OBJECT(cui->entry), "activate",
			G_CALLBACK(submit_cb), cui);
	g_signal_connect(G_OBJECT(button), "clicked",
			G_CALLBACK(submit_cb), cui);

	button = gtk_button_new_from_stock(GTK_STOCK_HELP);
	g_signal_connect(G_OBJECT(button), "clicked",
			G_CALLBACK(console_help), cui);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
	
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	cui->display = gtk_text_view_new();
	gtk_text_view_set_editable(GTK_TEXT_VIEW(cui->display), FALSE);
	gtk_box_pack_start(GTK_BOX(vbox), scroll_wrap(cui->display), 
			TRUE, TRUE, 0);

	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(cui->display));
	gtk_text_buffer_get_end_iter(buffer, &end);
	cui->mark_end = gtk_text_buffer_create_mark(buffer, NULL, &end, FALSE);
	gtk_text_buffer_create_tag(buffer, "command",
			"family", "monospace",
			 NULL);
	gtk_text_buffer_create_tag(buffer, "info",
			"family", "monospace",
			"foreground", "darkgreen",
			NULL);
	gtk_text_buffer_create_tag(buffer, "error",
			"family", "monospace",
			"weight", PANGO_WEIGHT_BOLD,
			"foreground", "red",
			NULL);

	jam_dialog_set_contents(GTK_DIALOG(cui->win), vbox);

	console_print(cui, NULL, _("LiveJournal console ready.\n"));

	gtk_widget_show(cui->win);
}