static void setup_email_dialog(void) { GntWidget *box, *tree, *button; if (emaildialog.window) return; emaildialog.window = box = gnt_vbox_new(FALSE); gnt_box_set_toplevel(GNT_BOX(box), TRUE); gnt_box_set_title(GNT_BOX(box), _("Emails")); gnt_box_set_fill(GNT_BOX(box), FALSE); gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); gnt_box_set_pad(GNT_BOX(box), 0); gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD)); emaildialog.tree = tree = gnt_tree_new_with_columns(3); gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("Sender"), _("Subject")); gnt_tree_set_show_title(GNT_TREE(tree), TRUE); gnt_tree_set_col_width(GNT_TREE(tree), 0, 15); gnt_tree_set_col_width(GNT_TREE(tree), 1, 25); gnt_tree_set_col_width(GNT_TREE(tree), 2, 25); gnt_box_add_widget(GNT_BOX(box), tree); 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), box); g_signal_connect(G_OBJECT(box), "destroy", G_CALLBACK(reset_email_dialog), NULL); }
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); }
static GntWidget * config_frame(void) { GntWidget *window, *tree, *check; int i; window = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(window), 0); gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); gnt_box_set_fill(GNT_BOX(window), TRUE); gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Notify with a toaster when"))); tree = gnt_tree_new(); gnt_box_add_widget(GNT_BOX(window), tree); for (i = 0; prefs[i].pref; i++) { gnt_tree_add_choice(GNT_TREE(tree), prefs[i].pref, gnt_tree_create_row(GNT_TREE(tree), prefs[i].display), NULL, NULL); gnt_tree_set_choice(GNT_TREE(tree), prefs[i].pref, purple_prefs_get_bool(prefs[i].pref)); } gnt_tree_set_col_width(GNT_TREE(tree), 0, 40); g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL); check = gnt_check_box_new(_("Beep too!")); gnt_check_box_set_checked(GNT_CHECK_BOX(check), purple_prefs_get_bool(PREFS_BEEP)); g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_BEEP); gnt_box_add_widget(GNT_BOX(window), check); #ifdef HAVE_X11 check = gnt_check_box_new(_("Set URGENT for the terminal window.")); gnt_check_box_set_checked(GNT_CHECK_BOX(check), purple_prefs_get_bool(PREFS_URGENT)); g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_URGENT); gnt_box_add_widget(GNT_BOX(window), check); #endif return window; }
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; }
static void * finch_notify_searchresults(PurpleConnection *gc, const char *title, const char *primary, const char *secondary, PurpleNotifySearchResults *results, gpointer data) { GntWidget *window, *tree, *box, *button; GList *iter; int columns, i; window = gnt_vbox_new(FALSE); gnt_box_set_toplevel(GNT_BOX(window), TRUE); gnt_box_set_title(GNT_BOX(window), title); gnt_box_set_fill(GNT_BOX(window), TRUE); gnt_box_set_pad(GNT_BOX(window), 0); gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); if (primary) gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD)); if (secondary) gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL)); columns = g_list_length(results->columns); tree = gnt_tree_new_with_columns(columns); gnt_tree_set_show_title(GNT_TREE(tree), TRUE); gnt_box_add_widget(GNT_BOX(window), tree); i = 0; for (iter = results->columns; iter; iter = iter->next) { PurpleNotifySearchColumn *column = iter->data; gnt_tree_set_column_title(GNT_TREE(tree), i, column->title); i++; } box = gnt_hbox_new(TRUE); for (iter = results->buttons; iter; iter = iter->next) { PurpleNotifySearchButton *b = iter->data; const char *text; switch (b->type) { case PURPLE_NOTIFY_BUTTON_LABELED: text = b->label; break; case PURPLE_NOTIFY_BUTTON_CONTINUE: text = _("Continue"); break; case PURPLE_NOTIFY_BUTTON_ADD: text = _("Add"); break; case PURPLE_NOTIFY_BUTTON_INFO: text = _("Info"); break; case PURPLE_NOTIFY_BUTTON_IM: text = _("IM"); break; case PURPLE_NOTIFY_BUTTON_JOIN: text = _("Join"); break; case PURPLE_NOTIFY_BUTTON_INVITE: text = _("Invite"); break; default: text = _("(none)"); } button = gnt_button_new(text); g_object_set_data(G_OBJECT(button), "notify-account", purple_connection_get_account(gc)); g_object_set_data(G_OBJECT(button), "notify-data", data); g_object_set_data(G_OBJECT(button), "notify-tree", tree); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(notify_button_activated), b); gnt_box_add_widget(GNT_BOX(box), button); } gnt_box_add_widget(GNT_BOX(window), box); finch_notify_sr_new_rows(gc, results, tree); gnt_widget_show(window); g_object_set_data(G_OBJECT(window), "notify-results", results); return tree; }
void finch_sounds_show_all(void) { GntWidget *box, *tmpbox, *splitbox, *cmbox, *slider; GntWidget *entry; GntWidget *chkbox; GntWidget *button; GntWidget *label; GntWidget *tree; GntWidget *win; gint i; GList *itr, *list; if (pref_dialog) { gnt_window_present(pref_dialog->window); return; } pref_dialog = g_new0(SoundPrefDialog, 1); pref_dialog->original_profile = g_strdup(finch_sound_get_active_profile()); pref_dialog->window = win = gnt_window_box_new(FALSE, TRUE); gnt_box_set_pad(GNT_BOX(win), 0); gnt_box_set_toplevel(GNT_BOX(win), TRUE); gnt_box_set_title(GNT_BOX(win), _("Sound Preferences")); gnt_box_set_fill(GNT_BOX(win), TRUE); gnt_box_set_alignment(GNT_BOX(win), GNT_ALIGN_MID); /* Profiles */ splitbox = gnt_hbox_new(FALSE); gnt_box_set_pad(GNT_BOX(splitbox), 0); gnt_box_set_alignment(GNT_BOX(splitbox), GNT_ALIGN_TOP); box = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(box), 0); gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Profiles"), GNT_TEXT_FLAG_BOLD)); pref_dialog->profiles = tree = gnt_tree_new(); gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); gnt_tree_set_compare_func(GNT_TREE(tree), (GCompareFunc)g_ascii_strcasecmp); g_signal_connect(G_OBJECT(tree), "selection-changed", G_CALLBACK(prof_load_cb), NULL); itr = list = finch_sound_get_profiles(); for (; itr; itr = itr->next) { /* Do not free itr->data. It's the stored as a key for the tree, and will * be freed when the tree is destroyed. */ gnt_tree_add_row_after(GNT_TREE(tree), itr->data, gnt_tree_create_row(GNT_TREE(tree), itr->data), NULL, NULL); } g_list_free(list); gnt_box_add_widget(GNT_BOX(box), tree); pref_dialog->new_profile = entry = gnt_entry_new(""); gnt_box_add_widget(GNT_BOX(box), entry); tmpbox = gnt_hbox_new(FALSE); button = gnt_button_new("Add"); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(prof_add_cb), entry); gnt_box_add_widget(GNT_BOX(tmpbox), button); button = gnt_button_new("Delete"); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(prof_del_cb), NULL); gnt_box_add_widget(GNT_BOX(tmpbox), button); gnt_box_add_widget(GNT_BOX(box), tmpbox); gnt_box_add_widget(GNT_BOX(splitbox), box); gnt_box_add_widget(GNT_BOX(splitbox), gnt_vline_new()); /* Sound method */ box = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(box), 0); pref_dialog->method = cmbox = gnt_combo_box_new(); gnt_tree_set_hash_fns(GNT_TREE(GNT_COMBO_BOX(cmbox)->dropdown), g_str_hash, g_str_equal, NULL); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "automatic", _("Automatic")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "alsa", "ALSA"); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "esd", "ESD"); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "beep", _("Console Beep")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "custom", _("Command")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "nosound", _("No Sound")); label = gnt_label_new_with_format(_("Sound Method"), GNT_TEXT_FLAG_BOLD); gnt_box_add_widget(GNT_BOX(box), label); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Method: "))); gnt_box_add_widget(GNT_BOX(tmpbox), cmbox); gnt_box_add_widget(GNT_BOX(box), tmpbox); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Sound Command\n(%s for filename)"))); pref_dialog->command = entry = gnt_entry_new(""); gnt_box_add_widget(GNT_BOX(tmpbox), entry); gnt_box_add_widget(GNT_BOX(box), tmpbox); gnt_box_add_widget(GNT_BOX(box), gnt_line_new(FALSE)); /* Sound options */ gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Sound Options"), GNT_TEXT_FLAG_BOLD)); pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus")); gnt_box_add_widget(GNT_BOX(box), chkbox); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new("Enable Sounds:")); pref_dialog->while_status = cmbox = gnt_combo_box_new(); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(3), _("Always")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(1), _("Only when available")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(2), _("Only when not available")); gnt_box_add_widget(GNT_BOX(tmpbox), cmbox); gnt_box_add_widget(GNT_BOX(box), tmpbox); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Volume(0-100):"))); pref_dialog->volume = slider = gnt_slider_new(FALSE, 100, 0); gnt_slider_set_step(GNT_SLIDER(slider), 5); gnt_slider_set_small_step(GNT_SLIDER(slider), 1); gnt_slider_set_large_step(GNT_SLIDER(slider), 20); label = gnt_label_new(""); gnt_slider_reflect_label(GNT_SLIDER(slider), GNT_LABEL(label)); gnt_box_set_pad(GNT_BOX(tmpbox), 1); gnt_box_add_widget(GNT_BOX(tmpbox), slider); gnt_box_add_widget(GNT_BOX(tmpbox), label); gnt_box_add_widget(GNT_BOX(box), tmpbox); gnt_box_add_widget(GNT_BOX(splitbox), box); gnt_box_add_widget(GNT_BOX(win), splitbox); gnt_box_add_widget(GNT_BOX(win), gnt_hline_new()); /* Sound events */ gnt_box_add_widget(GNT_BOX(win), gnt_label_new_with_format(_("Sound Events"), GNT_TEXT_FLAG_BOLD)); pref_dialog->events = tree = gnt_tree_new_with_columns(2); gnt_tree_set_column_titles(GNT_TREE(tree), _("Event"), _("File")); gnt_tree_set_show_title(GNT_TREE(tree), TRUE); for (i = 0; i < PURPLE_NUM_SOUNDS; i++) { FinchSoundEvent * event = &sounds[i]; if (event->label == NULL) { continue; } gnt_tree_add_choice(GNT_TREE(tree), GINT_TO_POINTER(i), gnt_tree_create_row(GNT_TREE(tree), event->label, event->def), NULL, NULL); } gnt_tree_adjust_columns(GNT_TREE(tree)); gnt_box_add_widget(GNT_BOX(win), tree); box = gnt_hbox_new(FALSE); button = gnt_button_new(_("Test")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(test_cb), NULL); gnt_box_add_widget(GNT_BOX(box), button); button = gnt_button_new(_("Reset")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(reset_cb), NULL); gnt_box_add_widget(GNT_BOX(box), button); button = gnt_button_new(_("Choose...")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(choose_cb), NULL); gnt_box_add_widget(GNT_BOX(box), button); gnt_box_add_widget(GNT_BOX(win), box); gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); /* Add new stuff before this */ box = gnt_hbox_new(FALSE); gnt_box_set_fill(GNT_BOX(box), TRUE); button = gnt_button_new(_("Save")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_cb), win); gnt_box_add_widget(GNT_BOX(box), button); button = gnt_button_new(_("Cancel")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cancel_cb), win); gnt_box_add_widget(GNT_BOX(box), button); gnt_box_add_widget(GNT_BOX(win), box); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(release_pref_dialog), NULL); load_pref_window(finch_sound_get_active_profile()); gnt_widget_show(win); }
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); }
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); }
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; }
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); }