[gnome-boxes] display-page: Show display size on widget resize
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] display-page: Show display size on widget resize
- Date: Sat, 8 Nov 2014 18:12:04 +0000 (UTC)
commit 7efd249a959128cba3559d2cca69bed23e42e88a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sat Nov 8 13:40:57 2014 +0000
display-page: Show display size on widget resize
This is similar to what gnome-terminal does but unlike gnome-terminal we
don't show display size label on user initiating the window drag but
rather *after* every resize of the widget. The label is automatically
hiden away after 4 seconds of last resize operation.
The reason we do it differently is mainly because I failed to find which
signals/events gnome-terminal (vte actually) hooks on to for this.
Besides this isn't so bad solution either and much better than not
showing the label at all.
https://bugzilla.gnome.org/show_bug.cgi?id=738760
data/ui/display-page.ui | 33 +++++++++++++++++++++++++--------
src/display-page.vala | 22 ++++++++++++++++++++++
2 files changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/data/ui/display-page.ui b/data/ui/display-page.ui
index fdd5ae4..24455cc 100644
--- a/data/ui/display-page.ui
+++ b/data/ui/display-page.ui
@@ -4,6 +4,7 @@
<template class="BoxesDisplayPage" parent="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">0</property>
+ <signal name="size-allocate" handler="on_size_allocate"/>
<child>
<object class="BoxesDisplayToolbar" id="toolbar">
@@ -25,15 +26,31 @@
<property name="visible">True</property>
<child>
- <object class="GtkEventBox" id="event_box">
+ <object class="GtkOverlay" id="size_overlay">
<property name="visible">True</property>
- <property name="above-child">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <signal name="event" handler="on_event_box_event"/>
- <style>
- <class name="boxes-toplevel"/>
- </style>
+
+ <child type="overlay">
+ <object class="GtkLabel" id="size_label">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="content-bg"/>
+ </style>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkEventBox" id="event_box">
+ <property name="visible">True</property>
+ <property name="above-child">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <signal name="event" handler="on_event_box_event"/>
+ <style>
+ <class name="boxes-toplevel"/>
+ </style>
+ </object>
+ </child>
</object>
<packing>
diff --git a/src/display-page.vala b/src/display-page.vala
index 4c063a4..4b3d836 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -10,6 +10,9 @@ private class Boxes.DisplayPage: Gtk.Box {
public DisplayToolbar toolbar;
[GtkChild]
+ public Gtk.Label size_label;
+
+ [GtkChild]
private EventBox event_box;
[GtkChild]
private DisplayToolbar overlay_toolbar;
@@ -20,6 +23,7 @@ private class Boxes.DisplayPage: Gtk.Box {
private ulong cursor_id;
private uint overlay_toolbar_invisible_timeout;
+ private uint size_label_timeout;
private AppWindow window;
@@ -217,4 +221,22 @@ private class Boxes.DisplayPage: Gtk.Box {
return false;
}
+
+ [GtkCallback]
+ private void on_size_allocate (Gtk.Allocation allocation) {
+ // Translators: Showing size of widget as WIDTHxHEIGHT here.
+ size_label.label = _("%dx%d").printf (allocation.width, allocation.height);
+ size_label.visible = true;
+
+ if (size_label_timeout != 0) {
+ Source.remove (size_label_timeout);
+ size_label_timeout = 0;
+ }
+ size_label_timeout = Timeout.add_seconds (3, () => {
+ size_label.visible = false;
+ size_label_timeout = 0;
+
+ return false;
+ });
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]