]> git.itanic.dy.fi Git - maemo-mapper/commitdiff
Fixed duplicate-repository bug in the "Manage Repositories" dialog box.
authorgnuite <gnuite@gmail.com>
Sat, 9 Jun 2007 15:48:34 +0000 (15:48 +0000)
committergnuite <gnuite@gmail.com>
Sat, 9 Jun 2007 15:48:34 +0000 (15:48 +0000)
git-svn-id: svn+ssh://garage/var/lib/gforge/svnroot/maemo-mapper/trunk@104 6c538b50-5814-0410-93ad-8bdf4c0149d1

src/maemo-mapper.c

index 1c6d634c598936dd82cb8d619126bb1f356a43f3..bde37fc6e8a381bb4974028ff899ddab92da2585 100644 (file)
@@ -11068,12 +11068,21 @@ repoman_dialog_rename(GtkWidget *widget, RepoManInfo *rmi)
     return TRUE;
 }
 
+static void
+repoman_delete(RepoManInfo *rmi, gint index)
+{
+    gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), index);
+    gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), index);
+    rmi->repo_edits = g_list_remove_link(
+            rmi->repo_edits,
+            g_list_nth(rmi->repo_edits, index));
+}
+
 static gboolean
 repoman_dialog_delete(GtkWidget *widget, RepoManInfo *rmi)
 {
     gchar buffer[100];
     GtkWidget *confirm;
-    gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     if(gtk_tree_model_iter_n_children(GTK_TREE_MODEL(
@@ -11090,22 +11099,19 @@ repoman_dialog_delete(GtkWidget *widget, RepoManInfo *rmi)
     snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
             _("Confirm delete of repository"),
             gtk_combo_box_get_active_text(GTK_COMBO_BOX(rmi->cmb_repos)));
-    confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
+
+    confirm = hildon_note_new_confirmation(GTK_WINDOW(rmi->dialog),buffer);
 
     if(GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm)))
     {
-        gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), active);
-        gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), active);
-        rmi->repo_edits = g_list_remove_link(
-                rmi->repo_edits,
-                g_list_nth(rmi->repo_edits, active));
+        gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
+        repoman_delete(rmi, active);
         gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos),
                 MAX(0, active - 1));
     }
 
     gtk_widget_destroy(confirm);
 
-    vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
     return TRUE;
 }
 
@@ -11126,6 +11132,10 @@ repoman_dialog_add_repo(RepoManInfo *rmi, gchar *name)
             vbox = gtk_vbox_new(FALSE, 4),
             gtk_label_new(name));
 
+    /* Prevent destruction of notebook page, because the destruction causes
+     * a seg fault (!?!?) */
+    gtk_object_ref(GTK_OBJECT(vbox));
+
     gtk_box_pack_start(GTK_BOX(vbox),
             table = gtk_table_new(2, 2, FALSE),
             FALSE, FALSE, 0);
@@ -11292,20 +11302,14 @@ repoman_reset(GtkWidget *widget, RepoManInfo *rmi)
     GtkWidget *confirm;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
-    confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
+    confirm = hildon_note_new_confirmation(GTK_WINDOW(rmi->dialog),
             _("Replace all repositories with the default repository?"));
 
     if(GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm)))
     {
         /* First, delete all existing repositories. */
         while(rmi->repo_edits)
-        {
-            gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), 0);
-            gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), 0);
-            rmi->repo_edits = g_list_remove_link(
-                    rmi->repo_edits,
-                    g_list_first(rmi->repo_edits));
-        }
+            repoman_delete(rmi, 0);
 
         /* Now, add the default repository. */
         repoman_dialog_add_repo(rmi, REPO_DEFAULT_NAME);
@@ -11572,6 +11576,10 @@ repoman_dialog()
 
     gtk_widget_hide(dialog);
 
+    /* Clear out the notebook entries. */
+    while(rmi.repo_edits)
+        repoman_delete(&rmi, 0);
+
     map_set_zoom(_zoom); /* make sure we're at an appropriate zoom level. */
 
     vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);