コード例 #1
0
ファイル: gntstatus.c プロジェクト: crodjer/pidgin_whiteboard
void finch_savedstatus_show_all()
{
	GntWidget *window, *tree, *box, *button;
	int widths[] = {25, 12, 35};
	if (statuses.window) {
		gnt_window_present(statuses.window);
		return;
	}

	statuses.window = window = gnt_vbox_new(FALSE);
	gnt_box_set_toplevel(GNT_BOX(window), TRUE);
	gnt_box_set_title(GNT_BOX(window), _("Saved Statuses"));
	gnt_box_set_fill(GNT_BOX(window), FALSE);
	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
	gnt_box_set_pad(GNT_BOX(window), 0);

	/* XXX: Add some sorting function to sort alphabetically, perhaps */
	statuses.tree = tree = gnt_tree_new_with_columns(3);
	gnt_tree_set_column_titles(GNT_TREE(tree), _("Title"), _("Type"), _("Message"));
	gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
	gnt_tree_set_column_width_ratio(GNT_TREE(tree), widths);
	gnt_widget_set_size(tree, 72, 0);
	gnt_box_add_widget(GNT_BOX(window), tree);

	populate_statuses(GNT_TREE(tree));

	box = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(window), box);

	button = gnt_button_new(_("Use"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_signal_connect(G_OBJECT(button), "activate",
			G_CALLBACK(use_savedstatus_cb), NULL);

	button = gnt_button_new(_("Add"));
	gnt_box_add_widget(GNT_BOX(box), button);
	gnt_util_set_trigger_widget(tree, GNT_KEY_INS, button);
	g_signal_connect_swapped(G_OBJECT(button), "activate",
			G_CALLBACK(finch_savedstatus_edit), NULL);

	button = gnt_button_new(_("Edit"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_signal_connect(G_OBJECT(button), "activate",
			G_CALLBACK(edit_savedstatus_cb), NULL);

	button = gnt_button_new(_("Delete"));
	gnt_box_add_widget(GNT_BOX(box), button);
	gnt_util_set_trigger_widget(tree, GNT_KEY_DEL, button);
	g_signal_connect(G_OBJECT(button), "activate",
			G_CALLBACK(ask_before_delete), NULL);

	button = gnt_button_new(_("Close"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_signal_connect_swapped(G_OBJECT(button), "activate",
			G_CALLBACK(gnt_widget_destroy), window);

	g_signal_connect(G_OBJECT(window), "destroy",
			G_CALLBACK(reset_status_window), NULL);
	gnt_widget_show(window);
}
コード例 #2
0
ファイル: gnttextview.c プロジェクト: Distrotech/pidgin
static void
gnt_text_view_size_request(GntWidget *widget)
{
	if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED))
	{
		gnt_widget_set_size(widget, 64, 20);
	}
}
コード例 #3
0
ファイル: gntcombobox.c プロジェクト: Distrotech/pidgin
static void
hide_popup(GntComboBox *box, gboolean set)
{
	gnt_widget_set_size(box->dropdown,
		box->dropdown->priv.width - 1, box->dropdown->priv.height);
	if (set)
		set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown)));
	else
		gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected);
	gnt_widget_hide(box->dropdown->parent);
}
コード例 #4
0
ファイル: gntbox.c プロジェクト: wosigh/messaging-plugins
static void
gnt_box_size_changed(GntWidget *widget, int oldw, int oldh)
{
	int wchange, hchange;
	GList *i;
	GntBox *box = GNT_BOX(widget);
	GntWidget *wid;
	int tw, th;
		
	wchange = widget->priv.width - oldw;
	hchange = widget->priv.height - oldh;
	
	wid = g_object_get_data(G_OBJECT(box), "size-queued");
	if (wid)
	{
		gnt_widget_get_size(wid, &tw, &th);
		gnt_widget_set_size(wid, tw + wchange, th + hchange);
		g_object_set_data(G_OBJECT(box), "size-queued", NULL);
	}

	if (box->vertical)
		hchange = 0;
	else
		wchange = 0;

	for (i = box->list; i; i = i->next)
	{
		if (wid != i->data)
		{
			gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
			gnt_widget_set_size(i->data, tw + wchange, th + hchange);
		}
	}

	reposition_children(widget);
}
コード例 #5
0
ファイル: s.c プロジェクト: CkNoSFeRaTU/pidgin
static void
s_new_window(GntWM *wm, GntWidget *win)
{
	int x, y, w, h;
	int maxx, maxy;
	const char *name;
	gboolean blist = FALSE;

	if (!GNT_IS_MENU(win)) {
		getmaxyx(stdscr, maxy, maxx);

		gnt_widget_get_position(win, &x, &y);
		gnt_widget_get_size(win, &w, &h);

		name = gnt_widget_get_name(win);

		if (name && strcmp(name, "buddylist") == 0) {
			/* The buddylist doesn't have no border nor nothing! */
			x = 0;
			y = 0;
			h = maxy - 1;
			blist = TRUE;

			gnt_box_set_toplevel(GNT_BOX(win), FALSE);
			GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_CAN_TAKE_FOCUS);

			gnt_widget_set_position(win, x, y);
			mvwin(win->window, y, x);

			gnt_widget_set_size(win, -1, h + 2);  /* XXX: Why is the +2 needed here? -- sadrul */
		} else if (!GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) {
			const char *title = GNT_BOX(win)->title;
			if (title == NULL || !g_hash_table_lookup(wm->positions, title)) {
				/* In the middle of the screen */
				x = (maxx - w) / 2;
				y = (maxy - h) / 2;

				gnt_widget_set_position(win, x, y);
				mvwin(win->window, y, x);
			}
		}
	}
	org_new_window(wm, win);

	if (blist)
		gnt_wm_raise_window(wm, win);
}
コード例 #6
0
ファイル: gntbox.c プロジェクト: wosigh/messaging-plugins
static void
gnt_box_size_request(GntWidget *widget)
{
	GntBox *box = GNT_BOX(widget);
	GList *iter;
	int maxw = 0, maxh = 0;
	
	g_list_foreach(box->list, (GFunc)gnt_widget_size_request, NULL);

	for (iter = box->list; iter; iter = iter->next)
	{
		int w, h;
		gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h);
		if (maxh < h)
			maxh = h;
		if (maxw < w)
			maxw = w;
	}

	for (iter = box->list; iter; iter = iter->next)
	{
		int w, h;
		GntWidget *wid = GNT_WIDGET(iter->data);

		gnt_widget_get_size(wid, &w, &h);

		if (box->homogeneous)
		{
			if (box->vertical)
				h = maxh;
			else
				w = maxw;
		}
		if (box->fill)
		{
			if (box->vertical)
				w = maxw;
			else
				h = maxh;
		}

		gnt_widget_confirm_size(wid, w, h);
		gnt_widget_set_size(wid, w, h);
	}

	reposition_children(widget);
}
コード例 #7
0
ファイル: gntrequest.c プロジェクト: bf4/pidgin-mac
static GntWidget*
create_account_field(PurpleRequestField *field)
{
	gboolean all;
	PurpleAccount *def;
	GList *list;
	GntWidget *combo = gnt_combo_box_new();

	all = purple_request_field_account_get_show_all(field);
	def = purple_request_field_account_get_value(field);
	if (!def)
		def = purple_request_field_account_get_default_value(field);

	if (all)
		list = purple_accounts_get_all();
	else
		list = purple_connections_get_all();

	for (; list; list = list->next)
	{
		PurpleAccount *account;
		char *text;

		if (all)
			account = list->data;
		else
			account = purple_connection_get_account(list->data);

		text = g_strdup_printf("%s (%s)",
				purple_account_get_username(account),
				purple_account_get_protocol_name(account));
		gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text);
		g_free(text);
		if (account == def)
			gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account);
	}
	gnt_widget_set_size(combo, 20, 3); /* ew */
	return combo;
}
コード例 #8
0
ファイル: gntcombobox.c プロジェクト: Distrotech/pidgin
static void
popup_dropdown(GntComboBox *box)
{
	GntWidget *widget = GNT_WIDGET(box);
	GntWidget *parent = box->dropdown->parent;
	int height = g_list_length(GNT_TREE(box->dropdown)->list);
	int y = widget->priv.y + widget->priv.height - 1;
	gnt_widget_set_size(box->dropdown, widget->priv.width, height + 2);

	if (y + height + 2 >= getmaxy(stdscr))
		y = widget->priv.y - height - 1;
	gnt_widget_set_position(parent, widget->priv.x, y);
	if (parent->window)
	{
		mvwin(parent->window, y, widget->priv.x);
		wresize(parent->window, height+2, widget->priv.width);
	}
	parent->priv.width = widget->priv.width;
	parent->priv.height = height + 2;

	GNT_WIDGET_UNSET_FLAGS(parent, GNT_WIDGET_INVISIBLE);
	gnt_widget_draw(parent);
}
コード例 #9
0
ファイル: gntplugin.c プロジェクト: N8Fear/purple-facebook
void finch_plugins_show_all(void)
{
	GntWidget *window, *tree, *box, *aboot, *button;
	GList *plugin_list, *iter;
	GList *seen;

	if (plugins.window) {
		gnt_window_present(plugins.window);
		return;
	}

	purple_plugins_refresh();

	plugins.window = window = gnt_vbox_new(FALSE);
	gnt_box_set_toplevel(GNT_BOX(window), TRUE);
	gnt_box_set_title(GNT_BOX(window), _("Plugins"));
	gnt_box_set_pad(GNT_BOX(window), 0);
	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);

	gnt_box_add_widget(GNT_BOX(window),
			gnt_label_new(_("You can (un)load plugins from the following list.")));
	gnt_box_add_widget(GNT_BOX(window), gnt_hline_new());

	box = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(window), box);
	gnt_box_add_widget(GNT_BOX(window), gnt_hline_new());

	gnt_box_set_pad(GNT_BOX(box), 0);
	plugins.tree = tree = gnt_tree_new();
	gnt_tree_set_compare_func(GNT_TREE(tree), (GCompareFunc)plugin_compare);
	GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER);
	gnt_box_add_widget(GNT_BOX(box), tree);
	gnt_box_add_widget(GNT_BOX(box), gnt_vline_new());

	plugins.aboot = aboot = gnt_text_view_new();
	gnt_text_view_set_flag(GNT_TEXT_VIEW(aboot), GNT_TEXT_VIEW_TOP_ALIGN);
	gnt_widget_set_size(aboot, 40, 20);
	gnt_box_add_widget(GNT_BOX(box), aboot);

	seen = purple_prefs_get_path_list("/finch/plugins/seen");

	plugin_list = purple_plugins_find_all();
	for (iter = plugin_list; iter; iter = iter->next)
	{
		PurplePlugin *plug = PURPLE_PLUGIN(iter->data);

		if (purple_plugin_is_internal(plug))
			continue;

		gnt_tree_add_choice(GNT_TREE(tree), plug,
				gnt_tree_create_row(GNT_TREE(tree),
				purple_plugin_info_get_name(purple_plugin_get_info(plug))),
				NULL, NULL);
		gnt_tree_set_choice(GNT_TREE(tree), plug, purple_plugin_is_loaded(plug));
		if (!g_list_find_custom(seen, purple_plugin_get_filename(plug),
				(GCompareFunc)strcmp))
			gnt_tree_set_row_flags(GNT_TREE(tree), plug, GNT_TEXT_FLAG_BOLD);
	}
	g_list_free(plugin_list);

	gnt_tree_set_col_width(GNT_TREE(tree), 0, 30);
	g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(plugin_toggled_cb), NULL);
	g_signal_connect(G_OBJECT(tree), "selection_changed", G_CALLBACK(selection_changed), NULL);
	g_object_set_data(G_OBJECT(tree), "seen-list", seen);

	box = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(window), box);

#if 0
	button = gnt_button_new(_("Install Plugin..."));
	gnt_box_add_widget(GNT_BOX(box), button);
	gnt_util_set_trigger_widget(GNT_WIDGET(tree), GNT_KEY_INS, button);
	g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(install_plugin_cb), NULL);
#endif

	button = gnt_button_new(_("Close"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_signal_connect_swapped(G_OBJECT(button), "activate",
			G_CALLBACK(gnt_widget_destroy), window);

	plugins.conf = button = gnt_button_new(_("Configure Plugin"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(configure_plugin_cb), NULL);

	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(reset_plugin_window), NULL);

	gnt_widget_show(window);

	decide_conf_button(gnt_tree_get_selection_data(GNT_TREE(tree)));
}
コード例 #10
0
ファイル: gntcombobox.c プロジェクト: Distrotech/pidgin
static void
gnt_combo_box_size_changed(GntWidget *widget, int oldw, int oldh)
{
	GntComboBox *box = GNT_COMBO_BOX(widget);
	gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height);
}
コード例 #11
0
ファイル: gntstatus.c プロジェクト: crodjer/pidgin_whiteboard
void finch_savedstatus_edit(PurpleSavedStatus *saved)
{
	EditStatus *edit;
	GntWidget *window, *box, *button, *entry, *combo, *label, *tree;
	PurpleStatusPrimitive prims[] = {PURPLE_STATUS_AVAILABLE, PURPLE_STATUS_AWAY,
		PURPLE_STATUS_INVISIBLE, PURPLE_STATUS_OFFLINE, PURPLE_STATUS_UNSET}, current;
	GList *iter;
	int i;

	if (saved)
	{
		GList *iter;
		for (iter = edits; iter; iter = iter->next)
		{
			edit = iter->data;
			if (edit->saved == saved)
				return;
		}
	}

	edit = g_new0(EditStatus, 1);
	edit->saved = saved;
	edit->window = window = gnt_vbox_new(FALSE);
	gnt_box_set_toplevel(GNT_BOX(window), TRUE);
	gnt_box_set_title(GNT_BOX(window), _("Edit Status"));
	gnt_box_set_fill(GNT_BOX(window), TRUE);
	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
	gnt_box_set_pad(GNT_BOX(window), 0);

	edits = g_list_append(edits, edit);

	/* Title */
	box = gnt_hbox_new(FALSE);
	gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_LEFT);
	gnt_box_add_widget(GNT_BOX(window), box);
	gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Title")));

	edit->title = entry = gnt_entry_new(saved ? purple_savedstatus_get_title(saved) : NULL);
	gnt_box_add_widget(GNT_BOX(box), entry);

	/* Type */
	box = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(window), box);
	gnt_box_add_widget(GNT_BOX(box), label = gnt_label_new(_("Status")));
	gnt_widget_set_size(label, 0, 1);

	edit->type = combo = gnt_combo_box_new();
	gnt_box_add_widget(GNT_BOX(box), combo);
	current = saved ? purple_savedstatus_get_type(saved) : PURPLE_STATUS_UNSET;
	for (i = 0; prims[i] != PURPLE_STATUS_UNSET; i++)
	{
		gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(prims[i]),
				purple_primitive_get_name_from_type(prims[i]));
		if (prims[i] == current)
			gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(current));
	}

	/* Message */
	box = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(window), box);
	gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Message")));

	edit->message = entry = gnt_entry_new(saved ? purple_savedstatus_get_message(saved) : NULL);
	gnt_box_add_widget(GNT_BOX(window), entry);

	gnt_box_add_widget(GNT_BOX(window), gnt_hline_new());
	gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Use different status for following accounts")));

	edit->hash = g_hash_table_new(g_direct_hash, g_direct_equal);
	edit->tree = tree = gnt_tree_new_with_columns(3);
	gnt_box_add_widget(GNT_BOX(window), tree);
	gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
	gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("Status"), _("Message"));
	gnt_tree_set_col_width(GNT_TREE(tree), 0, 30);
	gnt_tree_set_col_width(GNT_TREE(tree), 1, 10);
	gnt_tree_set_col_width(GNT_TREE(tree), 2, 30);

	for (iter = purple_accounts_get_all(); iter; iter = iter->next)
	{
		add_substatus(edit, iter->data);
	}

	g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(popup_substatus), edit);

	/* The buttons */
	box = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(window), box);

	/* Use */
	button = gnt_button_new(_("Use"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(use_trans_status_cb), edit);

	/* Save */
	button = gnt_button_new(_("Save"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_object_set_data(G_OBJECT(button), "use", NULL);
	g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_savedstatus_cb), edit);

	/* Save & Use */
	button = gnt_button_new(_("Save & Use"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_object_set_data(G_OBJECT(button), "use", GINT_TO_POINTER(TRUE));
	g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_savedstatus_cb), edit);

	/* Cancel */
	button = gnt_button_new(_("Cancel"));
	gnt_box_add_widget(GNT_BOX(box), button);
	g_signal_connect_swapped(G_OBJECT(button), "activate",
			G_CALLBACK(gnt_widget_destroy), window);

	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(update_edit_list), edit);

	gnt_widget_show(window);
}
コード例 #12
0
ファイル: gntdebug.c プロジェクト: bf4/pidgin-mac
void finch_debug_window_show()
{
	GntWidget *wid, *box, *label;

	debug.paused = FALSE;
	if (debug.window) {
		gnt_window_present(debug.window);
		return;
	}

	debug.window = gnt_vbox_new(FALSE);
	gnt_box_set_toplevel(GNT_BOX(debug.window), TRUE);
	gnt_box_set_title(GNT_BOX(debug.window), _("Debug Window"));
	gnt_box_set_pad(GNT_BOX(debug.window), 0);
	gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID);

	debug.tview = gnt_text_view_new();
	gnt_box_add_widget(GNT_BOX(debug.window), debug.tview);
	gnt_widget_set_size(debug.tview,
			purple_prefs_get_int(PREF_ROOT "/size/width"),
			purple_prefs_get_int(PREF_ROOT "/size/height"));
	g_signal_connect(G_OBJECT(debug.tview), "size_changed", G_CALLBACK(size_changed_cb), NULL);

	gnt_box_add_widget(GNT_BOX(debug.window), gnt_line_new(FALSE));

	box = gnt_hbox_new(FALSE);
	gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID);
	gnt_box_set_fill(GNT_BOX(box), FALSE);

	/* XXX: Setting the GROW_Y for the following widgets don't make sense. But right now
	 * it's necessary to make the width of the debug window resizable ... like I said,
	 * it doesn't make sense. The bug is likely in the packing in gntbox.c.
	 */
	wid = gnt_button_new(_("Clear"));
	g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(clear_debug_win), debug.tview);
	GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y);
	gnt_box_add_widget(GNT_BOX(box), wid);

	wid = gnt_button_new(_("Save"));
	g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(save_debug_win), debug.tview);
	GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y);
	gnt_box_add_widget(GNT_BOX(box), wid);

	debug.search = gnt_entry_new(purple_prefs_get_string(PREF_ROOT "/filter"));
	label = gnt_label_new(_("Filter:"));
	GNT_WIDGET_UNSET_FLAGS(label, GNT_WIDGET_GROW_X);
	gnt_box_add_widget(GNT_BOX(box), label);
	gnt_box_add_widget(GNT_BOX(box), debug.search);
	g_signal_connect(G_OBJECT(debug.search), "text_changed", G_CALLBACK(update_filter_string), NULL);

	wid = gnt_check_box_new(_("Pause"));
	g_signal_connect(G_OBJECT(wid), "toggled", G_CALLBACK(toggle_pause), NULL);
	GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y);
	gnt_box_add_widget(GNT_BOX(box), wid);

	gnt_box_add_widget(GNT_BOX(debug.window), box);
	GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_GROW_Y);

	gnt_widget_set_name(debug.window, "debug-window");

	g_signal_connect(G_OBJECT(debug.window), "destroy", G_CALLBACK(reset_debug_win), NULL);
	gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(debug.tview), debug.window);
	gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(debug.tview), debug.window);

	gnt_widget_show(debug.window);
}
コード例 #13
0
ファイル: gntft.c プロジェクト: CkNoSFeRaTU/pidgin
void
finch_xfer_dialog_new(void)
{
	GList *iter;
	GntWidget *window;
	GntWidget *bbox;
	GntWidget *button;
	GntWidget *checkbox;
	GntWidget *tree;
	int widths[] = {8, 12, 8, 8, 8, 8, -1};

	if (!xfer_dialog)
		xfer_dialog = g_new0(PurpleGntXferDialog, 1);

	xfer_dialog->keep_open =
		purple_prefs_get_bool("/finch/filetransfer/keep_open");
	xfer_dialog->auto_clear =
		purple_prefs_get_bool("/finch/filetransfer/clear_finished");

	/* Create the window. */
	xfer_dialog->window = window = gnt_vbox_new(FALSE);
	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(finch_xfer_dialog_destroy), NULL);
	gnt_box_set_toplevel(GNT_BOX(window), TRUE);
	gnt_box_set_title(GNT_BOX(window), _("File Transfers"));
	gnt_box_set_fill(GNT_BOX(window), TRUE);
	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);

	xfer_dialog->tree = tree = gnt_tree_new_with_columns(NUM_COLUMNS);
	gnt_tree_set_column_titles(GNT_TREE(tree), _("Progress"), _("Filename"), _("Size"), _("Speed"), _("Remaining"), _("Status"));
	gnt_tree_set_column_width_ratio(GNT_TREE(tree), widths);
	gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_PROGRESS, FALSE);
	gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_SIZE, FALSE);
	gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_SPEED, FALSE);
	gnt_tree_set_column_resizable(GNT_TREE(tree), COLUMN_REMAINING, FALSE);
	gnt_widget_set_size(tree, 70, -1);
	gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
	gnt_box_add_widget(GNT_BOX(window), tree);

	checkbox = gnt_check_box_new( _("Close this window when all transfers finish"));
	gnt_check_box_set_checked(GNT_CHECK_BOX(checkbox),
								 !xfer_dialog->keep_open);
	g_signal_connect(G_OBJECT(checkbox), "toggled",
					 G_CALLBACK(toggle_keep_open_cb), NULL);
	gnt_box_add_widget(GNT_BOX(window), checkbox);

	checkbox = gnt_check_box_new(_("Clear finished transfers"));
	gnt_check_box_set_checked(GNT_CHECK_BOX(checkbox),
								 xfer_dialog->auto_clear);
	g_signal_connect(G_OBJECT(checkbox), "toggled",
					 G_CALLBACK(toggle_clear_finished_cb), NULL);
	gnt_box_add_widget(GNT_BOX(window), checkbox);

	bbox = gnt_hbox_new(FALSE);

	xfer_dialog->remove_button = button = gnt_button_new(_("Remove"));
	g_signal_connect(G_OBJECT(button), "activate",
					 G_CALLBACK(remove_button_cb), NULL);
	gnt_box_add_widget(GNT_BOX(bbox), button);

	xfer_dialog->stop_button = button = gnt_button_new(_("Stop"));
	g_signal_connect(G_OBJECT(button), "activate",
					 G_CALLBACK(stop_button_cb), NULL);
	gnt_box_add_widget(GNT_BOX(bbox), button);

	xfer_dialog->close_button = button = gnt_button_new(_("Close"));
	g_signal_connect(G_OBJECT(button), "activate",
					 G_CALLBACK(finch_xfer_dialog_destroy), NULL);
	gnt_box_add_widget(GNT_BOX(bbox), button);

	gnt_box_add_widget(GNT_BOX(window), bbox);

	for (iter = purple_xfers_get_all(); iter; iter = iter->next) {
		PurpleXfer *xfer = (PurpleXfer *)iter->data;
		PurpleGntXferUiData *data = FINCHXFER(xfer);
		if (data->in_list) {
			finch_xfer_dialog_add_xfer(xfer);
			finch_xfer_dialog_update_xfer(xfer);
			gnt_tree_set_selected(GNT_TREE(tree), xfer);
		}
	}
	gnt_widget_show(xfer_dialog->window);
}
コード例 #14
0
ファイル: gntrequest.c プロジェクト: bf4/pidgin-mac
static void *
finch_request_fields(const char *title, const char *primary,
		const char *secondary, PurpleRequestFields *allfields,
		const char *ok, GCallback ok_cb,
		const char *cancel, GCallback cancel_cb,
		PurpleAccount *account, const char *who, PurpleConversation *conv,
		void *userdata)
{
	GntWidget *window, *box;
	GList *grlist;
	GntWidget *screenname = NULL, *accountlist = NULL;

	window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS);

	/* This is how it's going to work: the request-groups are going to be
	 * stacked vertically one after the other. A GntLine will be separating
	 * the groups. */
	box = gnt_vbox_new(FALSE);
	gnt_box_set_pad(GNT_BOX(box), 0);
	gnt_box_set_fill(GNT_BOX(box), TRUE);
	for (grlist = purple_request_fields_get_groups(allfields); grlist; grlist = grlist->next)
	{
		PurpleRequestFieldGroup *group = grlist->data;
		GList *fields = purple_request_field_group_get_fields(group);
		GntWidget *hbox;
		const char *title = purple_request_field_group_get_title(group);

		if (title)
			gnt_box_add_widget(GNT_BOX(box),
					gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD));

		for (; fields ; fields = fields->next)
		{
			/* XXX: Break each of the fields into a separate function? */
			PurpleRequestField *field = fields->data;
			PurpleRequestFieldType type = purple_request_field_get_type(field);
			const char *label = purple_request_field_get_label(field);

			hbox = gnt_hbox_new(TRUE);   /* hrm */
			gnt_box_add_widget(GNT_BOX(box), hbox);

			if (type != PURPLE_REQUEST_FIELD_BOOLEAN && label)
			{
				GntWidget *l;
				if (purple_request_field_is_required(field))
					l = gnt_label_new_with_format(label, GNT_TEXT_FLAG_UNDERLINE);
				else
					l = gnt_label_new(label);
				gnt_widget_set_size(l, 0, 1);
				gnt_box_add_widget(GNT_BOX(hbox), l);
			}

			if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
			{
				FINCH_SET_DATA(field, create_boolean_field(field));
			}
			else if (type == PURPLE_REQUEST_FIELD_STRING)
			{
				FINCH_SET_DATA(field, create_string_field(field, &screenname));
			}
			else if (type == PURPLE_REQUEST_FIELD_INTEGER)
			{
				FINCH_SET_DATA(field, create_integer_field(field));
			}
			else if (type == PURPLE_REQUEST_FIELD_CHOICE)
			{
				FINCH_SET_DATA(field, create_choice_field(field));
			}
			else if (type == PURPLE_REQUEST_FIELD_LIST)
			{
				FINCH_SET_DATA(field, create_list_field(field));
			}
			else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
			{
				accountlist = FINCH_SET_DATA(field, create_account_field(field));
			}
			else
			{
				FINCH_SET_DATA(field, gnt_label_new_with_format(_("Not implemented yet."),
						GNT_TEXT_FLAG_BOLD));
			}
			gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
			gnt_box_add_widget(GNT_BOX(hbox), GNT_WIDGET(FINCH_GET_DATA(field)));
		}
		if (grlist->next)
			gnt_box_add_widget(GNT_BOX(box), gnt_hline_new());
	}
	gnt_box_add_widget(GNT_BOX(window), box);

	box = setup_button_box(window, userdata, request_fields_cb, allfields,
			ok, ok_cb, cancel, cancel_cb, NULL);
	gnt_box_add_widget(GNT_BOX(window), box);

	setup_default_callback(window, cancel_cb, userdata);
	gnt_widget_show(window);

	if (screenname && accountlist) {
		g_signal_connect(screenname, "completion", G_CALLBACK(update_selected_account), accountlist);
	}

	g_object_set_data(G_OBJECT(window), "fields", allfields);

	return window;
}
コード例 #15
0
ファイル: gntroomlist.c プロジェクト: bf4/pidgin-mac
static void
setup_roomlist(PurpleAccount *account)
{
	GntWidget *window, *tree, *hbox, *accounts;
	int iter;
	struct {
		const char *label;
		GCallback callback;
		GntWidget **widget;
	} buttons[] = {
		{_("Stop"), G_CALLBACK(fl_stop), &froomlist.stop},
		{_("Get"), G_CALLBACK(fl_get_list), &froomlist.getlist},
		{_("Add"), G_CALLBACK(fl_add_chat), &froomlist.add},
		{_("Close"), G_CALLBACK(fl_close), &froomlist.close},
		{NULL, NULL, NULL}
	};

	if (froomlist.window)
		return;

	froomlist.window = window = gnt_window_new();
	g_object_set(G_OBJECT(window), "vertical", TRUE, NULL);
	gnt_box_set_pad(GNT_BOX(window), 0);
	gnt_box_set_title(GNT_BOX(window), _("Room List"));
	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);

	froomlist.accounts = accounts = gnt_combo_box_new();
	reset_account_list(account);
	gnt_box_add_widget(GNT_BOX(window), accounts);
	g_signal_connect(G_OBJECT(accounts), "selection-changed",
			G_CALLBACK(roomlist_account_changed), NULL);
	froomlist.account = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(accounts));

	froomlist.tree = tree = gnt_tree_new_with_columns(2);
	gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
	g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(roomlist_activated), NULL);
	gnt_tree_set_column_titles(GNT_TREE(tree), _("Name"), "");
	gnt_tree_set_show_separator(GNT_TREE(tree), FALSE);
	gnt_tree_set_col_width(GNT_TREE(tree), 1, 1);
	gnt_tree_set_column_resizable(GNT_TREE(tree), 1, FALSE);
	gnt_tree_set_search_column(GNT_TREE(tree), 0);

	gnt_box_add_widget(GNT_BOX(window), tree);

	froomlist.details = gnt_text_view_new();
	gnt_text_view_set_flag(GNT_TEXT_VIEW(froomlist.details), GNT_TEXT_VIEW_TOP_ALIGN);
	gnt_box_add_widget(GNT_BOX(window), froomlist.details);
	gnt_widget_set_size(froomlist.details, -1, 8);

	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(window), hbox);

	for (iter = 0; buttons[iter].label; iter++) {
		GntWidget *button = gnt_button_new(buttons[iter].label);
		gnt_box_add_widget(GNT_BOX(hbox), button);
		g_signal_connect(G_OBJECT(button), "activate", buttons[iter].callback, NULL);
		*buttons[iter].widget = button;
		gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(froomlist.details), button);
	}

	g_signal_connect(G_OBJECT(tree), "selection-changed", G_CALLBACK(roomlist_selection_changed), NULL);

	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(unset_roomlist), NULL);
}
コード例 #16
0
ファイル: gntbox.c プロジェクト: wosigh/messaging-plugins
static gboolean
gnt_box_confirm_size(GntWidget *widget, int width, int height)
{
	GList *iter;
	GntBox *box = GNT_BOX(widget);
	int wchange, hchange;

	if (!box->list)
		return TRUE;

	wchange = widget->priv.width - width;
	hchange = widget->priv.height - height;

	if (wchange == 0 && hchange == 0)
		return TRUE;		/* Quit playing games */

	/* XXX: Right now, I am trying to just apply all the changes to 
	 * just one widget. It should be possible to distribute the
	 * changes to all the widgets in the box. */
	for (iter = box->list; iter; iter = iter->next)
	{
		GntWidget *wid = iter->data;
		int w, h;

		gnt_widget_get_size(wid, &w, &h);

		if (gnt_widget_confirm_size(wid, w - wchange, h - hchange))
		{
			GList *i;

			for (i = box->list; i; i = i->next)
			{
				int tw, th;
				if (i == iter) continue;
				gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
				if (box->vertical)
				{
					if (!gnt_widget_confirm_size(i->data, tw - wchange, th)) {
						/* If we are decreasing the size and the widget is going
						 * to be too large to fit into the box, then do not allow
						 * resizing. */
						if (wchange > 0 && tw >= widget->priv.width)
							return FALSE;
					}
				}
				else
				{
					if (!gnt_widget_confirm_size(i->data, tw, th - hchange)) {
						if (hchange > 0 && th >= widget->priv.height)
							return FALSE;
						return FALSE;
					}
				}
			}
#if 0
			gnt_widget_set_size(wid, w - wchange, h - hchange);
			if (box->vertical)
				hchange = 0;
			else
				wchange = 0;

			for (i = box->list; i; i = i->next)
			{
				int tw, th;
				if (i == iter) continue;
				gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
				gnt_widget_set_size(i->data, tw - wchange, th - hchange);
			}
#endif
			g_object_set_data(G_OBJECT(box), "size-queued", wid);
			return TRUE;
		}
	}

	return FALSE;
}
コード例 #17
0
ファイル: gntstatus.c プロジェクト: crodjer/pidgin_whiteboard
static gboolean
popup_substatus(GntTree *tree, const char *key, EditStatus *edit)
{
	if (key[0] == ' ' && key[1] == 0)
	{
		EditSubStatus *sub;
		GntWidget *window, *combo, *entry, *box, *button, *l;
		PurpleSavedStatusSub *substatus = NULL;
		GList *iter;
		char *name;
		RowInfo *selected = gnt_tree_get_selection_data(tree);
		PurpleAccount *account = selected->account;

		if (gnt_tree_get_choice(tree, selected))
		{
			/* There was a savedstatus for this account. Now remove it. */
			g_free(selected->message);
			selected->type = NULL;
			selected->message = NULL;
			/* XXX: should we really be saving it right now? */
			purple_savedstatus_unset_substatus(edit->saved, account);
			gnt_tree_change_text(tree, account, 1, NULL);
			gnt_tree_change_text(tree, account, 2, NULL);
			return FALSE;
		}

		if (g_hash_table_lookup(edit->hash, account))
			return TRUE;

		if (edit->saved)
			substatus = purple_savedstatus_get_substatus(edit->saved, account);

		sub = g_new0(EditSubStatus, 1);
		sub->parent = edit;
		sub->key = selected;

		sub->window = window = gnt_vbox_new(FALSE);
		gnt_box_set_toplevel(GNT_BOX(window), TRUE);
		gnt_box_set_title(GNT_BOX(window), _("Substatus"));  /* XXX: a better title */
		gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);

		box = gnt_hbox_new(FALSE);
		gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Account:")));
		name = g_strdup_printf("%s (%s)", purple_account_get_username(account),
				purple_account_get_protocol_name(account));
		gnt_box_add_widget(GNT_BOX(box), gnt_label_new(name));
		g_free(name);
		gnt_box_add_widget(GNT_BOX(window), box);

		box = gnt_hbox_new(FALSE);
		gnt_box_add_widget(GNT_BOX(box), (l = gnt_label_new(_("Status:"))));
		gnt_widget_set_size(l, 0, 1);   /* I don't like having to do this */
		sub->type = combo = gnt_combo_box_new();
		gnt_box_add_widget(GNT_BOX(box), combo);
		gnt_box_add_widget(GNT_BOX(window), box);

		for (iter = purple_account_get_status_types(account); iter; iter = iter->next)
		{
			PurpleStatusType *type = iter->data;
			if (!purple_status_type_is_user_settable(type))
				continue;
			gnt_combo_box_add_data(GNT_COMBO_BOX(combo), type, purple_status_type_get_name(type));
		}

		box = gnt_hbox_new(FALSE);
		gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Message:")));
		sub->message = entry = gnt_entry_new(substatus ? purple_savedstatus_substatus_get_message(substatus) : NULL);
		gnt_box_add_widget(GNT_BOX(box), entry);
		gnt_box_add_widget(GNT_BOX(window), box);

		box  = gnt_hbox_new(FALSE);
		button = gnt_button_new(_("Cancel"));
		g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window);
		gnt_box_add_widget(GNT_BOX(box), button);
		button = gnt_button_new(_("Save"));
		g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_substatus_cb), sub);
		gnt_box_add_widget(GNT_BOX(box), button);
		gnt_box_add_widget(GNT_BOX(window), box);

		gnt_widget_show(window);

		g_hash_table_insert(edit->hash, account, sub);

		g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(substatus_window_destroy_cb), sub);

		return TRUE;
	}
	return FALSE;
}
コード例 #18
0
ファイル: gntnotify.c プロジェクト: Draghtnod/pidgin
static void *
finch_notify_common(PurpleNotifyType ntype, PurpleNotifyMsgType msgtype,
	const char *title, const char *primary, const char *secondary)
{
	GntWidget *window, *button;
	GntTextFormatFlags pf = 0, sf = 0;

	switch (msgtype)
	{
		case PURPLE_NOTIFY_MSG_ERROR:
			sf |= GNT_TEXT_FLAG_BOLD;
			/* fall through */
		case PURPLE_NOTIFY_MSG_WARNING:
			pf |= GNT_TEXT_FLAG_UNDERLINE;
			/* fall through */
		case PURPLE_NOTIFY_MSG_INFO:
			pf |= GNT_TEXT_FLAG_BOLD;
			break;
	}

	window = gnt_window_box_new(FALSE, TRUE);
	gnt_box_set_title(GNT_BOX(window), title);
	gnt_box_set_fill(GNT_BOX(window), FALSE);
	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
	gnt_box_set_pad(GNT_BOX(window), 0);

	if (primary)
		gnt_box_add_widget(GNT_BOX(window),
				gnt_label_new_with_format(primary, pf));

	button = gnt_button_new(_("OK"));

	if (secondary) {
		GntWidget *msg;
		if (ntype == PURPLE_NOTIFY_FORMATTED) {
			int width = -1, height = -1;
			char *plain = (char*)secondary;
			msg = gnt_text_view_new();
			gnt_text_view_set_flag(GNT_TEXT_VIEW(msg), GNT_TEXT_VIEW_TOP_ALIGN | GNT_TEXT_VIEW_NO_SCROLL);

			plain = purple_markup_strip_html(secondary);
			if (!gnt_util_parse_xhtml_to_textview(secondary, GNT_TEXT_VIEW(msg)))
				gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(msg), plain, sf);

			gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(msg), button);
			gnt_util_get_text_bound(plain, &width, &height);
			gnt_widget_set_size(msg, width + 3, height + 1);
			if (plain != secondary)
				g_free(plain);
		} else {
			msg = gnt_label_new_with_format(secondary, sf);
		}
		gnt_box_add_widget(GNT_BOX(window), msg);
		g_object_set_data(G_OBJECT(window), "info-widget", msg);
	}

	gnt_box_add_widget(GNT_BOX(window), button);
	g_signal_connect_swapped(G_OBJECT(button), "activate",
			G_CALLBACK(gnt_widget_destroy), window);
	g_signal_connect(G_OBJECT(window), "destroy",
			G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(ntype));

	gnt_widget_show(window);
	return window;
}
コード例 #19
0
ファイル: gntprogressbar.c プロジェクト: CkNoSFeRaTU/pidgin
static void
gnt_progress_bar_size_request (GntWidget *widget)
{
	gnt_widget_set_size (widget, widget->priv.minw, widget->priv.minh);
}