[balsa/gtk3] Remember geometry of MRU mailbox tree
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Remember geometry of MRU mailbox tree
- Date: Tue, 27 Mar 2012 22:05:31 +0000 (UTC)
commit 39557f6a4b01c9afeec4ba2d70320214038cc6e7
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Mar 27 17:43:57 2012 -0400
Remember geometry of MRU mailbox tree
* src/balsa-app.h: new members mru_tree_{width,height}
* src/balsa-mblist.c (bmbl_mru_size_allocate_cb): save them when
the dialog's size is changed;
(bmbl_mru_show_tree): use the saved values.
* src/save-restore.c (config_global_load), (config_save): save
and restore them.
ChangeLog | 11 +++++++++++
src/balsa-app.h | 4 ++++
src/balsa-mblist.c | 35 +++++++++++++++++++++++++++--------
src/save-restore.c | 12 ++++++++++++
4 files changed, 54 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9bdd3d7..28d01c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-03-27 Peter Bloomfield
+
+ Remember geometry of MRU mailbox tree
+
+ * src/balsa-app.h: new members mru_tree_{width,height}
+ * src/balsa-mblist.c (bmbl_mru_size_allocate_cb): save them when
+ the dialog's size is changed;
+ (bmbl_mru_show_tree): use the saved values.
+ * src/save-restore.c (config_global_load), (config_save): save
+ and restore them.
+
2012-03-20 Peter Bloomfield
* configure.in: work around "intltool-update -m" bug: it knows
diff --git a/src/balsa-app.h b/src/balsa-app.h
index 1b05715..8a2af60 100644
--- a/src/balsa-app.h
+++ b/src/balsa-app.h
@@ -281,6 +281,10 @@ extern struct BalsaApplication {
gint source_width;
gint source_height;
+ /* MRU mailbox tree */
+ gint mru_tree_width;
+ gint mru_tree_height;
+
/* what to do with message window after moving the message */
MwActionAfterMove mw_action_after_move;
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index b837493..2c13974 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -1825,6 +1825,28 @@ bmbl_mru_activate_cb(GtkWidget * item, gpointer data)
* Callback for the "activate" signal of the last menu item.
* Pops up a GtkDialog with a BalsaMBList.
*/
+
+/*
+ * bmbl_mru_size_allocate_cb:
+ *
+ * Callback for the dialog's "size-allocate" signal.
+ * Remember the width and height.
+ */
+static void
+bmbl_mru_size_allocate_cb(GtkWidget * widget, GdkRectangle * allocation,
+ gpointer user_data)
+{
+ GdkWindow *gdk_window;
+
+ /* Maximizing a GtkDialog may not be possible, but we check anyway. */
+ if ((gdk_window = gtk_widget_get_window(widget))
+ && !(gdk_window_get_state(gdk_window)
+ & GDK_WINDOW_STATE_MAXIMIZED)) {
+ balsa_app.mru_tree_width = allocation->width;
+ balsa_app.mru_tree_height = allocation->height;
+ }
+}
+
static void
bmbl_mru_show_tree(GtkWidget * widget, gpointer data)
{
@@ -1833,7 +1855,6 @@ bmbl_mru_show_tree(GtkWidget * widget, gpointer data)
GtkWidget *scroll;
GtkWidget *mblist;
GtkTreeSelection *selection;
- GtkRequisition req;
mblist = balsa_mblist_new();
g_signal_connect(mblist, "row-activated",
@@ -1864,13 +1885,11 @@ bmbl_mru_show_tree(GtkWidget * widget, gpointer data)
(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
scroll, TRUE, TRUE, 0);
- /* Force the mailbox list to be a reasonable size. */
- gtk_widget_get_preferred_size(mblist, NULL, &req);
- /* FIXME: Magic numbers to avoid showing scrollbars;
- * probably theme-dependent: */
- req.width = MIN(req.width + 25, balsa_app.mblist_width);
- req.height = MIN(req.height + 50, balsa_app.mw_height);
- gtk_window_set_default_size(GTK_WINDOW(dialog), req.width, req.height);
+ g_signal_connect(dialog, "size-allocate",
+ G_CALLBACK(bmbl_mru_size_allocate_cb), NULL);
+ gtk_window_set_default_size(GTK_WINDOW(dialog),
+ balsa_app.mru_tree_width,
+ balsa_app.mru_tree_height);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
diff --git a/src/save-restore.c b/src/save-restore.c
index d72cbe2..96bfd4a 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -849,6 +849,12 @@ config_global_load(void)
balsa_app.source_height = libbalsa_conf_get_int("Height=400");
libbalsa_conf_pop_group();
+ /* MRU mailbox tree ... */
+ libbalsa_conf_push_group("MruTree");
+ balsa_app.mru_tree_width = libbalsa_conf_get_int("Width=150");
+ balsa_app.mru_tree_height = libbalsa_conf_get_int("Height=300");
+ libbalsa_conf_pop_group();
+
/* Printing options ... */
libbalsa_conf_push_group("Printing");
@@ -1338,6 +1344,12 @@ config_save(void)
libbalsa_conf_set_int("Height", balsa_app.source_height);
libbalsa_conf_pop_group();
+ /* MRU mailbox tree ... */
+ libbalsa_conf_push_group("MruTree");
+ libbalsa_conf_set_int("Width", balsa_app.mru_tree_width);
+ libbalsa_conf_set_int("Height", balsa_app.mru_tree_height);
+ libbalsa_conf_pop_group();
+
/* Printing options ... */
libbalsa_conf_push_group("Printing");
save_gtk_page_setup(balsa_app.page_setup);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]