comparison console/gntblist.c @ 14126:b71bfeaaed58

[gaim-migrate @ 16764] 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. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 15 Aug 2006 06:21:39 +0000
parents eaf7f35635bc
children db2311999862
comparison
equal deleted inserted replaced
14125:7dfa024c1a4a 14126:b71bfeaaed58
15 #include "gntlabel.h" 15 #include "gntlabel.h"
16 #include "gntline.h" 16 #include "gntline.h"
17 #include "gnttree.h" 17 #include "gnttree.h"
18 18
19 #include "gntblist.h" 19 #include "gntblist.h"
20 #include "gntstatus.h"
20 #include <string.h> 21 #include <string.h>
21 22
22 #define PREF_ROOT "/gaim/gnt/blist" 23 #define PREF_ROOT "/gaim/gnt/blist"
23 #define TYPING_TIMEOUT 4000 24 #define TYPING_TIMEOUT 4000
24 25
40 } GGBlist; 41 } GGBlist;
41 42
42 typedef enum 43 typedef enum
43 { 44 {
44 STATUS_PRIMITIVE = 0, 45 STATUS_PRIMITIVE = 0,
45 STATUS_SAVED 46 STATUS_SAVED_POPULAR,
47 STATUS_SAVED_ALL,
46 } StatusType; 48 } StatusType;
47 49
48 typedef struct 50 typedef struct
49 { 51 {
50 StatusType type; 52 StatusType type;
1033 populate_status_dropdown() 1035 populate_status_dropdown()
1034 { 1036 {
1035 int i; 1037 int i;
1036 GList *iter; 1038 GList *iter;
1037 GList *items = NULL; 1039 GList *items = NULL;
1040 StatusBoxItem *item = NULL;
1038 1041
1039 /* First the primitives */ 1042 /* First the primitives */
1040 GaimStatusPrimitive prims[] = {GAIM_STATUS_AVAILABLE, GAIM_STATUS_AWAY, 1043 GaimStatusPrimitive prims[] = {GAIM_STATUS_AVAILABLE, GAIM_STATUS_AWAY,
1041 GAIM_STATUS_INVISIBLE, GAIM_STATUS_OFFLINE, GAIM_STATUS_UNSET}; 1044 GAIM_STATUS_INVISIBLE, GAIM_STATUS_OFFLINE, GAIM_STATUS_UNSET};
1042 1045
1043 for (i = 0; prims[i] != GAIM_STATUS_UNSET; i++) 1046 for (i = 0; prims[i] != GAIM_STATUS_UNSET; i++)
1044 { 1047 {
1045 StatusBoxItem *item = g_new0(StatusBoxItem, 1); 1048 item = g_new0(StatusBoxItem, 1);
1046 item->type = STATUS_PRIMITIVE; 1049 item->type = STATUS_PRIMITIVE;
1047 item->u.prim = prims[i]; 1050 item->u.prim = prims[i];
1048 items = g_list_prepend(items, item); 1051 items = g_list_prepend(items, item);
1049 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, 1052 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item,
1050 gaim_primitive_get_name_from_type(prims[i])); 1053 gaim_primitive_get_name_from_type(prims[i]));
1051 } 1054 }
1052 1055
1053 /* Now the popular statuses */ 1056 /* Now the popular statuses */
1054 for (iter = gaim_savedstatuses_get_popular(6); iter; iter = iter->next) 1057 for (iter = gaim_savedstatuses_get_popular(6); iter; iter = iter->next)
1055 { 1058 {
1056 StatusBoxItem *item = g_new0(StatusBoxItem, 1); 1059 item = g_new0(StatusBoxItem, 1);
1057 item->type = STATUS_SAVED; 1060 item->type = STATUS_SAVED_POPULAR;
1058 item->u.saved = iter->data; 1061 item->u.saved = iter->data;
1059 items = g_list_prepend(items, item); 1062 items = g_list_prepend(items, item);
1060 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, 1063 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item,
1061 gaim_savedstatus_get_title(iter->data)); 1064 gaim_savedstatus_get_title(iter->data));
1062 } 1065 }
1063 1066
1067 /* More savedstatuses */
1068 item = g_new0(StatusBoxItem, 1);
1069 item->type = STATUS_SAVED_ALL;
1070 items = g_list_prepend(items, item);
1071 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item,
1072 _("Saved..."));
1073
1064 /* The keys for the combobox are created here, and never used 1074 /* The keys for the combobox are created here, and never used
1065 * anywhere else. So make sure the keys are freed when the widget 1075 * anywhere else. So make sure the keys are freed when the widget
1066 * is destroyed. */ 1076 * is destroyed. */
1067 g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses", items, (GDestroyNotify)destroy_status_list); 1077 g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses",
1078 items, (GDestroyNotify)destroy_status_list);
1068 } 1079 }
1069 1080
1070 void gg_blist_init() 1081 void gg_blist_init()
1071 { 1082 {
1072 gaim_prefs_add_none(PREF_ROOT); 1083 gaim_prefs_add_none(PREF_ROOT);
1123 1134
1124 static void 1135 static void
1125 status_selection_changed(GntComboBox *box, StatusBoxItem *old, StatusBoxItem *now, gpointer null) 1136 status_selection_changed(GntComboBox *box, StatusBoxItem *old, StatusBoxItem *now, gpointer null)
1126 { 1137 {
1127 gnt_entry_set_text(GNT_ENTRY(ggblist->statustext), NULL); 1138 gnt_entry_set_text(GNT_ENTRY(ggblist->statustext), NULL);
1128 if (now->type == STATUS_SAVED) 1139 if (now->type == STATUS_SAVED_POPULAR)
1129 { 1140 {
1130 /* Set the status immediately */ 1141 /* Set the status immediately */
1131 gaim_savedstatus_activate(now->u.saved); 1142 gaim_savedstatus_activate(now->u.saved);
1132 } 1143 }
1133 else if (now->type == STATUS_PRIMITIVE) 1144 else if (now->type == STATUS_PRIMITIVE)
1134 { 1145 {
1135 /* Move the focus to the entry box */ 1146 /* Move the focus to the entry box */
1136 /* XXX: Make sure the selected status can have a message */ 1147 /* XXX: Make sure the selected status can have a message */
1137 gnt_box_move_focus(GNT_BOX(ggblist->window), 1); 1148 gnt_box_move_focus(GNT_BOX(ggblist->window), 1);
1138 ggblist->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, NULL); 1149 ggblist->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, NULL);
1150 }
1151 else if (now->type == STATUS_SAVED_ALL)
1152 {
1153 gg_savedstatus_show_all();
1139 } 1154 }
1140 else 1155 else
1141 g_return_if_reached(); 1156 g_return_if_reached();
1142 } 1157 }
1143 1158