# HG changeset patch
# Node ID 4323a690ec7c
# Parent  e8a4f48d595f
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -79,8 +79,6 @@
 
 } PidginRequestData;
 
-static GHashTable *datasheet_stock = NULL;
-
 static void
 pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account)
 {
@@ -1409,359 +1407,6 @@
 	return sw;
 }
 
-static GdkPixbuf*
-_pidgin_datasheet_stock_icon_get(const gchar *stock_name)
-{
-	GdkPixbuf *image = NULL;
-
-	if (stock_name == NULL)
-		return NULL;
-
-	/* core is quitting */
-	if (datasheet_stock == NULL)
-		return NULL;
-
-	if (g_hash_table_lookup_extended(datasheet_stock, stock_name,
-		NULL, (gpointer*)&image))
-	{
-		return image;
-	}
-
-	purple_debug_error("gtkrequest", "Unknown icon: %s", stock_name);
-
-	return NULL;
-}
-
-static PurpleRequestDatasheetRecord*
-datasheet_get_selected_row(GtkWidget *sheet_widget)
-{
-	PurpleRequestDatasheet *sheet;
-	GtkTreeView *view;
-	GtkTreeSelection *selection;
-	GtkTreeModel *model;
-	GtkTreeIter iter;
-	GList *sel_list;
-	gpointer key;
-
-	g_return_val_if_fail(sheet_widget != NULL, NULL);
-
-	view = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(sheet_widget), "view"));
-	sheet = g_object_get_data(G_OBJECT(sheet_widget), "sheet");
-
-	g_return_val_if_fail(view != NULL, NULL);
-	g_return_val_if_fail(sheet != NULL, NULL);
-
-	selection = gtk_tree_view_get_selection(view);
-	if (gtk_tree_selection_count_selected_rows(selection) != 1)
-		return NULL;
-
-	sel_list = gtk_tree_selection_get_selected_rows(selection, &model);
-	gtk_tree_model_get_iter(model, &iter, sel_list->data);
-	g_list_free_full(sel_list, (GDestroyNotify)gtk_tree_path_free);
-
-	gtk_tree_model_get(model, &iter, 0, &key, -1);
-
-	return purple_request_datasheet_record_find(sheet, key);
-}
-
-#if 0
-static void
-datasheet_button_check_sens(GtkWidget *button, gpointer _sheet_widget)
-{
-	PurpleRequestDatasheetAction *act;
-	GtkWidget *sheet_widget = GTK_WIDGET(_sheet_widget);
-
-	g_return_if_fail(sheet_widget != NULL);
-
-	act = g_object_get_data(G_OBJECT(button), "action");
-
-	g_return_if_fail(act != NULL);
-
-	gtk_widget_set_sensitive(button,
-		purple_request_datasheet_action_is_sensitive(act,
-			datasheet_get_selected_row(sheet_widget)));
-}
-#endif
-
-static void
-datasheet_selection_changed(G_GNUC_UNUSED GtkWidget *sheet_widget)
-{
-#if 0
-	gpointer buttons_box;
-
-	g_return_if_fail(sheet_widget != NULL);
-
-	buttons_box = g_object_get_data(G_OBJECT(sheet_widget), "buttons");
-	gtk_container_foreach(GTK_CONTAINER(buttons_box),
-		datasheet_button_check_sens, sheet_widget);
-#endif
-}
-
-static void
-datasheet_update_rec(PurpleRequestDatasheetRecord *rec, GtkListStore *model,
-	GtkTreeIter *iter)
-{
-	guint i, col_count;
-	PurpleRequestDatasheet *sheet;
-
-	g_return_if_fail(rec != NULL);
-	g_return_if_fail(model != NULL);
-	g_return_if_fail(iter != NULL);
-
-	sheet = purple_request_datasheet_record_get_datasheet(rec);
-
-	g_return_if_fail(sheet != NULL);
-
-	col_count = purple_request_datasheet_get_column_count(sheet);
-
-	for (i = 0; i < col_count; i++) {
-		PurpleRequestDatasheetColumnType type;
-
-		type = purple_request_datasheet_get_column_type(
-			sheet, i);
-		if (type == PURPLE_REQUEST_DATASHEET_COLUMN_STRING) {
-			GValue val;
-
-			val.g_type = 0;
-			g_value_init(&val, G_TYPE_STRING);
-			g_value_set_string(&val,
-				purple_request_datasheet_record_get_string_data(
-					rec, i));
-			gtk_list_store_set_value(model, iter,
-				i + 1, &val);
-		} else if (type ==
-			PURPLE_REQUEST_DATASHEET_COLUMN_IMAGE)
-		{
-			GdkPixbuf *pixbuf;
-
-			pixbuf = _pidgin_datasheet_stock_icon_get(
-				purple_request_datasheet_record_get_image_data(
-					rec, i));
-			gtk_list_store_set(model, iter, i + 1,
-				pixbuf, -1);
-		} else
-			g_warn_if_reached();
-	}
-}
-
-static void
-datasheet_fill(PurpleRequestDatasheet *sheet, GtkListStore *model)
-{
-	const GList *it;
-
-	gtk_list_store_clear(model);
-
-	it = purple_request_datasheet_get_records(sheet);
-	for (; it != NULL; it = g_list_next(it)) {
-		PurpleRequestDatasheetRecord *rec = it->data;
-		GtkTreeIter iter;
-
-		gtk_list_store_append(model, &iter);
-		gtk_list_store_set(model, &iter, 0,
-			purple_request_datasheet_record_get_key(rec), -1);
-
-		datasheet_update_rec(rec, model, &iter);
-	}
-
-	datasheet_selection_changed(GTK_WIDGET(g_object_get_data(
-		G_OBJECT(model), "sheet-widget")));
-}
-
-static void
-datasheet_update(PurpleRequestDatasheet *sheet, gpointer key,
-	GtkListStore *model)
-{
-	PurpleRequestDatasheetRecord *rec;
-	GtkTreeIter iter;
-	GtkTreeModel *tmodel = GTK_TREE_MODEL(model);
-	gboolean found = FALSE;
-
-	g_return_if_fail(tmodel != NULL);
-
-	if (key == NULL) {
-		datasheet_fill(sheet, model);
-		return;
-	}
-
-	rec = purple_request_datasheet_record_find(sheet, key);
-
-	if (gtk_tree_model_get_iter_first(tmodel, &iter)) {
-		do {
-			gpointer ikey;
-
-			gtk_tree_model_get(tmodel, &iter, 0, &ikey, -1);
-
-			if (key == ikey) {
-				found = TRUE;
-				break;
-			}
-		} while (gtk_tree_model_iter_next(tmodel, &iter));
-	}
-
-	if (rec == NULL && !found)
-		return;
-
-	if (rec == NULL) {
-		gtk_list_store_remove(model, &iter);
-		return;
-	}
-
-	if (!found) {
-		gtk_list_store_append(model, &iter);
-		gtk_list_store_set(model, &iter, 0, key, -1);
-	}
-
-	datasheet_update_rec(rec, model, &iter);
-
-	datasheet_selection_changed(GTK_WIDGET(g_object_get_data(
-		G_OBJECT(model), "sheet-widget")));
-}
-
-
-static void
-datasheet_selection_changed_cb(G_GNUC_UNUSED GtkTreeSelection *sel,
-                               gpointer sheet_widget)
-{
-	datasheet_selection_changed(GTK_WIDGET(sheet_widget));
-}
-
-static void
-datasheet_action_clicked(GtkButton *btn, PurpleRequestDatasheetAction *act)
-{
-	GtkWidget *sheet_widget;
-
-	sheet_widget = g_object_get_data(G_OBJECT(btn), "sheet-widget");
-
-	g_return_if_fail(sheet_widget != NULL);
-
-	purple_request_datasheet_action_call(act, datasheet_get_selected_row(
-		sheet_widget));
-}
-
-static GtkWidget *
-create_datasheet_field(PurpleRequestField *field, GtkSizeGroup *buttons_sg)
-{
-	PurpleRequestFieldDatasheet *dfield = PURPLE_REQUEST_FIELD_DATASHEET(field);
-	PurpleRequestDatasheet *sheet;
-	guint i, col_count;
-	GType *col_types;
-	GtkListStore *model;
-	GtkTreeView *view;
-	GtkTreeSelection *sel;
-	GtkWidget *scrollable;
-	GtkCellRenderer *renderer_image = NULL, *renderer_text = NULL;
-	GtkTreeViewColumn *id_column;
-	GtkWidget *main_box;
-	GtkWidget *buttons_box;
-	const GList *it;
-
-	sheet = purple_request_field_datasheet_get_sheet(dfield);
-	main_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-
-	col_count = purple_request_datasheet_get_column_count(sheet);
-
-	col_types = g_new0(GType, col_count + 1);
-	col_types[0] = G_TYPE_POINTER;
-	for (i = 0; i < col_count; i++) {
-		PurpleRequestDatasheetColumnType type;
-		type = purple_request_datasheet_get_column_type(sheet, i);
-		if (type == PURPLE_REQUEST_DATASHEET_COLUMN_STRING)
-			col_types[i + 1] = G_TYPE_STRING;
-		else if (type == PURPLE_REQUEST_DATASHEET_COLUMN_IMAGE)
-			col_types[i + 1] = GDK_TYPE_PIXBUF;
-		else
-			g_warn_if_reached();
-	}
-	model = gtk_list_store_newv(col_count + 1, col_types);
-	g_free(col_types);
-
-	view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(
-		GTK_TREE_MODEL(model)));
-	g_object_set_data(G_OBJECT(model), "sheet-widget", main_box);
-	g_object_unref(model);
-
-	id_column = gtk_tree_view_column_new();
-	gtk_tree_view_column_set_visible(id_column, FALSE);
-	gtk_tree_view_append_column(view, id_column);
-
-	for (i = 0; i < col_count; i++) {
-		PurpleRequestDatasheetColumnType type;
-		const gchar *title;
-		GtkCellRenderer *renderer = NULL;
-		const gchar *type_str = "";
-
-		type = purple_request_datasheet_get_column_type(sheet, i);
-		title = purple_request_datasheet_get_column_title(sheet, i);
-
-		if (type == PURPLE_REQUEST_DATASHEET_COLUMN_STRING) {
-			type_str = "text";
-			if (!renderer_text)
-				renderer_text = gtk_cell_renderer_text_new();
-			renderer = renderer_text;
-		}
-		else if (type == PURPLE_REQUEST_DATASHEET_COLUMN_IMAGE) {
-			type_str = "pixbuf";
-			if (!renderer_image)
-				renderer_image = gtk_cell_renderer_pixbuf_new();
-			renderer = renderer_image;
-		} else
-			g_warn_if_reached();
-
-		if (title == NULL)
-			title = "";
-		gtk_tree_view_insert_column_with_attributes(
-			view, -1, title, renderer, type_str,
-			i + 1, NULL);
-	}
-
-	gtk_widget_set_size_request(GTK_WIDGET(view), 400, 250);
-
-	scrollable = gtk_scrolled_window_new();
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollable),
-	                               GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-	gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrollable),
-	                              GTK_WIDGET(view));
-	gtk_widget_set_hexpand(scrollable, TRUE);
-	gtk_box_append(GTK_BOX(main_box), scrollable);
-
-	buttons_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
-	gtk_size_group_add_widget(buttons_sg, buttons_box);
-	gtk_box_append(GTK_BOX(main_box), buttons_box);
-
-	it = purple_request_datasheet_get_actions(sheet);
-	for (; it != NULL; it = g_list_next(it)) {
-		PurpleRequestDatasheetAction *act = it->data;
-		GtkButton *btn;
-		const gchar *label;
-
-		label = purple_request_datasheet_action_get_label(act);
-
-		btn = GTK_BUTTON(gtk_button_new_with_label(label ? label : ""));
-
-		g_object_set_data(G_OBJECT(btn), "action", act);
-		g_object_set_data(G_OBJECT(btn), "sheet-widget", main_box);
-		g_signal_connect(G_OBJECT(btn), "clicked",
-			G_CALLBACK(datasheet_action_clicked), act);
-
-		gtk_box_append(GTK_BOX(buttons_box), GTK_WIDGET(btn));
-	}
-
-	g_object_set_data(G_OBJECT(main_box), "view", view);
-	g_object_set_data(G_OBJECT(main_box), "buttons", buttons_box);
-	g_object_set_data(G_OBJECT(main_box), "sheet", sheet);
-
-	datasheet_fill(sheet, model);
-	purple_signal_connect(sheet, "record-changed",
-		pidgin_request_get_handle(),
-		G_CALLBACK(datasheet_update), model);
-
-	sel = gtk_tree_view_get_selection(view);
-	g_signal_connect(G_OBJECT(sel), "changed",
-		G_CALLBACK(datasheet_selection_changed_cb), main_box);
-
-	return main_box;
-}
-
 static void *
 pidgin_request_fields(const char *title, const char *primary,
 	const char *secondary, PurpleRequestPage *page, const char *ok_text,
@@ -1925,8 +1570,6 @@
 			} else if(PURPLE_IS_REQUEST_FIELD_ACCOUNT(field)) {
 				widget = create_account_field(field, &account_hint);
 				was_handled_by_create = TRUE;
-			} else if(PURPLE_IS_REQUEST_FIELD_DATASHEET(field)) {
-				widget = create_datasheet_field(field, datasheet_buttons_sg);
 			} else {
 				g_warning("Unhandled field type: %s",
 				          G_OBJECT_TYPE_NAME(field));
@@ -2280,24 +1923,13 @@
 	return &handle;
 }
 
-static void
-pidgin_request_datasheet_stock_remove(gpointer obj)
-{
-	if (obj == NULL)
-		return;
-	g_object_unref(obj);
-}
-
 void
 pidgin_request_init(void)
 {
-	datasheet_stock = g_hash_table_new_full(g_str_hash, g_str_equal,
-		g_free, pidgin_request_datasheet_stock_remove);
 }
 
 void
 pidgin_request_uninit(void)
 {
 	purple_signals_disconnect_by_handle(pidgin_request_get_handle());
-	g_clear_pointer(&datasheet_stock, g_hash_table_destroy);
 }
