aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-window.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-10-26 23:53:16 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-10-27 00:04:39 +0800
commit40b868004c9267a77daefc6f3eee4979ebe3a376 (patch)
tree281da6ab517752aaebbdc0305ca5ed0c711dff94 /shell/e-shell-window.c
parent22fb5d5f21d9ad8cb0f04cdfafdbe2d079c6d2f8 (diff)
downloadgsoc2013-evolution-40b868004c9267a77daefc6f3eee4979ebe3a376.tar
gsoc2013-evolution-40b868004c9267a77daefc6f3eee4979ebe3a376.tar.gz
gsoc2013-evolution-40b868004c9267a77daefc6f3eee4979ebe3a376.tar.bz2
gsoc2013-evolution-40b868004c9267a77daefc6f3eee4979ebe3a376.tar.lz
gsoc2013-evolution-40b868004c9267a77daefc6f3eee4979ebe3a376.tar.xz
gsoc2013-evolution-40b868004c9267a77daefc6f3eee4979ebe3a376.tar.zst
gsoc2013-evolution-40b868004c9267a77daefc6f3eee4979ebe3a376.zip
Bug 709428 - Searchbar widgets should not wrap
Instead of wrapping the searchbar for small screens (which looks ugly and breaks the initial window size on large screens), hide the filter combo box in views that would otherwise be too wide for the screen. There's no loss of functionality when hiding the filter combo box. It's just a set of convenient pre-defined searches, all of which can be reproduced through the Advanced Search interface. New functions: e_shell_searchbar_get_filter_visible() e_shell_searchbar_set_filter_visible()
Diffstat (limited to 'shell/e-shell-window.c')
-rw-r--r--shell/e-shell-window.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index f19af058cf..20af727664 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -172,6 +172,21 @@ shell_window_update_close_action_cb (EShellWindow *shell_window)
}
static void
+shell_window_tweak_for_small_screen (EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ GtkWidget *shell_searchbar;
+ const gchar *active_view;
+
+ active_view = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, active_view);
+ shell_searchbar = e_shell_view_get_searchbar (shell_view);
+
+ e_shell_searchbar_set_filter_visible (
+ E_SHELL_SEARCHBAR (shell_searchbar), FALSE);
+}
+
+static void
shell_window_set_geometry (EShellWindow *shell_window,
const gchar *geometry)
{
@@ -377,6 +392,40 @@ shell_window_constructed (GObject *object)
}
static void
+shell_window_get_preferred_width (GtkWidget *widget,
+ gint *out_minimum_width,
+ gint *out_natural_width)
+{
+ GdkScreen *screen;
+ gint screen_width;
+ gint minimum_width = 0;
+ gint natural_width = 0;
+ gboolean tweaked = FALSE;
+
+ screen = gtk_widget_get_screen (widget);
+ screen_width = gdk_screen_get_width (screen);
+
+try_again:
+ /* Chain up to parent's get_preferred_width() method. */
+ GTK_WIDGET_CLASS (e_shell_window_parent_class)->
+ get_preferred_width (widget, &minimum_width, &natural_width);
+
+ if (!tweaked && minimum_width > screen_width) {
+ EShellWindow *shell_window;
+
+ shell_window = E_SHELL_WINDOW (widget);
+ shell_window_tweak_for_small_screen (shell_window);
+
+ tweaked = TRUE; /* prevents looping */
+
+ goto try_again;
+ }
+
+ *out_minimum_width = minimum_width;
+ *out_natural_width = natural_width;
+}
+
+static void
shell_window_close_alert (EShellWindow *shell_window)
{
EShellView *shell_view;
@@ -746,6 +795,7 @@ static void
e_shell_window_class_init (EShellWindowClass *class)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
GtkBindingSet *binding_set;
g_type_class_add_private (class, sizeof (EShellWindowPrivate));
@@ -757,6 +807,9 @@ e_shell_window_class_init (EShellWindowClass *class)
object_class->finalize = shell_window_finalize;
object_class->constructed = shell_window_constructed;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->get_preferred_width = shell_window_get_preferred_width;
+
class->close_alert = shell_window_close_alert;
class->construct_menubar = shell_window_construct_menubar;
class->construct_toolbar = shell_window_construct_toolbar;
@@ -1330,6 +1383,10 @@ e_shell_window_set_active_view (EShellWindow *shell_window,
action = e_shell_view_get_action (shell_view);
gtk_action_activate (action);
+
+ /* Renegotiate the shell window size in case a newly-created
+ * shell view needs tweaked to accommodate a smaller screen. */
+ gtk_widget_queue_resize (GTK_WIDGET (shell_window));
}
/**