aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-08-27 06:51:47 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-08-28 05:35:21 +0800
commite1efca844727d9dc06b9d721be8434c1ffaf3fa7 (patch)
treef6c19d8f12a420112e6bd6b0e7f9b8b4ace3dd11
parent029b6cde2c9eb3854e72ccfa7dd590c5b5741098 (diff)
downloadgsoc2013-evolution-e1efca844727d9dc06b9d721be8434c1ffaf3fa7.tar
gsoc2013-evolution-e1efca844727d9dc06b9d721be8434c1ffaf3fa7.tar.gz
gsoc2013-evolution-e1efca844727d9dc06b9d721be8434c1ffaf3fa7.tar.bz2
gsoc2013-evolution-e1efca844727d9dc06b9d721be8434c1ffaf3fa7.tar.lz
gsoc2013-evolution-e1efca844727d9dc06b9d721be8434c1ffaf3fa7.tar.xz
gsoc2013-evolution-e1efca844727d9dc06b9d721be8434c1ffaf3fa7.tar.zst
gsoc2013-evolution-e1efca844727d9dc06b9d721be8434c1ffaf3fa7.zip
Fix preview pane size persistance.
The new packing style broke preview pane size restoration at startup. The fix is to store the size of the bottom GtkPaned child instead of the top child. Unfortunately GtkPaned does not make this easy. Will have to repeat this procedure for the other preview panes.
-rw-r--r--modules/mail/e-mail-shell-content.c144
-rw-r--r--modules/mail/e-mail-shell-content.h5
2 files changed, 127 insertions, 22 deletions
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index 436eaa4dfe..faa74473ac 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -72,6 +72,7 @@ struct _EMailShellContentPrivate {
enum {
PROP_0,
+ PROP_PREVIEW_SIZE,
PROP_PREVIEW_VISIBLE,
PROP_SHOW_DELETED,
PROP_VERTICAL_VIEW
@@ -81,6 +82,12 @@ static gpointer parent_class;
static GType mail_shell_content_type;
static void
+mail_shell_content_notify_preview_size (EMailShellContent *mail_shell_content)
+{
+ g_object_notify (G_OBJECT (mail_shell_content), "preview-size");
+}
+
+static void
mail_shell_content_etree_unfreeze (MessageList *message_list,
GdkEvent *event)
{
@@ -316,6 +323,12 @@ mail_shell_content_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_PREVIEW_SIZE:
+ e_mail_shell_content_set_preview_size (
+ E_MAIL_SHELL_CONTENT (object),
+ g_value_get_int (value));
+ return;
+
case PROP_PREVIEW_VISIBLE:
e_mail_shell_content_set_preview_visible (
E_MAIL_SHELL_CONTENT (object),
@@ -345,6 +358,13 @@ mail_shell_content_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_PREVIEW_SIZE:
+ g_value_set_int (
+ value,
+ e_mail_shell_content_get_preview_size (
+ E_MAIL_SHELL_CONTENT (object)));
+ return;
+
case PROP_PREVIEW_VISIBLE:
g_value_set_boolean (
value,
@@ -445,6 +465,11 @@ mail_shell_content_constructed (GObject *object)
priv->paned = g_object_ref (widget);
gtk_widget_show (widget);
+ g_signal_connect_swapped (
+ widget, "notify::position",
+ G_CALLBACK (mail_shell_content_notify_preview_size),
+ shell_content);
+
container = widget;
widget = message_list_new (shell_backend);
@@ -487,10 +512,6 @@ mail_shell_content_constructed (GObject *object)
bridge = gconf_bridge_get ();
- object = G_OBJECT (priv->paned);
- key = "/apps/evolution/mail/display/paned_size";
- gconf_bridge_bind_property_delayed (bridge, key, object, "position");
-
object = G_OBJECT (shell_content);
key = "/apps/evolution/mail/display/show_deleted";
gconf_bridge_bind_property (bridge, key, object, "show-deleted");
@@ -506,6 +527,33 @@ mail_shell_content_constructed (GObject *object)
shell_content);
}
+static void
+mail_shell_content_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ EMailShellContentPrivate *priv;
+ GConfBridge *bridge;
+ const gchar *key;
+
+ priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (widget);
+
+ /* Chain up to parent's size_allocate() method. */
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+
+ if (priv->paned_binding_id > 0)
+ return;
+
+ bridge = gconf_bridge_get ();
+
+ if (priv->vertical_view)
+ key = "/apps/evolution/mail/display/hpaned_size";
+ else
+ key = "/apps/evolution/mail/display/paned_size";
+
+ priv->paned_binding_id = gconf_bridge_bind_property_delayed (
+ bridge, key, G_OBJECT (widget), "preview-size");
+}
+
static guint32
mail_shell_content_check_state (EShellContent *shell_content)
{
@@ -642,6 +690,7 @@ static void
mail_shell_content_class_init (EMailShellContentClass *class)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
EShellContentClass *shell_content_class;
parent_class = g_type_class_peek_parent (class);
@@ -653,12 +702,27 @@ mail_shell_content_class_init (EMailShellContentClass *class)
object_class->dispose = mail_shell_content_dispose;
object_class->constructed = mail_shell_content_constructed;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->size_allocate = mail_shell_content_size_allocate;
+
shell_content_class = E_SHELL_CONTENT_CLASS (class);
shell_content_class->new_search_context = em_search_context_new;
shell_content_class->check_state = mail_shell_content_check_state;
g_object_class_install_property (
object_class,
+ PROP_PREVIEW_SIZE,
+ g_param_spec_int (
+ "preview-size",
+ _("Preview Size"),
+ _("Size of the preview pane in pixels"),
+ G_MININT,
+ G_MAXINT,
+ 100,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
PROP_PREVIEW_VISIBLE,
g_param_spec_boolean (
"preview-visible",
@@ -759,6 +823,53 @@ e_mail_shell_content_new (EShellView *shell_view)
"shell-view", shell_view, NULL);
}
+gint
+e_mail_shell_content_get_preview_size (EMailShellContent *mail_shell_content)
+{
+ GtkOrientable *orientable;
+ GtkOrientation orientation;
+ gint allocation;
+ gint position;
+
+ g_return_val_if_fail (
+ E_IS_MAIL_SHELL_CONTENT (mail_shell_content), 0);
+
+ orientable = GTK_ORIENTABLE (mail_shell_content->priv->paned);
+ orientation = gtk_orientable_get_orientation (orientable);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ allocation = GTK_WIDGET (orientable)->allocation.width;
+ else
+ allocation = GTK_WIDGET (orientable)->allocation.height;
+
+ position = gtk_paned_get_position (GTK_PANED (orientable));
+
+ return MAX (0, allocation - position);
+}
+
+void
+e_mail_shell_content_set_preview_size (EMailShellContent *mail_shell_content,
+ gint preview_size)
+{
+ GtkOrientable *orientable;
+ GtkOrientation orientation;
+ gint allocation;
+ gint position;
+
+ g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content));
+
+ orientable = GTK_ORIENTABLE (mail_shell_content->priv->paned);
+ orientation = gtk_orientable_get_orientation (orientable);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ allocation = GTK_WIDGET (orientable)->allocation.width;
+ else
+ allocation = GTK_WIDGET (orientable)->allocation.height;
+
+ position = MAX (0, allocation - preview_size);
+ gtk_paned_set_position (GTK_PANED (orientable), position);
+}
+
gboolean
e_mail_shell_content_get_preview_visible (EMailShellContent *mail_shell_content)
{
@@ -838,41 +949,30 @@ void
e_mail_shell_content_set_vertical_view (EMailShellContent *mail_shell_content,
gboolean vertical_view)
{
- GConfBridge *bridge;
GtkOrientable *orientable;
GtkOrientation orientation;
- GtkWidget *paned;
+ GConfBridge *bridge;
guint binding_id;
- const gchar *key;
g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content));
- if (vertical_view == mail_shell_content->priv->vertical_view)
- return;
-
bridge = gconf_bridge_get ();
- paned = mail_shell_content->priv->paned;
binding_id = mail_shell_content->priv->paned_binding_id;
- if (binding_id > 0)
+ if (binding_id > 0) {
gconf_bridge_unbind (bridge, binding_id);
+ mail_shell_content->priv->paned_binding_id = 0;
+ }
- if (vertical_view) {
+ if (vertical_view)
orientation = GTK_ORIENTATION_HORIZONTAL;
- key = "/apps/evolution/mail/display/hpaned_size";
- } else {
+ else
orientation = GTK_ORIENTATION_VERTICAL;
- key = "/apps/evolution/mail/display/paned_size";
- }
- orientable = GTK_ORIENTABLE (paned);
+ orientable = GTK_ORIENTABLE (mail_shell_content->priv->paned);
gtk_orientable_set_orientation (orientable, orientation);
- binding_id = gconf_bridge_bind_property_delayed (
- bridge, key, G_OBJECT (paned), "position");
-
mail_shell_content->priv->vertical_view = vertical_view;
- mail_shell_content->priv->paned_binding_id = binding_id;
e_mail_shell_content_update_view_instance (mail_shell_content);
diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h
index 57d2438705..48a0f9e234 100644
--- a/modules/mail/e-mail-shell-content.h
+++ b/modules/mail/e-mail-shell-content.h
@@ -65,6 +65,11 @@ GType e_mail_shell_content_get_type (void);
void e_mail_shell_content_register_type
(GTypeModule *type_module);
GtkWidget * e_mail_shell_content_new(EShellView *shell_view);
+gint e_mail_shell_content_get_preview_size
+ (EMailShellContent *mail_shell_content);
+void e_mail_shell_content_set_preview_size
+ (EMailShellContent *mail_shell_content,
+ gint preview_size);
gboolean e_mail_shell_content_get_preview_visible
(EMailShellContent *mail_shell_content);
void e_mail_shell_content_set_preview_visible