static void plugin_toggled_cb(GntWidget *tree, PurplePlugin *plugin, gpointer null) { if (gnt_tree_get_choice(GNT_TREE(tree), plugin)) { if (!purple_plugin_load(plugin)) { purple_notify_error(NULL, _("ERROR"), _("loading plugin failed"), NULL); gnt_tree_set_choice(GNT_TREE(tree), plugin, FALSE); } } else { GntWidget *win; if (!purple_plugin_unload(plugin)) { purple_notify_error(NULL, _("ERROR"), _("unloading plugin failed"), NULL); purple_plugin_disable(plugin); gnt_tree_set_choice(GNT_TREE(tree), plugin, TRUE); } if (confwins && (win = g_hash_table_lookup(confwins, plugin)) != NULL) { gnt_widget_destroy(win); } } decide_conf_button(plugin); finch_plugins_save_loaded(); }
static void choose_cb(GntWidget *button, gpointer null) { GntWidget *w = gnt_file_sel_new(); GntFileSel *sel = GNT_FILE_SEL(w); PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events))); FinchSoundEvent * event = &sounds[id]; char *path = NULL; gnt_box_set_title(GNT_BOX(w), _("Select Sound File ...")); gnt_file_sel_set_current_location(sel, (event && event->file) ? (path = g_path_get_dirname(event->file)) : purple_home_dir()); g_signal_connect_swapped(G_OBJECT(sel->cancel), "activate", G_CALLBACK(gnt_widget_destroy), sel); g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(file_cb), event); g_signal_connect_swapped(G_OBJECT(sel), "destroy", G_CALLBACK(g_nullify_pointer), &pref_dialog->selector); /* If there's an already open file-selector, close that one. */ if (pref_dialog->selector) gnt_widget_destroy(pref_dialog->selector); pref_dialog->selector = w; gnt_widget_show(w); g_free(path); }
static void finch_plugin_pref_close(PurplePlugin *plugin) { PurplePluginInfo *info; FinchPluginUiData *ui_data; g_return_if_fail(plugin != NULL); info = purple_plugin_get_info(plugin); ui_data = purple_plugin_info_get_ui_data(info); if (!ui_data) return; if (ui_data->type == FINCH_PLUGIN_UI_DATA_TYPE_REQUEST) { purple_request_close(PURPLE_REQUEST_FIELDS, ui_data->u.request_handle); return; } g_return_if_fail(ui_data->type == FINCH_PLUGIN_UI_DATA_TYPE_WINDOW); gnt_widget_destroy(ui_data->u.window); g_free(ui_data); purple_plugin_info_set_ui_data(info, NULL); }
void finch_xfer_dialog_destroy() { gnt_widget_destroy(xfer_dialog->window); g_free(xfer_dialog); xfer_dialog = NULL; }
static void gnt_entry_destroy(GntWidget *widget) { GntEntry *entry = GNT_ENTRY(widget); g_free(entry->start); if (entry->history) { entry->history = g_list_first(entry->history); g_list_foreach(entry->history, (GFunc)g_free, NULL); g_list_free(entry->history); } if (entry->suggests) { g_list_foreach(entry->suggests, (GFunc)g_free, NULL); g_list_free(entry->suggests); } if (entry->ddown) { gnt_widget_destroy(entry->ddown->parent); } g_free(entry->search->needle); g_free(entry->search); jail_killring(entry->killring); }
static void save_savedstatus_cb(GntWidget *button, EditStatus *edit) { const char *title, *message; PurpleStatusPrimitive prim; PurpleSavedStatus *find; title = gnt_entry_get_text(GNT_ENTRY(edit->title)); message = gnt_entry_get_text(GNT_ENTRY(edit->message)); if (!message || !*message) message = NULL; prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type))); if (!title || !*title) { purple_notify_error(edit, _("Error"), _("Invalid title"), _("Please enter a non-empty title for the status.")); gnt_box_give_focus_to_child(GNT_BOX(edit->window), edit->title); return; } find = purple_savedstatus_find(title); if (find && find != edit->saved) { purple_notify_error(edit, _("Error"), _("Duplicate title"), _("Please enter a different title for the status.")); gnt_box_give_focus_to_child(GNT_BOX(edit->window), edit->title); return; } if (edit->saved == NULL) { edit->saved = purple_savedstatus_new(title, prim); purple_savedstatus_set_message(edit->saved, message); set_substatuses(edit); if (statuses.tree) gnt_tree_add_row_last(GNT_TREE(statuses.tree), edit->saved, gnt_tree_create_row(GNT_TREE(statuses.tree), title, purple_primitive_get_name_from_type(prim), message), NULL); } else { purple_savedstatus_set_title(edit->saved, title); purple_savedstatus_set_type(edit->saved, prim); purple_savedstatus_set_message(edit->saved, message); if (statuses.tree) { gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 0, title); gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 1, purple_primitive_get_name_from_type(prim)); gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 2, message); } } if (g_object_get_data(G_OBJECT(button), "use")) purple_savedstatus_activate(edit->saved); gnt_widget_destroy(edit->window); }
static void destroy_toaster(GntToast *toast) { toasters = g_list_remove(toasters, toast); gnt_widget_destroy(toast->window); purple_timeout_remove(toast->timer); g_free(toast); }
/************************************************************************** * Callbacks **************************************************************************/ static gint delete_win_cb(GntWidget *w, PurpleGntPounceDialog *dialog) { gnt_widget_destroy(dialog->window); g_free(dialog); return TRUE; }
static void destroy_suggest(GntEntry *entry) { if (entry->ddown) { gnt_widget_destroy(entry->ddown->parent); entry->ddown = NULL; } }
static gboolean toggle_buddylist(GntBindable *bindable, GList *null) { GntWM *wm = GNT_WM(bindable); GntWidget *blist = find_widget(wm, "buddylist"); if (blist) gnt_widget_destroy(blist); else purple_blist_show(); return TRUE; }
static void file_cb(GntFileSel *w, const char *path, const char *file, gpointer data) { FinchSoundEvent *event = data; g_free(event->file); event->file = g_strdup(path); gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), 1, file); gnt_tree_set_choice(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), TRUE); gnt_widget_destroy(GNT_WIDGET(w)); }
static void finch_close_request(PurpleRequestType type, gpointer ui_handle) { GntWidget *widget = GNT_WIDGET(ui_handle); if (type == PURPLE_REQUEST_FIELDS) { PurpleRequestFields *fields = g_object_get_data(G_OBJECT(widget), "fields"); purple_request_fields_destroy(fields); } while (widget->parent) widget = widget->parent; gnt_widget_destroy(widget); }
static void gnt_window_destroy(GntWidget *widget) { GntWindow *window = GNT_WINDOW(widget); if (window->menu) gnt_widget_destroy(GNT_WIDGET(window->menu)); if (window->priv) { if (window->priv->accels) g_hash_table_destroy(window->priv->accels); g_free(window->priv); } org_destroy(widget); }
void finch_pounces_manager_hide(void) { if (pounces_manager == NULL) return; if (pounces_manager->window != NULL) gnt_widget_destroy(pounces_manager->window); purple_signals_disconnect_by_handle(pounces_manager); g_free(pounces_manager); pounces_manager = NULL; }
static void file_save(GntFileSel *fs, const char *path, const char *file, GntTextView *tv) { FILE *fp; if ((fp = g_fopen(path, "w+")) == NULL) { purple_notify_error(NULL, NULL, _("Unable to open file."), NULL); return; } fprintf(fp, "Finch Debug Log : %s\n", purple_date_format_full(NULL)); fprintf(fp, "%s", tv->string->str); fclose(fp); gnt_widget_destroy(GNT_WIDGET(fs)); }
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; }
/* handle is, in all/most occasions, a GntWidget * */ static void finch_close_notify(PurpleNotifyType type, void *handle) { GntWidget *widget = handle; if (!widget) return; while (widget->parent) widget = widget->parent; if (type == PURPLE_NOTIFY_SEARCHRESULTS) purple_notify_searchresults_free(g_object_get_data(handle, "notify-results")); #if 1 /* This did not seem to be necessary */ g_signal_handlers_disconnect_by_func(G_OBJECT(widget), G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); #endif gnt_widget_destroy(widget); }
static void really_delete_status(PurpleSavedStatus *saved) { GList *iter; for (iter = edits; iter; iter = iter->next) { EditStatus *edit = iter->data; if (edit->saved == saved) { gnt_widget_destroy(edit->window); break; } } if (statuses.tree) gnt_tree_remove(GNT_TREE(statuses.tree), saved); purple_savedstatus_delete(purple_savedstatus_get_title(saved)); }
static void use_trans_status_cb(GntWidget *button, EditStatus *edit) { const char *message; PurpleStatusPrimitive prim; PurpleSavedStatus *saved; message = gnt_entry_get_text(GNT_ENTRY(edit->message)); prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type))); saved = purple_savedstatus_find_transient_by_type_and_message(prim, message); if (saved == NULL) { saved = purple_savedstatus_new(NULL, prim); edit->saved = saved; set_substatuses(edit); } purple_savedstatus_set_message(saved, message); purple_savedstatus_activate(saved); gnt_widget_destroy(edit->window); }
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 gboolean s_mouse_clicked(GntWM *wm, GntMouseEvent event, int cx, int cy, GntWidget *widget) { int x, y, w, h; if (!widget) return FALSE; /* This might be a place to bring up a context menu */ if (event != GNT_LEFT_MOUSE_DOWN || GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) return FALSE; gnt_widget_get_position(widget, &x, &y); gnt_widget_get_size(widget, &w, &h); if (cy == y && cx == x + w - 3) { gnt_widget_destroy(widget); return TRUE; } return FALSE; }
static void save_substatus_cb(GntWidget *widget, EditSubStatus *sub) { PurpleSavedStatus *saved = sub->parent->saved; RowInfo *row = sub->key; const char *message; PurpleStatusType *type; type = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(sub->type)); message = gnt_entry_get_text(GNT_ENTRY(sub->message)); row->type = type; row->message = g_strdup(message); if (saved) /* Save the substatus if the savedstatus actually exists. */ purple_savedstatus_set_substatus(saved, row->account, type, message); gnt_tree_set_choice(GNT_TREE(sub->parent->tree), row, TRUE); gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 1, purple_status_type_get_name(type)); gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 2, message); gnt_widget_destroy(sub->window); }
static void gnt_combo_box_destroy(GntWidget *widget) { gnt_widget_destroy(GNT_COMBO_BOX(widget)->dropdown->parent); }
static gboolean show_suggest_dropdown(GntEntry *entry) { char *suggest = NULL; int len; int offset = 0, x, y; int count = 0; GList *iter; const char *text = NULL; const char *sgst = NULL; int max = -1; if (entry->word) { char *s = get_beginning_of_word(entry); suggest = g_strndup(s, entry->cursor - s); if (entry->scroll < s) offset = gnt_util_onscreen_width(entry->scroll, s); } else suggest = g_strdup(entry->start); len = strlen(suggest); /* Don't need to use the utf8-function here */ if (entry->ddown == NULL) { GntWidget *box = gnt_vbox_new(FALSE); entry->ddown = gnt_tree_new(); gnt_tree_set_compare_func(GNT_TREE(entry->ddown), (GCompareFunc)g_utf8_collate); gnt_box_add_widget(GNT_BOX(box), entry->ddown); GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); gnt_widget_get_position(GNT_WIDGET(entry), &x, &y); x += offset; y++; if (y + 10 >= getmaxy(stdscr)) y -= 11; gnt_widget_set_position(box, x, y); } else gnt_tree_remove_all(GNT_TREE(entry->ddown)); for (count = 0, iter = entry->suggests; iter; iter = iter->next) { text = iter->data; if (g_ascii_strncasecmp(suggest, text, len) == 0 && strlen(text) >= len) { gnt_tree_add_row_after(GNT_TREE(entry->ddown), (gpointer)text, gnt_tree_create_row(GNT_TREE(entry->ddown), text), NULL, NULL); count++; if (max == -1) max = strlen(text) - len; else if (max) max = MIN(max, max_common_prefix(sgst + len, text + len)); sgst = text; } } g_free(suggest); if (count == 0) { destroy_suggest(entry); return FALSE; } else if (count == 1) { char *store = g_strndup(entry->start, entry->end - entry->start); gboolean ret; destroy_suggest(entry); complete_suggest(entry, sgst); ret = (strncmp(store, entry->start, entry->end - entry->start) != 0); g_free(store); return ret; } else { if (max > 0) { GntWidget *ddown = entry->ddown; char *match = g_strndup(sgst + len, max); entry->ddown = NULL; gnt_entry_key_pressed(GNT_WIDGET(entry), match); g_free(match); if (entry->ddown) gnt_widget_destroy(ddown); else entry->ddown = ddown; } gnt_widget_draw(entry->ddown->parent); } return TRUE; }
static void cancel_cb(GntButton *button, gpointer win) { finch_sound_set_active_profile(pref_dialog->original_profile); gnt_widget_destroy(GNT_WIDGET(win)); }
static void notify(PurpleConversation *conv, const char *fmt, ...) { GntWidget *window; GntToast *toast; char *str; int h, w, i; va_list args; if (purple_prefs_get_bool(PREFS_BEEP)) beep(); if (conv != NULL) { FinchConv *fc = FINCH_CONV(conv); if (gnt_widget_has_focus(fc->window)) return; } #ifdef HAVE_X11 if (purple_prefs_get_bool(PREFS_URGENT)) urgent(); #endif window = gnt_vbox_new(FALSE); GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER); va_start(args, fmt); str = g_strdup_vprintf(fmt, args); va_end(args); gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(str, GNT_TEXT_FLAG_HIGHLIGHT)); g_free(str); gnt_widget_size_request(window); gnt_widget_get_size(window, &w, &h); for (i = 0; i < MAX_COLS && gpsy[i] + h >= getmaxy(stdscr) ; ++i) ; if (i >= MAX_COLS) { purple_debug_warning("GntGf", "Dude, that's way too many popups\n"); gnt_widget_destroy(window); return; } toast = g_new0(GntToast, 1); toast->window = window; toast->column = i; gpsy[i] += h; if (w > gpsw[i]) { if (i == 0) gpsw[i] = w; else gpsw[i] = gpsw[i - 1] + w + 1; } if (i == 0 || (w + gpsw[i - 1] >= getmaxx(stdscr))) { /* if it's going to be too far left, overlap. */ gnt_widget_set_position(window, getmaxx(stdscr) - w - 1, getmaxy(stdscr) - gpsy[i] - 1); } else { gnt_widget_set_position(window, getmaxx(stdscr) - gpsw[i - 1] - w - 1, getmaxy(stdscr) - gpsy[i] - 1); } gnt_widget_draw(window); toast->timer = purple_timeout_add_seconds(4, (GSourceFunc)remove_toaster, toast); toasters = g_list_prepend(toasters, toast); }
static void destroy_substatus_win(PurpleAccount *account, EditSubStatus *sub, gpointer null) { gnt_widget_destroy(sub->window); /* the "destroy" callback will remove entry from the hashtable */ }
static void save_pounce_cb(GntWidget *w, PurpleGntPounceDialog *dialog) { const char *name; const char *message, *command, *reason; PurplePounceEvent events = PURPLE_POUNCE_NONE; PurplePounceOption options = PURPLE_POUNCE_OPTION_NONE; name = gnt_entry_get_text(GNT_ENTRY(dialog->buddy_entry)); if (*name == '\0') { purple_notify_error(NULL, NULL, _("Please enter a buddy to pounce."), NULL); return; } /* Options */ if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->on_away))) options |= PURPLE_POUNCE_OPTION_AWAY; /* Events */ if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signon))) events |= PURPLE_POUNCE_SIGNON; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signoff))) events |= PURPLE_POUNCE_SIGNOFF; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away))) events |= PURPLE_POUNCE_AWAY; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away_return))) events |= PURPLE_POUNCE_AWAY_RETURN; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle))) events |= PURPLE_POUNCE_IDLE; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle_return))) events |= PURPLE_POUNCE_IDLE_RETURN; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typing))) events |= PURPLE_POUNCE_TYPING; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typed))) events |= PURPLE_POUNCE_TYPED; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->stop_typing))) events |= PURPLE_POUNCE_TYPING_STOPPED; if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->message_recv))) events |= PURPLE_POUNCE_MESSAGE_RECEIVED; /* Data fields */ message = gnt_entry_get_text(GNT_ENTRY(dialog->send_msg_entry)); command = gnt_entry_get_text(GNT_ENTRY(dialog->exec_cmd_entry)); reason = gnt_entry_get_text(GNT_ENTRY(dialog->popup_entry)); if (*reason == '\0') reason = NULL; if (*message == '\0') message = NULL; if (*command == '\0') command = NULL; if (dialog->pounce == NULL) { dialog->pounce = purple_pounce_new(FINCH_UI, dialog->account, name, events, options); } else { purple_pounce_set_events(dialog->pounce, events); purple_pounce_set_options(dialog->pounce, options); purple_pounce_set_pouncer(dialog->pounce, dialog->account); purple_pounce_set_pouncee(dialog->pounce, name); } /* Actions */ purple_pounce_action_set_enabled(dialog->pounce, "open-window", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win))); purple_pounce_action_set_enabled(dialog->pounce, "popup-notify", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup))); purple_pounce_action_set_enabled(dialog->pounce, "send-message", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg))); purple_pounce_action_set_enabled(dialog->pounce, "execute-command", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd))); purple_pounce_action_set_enabled(dialog->pounce, "play-beep", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); purple_pounce_action_set_attribute(dialog->pounce, "send-message", "message", message); purple_pounce_action_set_attribute(dialog->pounce, "execute-command", "command", command); purple_pounce_action_set_attribute(dialog->pounce, "popup-notify", "reason", reason); /* Set the defaults for next time. */ purple_prefs_set_bool("/finch/pounces/default_actions/open-window", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win))); purple_prefs_set_bool("/finch/pounces/default_actions/popup-notify", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup))); purple_prefs_set_bool("/finch/pounces/default_actions/send-message", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg))); purple_prefs_set_bool("/finch/pounces/default_actions/execute-command", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd))); purple_prefs_set_bool("/finch/pounces/default_actions/play-beep", gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); purple_pounce_set_save(dialog->pounce, gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->save_pounce))); purple_pounce_set_pouncer(dialog->pounce, (PurpleAccount *)gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->account_menu))); update_pounces(); gnt_widget_destroy(dialog->window); }
static void cancel_cb(GntWidget *w, PurpleGntPounceDialog *dialog) { gnt_widget_destroy(dialog->window); }
static void fl_close(GntWidget *button, gpointer null) { gnt_widget_destroy(froomlist.window); }