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)); }
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); }
static void toggle_option(GntCheckBox *check, gpointer str) { purple_prefs_set_bool(str, gnt_check_box_get_checked(check)); }
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); }