static gboolean dir_key_pressed(GntTree *tree, const char *key, GntFileSel *sel) { if (strcmp(key, "\r") == 0 || strcmp(key, "\n") == 0) { char *str = g_strdup(gnt_tree_get_selection_data(tree)); char *path, *dir; if (!str) return TRUE; path = g_build_filename(sel->current, str, NULL); dir = g_path_get_basename(sel->current); if (!gnt_file_sel_set_current_location(sel, path)) { gnt_tree_set_selected(tree, str); } else if (strcmp(str, "..") == 0) { gnt_tree_set_selected(tree, dir); } gnt_bindable_perform_action_named(GNT_BINDABLE(tree), "end-search", NULL); g_free(dir); g_free(str); g_free(path); return TRUE; } return FALSE; }
static gboolean check_for_trigger(GntMenu *menu, char trigger) { /* check for a trigger key */ GList *iter; GList *find; GList *nth = g_list_find(menu->list, gnt_tree_get_selection_data(GNT_TREE(menu))); if (nth == NULL) return FALSE; find = find_item_with_trigger(nth->next, NULL, trigger); if (!find) find = find_item_with_trigger(menu->list, nth->next, trigger); if (!find) return FALSE; if (find != nth) { gnt_tree_set_selected(GNT_TREE(menu), find->data); iter = find_item_with_trigger(find->next, NULL, trigger); if (iter != NULL && iter != find) return TRUE; iter = find_item_with_trigger(menu->list, nth, trigger); if (iter != NULL && iter != find) return TRUE; } gnt_widget_activate(GNT_WIDGET(menu)); return TRUE; }
static void finch_xfer_add_xfer(PurpleXfer *xfer) { if (!xfer_dialog) finch_xfer_dialog_new(); finch_xfer_dialog_add_xfer(xfer); gnt_tree_set_selected(GNT_TREE(xfer_dialog->tree), xfer); }
static void hide_popup(GntComboBox *box, gboolean set) { gnt_widget_set_size(box->dropdown, box->dropdown->priv.width - 1, box->dropdown->priv.height); if (set) set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown))); else gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected); gnt_widget_hide(box->dropdown->parent); }
static void load_pref_window(const char * profile) { gint i; finch_sound_set_active_profile(profile); gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->method), (gchar *)purple_prefs_get_string(make_pref("/method"))); gnt_entry_set_text(GNT_ENTRY(pref_dialog->command), purple_prefs_get_path(make_pref("/command"))); gnt_check_box_set_checked(GNT_CHECK_BOX(pref_dialog->conv_focus), purple_prefs_get_bool(make_pref("/conv_focus"))); gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->while_status), GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status"))); gnt_slider_set_value(GNT_SLIDER(pref_dialog->volume), CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100)); for (i = 0; i < PURPLE_NUM_SOUNDS; i++) { FinchSoundEvent * event = &sounds[i]; gchar *boolpref; gchar *filepref, *basename = NULL; const char * profile = finch_sound_get_active_profile(); filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", profile, event->pref); g_free(event->file); event->file = g_strdup(purple_prefs_get_path(filepref)); g_free(filepref); if (event->label == NULL) { continue; } boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", profile, event->pref); gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), 0, event->label); gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), 1, event->file[0] ? (basename = g_path_get_basename(event->file)) : _("(default)")); g_free(basename); gnt_tree_set_choice(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), purple_prefs_get_bool(boolpref)); g_free(boolpref); } gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles), (gchar *)finch_sound_get_active_profile()); gnt_widget_draw(pref_dialog->window); }
static void set_selection(GntComboBox *box, gpointer key) { if (box->selected != key) { /* XXX: make sure the key actually does exist */ gpointer old = box->selected; box->selected = key; if (GNT_WIDGET(box)->window) gnt_widget_draw(GNT_WIDGET(box)); if (box->dropdown) gnt_tree_set_selected(GNT_TREE(box->dropdown), key); g_signal_emit(box, signals[SIG_SELECTION_CHANGED], 0, old, key); } }
static void prof_add_cb(GntButton *button, GntEntry * entry) { const char * profile = gnt_entry_get_text(entry); GntTreeRow * row; if (!finch_sound_profile_exists(profile)) { gpointer key = g_strdup(profile); row = gnt_tree_create_row(GNT_TREE(pref_dialog->profiles), profile); gnt_tree_add_row_after(GNT_TREE(pref_dialog->profiles), key, row, NULL, NULL); gnt_entry_set_text(entry, ""); gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles), key); finch_sound_set_active_profile(key); } else reload_pref_window(profile); }
static gboolean up_directory(GntBindable *bind, GList *null) { char *path, *dir; GntFileSel *sel = GNT_FILE_SEL(bind); if (!gnt_widget_has_focus(sel->dirs) && !gnt_widget_has_focus(sel->files)) return FALSE; if (gnt_tree_is_searching(GNT_TREE(sel->dirs)) || gnt_tree_is_searching(GNT_TREE(sel->files))) return FALSE; path = g_build_filename(sel->current, "..", NULL); dir = g_path_get_basename(sel->current); if (gnt_file_sel_set_current_location(sel, path)) gnt_tree_set_selected(GNT_TREE(sel->dirs), dir); g_free(dir); g_free(path); return TRUE; }
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); }
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); }