[Frugalware-darcs] fw-control-center: gnetconfig: added support for deleting network profiles.

Priyank priyank at frugalware.org
Sun Jun 10 12:47:14 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=fw-control-center;a=darcs_commitdiff;h=20070610104618-5ce2c-74c52986cf75b97649260493bfd51b86292d5dcb.gz;

[gnetconfig: added support for deleting network profiles.
Priyank <priyank at frugalware.org>**20070610104618] {
hunk ./gnetconfig/src/gnetconfig-interface.c 81
-static void gnetconfig_setup_new_profile (const char *profile);
hunk ./gnetconfig/src/gnetconfig-interface.c 101
+static void cb_gn_delete_profile_clicked (GtkButton *button, gpointer data);
hunk ./gnetconfig/src/gnetconfig-interface.c 245
+	widget = glade_xml_get_widget (xml, "fwn_delete_profile");
+	g_signal_connect (G_OBJECT(widget),
+			"clicked",
+			G_CALLBACK(cb_gn_delete_profile_clicked),
+			NULL);
hunk ./gnetconfig/src/gnetconfig-interface.c 565
+static void
+cb_gn_delete_profile_clicked (GtkButton *button, gpointer data)
+{
+	GtkTreeModel	*model = NULL;
+	GtkTreeIter	iter;
+	gchar		*path = NULL;
+	gchar		*profile = NULL;
+
+	gtk_combo_box_get_active_iter (GTK_COMBO_BOX(gn_profile_combo), &iter);
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX(gn_profile_combo));
+	gtk_tree_model_get (model, &iter, 1, &profile, -1);
+	if (strcmp(profile, fwnet_lastprofile()))
+	{
+		GtkWidget *ask = gtk_message_dialog_new (GTK_WINDOW(gn_main_window),
+							GTK_DIALOG_DESTROY_WITH_PARENT,
+							GTK_MESSAGE_QUESTION,
+							GTK_BUTTONS_YES_NO,
+							"%s",
+							_("Are you sure you want to delete this profile ?"));
+		switch ( gtk_dialog_run(GTK_DIALOG(ask)) )
+		{
+			case GTK_RESPONSE_YES:
+				path = g_strdup_printf ("/etc/sysconfig/network/%s", profile);
+				gint ret = g_remove (path);
+				if (ret == -1)
+					gn_error (_("The was an error deleting the profile."), ERROR_GUI);
+				else
+					gn_message (_("Profile delete successfully"));
+				g_free (path);
+				gnetconfig_populate_profile_list ();
+				break;
+
+			case GTK_RESPONSE_NO:
+			case GTK_RESPONSE_DELETE_EVENT:
+					break;
+		}
+		gtk_widget_destroy (ask);
+	}
+	else
+	{
+		gn_error ("You cannot delete an active network profile.", ERROR_GUI);
+		g_free (profile);
+	}
+
+	return;
+}
+
hunk ./gnetconfig/src/gnetconfig-interface.c 886
-	gtk_combo_box_get_active_iter (gn_profile_combo, &iter);
-	model = gtk_combo_box_get_model (gn_profile_combo);
+	gtk_combo_box_get_active_iter (GTK_COMBO_BOX(gn_profile_combo), &iter);
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX(gn_profile_combo));
hunk ./gnetconfig/src/gnetconfig-interface.c 1200
-	if_name = gtk_label_get_text (GTK_LABEL(data));
+	if_name = (gchar*)gtk_label_get_text (GTK_LABEL(data));
}


More information about the Frugalware-darcs mailing list