diff options
Diffstat (limited to 'shell/e-shell-window.c')
-rw-r--r-- | shell/e-shell-window.c | 57 |
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)); } /** |