[evolution] The 'Show' combo box hidden for small screens in the search bar
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] The 'Show' combo box hidden for small screens in the search bar
- Date: Mon, 18 Feb 2019 14:58:08 +0000 (UTC)
commit 9e9cc42454569bfabfb35870d63251d0aba6d22e
Author: Milan Crha <mcrha redhat com>
Date: Mon Feb 18 15:53:35 2019 +0100
The 'Show' combo box hidden for small screens in the search bar
When Evolution detected that the window width would be larger than
screen width it hid the Show combo box to avoid the window oversize,
but users do use this combo for filtering, thus it was not ideal.
Rather than hiding anything, make the combo box texts ellipsizable,
which can save plenty of space without hiding any widget.
Reported downstream at:
https://bugzilla.redhat.com/show_bug.cgi?id=1678253
src/e-util/e-action-combo-box.c | 18 +++++++++++++++
src/shell/e-shell-window.c | 50 -----------------------------------------
2 files changed, 18 insertions(+), 50 deletions(-)
---
diff --git a/src/e-util/e-action-combo-box.c b/src/e-util/e-action-combo-box.c
index 1dfe7f26e1..aca5ef1cab 100644
--- a/src/e-util/e-action-combo-box.c
+++ b/src/e-util/e-action-combo-box.c
@@ -298,6 +298,17 @@ action_combo_box_update_model (EActionComboBox *combo_box)
combo_box);
}
+static void
+e_action_combo_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GTK_WIDGET_CLASS (e_action_combo_box_parent_class)->get_preferred_width (widget, minimum_width,
natural_width);
+
+ if (*natural_width > 250)
+ *natural_width = 225;
+}
+
static void
action_combo_box_set_property (GObject *object,
guint property_id,
@@ -387,6 +398,9 @@ action_combo_box_constructed (GObject *object)
combo_box, NULL);
renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ NULL);
gtk_cell_layout_pack_start (
GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
gtk_cell_layout_set_cell_data_func (
@@ -423,6 +437,7 @@ static void
e_action_combo_box_class_init (EActionComboBoxClass *class)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
GtkComboBoxClass *combo_box_class;
g_type_class_add_private (class, sizeof (EActionComboBoxPrivate));
@@ -434,6 +449,9 @@ e_action_combo_box_class_init (EActionComboBoxClass *class)
object_class->finalize = action_combo_box_finalize;
object_class->constructed = action_combo_box_constructed;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->get_preferred_width = e_action_combo_box_get_preferred_width;
+
combo_box_class = GTK_COMBO_BOX_CLASS (class);
combo_box_class->changed = action_combo_box_changed;
diff --git a/src/shell/e-shell-window.c b/src/shell/e-shell-window.c
index 8d31e6a314..56bc01b972 100644
--- a/src/shell/e-shell-window.c
+++ b/src/shell/e-shell-window.c
@@ -197,21 +197,6 @@ shell_window_update_close_action_cb (EShellWindow *shell_window)
gtk_action_set_sensitive (ACTION (CLOSE), n_shell_windows > 1);
}
-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)
@@ -429,40 +414,6 @@ shell_window_constructed (GObject *object)
G_OBJECT_CLASS (e_shell_window_parent_class)->constructed (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)
{
@@ -931,7 +882,6 @@ e_shell_window_class_init (EShellWindowClass *class)
object_class->constructed = shell_window_constructed;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->get_preferred_width = shell_window_get_preferred_width;
widget_class->map_event = shell_window_map_event;
class->close_alert = shell_window_close_alert;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]