comparison src/gtkaccount.c @ 5802:d23c0d94be18

[gaim-migrate @ 6232] The account editor is now gtk 2.0 again. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 07 Jun 2003 20:12:02 +0000
parents d4171d0bc80a
children 56042e59499a
comparison
equal deleted inserted replaced
5801:4ee33a2f421e 5802:d23c0d94be18
1141 gtk_tree_path_free(source_row); 1141 gtk_tree_path_free(source_row);
1142 } 1142 }
1143 } 1143 }
1144 1144
1145 static void 1145 static void
1146 move_account_after(GtkListStore *store, GtkTreeIter *iter,
1147 GtkTreeIter *position)
1148 {
1149 GtkTreeIter new_iter;
1150 GaimAccount *account;
1151
1152 gtk_tree_model_get(GTK_TREE_MODEL(store), iter,
1153 COLUMN_DATA, &account,
1154 -1);
1155
1156 gtk_list_store_insert_after(store, &new_iter, position);
1157
1158 set_account(store, &new_iter, account);
1159
1160 gtk_list_store_remove(store, iter);
1161 }
1162
1163 static void
1164 move_account_before(GtkListStore *store, GtkTreeIter *iter,
1165 GtkTreeIter *position)
1166 {
1167 GtkTreeIter new_iter;
1168 GaimAccount *account;
1169
1170 gtk_tree_model_get(GTK_TREE_MODEL(store), iter,
1171 COLUMN_DATA, &account,
1172 -1);
1173
1174 gtk_list_store_insert_before(store, &new_iter, position);
1175
1176 set_account(store, &new_iter, account);
1177
1178 gtk_list_store_remove(store, iter);
1179 }
1180
1181 static void
1146 drag_data_received_cb(GtkWidget *widget, GdkDragContext *ctx, 1182 drag_data_received_cb(GtkWidget *widget, GdkDragContext *ctx,
1147 guint x, guint y, GtkSelectionData *sd, 1183 guint x, guint y, GtkSelectionData *sd,
1148 guint info, guint t, AccountsDialog *dialog) 1184 guint info, guint t, AccountsDialog *dialog)
1149 { 1185 {
1150 if (sd->target == gdk_atom_intern("GAIM_ACCOUNT", FALSE) && sd->data) { 1186 if (sd->target == gdk_atom_intern("GAIM_ACCOUNT", FALSE) && sd->data) {
1169 account = g_value_get_pointer(&val); 1205 account = g_value_get_pointer(&val);
1170 1206
1171 switch (position) { 1207 switch (position) {
1172 case GTK_TREE_VIEW_DROP_AFTER: 1208 case GTK_TREE_VIEW_DROP_AFTER:
1173 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: 1209 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
1174 gaim_debug(GAIM_DEBUG_MISC, "gtkaccount", 1210 move_account_after(dialog->model, &dialog->drag_iter,
1175 "after\n"); 1211 &iter);
1176 gtk_list_store_move_after(dialog->model,
1177 &dialog->drag_iter, &iter);
1178 dest_index = g_list_index(gaim_accounts_get_all(), 1212 dest_index = g_list_index(gaim_accounts_get_all(),
1179 account) + 1; 1213 account) + 1;
1180 break; 1214 break;
1181 1215
1182 case GTK_TREE_VIEW_DROP_BEFORE: 1216 case GTK_TREE_VIEW_DROP_BEFORE:
1183 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: 1217 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
1184 gaim_debug(GAIM_DEBUG_MISC, "gtkaccount",
1185 "before\n");
1186 dest_index = g_list_index(gaim_accounts_get_all(), 1218 dest_index = g_list_index(gaim_accounts_get_all(),
1187 account); 1219 account);
1188 1220
1189 gaim_debug(GAIM_DEBUG_MISC, "gtkaccount", 1221 move_account_before(dialog->model, &dialog->drag_iter,
1190 "iter = %p\n", &iter); 1222 &iter);
1191 gaim_debug(GAIM_DEBUG_MISC, "gtkaccount",
1192 "account = %s\n",
1193 gaim_account_get_username(account));
1194
1195 /*
1196 * Somebody figure out why inserting before the first
1197 * account sometimes moves to the end, please :(
1198 */
1199 if (dest_index == 0) {
1200 gtk_list_store_move_after(dialog->model,
1201 &dialog->drag_iter, &iter);
1202 gtk_list_store_swap(dialog->model, &iter,
1203 &dialog->drag_iter);
1204 }
1205 else {
1206 gtk_list_store_move_before(dialog->model,
1207 &dialog->drag_iter, &iter);
1208 }
1209
1210 break; 1223 break;
1211 1224
1212 default: 1225 default:
1213 return; 1226 return;
1214 } 1227 }