comparison libpurple/protocols/myspace/zap.c @ 19715:472e263e88a8

Eliminate an excess array and loop.
author Richard Laager <rlaager@wiktel.com>
date Mon, 10 Sep 2007 20:56:02 +0000
parents 77673386d31d
children 51457cf3d27b 1141d47b162c
comparison
equal deleted inserted replaced
19714:77673386d31d 19715:472e263e88a8
147 msim_blist_node_menu(PurpleBlistNode *node) 147 msim_blist_node_menu(PurpleBlistNode *node)
148 { 148 {
149 GList *menu, *zap_menu; 149 GList *menu, *zap_menu;
150 GList *types; 150 GList *types;
151 PurpleMenuAction *act; 151 PurpleMenuAction *act;
152 /* Warning: hardcoded to match that in msim_attention_types. */
153 const gchar *zap_names[10];
154 guint i; 152 guint i;
155 153
156 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { 154 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) {
157 /* Only know about buddies for now. */ 155 /* Only know about buddies for now. */
158 return NULL; 156 return NULL;
159 } 157 }
160 158
161 /* Names from official client. */ 159 zap_menu = NULL;
160
161 /* TODO: get rid of once is accessible directly in GUI */
162 types = msim_attention_types(NULL); 162 types = msim_attention_types(NULL);
163 i = 0; 163 i = 0;
164 do 164 do
165 { 165 {
166 MsimAttentionType *attn; 166 MsimAttentionType *attn;
167 167
168 attn = (MsimAttentionType *)types->data; 168 attn = (MsimAttentionType *)types->data;
169 zap_names[i] = attn->name; 169
170 act = purple_menu_action_new(attn->name, PURPLE_CALLBACK(msim_send_zap_from_menu),
171 GUINT_TO_POINTER(i), NULL);
172 zap_menu = g_list_append(zap_menu, act);
173
170 ++i; 174 ++i;
171 } while ((types = g_list_next(types))); 175 } while ((types = g_list_next(types)));
172 176
173 menu = zap_menu = NULL;
174
175 /* TODO: get rid of once is accessible directly in GUI */
176 for (i = 0; i < sizeof(zap_names) / sizeof(zap_names[0]); ++i) {
177 act = purple_menu_action_new(zap_names[i], PURPLE_CALLBACK(msim_send_zap_from_menu),
178 GUINT_TO_POINTER(i), NULL);
179 zap_menu = g_list_append(zap_menu, act);
180 }
181
182 act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu); 177 act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu);
183 menu = g_list_append(menu, act); 178 menu = g_list_append(NULL, act);
184 179
185 return menu; 180 return menu;
186 } 181 }
187 182
188 /** Process an incoming zap. */ 183 /** Process an incoming zap. */