# HG changeset patch # User Mark Doliner # Date 1190011396 0 # Node ID e47e8d670bfabd11c1f55d42817aa842e85ded61 # Parent 3a5f152e7ed09983d61735d734ecc4ac6a8995c7# Parent a3f07fa68e90d8afd15718dbe8c83d27ebb74db2 merge of '936cdaa27fea9a9673ee31a184af0a30d9471abe' and 'b017e4ee0447b76795120d6997db9b26e1a0dfba' diff -r 3a5f152e7ed0 -r e47e8d670bfa finch/gntnotify.c --- a/finch/gntnotify.c Mon Sep 17 04:50:24 2007 +0000 +++ b/finch/gntnotify.c Mon Sep 17 06:43:16 2007 +0000 @@ -352,14 +352,17 @@ gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL)); - columns = purple_notify_searchresults_get_columns_count(results); + columns = g_list_length(results->columns); tree = gnt_tree_new_with_columns(columns); gnt_tree_set_show_title(GNT_TREE(tree), TRUE); gnt_box_add_widget(GNT_BOX(window), tree); - for (i = 0; i < columns; i++) - gnt_tree_set_column_title(GNT_TREE(tree), i, - purple_notify_searchresults_column_get_title(results, i)); + i = 0; + for (iter = results->columns; iter; iter = iter->next) + { + gnt_tree_set_column_title(GNT_TREE(tree), i, iter->data); + i++; + } box = gnt_hbox_new(TRUE); diff -r 3a5f152e7ed0 -r e47e8d670bfa libpurple/notify.h --- a/libpurple/notify.h Mon Sep 17 04:50:24 2007 +0000 +++ b/libpurple/notify.h Mon Sep 17 06:43:16 2007 +0000 @@ -293,7 +293,17 @@ /** * Returns a number of the rows in the search results object. - * + * + * @deprecated This function will be removed in Pidgin 3.0.0 unless + * there is sufficient demand to keep it. Using this + * function encourages looping through the results + * inefficiently. Instead of using this function you + * should iterate through the results using a loop + * similar to this: + * for (l = results->rows; l != NULL; l = l->next) + * If you really need to get the number of rows you + * can use g_list_length(results->rows). + * * @param results The search results object. * * @return Number of the result rows. @@ -303,6 +313,16 @@ /** * Returns a number of the columns in the search results object. * + * @deprecated This function will be removed in Pidgin 3.0.0 unless + * there is sufficient demand to keep it. Using this + * function encourages looping through the columns + * inefficiently. Instead of using this function you + * should iterate through the columns using a loop + * similar to this: + * for (l = results->columns; l != NULL; l = l->next) + * If you really need to get the number of columns you + * can use g_list_length(results->columns). + * * @param results The search results object. * * @return Number of the columns. @@ -312,6 +332,16 @@ /** * Returns a row of the results from the search results object. * + * @deprecated This function will be removed in Pidgin 3.0.0 unless + * there is sufficient demand to keep it. Using this + * function encourages looping through the results + * inefficiently. Instead of using this function you + * should iterate through the results using a loop + * similar to this: + * for (l = results->rows; l != NULL; l = l->next) + * If you really need to get the data for a particular + * row you can use g_list_nth_data(results->rows, row_id). + * * @param results The search results object. * @param row_id Index of the row to be returned. * @@ -322,7 +352,15 @@ /** * Returns a title of the search results object's column. - * + * + * @deprecated This function will be removed in Pidgin 3.0.0 unless + * there is sufficient demand to keep it. Using this + * function encourages looping through the columns + * inefficiently. Instead of using this function you + * should iterate through the name of a particular + * column you can use + * g_list_nth_data(results->columns, row_id). + * * @param results The search results object. * @param column_id Index of the column. * diff -r 3a5f152e7ed0 -r e47e8d670bfa pidgin/gtknotify.c --- a/pidgin/gtknotify.c Mon Sep 17 04:50:24 2007 +0000 +++ b/pidgin/gtknotify.c Mon Sep 17 06:43:16 2007 +0000 @@ -661,30 +661,30 @@ GtkTreeIter iter; GdkPixbuf *pixbuf; guint col_num; - guint i; - guint j; + GList *row, *column; + guint n; gtk_list_store_clear(data->model); pixbuf = pidgin_create_prpl_icon(purple_connection_get_account(gc), 0.5); /* +1 is for the automagically created Status column. */ - col_num = purple_notify_searchresults_get_columns_count(results) + 1; + col_num = g_list_length(results->columns) + 1; - for (i = 0; i < purple_notify_searchresults_get_rows_count(results); i++) { - GList *row = purple_notify_searchresults_row_get(results, i); + for (row = results->rows; row != NULL; row = row->next) { gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, 0, pixbuf, -1); - for (j = 1; j < col_num; j++) { + n = 1; + for (column = row->data; column != NULL; column = column->next) { GValue v; - char *data = g_list_nth_data(row, j - 1); v.g_type = 0; g_value_init(&v, G_TYPE_STRING); - g_value_set_string(&v, data); - gtk_list_store_set_value(model, &iter, j, &v); + g_value_set_string(&v, column->data); + gtk_list_store_set_value(model, &iter, n, &v); + n++; } } @@ -704,6 +704,7 @@ GtkListStore *model; GtkCellRenderer *renderer; guint col_num; + GList *column; guint i; GtkWidget *vbox; @@ -751,7 +752,7 @@ g_free(label_text); /* +1 is for the automagically created Status column. */ - col_num = purple_notify_searchresults_get_columns_count(results) + 1; + col_num = g_list_length(results->columns) + 1; /* Setup the list model */ col_types = g_new0(GType, col_num); @@ -786,12 +787,13 @@ gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), -1, "", renderer, "pixbuf", 0, NULL); - for (i = 1; i < col_num; i++) { + i = 1; + for (column = results->columns; column != NULL; column = column->next) { renderer = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), -1, - purple_notify_searchresults_column_get_title(results, i-1), - renderer, "text", i, NULL); + column->data, renderer, "text", i, NULL); + i++; } for (i = 0; i < g_list_length(results->buttons); i++) {