Mercurial > pidgin
changeset 18203:c23aef39f9bb
merge of '088881d37b32f572377200c693a5d9662e4e3586'
and 'c8ccb9550c625221a5a784368b13cfb5bf821c00'
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Tue, 19 Jun 2007 23:52:23 +0000 |
parents | f54f83b20929 (current diff) 7df46d8bf114 (diff) |
children | 4cc042912ac2 |
files | |
diffstat | 15 files changed, 250 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/libgnt/gntfilesel.c Tue Jun 19 13:33:26 2007 +0000 +++ b/finch/libgnt/gntfilesel.c Tue Jun 19 23:52:23 2007 +0000 @@ -46,6 +46,7 @@ static GntWindowClass *parent_class = NULL; static guint signals[SIGS] = { 0 }; static void (*orig_map)(GntWidget *widget); +static void (*orig_size_request)(GntWidget *widget); static void gnt_file_sel_destroy(GntWidget *widget) @@ -552,6 +553,19 @@ } static void +gnt_file_sel_size_request(GntWidget *widget) +{ + GntFileSel *sel; + if (widget->priv.height > 0) + return; + + sel = GNT_FILE_SEL(widget); + sel->dirs->priv.height = 16; + sel->files->priv.height = 16; + orig_size_request(widget); +} + +static void gnt_file_sel_class_init(GntFileSelClass *klass) { GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); @@ -560,6 +574,8 @@ kl->destroy = gnt_file_sel_destroy; orig_map = kl->map; kl->map = gnt_file_sel_map; + orig_size_request = kl->size_request; + kl->size_request = gnt_file_sel_size_request; signals[SIG_FILE_SELECTED] = g_signal_new("file_selected",
--- a/finch/libgnt/gntmain.c Tue Jun 19 13:33:26 2007 +0000 +++ b/finch/libgnt/gntmain.c Tue Jun 19 23:52:23 2007 +0000 @@ -429,10 +429,14 @@ setup_io(); +#ifdef NO_WIDECHAR + ascii_only = TRUE; +#else if (locale && (strstr(locale, "UTF") || strstr(locale, "utf"))) ascii_only = FALSE; else ascii_only = TRUE; +#endif initscr(); typeahead(-1);
--- a/libpurple/accountopt.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/accountopt.c Tue Jun 19 23:52:23 2007 +0000 @@ -22,6 +22,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "internal.h" + #include "accountopt.h" #include "util.h"
--- a/libpurple/cmds.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/cmds.c Tue Jun 19 23:52:23 2007 +0000 @@ -22,6 +22,8 @@ #include <string.h> +#include "internal.h" + #include "account.h" #include "util.h" #include "cmds.h"
--- a/libpurple/imgstore.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/imgstore.c Tue Jun 19 23:52:23 2007 +0000 @@ -25,6 +25,8 @@ */ #include <glib.h> +#include "internal.h" + #include "dbus-maybe.h" #include "debug.h" #include "imgstore.h"
--- a/libpurple/internal.h Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/internal.h Tue Jun 19 23:52:23 2007 +0000 @@ -170,6 +170,10 @@ # endif #endif +#ifndef G_GNUC_NULL_TERMINATED +# define G_GNUC_NULL_TERMINATED +#endif + /* Safer ways to work with static buffers. When using non-static * buffers, either use g_strdup_* functions (preferred) or use * g_strlcpy/g_strlcpy directly. */
--- a/libpurple/mime.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/mime.c Tue Jun 19 23:52:23 2007 +0000 @@ -29,6 +29,8 @@ #include <glib/glist.h> #include <glib/gstring.h> +#include "internal.h" + /* this should become "util.h" if we ever get this into purple proper */ #include "debug.h" #include "mime.h"
--- a/libpurple/ntlm.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/ntlm.c Tue Jun 19 23:52:23 2007 +0000 @@ -25,6 +25,8 @@ #include <glib.h> #include <stdlib.h> +#include "internal.h" + #include "util.h" #include "ntlm.h" #include "cipher.h"
--- a/libpurple/request.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/request.c Tue Jun 19 23:52:23 2007 +0000 @@ -22,6 +22,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "internal.h" + #include "notify.h" #include "request.h" #include "debug.h"
--- a/libpurple/roomlist.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/roomlist.c Tue Jun 19 23:52:23 2007 +0000 @@ -25,6 +25,8 @@ #include <glib.h> +#include "internal.h" + #include "account.h" #include "connection.h" #include "debug.h"
--- a/libpurple/savedstatuses.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/savedstatuses.c Tue Jun 19 23:52:23 2007 +0000 @@ -29,6 +29,7 @@ #include "notify.h" #include "savedstatuses.h" #include "dbus-maybe.h" +#include "request.h" #include "status.h" #include "util.h" #include "xmlnode.h" @@ -110,6 +111,7 @@ g_return_if_fail(substatus != NULL); g_free(substatus->message); + purple_request_close_with_handle(substatus); PURPLE_DBUS_UNREGISTER_POINTER(substatus); g_free(substatus); } @@ -128,7 +130,7 @@ status->substatuses = g_list_remove(status->substatuses, substatus); free_saved_status_sub(substatus); } - + purple_request_close_with_handle(status); PURPLE_DBUS_UNREGISTER_POINTER(status); g_free(status); } @@ -569,6 +571,9 @@ schedule_save(); + purple_signal_emit(purple_savedstatuses_get_handle(), "savedstatus-added", + status); + return status; } @@ -584,6 +589,9 @@ status->title = g_strdup(title); schedule_save(); + + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", status); } void @@ -594,6 +602,8 @@ status->type = type; schedule_save(); + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", status); } void @@ -608,6 +618,9 @@ status->message = g_strdup(message); schedule_save(); + + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", status); } void @@ -637,6 +650,8 @@ substatus->message = g_strdup(message); schedule_save(); + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", saved_status); } void @@ -660,6 +675,9 @@ return; } } + + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-modified", saved_status); } /* @@ -683,16 +701,12 @@ } } -gboolean -purple_savedstatus_delete(const char *title) +void +purple_savedstatus_delete_by_status(PurpleSavedStatus *status) { - PurpleSavedStatus *status; time_t creation_time, current, idleaway; - status = purple_savedstatus_find(title); - - if (status == NULL) - return FALSE; + g_return_if_fail(status != NULL); saved_statuses = g_list_remove(saved_statuses, status); creation_time = purple_savedstatus_get_creation_time(status); @@ -713,6 +727,25 @@ if (idleaway == creation_time) purple_prefs_set_int("/purple/savedstatus/idleaway", 0); + purple_signal_emit(purple_savedstatuses_get_handle(), + "savedstatus-deleted", status); +} + +gboolean +purple_savedstatus_delete(const char *title) +{ + PurpleSavedStatus *status; + + status = purple_savedstatus_find(title); + + if (status == NULL) + return FALSE; + + if (purple_savedstatus_get_current() == status) + return FALSE; + + purple_savedstatus_delete_by_status(status); + return TRUE; } @@ -1171,6 +1204,21 @@ purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_SAVEDSTATUS)); + purple_signal_register(handle, "savedstatus-added", + purple_marshal_VOID__POINTER, NULL, 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_SAVEDSTATUS)); + + purple_signal_register(handle, "savedstatus-deleted", + purple_marshal_VOID__POINTER, NULL, 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_SAVEDSTATUS)); + + purple_signal_register(handle, "savedstatus-modified", + purple_marshal_VOID__POINTER, NULL, 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_SAVEDSTATUS)); + purple_signal_connect(purple_accounts_get_handle(), "account-removed", handle, PURPLE_CALLBACK(purple_savedstatus_unset_all_substatuses),
--- a/libpurple/savedstatuses.h Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/savedstatuses.h Tue Jun 19 23:52:23 2007 +0000 @@ -149,6 +149,16 @@ gboolean purple_savedstatus_delete(const char *title); /** + * Delete a saved status. This removes the saved status from the list + * of saved statuses, and writes the revised list to status.xml. + * + * @param saved_status the status to delete, the pointer is invalid after + * the call + * + */ +void purple_savedstatus_delete_by_status(PurpleSavedStatus *saved_status); + +/** * Returns all saved statuses. * * @constreturn A list of saved statuses.
--- a/libpurple/whiteboard.c Tue Jun 19 13:33:26 2007 +0000 +++ b/libpurple/whiteboard.c Tue Jun 19 23:52:23 2007 +0000 @@ -23,6 +23,7 @@ #include <string.h> +#include "internal.h" #include "whiteboard.h" #include "prpl.h"
--- a/pidgin/gtksavedstatuses.c Tue Jun 19 13:33:26 2007 +0000 +++ b/pidgin/gtksavedstatuses.c Tue Jun 19 23:52:23 2007 +0000 @@ -285,9 +285,11 @@ for (l = sel_titles; l != NULL; l = l->next) { title = l->data; - if (status_window_find_savedstatus(&iter, title)) - gtk_list_store_remove(status_window->model, &iter); - purple_savedstatus_delete(title); + if (purple_savedstatus_find(title) != purple_savedstatus_get_current()) { + if (status_window_find_savedstatus(&iter, title)) + gtk_list_store_remove(status_window->model, &iter); + purple_savedstatus_delete(title); + } g_free(title); } g_list_free(sel_titles); @@ -302,6 +304,7 @@ GList *sel_paths, *l, *sel_titles = NULL; GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); char *title; + gpointer handle; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); #if GTK_CHECK_VERSION(2,2,0) @@ -324,13 +327,16 @@ } g_list_free(sel_paths); - if (g_list_length(sel_titles) == 1) + if (g_list_length(sel_titles) == 1) { title = g_strdup_printf(_("Are you sure you want to delete %s?"), (const gchar *)sel_titles->data); - else + handle = purple_savedstatus_find(sel_titles->data); + } else { title = g_strdup(_("Are you sure you want to delete the selected saved statuses?")); + handle = dialog; + } - purple_request_action(dialog, NULL, title, NULL, 0, + purple_request_action(handle, NULL, title, NULL, 0, NULL, NULL, NULL, sel_titles, 2, _("Delete"), status_window_delete_confirm_cb, @@ -349,17 +355,39 @@ status_selected_cb(GtkTreeSelection *sel, gpointer user_data) { StatusWindow *dialog = user_data; - int num_selected = 0; + GList *sel_paths, *tmp; + gboolean can_use = TRUE, can_delete = TRUE; + int num_selected; + GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); #if GTK_CHECK_VERSION(2,2,0) - num_selected = gtk_tree_selection_count_selected_rows(sel); + sel_paths = gtk_tree_selection_get_selected_rows(sel, NULL); #else - gtk_tree_selection_selected_foreach(sel, count_selected_helper, &num_selected); + gtk_tree_selection_selected_foreach(sel, list_selected_helper, &sel_paths); #endif - gtk_widget_set_sensitive(dialog->use_button, (num_selected == 1)); + for (tmp = sel_paths, num_selected = 0; tmp; tmp = tmp->next, num_selected++) { + GtkTreeIter iter; + char *title; + + if (gtk_tree_model_get_iter(model, &iter, tmp->data)) { + gtk_tree_model_get(model, &iter, + STATUS_WINDOW_COLUMN_TITLE, &title, -1); + if (purple_savedstatus_find(title) == purple_savedstatus_get_current()) { + can_use = can_delete = FALSE; + } + + g_free(title); + } + + gtk_tree_path_free(tmp->data); + } + + gtk_widget_set_sensitive(dialog->use_button, (num_selected == 1) && can_use); gtk_widget_set_sensitive(dialog->modify_button, (num_selected > 0)); - gtk_widget_set_sensitive(dialog->delete_button, (num_selected > 0)); + gtk_widget_set_sensitive(dialog->delete_button, can_delete); + + g_list_free(sel_paths); } static void @@ -421,6 +449,12 @@ status_window_modify_cb(NULL, dialog); } +static void +saved_status_updated_cb(PurpleSavedStatus *status, StatusWindow *sw) +{ + populate_saved_status_list(sw); +} + static GtkWidget * create_saved_status_list(StatusWindow *dialog) { @@ -529,6 +563,13 @@ return FALSE; } +static void +current_status_changed(PurpleSavedStatus *old, PurpleSavedStatus *new_status, + StatusWindow *dialog) +{ + status_selected_cb(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)), dialog); +} + void pidgin_status_window_show(void) { @@ -615,6 +656,20 @@ g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(status_window_close_cb), dialog); + purple_signal_connect(purple_savedstatuses_get_handle(), + "savedstatus-changed", dialog, + PURPLE_CALLBACK(current_status_changed), dialog); + + purple_signal_connect(purple_savedstatuses_get_handle(), + "savedstatus-added", dialog, + PURPLE_CALLBACK(saved_status_updated_cb), dialog); + purple_signal_connect(purple_savedstatuses_get_handle(), + "savedstatus-deleted", dialog, + PURPLE_CALLBACK(saved_status_updated_cb), dialog); + purple_signal_connect(purple_savedstatuses_get_handle(), + "savedstatus-modified", dialog, + PURPLE_CALLBACK(saved_status_updated_cb), dialog); + gtk_widget_show_all(win); } @@ -804,8 +859,10 @@ gtk_widget_destroy(dialog->window); g_free(dialog->original_title); +/* if (status_window != NULL) add_status_to_saved_status_list(status_window->model, saved_status); +*/ /* If they clicked on "Save & Use" or "Use," then activate the status */ if (button != dialog->save_button)
--- a/pidgin/gtkstatusbox.c Tue Jun 19 13:33:26 2007 +0000 +++ b/pidgin/gtkstatusbox.c Tue Jun 19 23:52:23 2007 +0000 @@ -47,6 +47,7 @@ #include "internal.h" #include "imgstore.h" #include "network.h" +#include "request.h" #include "savedstatuses.h" #include "status.h" #include "debug.h" @@ -1223,6 +1224,12 @@ } static void +saved_status_updated_cb(PurpleSavedStatus *status, PidginStatusBox *status_box) +{ + pidgin_status_box_regenerate(status_box); +} + +static void spellcheck_prefs_cb(const char *name, PurplePrefType type, gconstpointer value, gpointer data) { @@ -1514,6 +1521,56 @@ pidgin_status_box_changed(status_box); } +static void tree_view_delete_current_selection_cb(gpointer data) +{ + PurpleSavedStatus *saved; + + saved = purple_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); + g_return_if_fail(saved != NULL); + + if (purple_savedstatus_get_current() != saved) + purple_savedstatus_delete_by_status(saved); +} + +static void +tree_view_delete_current_selection(PidginStatusBox *status_box, GtkTreePath *path) +{ + GtkTreeIter iter; + gpointer data; + PurpleSavedStatus *saved; + gchar *msg; + + if (status_box->active_row) { + /* don't delete active status */ + if (gtk_tree_path_compare(path, gtk_tree_row_reference_get_path(status_box->active_row)) == 0) + return; + } + + if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(status_box->dropdown_store), &iter, path)) + return; + + gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, + DATA_COLUMN, &data, + -1); + + saved = purple_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); + g_return_if_fail(saved != NULL); + if (saved == purple_savedstatus_get_current()) + return; + + msg = g_strdup_printf(_("Are you sure you want to delete %s?"), purple_savedstatus_get_title(saved)); + + purple_request_action(saved, NULL, msg, NULL, 0, + NULL, NULL, NULL, + data, 2, + _("Delete"), tree_view_delete_current_selection_cb, + _("Cancel"), NULL); + + g_free(msg); + + pidgin_status_box_popdown(status_box); +} + static gboolean treeview_button_release_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *status_box) { @@ -1561,18 +1618,25 @@ if (event->keyval == GDK_Escape) { pidgin_status_box_popdown(box); return TRUE; - } else if (event->keyval == GDK_Return) { + } else { GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(box->tree_view)); GtkTreeIter iter; GtkTreePath *path; if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { + gboolean ret = TRUE; path = gtk_tree_model_get_path(GTK_TREE_MODEL(box->dropdown_store), &iter); - treeview_activate_current_selection(box, path); + if (event->keyval == GDK_Return) { + treeview_activate_current_selection(box, path); + } else if (event->keyval == GDK_Delete) { + tree_view_delete_current_selection(box, path); + } else + ret = FALSE; + gtk_tree_path_free (path); - return TRUE; + return ret; } - } + } } return FALSE; } @@ -1742,6 +1806,15 @@ status_box, PURPLE_CALLBACK(current_savedstatus_changed_cb), status_box); + purple_signal_connect(purple_savedstatuses_get_handle(), + "savedstatus-added", status_box, + PURPLE_CALLBACK(saved_status_updated_cb), status_box); + purple_signal_connect(purple_savedstatuses_get_handle(), + "savedstatus-deleted", status_box, + PURPLE_CALLBACK(saved_status_updated_cb), status_box); + purple_signal_connect(purple_savedstatuses_get_handle(), + "savedstatus-modified", status_box, + PURPLE_CALLBACK(saved_status_updated_cb), status_box); purple_signal_connect(purple_accounts_get_handle(), "account-enabled", status_box, PURPLE_CALLBACK(account_enabled_cb), status_box);