[gnome-boxes/wip/csd: 4/4] tmp
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/csd: 4/4] tmp
- Date: Fri, 30 Aug 2013 01:36:20 +0000 (UTC)
commit 54e8c3e4d7f61f0c19061821c50e281c405083c6
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Aug 30 02:02:48 2013 +0300
tmp
src/display-page.vala | 105 ++++++++-----------------------------------------
src/topbar.vala | 17 +++++++-
2 files changed, 32 insertions(+), 90 deletions(-)
---
diff --git a/src/display-page.vala b/src/display-page.vala
index 416f746..0264389 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -2,27 +2,17 @@
using Gtk;
using Gdk;
-private class Boxes.DisplayToolbar: Gd.MainToolbar {
+private class Boxes.DisplayToolbar: Gtk.HeaderBar {
private bool overlay;
- /* The left/right containers of Gd.MainToolbar are GtkGrids, which don't support first/last theming,
- which the osd css uses, so we need to add our own GtkBoxes instead. */
- private Gtk.Box leftbox;
- private Gtk.Box rightbox;
public DisplayToolbar (bool overlay) {
- add_events (Gdk.EventMask.POINTER_MOTION_MASK);
this.overlay = overlay;
if (overlay)
get_style_context ().add_class ("osd");
- else
+ else {
get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
-
- int spacing = overlay ? 0 : 12;
- leftbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, spacing);
- add_widget (leftbox, true);
-
- rightbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, spacing);
- add_widget (rightbox, false);
+ show_close_button = true;
+ }
var back_icon = (get_direction () == Gtk.TextDirection.RTL)? "go-previous-rtl-symbolic" :
"go-previous-symbolic";
@@ -48,87 +38,29 @@ private class Boxes.DisplayToolbar: Gd.MainToolbar {
var img = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.MENU);
img.show ();
button.image = img;
+ button.valign = Gtk.Align.CENTER;
if (pack_start)
- leftbox.add (button);
+ this.pack_start (button);
else
- rightbox.add (button);
+ this.pack_end (button);
if (!overlay)
button.get_style_context ().add_class ("raised");
button.get_style_context ().add_class ("image-button");
return button;
}
-
- private bool button_down;
- private int button_down_x;
- private int button_down_y;
- private uint button_down_button;
-
- public override bool button_press_event (Gdk.EventButton event) {
- var res = base.button_press_event (event);
-
- // With the current GdkEvent bindings this is the only way to
- // upcast a GdkEventButton to a GdkEvent (which we need for
- // the triggerts_context_menu() method call.
- // TODO: Fix this when vala bindings are corrected
- Gdk.Event *base_event = (Gdk.Event *)(&event);
-
- if (!res && !base_event->triggers_context_menu ()) {
- button_down = true;
- button_down_button = event.button;
- button_down_x = (int) event.x;
- button_down_y = (int) event.y;
- }
- return res;
- }
-
- public override bool button_release_event (Gdk.EventButton event) {
- button_down = false;
- return base.button_press_event (event);
- }
-
- public override bool motion_notify_event (Gdk.EventMotion event) {
- if (button_down) {
- double dx = event.x - button_down_x;
- double dy = event.y - button_down_y;
-
- // Break out when the dragged distance is 40 pixels
- if (dx * dx + dy * dy > 40 * 40) {
- button_down = false;
- App.app.fullscreen = false;
-
- var window = get_toplevel () as Gtk.Window;
- int old_width;
- window.get_size (out old_width, null);
-
- ulong id = 0;
- id = App.app.notify["fullscreen"].connect ( () => {
- int root_x, root_y, width;
- window.get_position (out root_x, out root_y);
- window.get_window ().get_geometry (null, null, out width, null);
- window.begin_move_drag ((int) button_down_button,
- root_x + (int) ((button_down_x / (double) old_width) * width),
- root_y + button_down_y,
- event.time);
- App.app.disconnect (id);
- } );
- }
- }
- if (base.motion_notify_event != null)
- return base.motion_notify_event (event);
- return false;
- }
}
private class Boxes.DisplayPage: GLib.Object {
- public Widget widget { get { return box; } }
+ public Widget widget { get { return grid; } }
+
+ public DisplayToolbar toolbar;
private EventBox event_box;
- private Box box;
+ private Gtk.Grid grid;
private DisplayToolbar overlay_toolbar;
private EventBox overlay_toolbar_box;
private Grid notification_grid;
- private DisplayToolbar toolbar;
private uint toolbar_hide_id;
private uint toolbar_show_id;
private ulong cursor_id;
@@ -195,10 +127,7 @@ private class Boxes.DisplayPage: GLib.Object {
toolbar = new DisplayToolbar (false);
- box = new Box (Orientation.VERTICAL, 0);
- box.pack_start (toolbar, false, false, 0);
-
- var grid = new Gtk.Grid ();
+ grid = new Gtk.Grid ();
App.app.window.window_state_event.connect ((event) => {
update_toolbar_visible ();
@@ -207,8 +136,6 @@ private class Boxes.DisplayPage: GLib.Object {
event_box.hexpand = true;
event_box.vexpand = true;
- box.pack_start (grid, true, true, 0);
-
overlay_toolbar = new DisplayToolbar (true);
overlay_toolbar_box = new EventBox ();
overlay_toolbar_box.add (overlay_toolbar);
@@ -224,7 +151,7 @@ private class Boxes.DisplayPage: GLib.Object {
grid.attach (overlay_toolbar_box, 0, 0, 1, 1);
grid.attach (notification_grid, 0, 1, 1, 1);
- box.show_all ();
+ grid.show_all ();
}
public void add_notification (Widget w) {
@@ -286,8 +213,10 @@ private class Boxes.DisplayPage: GLib.Object {
if (grabbed)
hint = _("(press Ctrl+Alt keys to ungrab)");
- overlay_toolbar.set_labels (title, hint);
- toolbar.set_labels (title, hint);
+ overlay_toolbar.set_title (title);
+ overlay_toolbar.set_subtitle (hint);
+ toolbar.set_title (title);
+ toolbar.set_subtitle (hint);
}
public void show_display (Boxes.Display display, Widget widget) {
diff --git a/src/topbar.vala b/src/topbar.vala
index f8967a2..c8e9e6f 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -6,7 +6,8 @@ public enum Boxes.TopbarPage {
COLLECTION,
SELECTION,
WIZARD,
- PROPERTIES
+ PROPERTIES,
+ DISPLAY
}
private class Boxes.Topbar: Boxes.UI {
@@ -36,11 +37,16 @@ private class Boxes.Topbar: Boxes.UI {
private Gtk.MenuButton selection_menu_button;
private Gtk.HeaderBar selection_toolbar;
private Gtk.HeaderBar collection_toolbar;
+ private Gtk.HeaderBar display_toolbar;
public string? _status;
public string? status {
get { return _status; }
- set { _status = value; collection_toolbar.set_title (_status); }
+ set {
+ _status = value;
+ collection_toolbar.set_title (_status);
+ display_toolbar.set_title (_status);
+ }
}
public Topbar () {
@@ -162,6 +168,11 @@ private class Boxes.Topbar: Boxes.UI {
hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
notebook.append_page (hbox, null);
+ /* TopbarPage.DISPLAY */
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+ display_toolbar = App.app.display_page.toolbar;
+ hbox.pack_start (display_toolbar, true, true, 0);
+ notebook.append_page (hbox, null);
update_search_btn ();
App.app.collection.item_added.connect (update_search_btn);
@@ -212,6 +223,8 @@ private class Boxes.Topbar: Boxes.UI {
break;
case UIState.DISPLAY:
+ notebook.page = TopbarPage.DISPLAY;
+ spinner.hide ();
break;
case UIState.PROPERTIES:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]