static void update_edit_list(GntWidget *widget, EditStatus *edit) { edits = g_list_remove(edits, edit); purple_notify_close_with_handle(edit); g_hash_table_foreach(edit->hash, (GHFunc)destroy_substatus_win, NULL); g_list_foreach((GList*)gnt_tree_get_rows(GNT_TREE(edit->tree)), free_key, NULL); g_free(edit); }
static gboolean meebo_init() { GntTree *tree = finch_blist_get_tree(); if (!g_list_find(gnt_tree_get_rows(tree), &meebo)) { gnt_tree_add_row_last(tree, &meebo, gnt_tree_create_row(tree, _("Offline")), NULL); } return TRUE; }
static void set_substatuses(EditStatus *edit) { GList *iter; for (iter = gnt_tree_get_rows(GNT_TREE(edit->tree)); iter; iter = iter->next) { RowInfo *key = iter->data; if (gnt_tree_get_choice(GNT_TREE(edit->tree), key)) { purple_savedstatus_set_substatus(edit->saved, key->account, key->type, key->message); } } }
static void update_selected_account(GntEntry *screenname, const char *start, const char *end, GntComboBox *accountlist) { GList *accounts = gnt_tree_get_rows(GNT_TREE(accountlist->dropdown)); const char *name = gnt_entry_get_text(screenname); while (accounts) { if (purple_find_buddy(accounts->data, name)) { gnt_combo_box_set_selected(accountlist, accounts->data); gnt_widget_draw(GNT_WIDGET(accountlist)); break; } accounts = accounts->next; } }
static void release_pref_dialog(GntBindable *data, gpointer null) { GList * itr; for (itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events)); itr; itr = itr->next) { PurpleSoundEventID id = GPOINTER_TO_INT(itr->data); FinchSoundEvent * e = &sounds[id]; g_free(e->file); e->file = NULL; } if (pref_dialog->selector) gnt_widget_destroy(pref_dialog->selector); g_free(pref_dialog->original_profile); g_free(pref_dialog); pref_dialog = NULL; }
static void update_title_progress(void) { GList *list; int num_active_xfers = 0; guint64 total_bytes_xferred = 0; guint64 total_file_size = 0; if (xfer_dialog == NULL || xfer_dialog->window == NULL) return; /* Find all active transfers */ for (list = gnt_tree_get_rows(GNT_TREE(xfer_dialog->tree)); list; list = list->next) { PurpleXfer *xfer = (PurpleXfer *)list->data; if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) { num_active_xfers++; total_bytes_xferred += purple_xfer_get_bytes_sent(xfer); total_file_size += purple_xfer_get_size(xfer); } } /* Update the title */ if (num_active_xfers > 0) { gchar *title; int total_pct = 0; if (total_file_size > 0) { total_pct = 100 * total_bytes_xferred / total_file_size; } title = g_strdup_printf(ngettext("File Transfers - %d%% of %d file", "File Transfers - %d%% of %d files", num_active_xfers), total_pct, num_active_xfers); gnt_screen_rename_widget((xfer_dialog->window), title); g_free(title); } else { gnt_screen_rename_widget((xfer_dialog->window), _("File Transfers")); } }
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 install_selected_file_cb(gpointer handle, const char *filename) { /* Try to init the selected file. * If it succeeds, try to make a copy of the file in $USERDIR/plugins/. * If the copy succeeds, unload and destroy the plugin in the original * location and init+load the new one. * Select the plugin in the plugin list. */ char *path; PurplePlugin *plugin; g_return_if_fail(plugins.window); plugin = purple_plugin_probe(filename); if (!plugin) { purple_notify_error(handle, _("Error loading plugin"), _("The selected file is not a valid plugin."), _("Please open the debug window and try again to see the exact error message."), NULL); return; } if (g_list_find(gnt_tree_get_rows(GNT_TREE(plugins.tree)), plugin)) { purple_plugin_load(plugin); gnt_tree_set_choice(GNT_TREE(plugins.tree), plugin, purple_plugin_is_loaded(plugin)); gnt_tree_set_selected(GNT_TREE(plugins.tree), plugin); return; } path = g_build_filename(purple_user_dir(), "plugins", NULL); if (purple_build_dir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) { char *content = NULL; gsize length = 0; if (g_file_get_contents(filename, &content, &length, NULL)) { char *file = g_path_get_basename(filename); g_free(path); path = g_build_filename(purple_user_dir(), "plugins", file, NULL); if (purple_util_write_data_to_file_absolute(path, content, length)) { purple_plugin_destroy(plugin); plugin = purple_plugin_probe(path); if (!plugin) { purple_debug_warning("gntplugin", "This is really strange. %s can be loaded, but %s can't!\n", filename, path); g_unlink(path); plugin = purple_plugin_probe(filename); } } else { } } g_free(content); } g_free(path); purple_plugin_load(plugin); if (plugin->info->type == PURPLE_PLUGIN_LOADER) { GList *cur; for (cur = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; cur != NULL; cur = cur->next) purple_plugins_probe(cur->data); return; } if (plugin->info->type != PURPLE_PLUGIN_STANDARD || (plugin->info->flags & PURPLE_PLUGIN_FLAG_INVISIBLE) || plugin->error) return; gnt_tree_add_choice(GNT_TREE(plugins.tree), plugin, gnt_tree_create_row(GNT_TREE(plugins.tree), plugin->info->name), NULL, NULL); gnt_tree_set_choice(GNT_TREE(plugins.tree), plugin, purple_plugin_is_loaded(plugin)); gnt_tree_set_row_flags(GNT_TREE(plugins.tree), plugin, GNT_TEXT_FLAG_BOLD); gnt_tree_set_selected(GNT_TREE(plugins.tree), plugin); }