static void
save_savedstatus_cb(GntWidget *button, EditStatus *edit)
{
	const char *title, *message;
	PurpleStatusPrimitive prim;
	PurpleSavedStatus *find;

	title = gnt_entry_get_text(GNT_ENTRY(edit->title));
	message = gnt_entry_get_text(GNT_ENTRY(edit->message));
	if (!message || !*message)
		message = NULL;

	prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type)));

	if (!title || !*title)
	{
		purple_notify_error(edit, _("Error"), _("Invalid title"),
				_("Please enter a non-empty title for the status."));
		gnt_box_give_focus_to_child(GNT_BOX(edit->window), edit->title);
		return;
	}

	find = purple_savedstatus_find(title);
	if (find && find != edit->saved)
	{
		purple_notify_error(edit, _("Error"), _("Duplicate title"),
				_("Please enter a different title for the status."));
		gnt_box_give_focus_to_child(GNT_BOX(edit->window), edit->title);
		return;
	}
	
	if (edit->saved == NULL)
	{
		edit->saved = purple_savedstatus_new(title, prim);
		purple_savedstatus_set_message(edit->saved, message);
		set_substatuses(edit);
		if (statuses.tree)
			gnt_tree_add_row_last(GNT_TREE(statuses.tree), edit->saved,
					gnt_tree_create_row(GNT_TREE(statuses.tree), title,
						purple_primitive_get_name_from_type(prim), message), NULL);
	}
	else
	{
		purple_savedstatus_set_title(edit->saved, title);
		purple_savedstatus_set_type(edit->saved, prim);
		purple_savedstatus_set_message(edit->saved, message);
		if (statuses.tree)
		{
			gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 0, title);
			gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 1,
						purple_primitive_get_name_from_type(prim));
			gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 2, message);
		}
	}

	if (g_object_get_data(G_OBJECT(button), "use"))
		purple_savedstatus_activate(edit->saved);

	gnt_widget_destroy(edit->window);
}
Exemple #2
0
static void
save_cb(GntWidget *button, gpointer win)
{
	GList * itr;

	purple_prefs_set_string(make_pref("/method"), gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->method)));
	purple_prefs_set_path(make_pref("/command"), gnt_entry_get_text(GNT_ENTRY(pref_dialog->command)));
	purple_prefs_set_bool(make_pref("/conv_focus"), gnt_check_box_get_checked(GNT_CHECK_BOX(pref_dialog->conv_focus)));
	purple_prefs_set_int("/purple/sound/while_status", GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->while_status))));

	for (itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events)); itr; itr = itr->next) {
		FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(itr->data)];
		char * filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", finch_sound_get_active_profile(), event->pref);
		char * boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", finch_sound_get_active_profile(), event->pref);
		purple_prefs_set_bool(boolpref, gnt_tree_get_choice(GNT_TREE(pref_dialog->events), itr->data));
		purple_prefs_set_path(filepref, event->file ? event->file : "");
		g_free(filepref);
		g_free(boolpref);
	}
	gnt_widget_destroy(GNT_WIDGET(win));
}
Exemple #3
0
static void fl_get_list(GntWidget *button, gpointer null)
{
	PurpleAccount *account = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(froomlist.accounts));
	PurpleConnection *gc = purple_account_get_connection(account);

	if (!gc)
		return;

	update_roomlist(NULL);
	froomlist.roomlist = purple_roomlist_get_list(gc);
	gnt_box_give_focus_to_child(GNT_BOX(froomlist.window), froomlist.tree);
}
Exemple #4
0
static void
request_choice_cb(GntWidget *button, GntComboBox *combo)
{
	PurpleRequestChoiceCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
	gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
	int choice = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))) - 1;

	if (callback)
		callback(data, choice);

	while (button->parent)
		button = button->parent;

	purple_request_close(PURPLE_REQUEST_INPUT, button);
}
static void
use_trans_status_cb(GntWidget *button, EditStatus *edit)
{
	const char *message;
	PurpleStatusPrimitive prim;
	PurpleSavedStatus *saved;

	message = gnt_entry_get_text(GNT_ENTRY(edit->message));
	prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type)));

	saved = purple_savedstatus_find_transient_by_type_and_message(prim, message);
	if (saved == NULL) {
		saved = purple_savedstatus_new(NULL, prim);
		edit->saved = saved;
		set_substatuses(edit);
	}
	purple_savedstatus_set_message(saved, message);
	purple_savedstatus_activate(saved);
	gnt_widget_destroy(edit->window);
}
static void
save_substatus_cb(GntWidget *widget, EditSubStatus *sub)
{
	PurpleSavedStatus *saved = sub->parent->saved;
	RowInfo *row = sub->key;
	const char *message;
	PurpleStatusType *type;

	type = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(sub->type));
	message = gnt_entry_get_text(GNT_ENTRY(sub->message));

	row->type = type;
	row->message = g_strdup(message);

	if (saved)    /* Save the substatus if the savedstatus actually exists. */
		purple_savedstatus_set_substatus(saved, row->account, type, message);

	gnt_tree_set_choice(GNT_TREE(sub->parent->tree), row, TRUE);
	gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 1,
			purple_status_type_get_name(type));
	gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 2, message);
	
	gnt_widget_destroy(sub->window);
}
Exemple #7
0
static void
save_pounce_cb(GntWidget *w, PurpleGntPounceDialog *dialog)
{
	const char *name;
	const char *message, *command, *reason;
	PurplePounceEvent events   = PURPLE_POUNCE_NONE;
	PurplePounceOption options = PURPLE_POUNCE_OPTION_NONE;

	name = gnt_entry_get_text(GNT_ENTRY(dialog->buddy_entry));

	if (*name == '\0')
	{
		purple_notify_error(NULL, NULL,
						  _("Please enter a buddy to pounce."), NULL);
		return;
	}

	/* Options */
	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->on_away)))
		options |= PURPLE_POUNCE_OPTION_AWAY;

	/* Events */
	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signon)))
		events |= PURPLE_POUNCE_SIGNON;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signoff)))
		events |= PURPLE_POUNCE_SIGNOFF;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away)))
		events |= PURPLE_POUNCE_AWAY;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away_return)))
		events |= PURPLE_POUNCE_AWAY_RETURN;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle)))
		events |= PURPLE_POUNCE_IDLE;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle_return)))
		events |= PURPLE_POUNCE_IDLE_RETURN;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typing)))
		events |= PURPLE_POUNCE_TYPING;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typed)))
		events |= PURPLE_POUNCE_TYPED;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->stop_typing)))
		events |= PURPLE_POUNCE_TYPING_STOPPED;

	if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->message_recv)))
		events |= PURPLE_POUNCE_MESSAGE_RECEIVED;

	/* Data fields */
	message = gnt_entry_get_text(GNT_ENTRY(dialog->send_msg_entry));
	command = gnt_entry_get_text(GNT_ENTRY(dialog->exec_cmd_entry));
	reason  = gnt_entry_get_text(GNT_ENTRY(dialog->popup_entry));

	if (*reason == '\0') reason = NULL;
	if (*message == '\0') message = NULL;
	if (*command == '\0') command = NULL;

	if (dialog->pounce == NULL) {
		dialog->pounce = purple_pounce_new(FINCH_UI, dialog->account,
										 name, events, options);
	} else {
		purple_pounce_set_events(dialog->pounce, events);
		purple_pounce_set_options(dialog->pounce, options);
		purple_pounce_set_pouncer(dialog->pounce, dialog->account);
		purple_pounce_set_pouncee(dialog->pounce, name);
	}

	/* Actions */
	purple_pounce_action_set_enabled(dialog->pounce, "open-window",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win)));
	purple_pounce_action_set_enabled(dialog->pounce, "popup-notify",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup)));
	purple_pounce_action_set_enabled(dialog->pounce, "send-message",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg)));
	purple_pounce_action_set_enabled(dialog->pounce, "execute-command",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd)));
	purple_pounce_action_set_enabled(dialog->pounce, "play-beep",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound)));

	purple_pounce_action_set_attribute(dialog->pounce, "send-message",
									 "message", message);
	purple_pounce_action_set_attribute(dialog->pounce, "execute-command",
									 "command", command);
	purple_pounce_action_set_attribute(dialog->pounce, "popup-notify",
									 "reason", reason);

	/* Set the defaults for next time. */
	purple_prefs_set_bool("/finch/pounces/default_actions/open-window",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win)));
	purple_prefs_set_bool("/finch/pounces/default_actions/popup-notify",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup)));
	purple_prefs_set_bool("/finch/pounces/default_actions/send-message",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg)));
	purple_prefs_set_bool("/finch/pounces/default_actions/execute-command",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd)));
	purple_prefs_set_bool("/finch/pounces/default_actions/play-beep",
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound)));

	purple_pounce_set_save(dialog->pounce,
		gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->save_pounce)));

	purple_pounce_set_pouncer(dialog->pounce,
		(PurpleAccount *)gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->account_menu)));

	update_pounces();

	gnt_widget_destroy(dialog->window);
}
Exemple #8
0
static void
request_fields_cb(GntWidget *button, PurpleRequestFields *fields)
{
	PurpleRequestFieldsCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
	gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
	GList *list;

	/* Update the data of the fields. Pidgin does this differently. Instead of
	 * updating the fields at the end like here, it updates the appropriate field
	 * instantly whenever a change is made. That allows it to make sure the
	 * 'required' fields are entered before the user can hit OK. It's not the case
	 * here, althought it can be done. */
	for (list = purple_request_fields_get_groups(fields); list; list = list->next)
	{
		PurpleRequestFieldGroup *group = list->data;
		GList *fields = purple_request_field_group_get_fields(group);

		for (; fields ; fields = fields->next)
		{
			PurpleRequestField *field = fields->data;
			PurpleRequestFieldType type = purple_request_field_get_type(field);
			if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
			{
				GntWidget *check = FINCH_GET_DATA(field);
				gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check));
				purple_request_field_bool_set_value(field, value);
			}
			else if (type == PURPLE_REQUEST_FIELD_STRING)
			{
				GntWidget *entry = FINCH_GET_DATA(field);
				const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
				purple_request_field_string_set_value(field, (text && *text) ? text : NULL);
			}
			else if (type == PURPLE_REQUEST_FIELD_INTEGER)
			{
				GntWidget *entry = FINCH_GET_DATA(field);
				const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
				int value = (text && *text) ? atoi(text) : 0;
				purple_request_field_int_set_value(field, value);
			}
			else if (type == PURPLE_REQUEST_FIELD_CHOICE)
			{
				GntWidget *combo = FINCH_GET_DATA(field);
				int id;
				id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
				purple_request_field_choice_set_value(field, id);
			}
			else if (type == PURPLE_REQUEST_FIELD_LIST)
			{
				GList *list = NULL;
				if (purple_request_field_list_get_multi_select(field))
				{
					GList *iter;
					GntWidget *tree = FINCH_GET_DATA(field);

					iter = purple_request_field_list_get_items(field);
					for (; iter; iter = iter->next)
					{
						const char *text = iter->data;
						gpointer key = purple_request_field_list_get_data(field, text);
						if (gnt_tree_get_choice(GNT_TREE(tree), key))
							list = g_list_prepend(list, key);
					}
				}
				else
				{
					GntWidget *combo = FINCH_GET_DATA(field);
					gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
					list = g_list_append(list, data);
				}

				purple_request_field_list_set_selected(field, list);
				g_list_free(list);
			}
			else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
			{
				GntWidget *combo = FINCH_GET_DATA(field);
				PurpleAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
				purple_request_field_account_set_value(field, acc);
			}
		}
	}

	purple_notify_close_with_handle(button);

	if (!g_object_get_data(G_OBJECT(button), "cancellation-function") &&
			!purple_request_fields_all_required_filled(fields)) {
		purple_notify_error(button, _("Error"),
				_("You must fill all the required fields."),
				_("The required fields are underlined."));
		return;
	}

	if (callback)
		callback(data, fields);

	while (button->parent)
		button = button->parent;

	purple_request_close(PURPLE_REQUEST_FIELDS, button);
}
Exemple #9
0
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);
}