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); }
/** * window: this is the window * userdata: the userdata to pass to the primary callbacks * cb: the callback * data: data for the callback * (text, primary-callback) pairs, ended by a NULL * * The cancellation callback should be the last callback sent. */ static GntWidget * setup_button_box(GntWidget *win, gpointer userdata, gpointer cb, gpointer data, ...) { GntWidget *box; GntWidget *button = NULL; va_list list; const char *text; gpointer callback; box = gnt_hbox_new(FALSE); va_start(list, data); while ((text = va_arg(list, const char *))) { callback = va_arg(list, gpointer); button = gnt_button_new(text); gnt_box_add_widget(GNT_BOX(box), button); g_object_set_data(G_OBJECT(button), "activate-callback", callback); g_object_set_data(G_OBJECT(button), "activate-userdata", userdata); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(action_performed), win); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data); } if (button) g_object_set_data(G_OBJECT(button), "cancellation-function", GINT_TO_POINTER(TRUE)); va_end(list); return box; }
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); }
static void ask_before_exit(void) { static GntWidget *win = NULL; GntWidget *bbox, *button; if (wm->menu) { do { gnt_widget_hide(GNT_WIDGET(wm->menu)); if (wm->menu) wm->menu = wm->menu->parentmenu; } while (wm->menu); } if (win) goto raise; win = gnt_vwindow_new(FALSE); gnt_box_add_widget(GNT_BOX(win), gnt_label_new("Are you sure you want to quit?")); gnt_box_set_title(GNT_BOX(win), "Quit?"); gnt_box_set_alignment(GNT_BOX(win), GNT_ALIGN_MID); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(exit_win_close), &win); bbox = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(win), bbox); button = gnt_button_new("Quit"); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(exit_confirmed), NULL); gnt_box_add_widget(GNT_BOX(bbox), button); button = gnt_button_new("Cancel"); g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), win); gnt_box_add_widget(GNT_BOX(bbox), button); gnt_widget_show(win); raise: gnt_wm_raise_window(wm, win); }
static void* finch_request_action(const char *title, const char *primary, const char *secondary, int default_value, PurpleAccount *account, const char *who, PurpleConversation *conv, void *user_data, size_t actioncount, va_list actions) { GntWidget *window, *box, *button, *focus = NULL; int i; window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_ACTION); box = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(window), box); for (i = 0; i < actioncount; i++) { const char *text = va_arg(actions, const char *); PurpleRequestActionCb callback = va_arg(actions, PurpleRequestActionCb); button = gnt_button_new(text); gnt_box_add_widget(GNT_BOX(box), button); g_object_set_data(G_OBJECT(button), "activate-callback", callback); g_object_set_data(G_OBJECT(button), "activate-userdata", user_data); g_object_set_data(G_OBJECT(button), "activate-id", GINT_TO_POINTER(i)); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(request_action_cb), window); if (i == default_value) focus = button; } gnt_widget_show(window); if (focus) gnt_box_give_focus_to_child(GNT_BOX(window), focus); return window; }
static void configure_plugin_cb(GntWidget *button, gpointer null) { PurplePlugin *plugin; PurplePluginInfo *info; FinchPluginInfoPrivate *priv = NULL; FinchPluginUiData *ui_data; g_return_if_fail(plugins.tree != NULL); plugin = gnt_tree_get_selection_data(GNT_TREE(plugins.tree)); if (!purple_plugin_is_loaded(plugin)) { purple_notify_error(plugin, _("Error"), _("Plugin need to be loaded before you can configure it."), NULL, NULL); return; } info = purple_plugin_get_info(plugin); if (purple_plugin_info_get_ui_data(info)) return; ui_data = g_new0(FinchPluginUiData, 1); purple_plugin_info_set_ui_data(info, ui_data); if (FINCH_IS_PLUGIN_INFO(info)) priv = FINCH_PLUGIN_INFO_GET_PRIVATE(info); if (priv && priv->pref_frame_cb != NULL) { GntWidget *window = gnt_vbox_new(FALSE); GntWidget *box, *button; gnt_box_set_toplevel(GNT_BOX(window), TRUE); gnt_box_set_title(GNT_BOX(window), purple_plugin_info_get_name(info)); gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); box = priv->pref_frame_cb(); gnt_box_add_widget(GNT_BOX(window), box); box = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(window), box); 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(remove_confwin), plugin); gnt_widget_show(window); ui_data->type = FINCH_PLUGIN_UI_DATA_TYPE_WINDOW; ui_data->u.window = window; } else if (purple_plugin_info_get_pref_request_cb(info)) { PurplePluginPrefRequestCb pref_request_cb = purple_plugin_info_get_pref_request_cb(info); gpointer handle; ui_data->type = FINCH_PLUGIN_UI_DATA_TYPE_REQUEST; ui_data->u.request_handle = handle = pref_request_cb(plugin); purple_request_add_close_notify(handle, purple_callback_set_zero, &info->ui_data); purple_request_add_close_notify(handle, g_free, ui_data); } else if (purple_plugin_info_get_pref_frame_cb(info)) { PurplePluginPrefFrameCb pref_frame_cb = purple_plugin_info_get_pref_frame_cb(info); GntWidget *win = process_pref_frame(pref_frame_cb(plugin)); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(remove_confwin), plugin); ui_data->type = FINCH_PLUGIN_UI_DATA_TYPE_WINDOW; ui_data->u.window = win; } else { purple_notify_info(plugin, _("Error"), _("No configuration " "options for this plugin."), NULL, NULL); g_free(ui_data); purple_plugin_info_set_ui_data(info, NULL); } }
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); }
g_signal_connect(G_OBJECT(sel->dirs), "key_pressed", G_CALLBACK(dir_key_pressed), sel); sel->files = gnt_tree_new_with_columns(2); /* Name, Size */ gnt_tree_set_compare_func(GNT_TREE(sel->files), (GCompareFunc)g_utf8_collate); gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size"); gnt_tree_set_show_title(GNT_TREE(sel->files), TRUE); gnt_tree_set_col_width(GNT_TREE(sel->files), 0, 25); gnt_tree_set_col_width(GNT_TREE(sel->files), 1, 10); gnt_tree_set_column_is_right_aligned(GNT_TREE(sel->files), 1, TRUE); g_signal_connect(G_OBJECT(sel->files), "selection_changed", G_CALLBACK(file_sel_changed), sel); /* The location entry */ sel->location = gnt_entry_new(NULL); g_signal_connect(G_OBJECT(sel->location), "key_pressed", G_CALLBACK(location_key_pressed), sel); sel->cancel = gnt_button_new("Cancel"); sel->select = gnt_button_new("Select"); g_signal_connect_swapped(G_OBJECT(sel->files), "activate", G_CALLBACK(gnt_widget_activate), sel->select); g_signal_connect(G_OBJECT(sel->select), "activate", G_CALLBACK(select_activated_cb), sel); } /****************************************************************************** * GntFileSel API *****************************************************************************/ GType gnt_file_sel_get_gtype(void) { static GType type = 0; if(type == 0)
void finch_pounces_manager_show(void) { PouncesManager *dialog; GntWidget *bbox; GntWidget *button; GntWidget *tree; GntWidget *win; if (pounces_manager != NULL) { gnt_window_present(pounces_manager->window); return; } pounces_manager = dialog = g_new0(PouncesManager, 1); dialog->window = win = gnt_vbox_new(FALSE); gnt_box_set_toplevel(GNT_BOX(win), TRUE); gnt_box_set_title(GNT_BOX(win), _("Buddy Pounces")); gnt_box_set_pad(GNT_BOX(win), 0); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(pounces_manager_destroy_cb), dialog); /* List of saved buddy pounces */ dialog->tree = tree = GNT_WIDGET(gnt_tree_new_with_columns(2)); gnt_tree_set_column_titles(GNT_TREE(tree), "Account", "Pouncee", NULL); gnt_tree_set_show_title(GNT_TREE(tree), TRUE); gnt_box_add_widget(GNT_BOX(win), tree); /* Button box. */ bbox = gnt_hbox_new(FALSE); /* Add button */ button = gnt_button_new(_("Add")); gnt_box_add_widget(GNT_BOX(bbox), button); gnt_util_set_trigger_widget(tree, GNT_KEY_INS, button); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(pounces_manager_add_cb), dialog); /* Modify button */ button = gnt_button_new(_("Modify")); dialog->modify_button = button; gnt_box_add_widget(GNT_BOX(bbox), button); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(pounces_manager_modify_cb), dialog); /* Delete button */ button = gnt_button_new(_("Delete")); dialog->delete_button = button; gnt_box_add_widget(GNT_BOX(bbox), button); gnt_util_set_trigger_widget(tree, GNT_KEY_DEL, button); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(pounces_manager_delete_cb), dialog); /* Close button */ button = gnt_button_new(_("Close")); gnt_box_add_widget(GNT_BOX(bbox), button); gnt_widget_show(button); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(pounces_manager_close_cb), dialog); gnt_box_add_widget(GNT_BOX(win), bbox); gnt_widget_show(win); populate_pounces_list(pounces_manager); }
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); }
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; }
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; }
static void configure_plugin_cb(GntWidget *button, gpointer null) { PurplePlugin *plugin; FinchPluginFrame callback; g_return_if_fail(plugins.tree != NULL); plugin = gnt_tree_get_selection_data(GNT_TREE(plugins.tree)); if (!purple_plugin_is_loaded(plugin)) { purple_notify_error(plugin, _("Error"), _("Plugin need to be loaded before you can configure it."), NULL); return; } if (confwins && g_hash_table_lookup(confwins, plugin)) return; if (PURPLE_IS_GNT_PLUGIN(plugin) && (callback = FINCH_PLUGIN_UI_INFO(plugin)) != NULL) { GntWidget *window = gnt_vbox_new(FALSE); GntWidget *box, *button; gnt_box_set_toplevel(GNT_BOX(window), TRUE); gnt_box_set_title(GNT_BOX(window), plugin->info->name); gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); box = callback(); gnt_box_add_widget(GNT_BOX(window), box); box = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(window), box); 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(remove_confwin), plugin); gnt_widget_show(window); if (confwins == NULL) confwin_init(); g_hash_table_insert(confwins, plugin, window); } else if (plugin->info->prefs_info && plugin->info->prefs_info->get_plugin_pref_frame) { GntWidget *win = process_pref_frame(plugin->info->prefs_info->get_plugin_pref_frame(plugin)); if (confwins == NULL) confwin_init(); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(remove_confwin), plugin); g_hash_table_insert(confwins, plugin, win); return; } else { purple_notify_info(plugin, _("Error"), _("No configuration options for this plugin."), NULL); return; } }
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); }
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))); }
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_pounce_editor_show(PurpleAccount *account, const char *name, PurplePounce *cur_pounce) { PurpleGntPounceDialog *dialog; GntWidget *window; GntWidget *bbox; GntWidget *hbox, *vbox; GntWidget *button; GntWidget *combo; GList *list; g_return_if_fail((cur_pounce != NULL) || (account != NULL) || (purple_accounts_get_all() != NULL)); dialog = g_new0(PurpleGntPounceDialog, 1); if (cur_pounce != NULL) { dialog->pounce = cur_pounce; dialog->account = purple_pounce_get_pouncer(cur_pounce); } else if (account != NULL) { dialog->pounce = NULL; dialog->account = account; } else { GList *connections = purple_connections_get_all(); PurpleConnection *gc; if (connections != NULL) { gc = (PurpleConnection *)connections->data; dialog->account = purple_connection_get_account(gc); } else dialog->account = purple_accounts_get_all()->data; dialog->pounce = NULL; } /* Create the window. */ dialog->window = window = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(window), 0); gnt_box_set_toplevel(GNT_BOX(window), TRUE); gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT); gnt_box_set_title(GNT_BOX(window), (cur_pounce == NULL ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(delete_win_cb), dialog); gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce on Whom"), GNT_TEXT_FLAG_BOLD)); /* Account: */ gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Account:"))); dialog->account_menu = combo = gnt_combo_box_new(); list = purple_accounts_get_all(); for (; list; list = list->next) { PurpleAccount *account; char *text; 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 (dialog->account) gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), dialog->account); gnt_box_add_widget(GNT_BOX(window), combo); /* Buddy: */ hbox = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Buddy name:"))); dialog->buddy_entry = gnt_entry_new(NULL); gnt_box_add_widget(GNT_BOX(hbox), dialog->buddy_entry); setup_buddy_list_suggestion(GNT_ENTRY(dialog->buddy_entry), TRUE); gnt_box_add_widget(GNT_BOX(window), hbox); if (cur_pounce != NULL) { gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), purple_pounce_get_pouncee(cur_pounce)); } else if (name != NULL) { gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), name); } /* Create the event frame */ gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce When Buddy..."), GNT_TEXT_FLAG_BOLD)); dialog->signon = gnt_check_box_new(_("Signs on")); dialog->signoff = gnt_check_box_new(_("Signs off")); dialog->away = gnt_check_box_new(_("Goes away")); dialog->away_return = gnt_check_box_new(_("Returns from away")); dialog->idle = gnt_check_box_new(_("Becomes idle")); dialog->idle_return = gnt_check_box_new(_("Is no longer idle")); dialog->typing = gnt_check_box_new(_("Starts typing")); dialog->typed = gnt_check_box_new(_("Pauses while typing")); dialog->stop_typing = gnt_check_box_new(_("Stops typing")); dialog->message_recv = gnt_check_box_new(_("Sends a message")); hbox = gnt_hbox_new(TRUE); gnt_box_set_pad(GNT_BOX(hbox), 2); vbox = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(vbox), 0); gnt_box_add_widget(GNT_BOX(hbox), vbox); gnt_box_add_widget(GNT_BOX(vbox), dialog->signon); gnt_box_add_widget(GNT_BOX(vbox), dialog->away); gnt_box_add_widget(GNT_BOX(vbox), dialog->idle); gnt_box_add_widget(GNT_BOX(vbox), dialog->typing); gnt_box_add_widget(GNT_BOX(vbox), dialog->stop_typing); vbox = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(vbox), 0); gnt_box_add_widget(GNT_BOX(hbox), vbox); gnt_box_add_widget(GNT_BOX(vbox), dialog->signoff); gnt_box_add_widget(GNT_BOX(vbox), dialog->away_return); gnt_box_add_widget(GNT_BOX(vbox), dialog->idle_return); gnt_box_add_widget(GNT_BOX(vbox), dialog->typed); gnt_box_add_widget(GNT_BOX(vbox), dialog->message_recv); gnt_box_add_widget(GNT_BOX(window), hbox); /* Create the "Action" frame. */ gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Action"), GNT_TEXT_FLAG_BOLD)); dialog->open_win = gnt_check_box_new(_("Open an IM window")); dialog->popup = gnt_check_box_new(_("Pop up a notification")); dialog->send_msg = gnt_check_box_new(_("Send a message")); dialog->exec_cmd = gnt_check_box_new(_("Execute a command")); dialog->play_sound = gnt_check_box_new(_("Play a sound")); dialog->send_msg_entry = gnt_entry_new(NULL); dialog->exec_cmd_entry = gnt_entry_new(NULL); dialog->popup_entry = gnt_entry_new(NULL); dialog->exec_cmd_entry = gnt_entry_new(NULL); hbox = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(hbox), dialog->open_win); gnt_box_add_widget(GNT_BOX(window), hbox); hbox = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(hbox), dialog->popup); gnt_box_add_widget(GNT_BOX(hbox), dialog->popup_entry); gnt_box_add_widget(GNT_BOX(window), hbox); hbox = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg); gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg_entry); gnt_box_add_widget(GNT_BOX(window), hbox); hbox = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd); gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd_entry); gnt_box_add_widget(GNT_BOX(window), hbox); hbox = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(hbox), dialog->play_sound); gnt_box_add_widget(GNT_BOX(window), hbox); gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Options"), GNT_TEXT_FLAG_BOLD)); dialog->on_away = gnt_check_box_new(_("Pounce only when my status is not Available")); gnt_box_add_widget(GNT_BOX(window), dialog->on_away); dialog->save_pounce = gnt_check_box_new(_("Recurring")); gnt_box_add_widget(GNT_BOX(window), dialog->save_pounce); gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); /* Now the button box! */ bbox = gnt_hbox_new(FALSE); /* Cancel button */ button = gnt_button_new(_("Cancel")); gnt_box_add_widget(GNT_BOX(bbox), button); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cancel_cb), dialog); /* Save button */ dialog->save_button = button = gnt_button_new(_("Save")); gnt_box_add_widget(GNT_BOX(bbox), button); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_pounce_cb), dialog); gnt_box_add_widget(GNT_BOX(window), bbox); /* Set the values of stuff. */ if (cur_pounce != NULL) { PurplePounceEvent events = purple_pounce_get_events(cur_pounce); PurplePounceOption options = purple_pounce_get_options(cur_pounce); const char *value; /* Options */ gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->on_away), (options & PURPLE_POUNCE_OPTION_AWAY)); /* Events */ gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signon), (events & PURPLE_POUNCE_SIGNON)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signoff), (events & PURPLE_POUNCE_SIGNOFF)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away), (events & PURPLE_POUNCE_AWAY)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away_return), (events & PURPLE_POUNCE_AWAY_RETURN)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle), (events & PURPLE_POUNCE_IDLE)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle_return), (events & PURPLE_POUNCE_IDLE_RETURN)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typing), (events & PURPLE_POUNCE_TYPING)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typed), (events & PURPLE_POUNCE_TYPED)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->stop_typing), (events & PURPLE_POUNCE_TYPING_STOPPED)); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->message_recv), (events & PURPLE_POUNCE_MESSAGE_RECEIVED)); /* Actions */ gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win), purple_pounce_action_is_enabled(cur_pounce, "open-window")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup), purple_pounce_action_is_enabled(cur_pounce, "popup-notify")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg), purple_pounce_action_is_enabled(cur_pounce, "send-message")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd), purple_pounce_action_is_enabled(cur_pounce, "execute-command")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound), purple_pounce_action_is_enabled(cur_pounce, "play-beep")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->save_pounce), purple_pounce_get_save(cur_pounce)); if ((value = purple_pounce_action_get_attribute(cur_pounce, "send-message", "message")) != NULL) { gnt_entry_set_text(GNT_ENTRY(dialog->send_msg_entry), value); } if ((value = purple_pounce_action_get_attribute(cur_pounce, "popup-notify", "reason")) != NULL) { gnt_entry_set_text(GNT_ENTRY(dialog->popup_entry), value); } if ((value = purple_pounce_action_get_attribute(cur_pounce, "execute-command", "command")) != NULL) { gnt_entry_set_text(GNT_ENTRY(dialog->exec_cmd_entry), value); } } else { PurpleBuddy *buddy = NULL; if (name != NULL) buddy = purple_find_buddy(account, name); /* Set some defaults */ if (buddy == NULL) { gnt_check_box_set_checked( GNT_CHECK_BOX(dialog->signon), TRUE); } else { if (!PURPLE_BUDDY_IS_ONLINE(buddy)) { gnt_check_box_set_checked( GNT_CHECK_BOX(dialog->signon), TRUE); } else { gboolean default_set = FALSE; PurplePresence *presence = purple_buddy_get_presence(buddy); if (purple_presence_is_idle(presence)) { gnt_check_box_set_checked( GNT_CHECK_BOX(dialog->idle_return), TRUE); default_set = TRUE; } if (!purple_presence_is_available(presence)) { gnt_check_box_set_checked( GNT_CHECK_BOX(dialog->away_return), TRUE); default_set = TRUE; } if (!default_set) { gnt_check_box_set_checked( GNT_CHECK_BOX(dialog->signon), TRUE); } } } gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win), purple_prefs_get_bool("/finch/pounces/default_actions/open-window")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup), purple_prefs_get_bool("/finch/pounces/default_actions/popup-notify")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg), purple_prefs_get_bool("/finch/pounces/default_actions/send-message")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd), purple_prefs_get_bool("/finch/pounces/default_actions/execute-command")); gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound), purple_prefs_get_bool("/finch/pounces/default_actions/play-beep")); } gnt_widget_show(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; }
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); }