[recipes] Maximize the window if the screen is too small
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Maximize the window if the screen is too small
- Date: Tue, 17 Jan 2017 02:09:05 +0000 (UTC)
commit eca737373f80b8f87520451408220d4ec51ff7a2
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 16 21:06:57 2017 -0500
Maximize the window if the screen is too small
This should prevent the window from coming up halfway offscreen.
https://bugzilla.gnome.org/show_bug.cgi?id=777303
src/gr-window.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index b6c9bc5..e4a8a6d 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -320,10 +320,40 @@ window_keypress_handler (GtkWidget *widget,
return gr_query_editor_handle_event (GR_QUERY_EDITOR (window->search_bar), event);
}
+static gboolean
+is_small_screen (GdkMonitor *monitor)
+{
+ GdkRectangle geom;
+
+ gdk_monitor_get_geometry (monitor, &geom);
+
+ return geom.height < 1000 || geom.width < 1200;
+}
+
+static gboolean
+maximize (gpointer data)
+{
+ GtkWindow *window = data;
+
+ gtk_window_maximize (window);
+
+ return G_SOURCE_REMOVE;
+}
+
static void
window_mapped_handler (GtkWidget *widget)
{
GrWindow *window = GR_WINDOW (widget);
+ GdkDisplay *display;
+ GdkWindow *win;
+ GdkMonitor *monitor;
+
+ display = gtk_widget_get_display (widget);
+ win = gtk_widget_get_window (widget);
+ monitor = gdk_display_get_monitor_at_window (display, win);
+
+ if (is_small_screen (monitor))
+ g_idle_add (maximize, window);
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gr_recipes_page_unexpand (GR_RECIPES_PAGE (window->recipes_page));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]