[balsa] Revert two commits



commit fecf491214b1f984b6eb9a59f9421c92a0b9f8db
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Feb 6 12:56:11 2019 -0500

    Revert two commits
    
    Revert fe3cc14be70b029c3f9ba2cc3d6e7c20a2422193 and
    0927a4503bf66f3f09964ad08b58ad6bd0e2a238; that approach to remembering
    the positions of open mailboxes did not work.

 ChangeLog          | 19 -------------------
 libbalsa/mailbox.c | 32 ++------------------------------
 libbalsa/mailbox.h |  3 ---
 src/balsa-app.c    | 10 +++-------
 src/main-window.c  | 45 +++++++++++----------------------------------
 src/save-restore.c | 41 +++--------------------------------------
 src/save-restore.h |  1 -
 7 files changed, 19 insertions(+), 132 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2e545ec65..6e8e525cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,22 +1,3 @@
-2019-02-05  Peter Bloomfield  <pbloomfield bellsouth net>
-
-       Remember and restore the order of open mailboxes between
-       sessions.
-
-       * libbalsa/mailbox.c (libbalsa_mailbox_set_open): set the
-       position to the unset value, -1, when a mailbox is closed;
-       (libbalsa_mailbox_set_position): new method;
-       (libbalsa_mailbox_get_position): ditto;
-       * libbalsa/mailbox.h: new methods.
-       * src/balsa-app.c (append_url_if_open): use the saved position
-       of a mailbox when added it to the window;
-       * src/main-window.c (balsa_window_new),
-       (bw_real_open_mbnode_idle_cb), (bw_notebook_page_notify_cb):
-       * src/save-restore.c (config_load_mailbox_view),
-       (config_save_mailbox_view), (config_mailbox_was_exposed),
-       (config_mailbox_get_int_property), (config_mailbox_get_position):
-       save and restore it.
-
 2019-02-04  Peter Bloomfield  <pbloomfield bellsouth net>
 
        * meson_options.txt: make 'autocrypt' a boolean option, default
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 1a48c8060..564347a46 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -2316,8 +2316,7 @@ static LibBalsaMailboxView libbalsa_mailbox_view_default = {
 #endif
     -1,                         /* total messages      */
     -1,                         /* unread messages     */
-    0,                          /* mod time             */
-    -1                          /* position             */
+    0                           /* mod time             */
 };
 
 LibBalsaMailboxView *
@@ -2478,11 +2477,8 @@ libbalsa_mailbox_set_open(LibBalsaMailbox * mailbox, gboolean open)
 
     if (view->open != open) {
        view->open = open ? 1 : 0;
-       if (mailbox != NULL) {
-           if (!open)
-                view->position = -1;
+       if (mailbox)
            view->in_sync = 0;
-        }
     }
 }
 
@@ -2565,23 +2561,6 @@ libbalsa_mailbox_set_mtime(LibBalsaMailbox * mailbox, time_t mtime)
     }
 }
 
-void
-libbalsa_mailbox_set_position(LibBalsaMailbox * mailbox, gint position)
-{
-    LibBalsaMailboxView *view;
-
-    /* Changing the default is not allowed. */
-    g_return_if_fail(mailbox != NULL);
-
-    view = lbm_get_view(mailbox);
-    view->used = 1;
-
-    if (view->position != position) {
-       view->position = position;
-        view->in_sync = 0;
-    }
-}
-
 /* End of set methods. */
 
 /* Get methods; NULL mailbox is valid, and returns the default value. */
@@ -2696,13 +2675,6 @@ libbalsa_mailbox_get_mtime(LibBalsaMailbox * mailbox)
        mailbox->view->mtime : libbalsa_mailbox_view_default.mtime;
 }
 
-gint
-libbalsa_mailbox_get_position(LibBalsaMailbox * mailbox)
-{
-    return (mailbox && mailbox->view) ?
-       mailbox->view->position : libbalsa_mailbox_view_default.position;
-}
-
 /* End of get methods. */
 
 /* =================================================================== *
diff --git a/libbalsa/mailbox.h b/libbalsa/mailbox.h
index 5dfd23d7a..890812b58 100644
--- a/libbalsa/mailbox.h
+++ b/libbalsa/mailbox.h
@@ -184,7 +184,6 @@ struct _LibBalsaMailboxView {
     int unread;
     int total;
     time_t mtime;       /* Mailbox mtime when counts were cached. */
-    gint position;      /* Position in the notebook */
 };
 
 struct _LibBalsaMailbox {
@@ -557,7 +556,6 @@ gboolean libbalsa_mailbox_set_crypto_mode(LibBalsaMailbox * mailbox,
 void libbalsa_mailbox_set_unread(LibBalsaMailbox * mailbox, gint unread);
 void libbalsa_mailbox_set_total (LibBalsaMailbox * mailbox, gint total);
 void libbalsa_mailbox_set_mtime (LibBalsaMailbox * mailbox, time_t mtime);
-void libbalsa_mailbox_set_position(LibBalsaMailbox * mailbox, gint position);
 
 const gchar *libbalsa_mailbox_get_identity_name(LibBalsaMailbox * mailbox);
 LibBalsaMailboxThreadingType
@@ -579,7 +577,6 @@ LibBalsaChkCryptoMode libbalsa_mailbox_get_crypto_mode(LibBalsaMailbox * mailbox
 gint libbalsa_mailbox_get_unread(LibBalsaMailbox * mailbox);
 gint libbalsa_mailbox_get_total (LibBalsaMailbox * mailbox);
 time_t libbalsa_mailbox_get_mtime(LibBalsaMailbox * mailbox);
-gint libbalsa_mailbox_get_position(LibBalsaMailbox * mailbox);
 
 /** force update of given msgno */
 void libbalsa_mailbox_msgno_changed(LibBalsaMailbox  *mailbox, guint seqno);
diff --git a/src/balsa-app.c b/src/balsa-app.c
index efcefc6af..583e6093f 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -489,14 +489,10 @@ append_url_if_open(const gchar * group, const gchar * encoded_url,
 
     url = libbalsa_urldecode(encoded_url);
 
-    if (config_mailbox_was_open(url)) {
-        gint position;
-
-        position = config_mailbox_get_position(url);
-        g_ptr_array_insert(array, position, url);
-    } else {
+    if (config_mailbox_was_open(url))
+        g_ptr_array_add(array, url);
+    else
         g_free(url);
-    }
 
     return FALSE;
 }
diff --git a/src/main-window.c b/src/main-window.c
index 98d14bda9..47a34f68e 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -171,9 +171,6 @@ static gboolean bw_notebook_drag_motion_cb(GtkWidget* widget,
                                            GdkDragContext* context,
                                            gint x, gint y, guint time,
                                            gpointer user_data);
-static void bw_notebook_page_notify_cb(GtkWidget  *child,
-                                       GParamSpec *child_property,
-                                       gpointer    user_data);
 
 
 static GtkWidget *bw_notebook_label_new (BalsaMailboxNode* mbnode);
@@ -2138,7 +2135,6 @@ balsa_window_new(GtkApplication *application)
 #endif
     GtkAdjustment *hadj, *vadj;
     GAction *action;
-    GtkWidget *notebook;
 
     /* Call to register custom balsa pixmaps with GNOME_STOCK_PIXMAPS
      * - allows for grey out */
@@ -2190,24 +2186,23 @@ balsa_window_new(GtkApplication *application)
 
     geometry_manager_attach(GTK_WINDOW(window), "MainWindow");
 
-    window->notebook = notebook = gtk_notebook_new();
-    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook),
+    window->notebook = gtk_notebook_new();
+    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(window->notebook),
                                balsa_app.show_notebook_tabs);
-    gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
-    gtk_notebook_set_scrollable(GTK_NOTEBOOK (notebook), TRUE);
-    g_signal_connect(notebook, "switch_page",
+    gtk_notebook_set_show_border (GTK_NOTEBOOK(window->notebook), FALSE);
+    gtk_notebook_set_scrollable (GTK_NOTEBOOK (window->notebook), TRUE);
+    g_signal_connect(G_OBJECT(window->notebook), "switch_page",
                      G_CALLBACK(bw_notebook_switch_page_cb), window);
-    gtk_drag_dest_set(notebook, GTK_DEST_DEFAULT_ALL,
+    gtk_drag_dest_set (GTK_WIDGET (window->notebook), GTK_DEST_DEFAULT_ALL,
                        notebook_drop_types, NUM_DROP_TYPES,
                        GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE);
-    g_signal_connect(notebook, "drag-data-received",
+    g_signal_connect(G_OBJECT (window->notebook), "drag-data-received",
                      G_CALLBACK (bw_notebook_drag_received_cb), NULL);
-    g_signal_connect(notebook, "drag-motion",
+    g_signal_connect(G_OBJECT (window->notebook), "drag-motion",
                      G_CALLBACK (bw_notebook_drag_motion_cb), NULL);
-
-    balsa_app.notebook = notebook;
-    g_object_add_weak_pointer(G_OBJECT(notebook),
-                             (gpointer *) &balsa_app.notebook);
+    balsa_app.notebook = window->notebook;
+    g_object_add_weak_pointer(G_OBJECT(window->notebook),
+                             (gpointer) &balsa_app.notebook);
 
     window->preview = balsa_message_new();
     gtk_widget_hide(window->preview);
@@ -2825,8 +2820,6 @@ bw_real_open_mbnode_idle_cb(BalsaWindowRealOpenMbnodeInfo * info)
                                    GTK_POLICY_AUTOMATIC);
     gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(index));
     gtk_widget_show(scroll);
-    g_signal_connect(scroll, "child-notify::position",
-                     G_CALLBACK(bw_notebook_page_notify_cb), window->notebook);
     page_num = gtk_notebook_append_page(GTK_NOTEBOOK(window->notebook),
                                         scroll, label);
     gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(window->notebook),
@@ -4356,22 +4349,6 @@ static gboolean bw_notebook_drag_motion_cb(GtkWidget * widget,
     return FALSE;
 }
 
-static void
-bw_notebook_page_notify_cb(GtkWidget  *child,
-                           GParamSpec *child_property,
-                           gpointer    user_data)
-{
-    GtkNotebook *notebook = user_data;
-    BalsaIndex *bindex;
-    LibBalsaMailbox *mailbox;
-    gint page_num;
-
-    page_num = gtk_notebook_page_num(notebook, child);
-    bindex = BALSA_INDEX(gtk_bin_get_child(GTK_BIN(child)));
-    mailbox = bindex->mailbox_node->mailbox;
-    libbalsa_mailbox_set_position(mailbox, page_num);
-}
-
 /* bw_progress_timeout
  *
  * This function is called at a preset interval to cause the progress
diff --git a/src/save-restore.c b/src/save-restore.c
index 75fc19ac7..23313fb9c 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -1783,9 +1783,6 @@ config_load_mailbox_view(const gchar * url)
     if (libbalsa_conf_has_key("Open"))
         view->open = libbalsa_conf_get_bool("Open");
 
-    if (libbalsa_conf_has_key("Position"))
-        view->position = libbalsa_conf_get_int("Position");
-
 #ifdef HAVE_GPGME
     if (libbalsa_conf_has_key("CryptoMode"))
         view->gpg_chk_mode = libbalsa_conf_get_int("CryptoMode");
@@ -1839,12 +1836,9 @@ config_save_mailbox_view(const gchar * url, LibBalsaMailboxView * view)
        libbalsa_conf_set_int("Subscribe",   view->subscribe);
     if (view->exposed        != libbalsa_mailbox_get_exposed(NULL))
        libbalsa_conf_set_bool("Exposed",    view->exposed);
-    if (balsa_app.remember_open_mboxes) {
-        if (view->open       != libbalsa_mailbox_get_open(NULL))
-            libbalsa_conf_set_bool("Open",   view->open);
-        if (view->position   != libbalsa_mailbox_get_position(NULL))
-            libbalsa_conf_set_int("Position", view->position);
-    }
+    if (balsa_app.remember_open_mboxes &&
+        view->open           != libbalsa_mailbox_get_open(NULL))
+       libbalsa_conf_set_bool("Open",       view->open);
 #ifdef HAVE_GPGME
     if (view->gpg_chk_mode   != libbalsa_mailbox_get_crypto_mode(NULL))
        libbalsa_conf_set_int("CryptoMode",  view->gpg_chk_mode);
@@ -2117,32 +2111,3 @@ config_mailbox_was_exposed(const gchar * url)
 {
     return config_mailbox_had_property(url, "Exposed");
 }
-
-static gint
-config_mailbox_get_int_property(const gchar * url, const gchar * key)
-{
-    gchar *prefix;
-    gint retval = -1;
-
-    prefix = view_by_url_prefix(url);
-    if (!libbalsa_conf_has_group(prefix)) {
-        g_free(prefix);
-        return retval;
-    }
-
-    libbalsa_conf_push_group(prefix);
-
-    if (libbalsa_conf_has_key(key))
-        retval = libbalsa_conf_get_int(key);
-
-    libbalsa_conf_pop_group();
-    g_free(prefix);
-
-    return retval;
-}
-
-gint
-config_mailbox_get_position(const gchar * url)
-{
-    return config_mailbox_get_int_property(url, "Position");
-}
diff --git a/src/save-restore.h b/src/save-restore.h
index f6bb24587..adc2c9222 100644
--- a/src/save-restore.h
+++ b/src/save-restore.h
@@ -65,7 +65,6 @@ void config_save_mailbox_view(const gchar * url, LibBalsaMailboxView * view);
 
 gboolean config_mailbox_was_open(const gchar * url);
 gboolean config_mailbox_was_exposed(const gchar * url);
-gint config_mailbox_get_position(const gchar * url);
 
 void config_filters_save(void);
 void config_mailbox_filters_save(LibBalsaMailbox * mbox);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]