From: <sa...@us...> - 2006-08-15 06:22:03
|
Revision: 16764 Author: sadrul Date: 2006-08-14 23:21:39 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16764&view=rev Log Message: ----------- Add a savedstatus dialog, and a "status" command to bring it up. You an also select "Saved..." from the dropdown in the buddylist. The 'Add' and 'Edit' buttons don't do anything yet. They will probably get to work some time tomorrow. Modified Paths: -------------- trunk/console/Makefile trunk/console/gntblist.c trunk/console/gntconv.c trunk/console/libgnt/gnttree.c trunk/doc/gntgaim.1.in Added Paths: ----------- trunk/console/gntstatus.c trunk/console/gntstatus.h Modified: trunk/console/Makefile =================================================================== --- trunk/console/Makefile 2006-08-15 04:07:38 UTC (rev 16763) +++ trunk/console/Makefile 2006-08-15 06:21:39 UTC (rev 16764) @@ -13,6 +13,7 @@ gntplugin.c \ gntprefs.c \ gntrequest.c \ + gntstatus.c \ gntui.c GG_HEADERS = \ @@ -25,6 +26,7 @@ gntprefs.h \ gntplugin.h \ gntrequest.h \ + gntstatus.h \ gntui.h GG_OBJECTS = \ @@ -37,6 +39,7 @@ gntplugin.o \ gntprefs.o \ gntrequest.o \ + gntstatus.o \ gntui.o all: gntgaim Modified: trunk/console/gntblist.c =================================================================== --- trunk/console/gntblist.c 2006-08-15 04:07:38 UTC (rev 16763) +++ trunk/console/gntblist.c 2006-08-15 06:21:39 UTC (rev 16764) @@ -17,6 +17,7 @@ #include "gnttree.h" #include "gntblist.h" +#include "gntstatus.h" #include <string.h> #define PREF_ROOT "/gaim/gnt/blist" @@ -42,7 +43,8 @@ typedef enum { STATUS_PRIMITIVE = 0, - STATUS_SAVED + STATUS_SAVED_POPULAR, + STATUS_SAVED_ALL, } StatusType; typedef struct @@ -1035,6 +1037,7 @@ int i; GList *iter; GList *items = NULL; + StatusBoxItem *item = NULL; /* First the primitives */ GaimStatusPrimitive prims[] = {GAIM_STATUS_AVAILABLE, GAIM_STATUS_AWAY, @@ -1042,7 +1045,7 @@ for (i = 0; prims[i] != GAIM_STATUS_UNSET; i++) { - StatusBoxItem *item = g_new0(StatusBoxItem, 1); + item = g_new0(StatusBoxItem, 1); item->type = STATUS_PRIMITIVE; item->u.prim = prims[i]; items = g_list_prepend(items, item); @@ -1053,18 +1056,26 @@ /* Now the popular statuses */ for (iter = gaim_savedstatuses_get_popular(6); iter; iter = iter->next) { - StatusBoxItem *item = g_new0(StatusBoxItem, 1); - item->type = STATUS_SAVED; + item = g_new0(StatusBoxItem, 1); + item->type = STATUS_SAVED_POPULAR; item->u.saved = iter->data; items = g_list_prepend(items, item); gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, gaim_savedstatus_get_title(iter->data)); } + /* More savedstatuses */ + item = g_new0(StatusBoxItem, 1); + item->type = STATUS_SAVED_ALL; + items = g_list_prepend(items, item); + gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, + _("Saved...")); + /* The keys for the combobox are created here, and never used * anywhere else. So make sure the keys are freed when the widget * is destroyed. */ - g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses", items, (GDestroyNotify)destroy_status_list); + g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses", + items, (GDestroyNotify)destroy_status_list); } void gg_blist_init() @@ -1125,7 +1136,7 @@ status_selection_changed(GntComboBox *box, StatusBoxItem *old, StatusBoxItem *now, gpointer null) { gnt_entry_set_text(GNT_ENTRY(ggblist->statustext), NULL); - if (now->type == STATUS_SAVED) + if (now->type == STATUS_SAVED_POPULAR) { /* Set the status immediately */ gaim_savedstatus_activate(now->u.saved); @@ -1137,6 +1148,10 @@ gnt_box_move_focus(GNT_BOX(ggblist->window), 1); ggblist->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, NULL); } + else if (now->type == STATUS_SAVED_ALL) + { + gg_savedstatus_show_all(); + } else g_return_if_reached(); } Modified: trunk/console/gntconv.c =================================================================== --- trunk/console/gntconv.c 2006-08-15 04:07:38 UTC (rev 16763) +++ trunk/console/gntconv.c 2006-08-15 06:21:39 UTC (rev 16764) @@ -11,6 +11,7 @@ #include "gntdebug.h" #include "gntplugin.h" #include "gntprefs.h" +#include "gntstatus.h" #include "gnt.h" #include "gntbox.h" @@ -566,6 +567,9 @@ gaim_cmd_register("prefs", "", GAIM_CMD_P_DEFAULT, GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, cmd_show_window, _("prefs: Show the preference window."), gg_prefs_show_all); + gaim_cmd_register("status", "", GAIM_CMD_P_DEFAULT, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, + cmd_show_window, _("statuses: Show the savedstatuses window."), gg_savedstatus_show_all); } void gg_conversation_uninit() Added: trunk/console/gntstatus.c =================================================================== --- trunk/console/gntstatus.c (rev 0) +++ trunk/console/gntstatus.c 2006-08-15 06:21:39 UTC (rev 16764) @@ -0,0 +1,139 @@ +#include <gnt.h> +#include <gntbox.h> +#include <gntbutton.h> +#include <gntentry.h> +#include <gntlabel.h> +#include <gnttree.h> + +#include <request.h> + +#include "gntgaim.h" +#include "gntstatus.h" + +static struct +{ + GntWidget *window; + GntWidget *tree; +} statuses; + +static void +reset_status_window(GntWidget *widget, gpointer null) +{ + statuses.window = NULL; + statuses.tree = NULL; +} + +static void +populate_statuses(GntTree *tree) +{ + const GList *list; + + for (list = gaim_savedstatuses_get_all(); list; list = list->next) + { + GaimSavedStatus *saved = list->data; + const char *title, *type, *message; + + if (gaim_savedstatus_is_transient(saved)) + continue; + + title = gaim_savedstatus_get_title(saved); + type = gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved)); + message = gaim_savedstatus_get_message(saved); /* XXX: Strip possible markups */ + + gnt_tree_add_row_last(tree, saved, + gnt_tree_create_row(tree, title, type, message), NULL); + } +} + +static void +really_delete_status(GaimSavedStatus *saved) +{ + /* XXX: Close any modify dialog opened for the savedstatus */ + if (statuses.tree) + gnt_tree_remove(GNT_TREE(statuses.tree), saved); + + gaim_savedstatus_delete(gaim_savedstatus_get_title(saved)); +} + +static void +ask_before_delete(GntWidget *button, gpointer null) +{ + char *ask; + GaimSavedStatus *saved; + + g_return_if_fail(statuses.tree != NULL); + + saved = gnt_tree_get_selection_data(GNT_TREE(statuses.tree)); + ask = g_strdup_printf(_("Are you sure you want to delete \"%s\""), + gaim_savedstatus_get_title(saved)); + + gaim_request_action(saved, _("Delete Status"), ask, NULL, 0, saved, 2, + _("Delete"), really_delete_status, _("Cancel"), NULL); + g_free(ask); +} + +static void +use_savedstatus_cb(GntWidget *widget, gpointer null) +{ + g_return_if_fail(statuses.tree != NULL); + + gaim_savedstatus_activate(gnt_tree_get_selection_data(GNT_TREE(statuses.tree))); +} + +void gg_savedstatus_show_all() +{ + GntWidget *window, *tree, *box, *button; + if (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_col_width(GNT_TREE(tree), 0, 25); + gnt_tree_set_col_width(GNT_TREE(tree), 1, 12); + gnt_tree_set_col_width(GNT_TREE(tree), 2, 35); + 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); + + button = gnt_button_new(_("Edit")); + gnt_box_add_widget(GNT_BOX(box), button); + + button = gnt_button_new(_("Delete")); + gnt_box_add_widget(GNT_BOX(box), 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); +} + +void gg_savedstatus_edit(GaimSavedStatus *saved) +{ +} + Property changes on: trunk/console/gntstatus.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/console/gntstatus.h =================================================================== --- trunk/console/gntstatus.h (rev 0) +++ trunk/console/gntstatus.h 2006-08-15 06:21:39 UTC (rev 16764) @@ -0,0 +1,7 @@ +#include <status.h> +#include <savedstatuses.h> + +void gg_savedstatus_show_all(); + +void gg_savedstatus_edit(GaimSavedStatus *saved); + Property changes on: trunk/console/gntstatus.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/console/libgnt/gnttree.c =================================================================== --- trunk/console/libgnt/gnttree.c 2006-08-15 04:07:38 UTC (rev 16763) +++ trunk/console/libgnt/gnttree.c 2006-08-15 06:21:39 UTC (rev 16764) @@ -274,7 +274,7 @@ int x = pos; mvwhline(widget->window, pos + 1, pos, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), - widget->priv.width - pos); + widget->priv.width - pos - 1); for (i = 0; i < tree->ncol; i++) { Modified: trunk/doc/gntgaim.1.in =================================================================== --- trunk/doc/gntgaim.1.in 2006-08-15 04:07:38 UTC (rev 16763) +++ trunk/doc/gntgaim.1.in 2006-08-15 06:21:39 UTC (rev 16764) @@ -169,6 +169,10 @@ .B prefs for the preferences window. +.TP +.B status +for the status window. + .SH BUGS Known bugs are listed at .br This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |