From 0fda8cb5a28729724c678c4e379c12a79f1e820e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 27 Aug 2009 14:42:36 -0400 Subject: Remove redundant "vertical view" functions. --- modules/mail/e-mail-shell-content.c | 112 +++++++++++++++---------------- modules/mail/e-mail-shell-content.h | 5 -- modules/mail/e-mail-shell-view-actions.c | 19 ++++-- widgets/misc/e-paned.c | 89 ++++++++---------------- widgets/misc/e-paned.h | 3 - 5 files changed, 98 insertions(+), 130 deletions(-) diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index 3a4f5aed74..20c9df7a29 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -55,6 +55,7 @@ struct _EMailShellContentPrivate { EMFormatHTMLDisplay *html_display; GalViewInstance *view_instance; + GtkOrientation orientation; /* ETable scrolling hack */ gdouble default_scrollbar_position; @@ -68,15 +69,14 @@ struct _EMailShellContentPrivate { guint preview_visible : 1; guint suppress_message_selection : 1; - guint vertical_view : 1; guint show_deleted : 1; }; enum { PROP_0, + PROP_ORIENTATION, PROP_PREVIEW_VISIBLE, - PROP_SHOW_DELETED, - PROP_VERTICAL_VIEW + PROP_SHOW_DELETED }; static gpointer parent_class; @@ -311,6 +311,23 @@ mail_shell_content_message_selected_cb (EMailShellContent *mail_shell_content, g_free (group_name); } +static GtkOrientation +mail_shell_content_get_orientation (EMailShellContent *mail_shell_content) +{ + return mail_shell_content->priv->orientation; +} + +static void +mail_shell_content_set_orientation (EMailShellContent *mail_shell_content, + GtkOrientation orientation) +{ + mail_shell_content->priv->orientation = orientation; + + g_object_notify (G_OBJECT (mail_shell_content), "orientation"); + + e_mail_shell_content_update_view_instance (mail_shell_content); +} + static void mail_shell_content_set_property (GObject *object, guint property_id, @@ -318,6 +335,12 @@ mail_shell_content_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_ORIENTATION: + mail_shell_content_set_orientation ( + E_MAIL_SHELL_CONTENT (object), + g_value_get_enum (value)); + return; + case PROP_PREVIEW_VISIBLE: e_mail_shell_content_set_preview_visible ( E_MAIL_SHELL_CONTENT (object), @@ -329,12 +352,6 @@ mail_shell_content_set_property (GObject *object, E_MAIL_SHELL_CONTENT (object), g_value_get_boolean (value)); return; - - case PROP_VERTICAL_VIEW: - e_mail_shell_content_set_vertical_view ( - E_MAIL_SHELL_CONTENT (object), - g_value_get_boolean (value)); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -347,24 +364,24 @@ mail_shell_content_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_PREVIEW_VISIBLE: - g_value_set_boolean ( + case PROP_ORIENTATION: + g_value_set_enum ( value, - e_mail_shell_content_get_preview_visible ( + mail_shell_content_get_orientation ( E_MAIL_SHELL_CONTENT (object))); return; - case PROP_SHOW_DELETED: + case PROP_PREVIEW_VISIBLE: g_value_set_boolean ( value, - e_mail_shell_content_get_show_deleted ( + e_mail_shell_content_get_preview_visible ( E_MAIL_SHELL_CONTENT (object))); return; - case PROP_VERTICAL_VIEW: + case PROP_SHOW_DELETED: g_value_set_boolean ( value, - e_mail_shell_content_get_vertical_view ( + e_mail_shell_content_get_show_deleted ( E_MAIL_SHELL_CONTENT (object))); return; } @@ -449,8 +466,8 @@ mail_shell_content_constructed (GObject *object) gtk_widget_show (widget); e_binding_new ( - G_OBJECT (object), "vertical-view", - G_OBJECT (widget), "vertical-view"); + G_OBJECT (object), "orientation", + G_OBJECT (widget), "orientation"); container = widget; @@ -692,19 +709,12 @@ mail_shell_content_class_init (EMailShellContentClass *class) FALSE, G_PARAM_READWRITE)); - g_object_class_install_property ( - object_class, - PROP_VERTICAL_VIEW, - g_param_spec_boolean ( - "vertical-view", - _("Vertical View"), - _("Whether vertical view is enabled"), - FALSE, - G_PARAM_READWRITE)); + g_object_class_override_property ( + object_class, PROP_ORIENTATION, "orientation"); } static void -mail_shell_content_iface_init (EMailReaderIface *iface) +mail_shell_content_reader_init (EMailReaderIface *iface) { iface->get_action_group = mail_shell_content_get_action_group; iface->get_hide_deleted = mail_shell_content_get_hide_deleted; @@ -749,8 +759,14 @@ e_mail_shell_content_register_type (GTypeModule *type_module) NULL /* value_table */ }; - static const GInterfaceInfo iface_info = { - (GInterfaceInitFunc) mail_shell_content_iface_init, + static const GInterfaceInfo orientable_info = { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL /* interface_data */ + }; + + static const GInterfaceInfo reader_info = { + (GInterfaceInitFunc) mail_shell_content_reader_init, (GInterfaceFinalizeFunc) NULL, NULL /* interface_data */ }; @@ -761,7 +777,11 @@ e_mail_shell_content_register_type (GTypeModule *type_module) g_type_module_add_interface ( type_module, mail_shell_content_type, - E_TYPE_MAIL_READER, &iface_info); + GTK_TYPE_ORIENTABLE, &orientable_info); + + g_type_module_add_interface ( + type_module, mail_shell_content_type, + E_TYPE_MAIL_READER, &reader_info); } GtkWidget * @@ -829,28 +849,6 @@ e_mail_shell_content_set_show_deleted (EMailShellContent *mail_shell_content, g_object_notify (G_OBJECT (mail_shell_content), "show-deleted"); } -gboolean -e_mail_shell_content_get_vertical_view (EMailShellContent *mail_shell_content) -{ - g_return_val_if_fail ( - E_IS_MAIL_SHELL_CONTENT (mail_shell_content), FALSE); - - return mail_shell_content->priv->vertical_view; -} - -void -e_mail_shell_content_set_vertical_view (EMailShellContent *mail_shell_content, - gboolean vertical_view) -{ - g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content)); - - mail_shell_content->priv->vertical_view = vertical_view; - - g_object_notify (G_OBJECT (mail_shell_content), "vertical-view"); - - e_mail_shell_content_update_view_instance (mail_shell_content); -} - GalViewInstance * e_mail_shell_content_get_view_instance (EMailShellContent *mail_shell_content) { @@ -887,7 +885,6 @@ e_mail_shell_content_set_search_strings (EMailShellContent *mail_shell_content, void e_mail_shell_content_update_view_instance (EMailShellContent *mail_shell_content) { - EPaned *paned; EMailReader *reader; EShellContent *shell_content; EShellView *shell_view; @@ -895,6 +892,8 @@ e_mail_shell_content_update_view_instance (EMailShellContent *mail_shell_content GalViewCollection *view_collection; GalViewInstance *view_instance; MessageList *message_list; + GtkOrientable *orientable; + GtkOrientation orientation; gboolean outgoing_folder; gboolean show_vertical_view; gchar *view_id; @@ -925,8 +924,9 @@ e_mail_shell_content_update_view_instance (EMailShellContent *mail_shell_content view_instance = e_shell_view_new_view_instance (shell_view, view_id); mail_shell_content->priv->view_instance = view_instance; - paned = E_PANED (mail_shell_content->priv->paned); - show_vertical_view = e_paned_get_vertical_view (paned); + orientable = GTK_ORIENTABLE (mail_shell_content); + orientation = gtk_orientable_get_orientation (orientable); + show_vertical_view = (orientation == GTK_ORIENTATION_HORIZONTAL); if (show_vertical_view) { gchar *filename; diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h index 57d2438705..88714f8f95 100644 --- a/modules/mail/e-mail-shell-content.h +++ b/modules/mail/e-mail-shell-content.h @@ -75,11 +75,6 @@ gboolean e_mail_shell_content_get_show_deleted void e_mail_shell_content_set_show_deleted (EMailShellContent *mail_shell_content, gboolean show_deleted); -gboolean e_mail_shell_content_get_vertical_view - (EMailShellContent *mail_shell_content); -void e_mail_shell_content_set_vertical_view - (EMailShellContent *mail_shell_content, - gboolean vertical_view); GalViewInstance * e_mail_shell_content_get_view_instance (EMailShellContent *mail_shell_content); diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 08a8d12aa0..5e6a9ba9cf 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -866,13 +866,24 @@ action_mail_view_cb (GtkRadioAction *action, EMailShellView *mail_shell_view) { EMailShellContent *mail_shell_content; - gboolean vertical_view; + GtkOrientable *orientable; + GtkOrientation orientation; mail_shell_content = mail_shell_view->priv->mail_shell_content; - vertical_view = (gtk_radio_action_get_current_value (action) == 1); + orientable = GTK_ORIENTABLE (mail_shell_content); + + switch (gtk_radio_action_get_current_value (action)) { + case 0: + orientation = GTK_ORIENTATION_VERTICAL; + break; + case 1: + orientation = GTK_ORIENTATION_HORIZONTAL; + break; + default: + g_return_if_reached (); + } - e_mail_shell_content_set_vertical_view ( - mail_shell_content, vertical_view); + gtk_orientable_set_orientation (orientable, orientation); } static void diff --git a/widgets/misc/e-paned.c b/widgets/misc/e-paned.c index 2c8a1820d7..51f8dbfa1c 100644 --- a/widgets/misc/e-paned.c +++ b/widgets/misc/e-paned.c @@ -38,8 +38,7 @@ struct _EPanedPrivate { enum { PROP_0, PROP_HPOSITION, - PROP_VPOSITION, - PROP_VERTICAL_VIEW + PROP_VPOSITION }; static gpointer parent_class; @@ -50,23 +49,26 @@ paned_notify_orientation_cb (EPaned *paned) /* Ignore the next "notify::position" emission. */ paned->priv->sync_position = TRUE; gtk_widget_queue_resize (GTK_WIDGET (paned)); - - g_object_notify (G_OBJECT (paned), "vertical-view"); } static void paned_notify_position_cb (EPaned *paned) { GtkAllocation *allocation; + GtkOrientable *orientable; + GtkOrientation orientation; gint position; if (paned->priv->sync_position) return; + orientable = GTK_ORIENTABLE (paned); + orientation = gtk_orientable_get_orientation (orientable); + allocation = >K_WIDGET (paned)->allocation; position = gtk_paned_get_position (GTK_PANED (paned)); - if (e_paned_get_vertical_view (paned)) { + if (orientation == GTK_ORIENTATION_HORIZONTAL) { position = MAX (0, allocation->width - position); e_paned_set_hposition (paned, position); } else { @@ -93,12 +95,6 @@ paned_set_property (GObject *object, E_PANED (object), g_value_get_int (value)); return; - - case PROP_VERTICAL_VIEW: - e_paned_set_vertical_view ( - E_PANED (object), - g_value_get_boolean (value)); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -122,12 +118,6 @@ paned_get_property (GObject *object, value, e_paned_get_vposition ( E_PANED (object))); return; - - case PROP_VERTICAL_VIEW: - g_value_set_boolean ( - value, e_paned_get_vertical_view ( - E_PANED (object))); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -138,6 +128,8 @@ paned_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { EPaned *paned = E_PANED (widget); + GtkOrientable *orientable; + GtkOrientation orientation; gint allocated; gint position; @@ -147,7 +139,10 @@ paned_size_allocate (GtkWidget *widget, if (!paned->priv->sync_position) return; - if (e_paned_get_vertical_view (paned)) { + orientable = GTK_ORIENTABLE (paned); + orientation = gtk_orientable_get_orientation (orientable); + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { allocated = allocation->width; position = e_paned_get_hposition (paned); } else { @@ -200,16 +195,6 @@ paned_class_init (EPanedClass *class) G_MAXINT, 0, G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_VERTICAL_VIEW, - g_param_spec_boolean ( - "vertical-view", - _("Vertical View"), - _("Whether vertical view is enabled"), - FALSE, - G_PARAM_READWRITE)); } static void @@ -270,6 +255,9 @@ void e_paned_set_hposition (EPaned *paned, gint hposition) { + GtkOrientable *orientable; + GtkOrientation orientation; + g_return_if_fail (E_IS_PANED (paned)); if (hposition == paned->priv->hposition) @@ -279,7 +267,10 @@ e_paned_set_hposition (EPaned *paned, g_object_notify (G_OBJECT (paned), "hposition"); - if (e_paned_get_vertical_view (paned)) { + orientable = GTK_ORIENTABLE (paned); + orientation = gtk_orientable_get_orientation (orientable); + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { paned->priv->sync_position = TRUE; gtk_widget_queue_resize (GTK_WIDGET (paned)); } @@ -297,6 +288,9 @@ void e_paned_set_vposition (EPaned *paned, gint vposition) { + GtkOrientable *orientable; + GtkOrientation orientation; + g_return_if_fail (E_IS_PANED (paned)); if (vposition == paned->priv->vposition) @@ -306,40 +300,11 @@ e_paned_set_vposition (EPaned *paned, g_object_notify (G_OBJECT (paned), "vposition"); - if (!e_paned_get_vertical_view (paned)) { - paned->priv->sync_position = TRUE; - gtk_widget_queue_resize (GTK_WIDGET (paned)); - } -} - -gboolean -e_paned_get_vertical_view (EPaned *paned) -{ - GtkOrientable *orientable; - GtkOrientation orientation; - - g_return_val_if_fail (E_IS_PANED (paned), FALSE); - orientable = GTK_ORIENTABLE (paned); orientation = gtk_orientable_get_orientation (orientable); - return (orientation == GTK_ORIENTATION_HORIZONTAL); -} - -void -e_paned_set_vertical_view (EPaned *paned, - gboolean vertical_view) -{ - GtkOrientable *orientable; - GtkOrientation orientation; - - g_return_if_fail (E_IS_PANED (paned)); - - if (vertical_view) - orientation = GTK_ORIENTATION_HORIZONTAL; - else - orientation = GTK_ORIENTATION_VERTICAL; - - orientable = GTK_ORIENTABLE (paned); - gtk_orientable_set_orientation (orientable, orientation); + if (orientation == GTK_ORIENTATION_VERTICAL) { + paned->priv->sync_position = TRUE; + gtk_widget_queue_resize (GTK_WIDGET (paned)); + } } diff --git a/widgets/misc/e-paned.h b/widgets/misc/e-paned.h index ea37cbab21..8bd1c22024 100644 --- a/widgets/misc/e-paned.h +++ b/widgets/misc/e-paned.h @@ -66,9 +66,6 @@ void e_paned_set_hposition (EPaned *paned, gint e_paned_get_vposition (EPaned *paned); void e_paned_set_vposition (EPaned *paned, gint vposition); -gboolean e_paned_get_vertical_view (EPaned *paned); -void e_paned_set_vertical_view (EPaned *paned, - gboolean vertical_view); G_END_DECLS -- cgit