[Frugalware-darcs] gfpm: implemented use of GFPM_PACKAGE_LIST to store a list of packages to be installed or removed.

Priyank priyank at frugalware.org
Sun Jul 1 18:05:02 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=gfpm;a=darcs_commitdiff;h=20070701160307-5ce2c-0643d26acd63cc0068b50c86fdd7cb2bb044c026.gz;

[implemented use of GFPM_PACKAGE_LIST to store a list of packages to be installed or removed.
Priyank <priyank at frugalware.org>**20070701160307] {
hunk ./src/Makefile.am 10
+			gfpm-packagelist.c		\
hunk ./src/gfpm-interface.c 35
+#include "gfpm-packagelist.h"
hunk ./src/gfpm-interface.c 57
+static void cb_gfpm_pkg_selection_toggled (GtkCellRendererToggle *toggle, gchar *path_str, gpointer data);
hunk ./src/gfpm-interface.c 104
-	//g_signal_connect (renderer, "toggled", G_CALLBACK(cb_pkg_selection_toggled), store);
+	g_signal_connect (renderer, "toggled", G_CALLBACK(cb_gfpm_pkg_selection_toggled), store);
hunk ./src/gfpm-interface.c 710
+	return;
+}
+
+static void
+cb_gfpm_pkg_selection_toggled (GtkCellRendererToggle *toggle, gchar *path_str, gpointer data)
+{
+	GtkTreeModel	*model;
+	GtkTreeIter		iter;
+	GtkTreePath		*path;
+	gchar			*pkgname = NULL;
+	gchar			*pkg = NULL;
+	gboolean		check;
+	gboolean		inst;
+	PM_PKG			*pm_pkg = NULL;
+
+	model = (GtkTreeModel *)data;
+	path = gtk_tree_path_new_from_string (path_str);
+	gtk_tree_model_get_iter (model, &iter, path);
+	gtk_tree_model_get (model, &iter, 0, &check, 2, &pkgname, -1);
+
+	/* check if the package is installed or not */
+	pm_pkg = pacman_db_readpkg (local_db, pkgname);
+	if (pm_pkg == NULL)
+		inst = FALSE;
+	else
+		inst = TRUE;
+
+	/* manually toggle the toggle button */
+	check ^= 1;
+	gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, check, -1);
+
+	pkg = g_strdup (pkgname);
+	if (check == TRUE)
+	{
+		if (inst == FALSE)
+			gfpm_package_list_add (GFPM_INSTALL_LIST, pkg);
+		else
+			gfpm_package_list_del (GFPM_INSTALL_LIST, pkg);
+
+		gfpm_package_list_del (GFPM_REMOVE_LIST, pkg);
+	}
+	else
+	{
+		if (inst == TRUE)
+		{
+			gfpm_package_list_add (GFPM_REMOVE_LIST, pkg);
+			g_print ("adding to remove list\n");
+		}
+		else
+			gfpm_package_list_del (GFPM_REMOVE_LIST, pkg);
+
+		gfpm_package_list_del (GFPM_INSTALL_LIST, pkg);
+	}
+
+	/* remove the following snippet after testing */
+	g_print ("Contents of INSTALL LIST\n");
+	gfpm_package_list_print (GFPM_INSTALL_LIST);
+
+	g_print ("Contents of REMOVE LIST\n");
+	gfpm_package_list_print (GFPM_REMOVE_LIST);
+
+	g_free (pkg);
+	gtk_tree_path_free (path);
+
}


More information about the Frugalware-darcs mailing list