[gnome-boxes/wip/feborges/flowbox: 1/2] FIXME
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/feborges/flowbox: 1/2] FIXME
- Date: Tue, 28 Mar 2017 15:25:44 +0000 (UTC)
commit adac32492f8ffd5b9e346d0169d2f248587b8664
Author: Felipe Borges <felipeborges gnome org>
Date: Fri Mar 24 13:06:36 2017 +0100
FIXME
src/icon-view.vala | 78 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 59 insertions(+), 19 deletions(-)
---
diff --git a/src/icon-view.vala b/src/icon-view.vala
index 4fb98d9..39ffedc 100644
--- a/src/icon-view.vala
+++ b/src/icon-view.vala
@@ -6,7 +6,21 @@ public enum Boxes.SelectionCriteria {
RUNNING
}
-private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
+private class Boxes.IconViewRow : Gtk.Box {
+ public CollectionItem item { get; private set; }
+ private Machine machine {
+ get { return item as Machine; }
+ }
+
+ public IconViewRow (CollectionItem item) {
+ this.item = item;
+
+ this.orientation = Gtk.Orientation.VERTICAL;
+ this.spacing = 5;
+ }
+}
+
+private class Boxes.IconView: Gtk.FlowBox, Boxes.ICollectionView, Boxes.UI {
public UIState previous_ui_state { get; protected set; }
public UIState ui_state { get; protected set; }
@@ -32,6 +46,7 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
LAST
}
+ private GLib.ListStore list_store;
private Gtk.ListStore store;
private Gtk.TreeModelFilter model_filter;
private Boxes.ActionsPopover context_popover;
@@ -53,23 +68,23 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
public const int EMBLEM_PADDING = 8;
construct {
- category = new Category (_("New and Recent"), Category.Kind.NEW);
- hidden_items = new GLib.List<CollectionItem> ();
- filter = new CollectionFilter ();
+ //category = new Category (_("New and Recent"), Category.Kind.NEW);
+ //hidden_items = new GLib.List<CollectionItem> ();
+ //filter = new CollectionFilter ();
setup_view ();
- notify["ui-state"].connect (ui_state_changed);
+ /*notify["ui-state"].connect (ui_state_changed);
filter.notify["text"].connect (() => {
model_filter.refilter ();
});
filter.filter_func_changed.connect (() => {
model_filter.refilter ();
- });
+ });*/
}
public void setup_ui (AppWindow window) {
this.window = window;
- window.notify["selection-mode"].connect (() => {
+ /*window.notify["selection-mode"].connect (() => {
set_selection_mode (window.selection_mode);
if (!window.selection_mode)
unselect_all (); // Reset selection on exiting selection mode
@@ -79,7 +94,7 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
icon_view.button_release_event.connect (on_button_press_event);
icon_view.key_press_event.connect (on_key_press_event);
context_popover = new Boxes.ActionsPopover (window);
- context_popover.relative_to = icon_view;
+ context_popover.relative_to = icon_view;*/
}
private void ui_state_changed () {
@@ -147,6 +162,9 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
return;
}
+ list_store.append (item);
+ return;
+
var info = machine.status?? machine.info;
var iter = append (machine.name, info, item);
var thumbnail_id = machine.thumbnailer.notify["thumbnail"].connect (() => {
@@ -274,14 +292,32 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
}
public void activate_first_item () {
- if (model_filter.iter_n_children (null) == 1) {
+/* if (model_filter.iter_n_children (null) == 1) {
Gtk.TreePath path = new Gtk.TreePath.from_string ("0");
(get_generic_view () as Gtk.IconView).item_activated (path);
- }
+ }*/
+ }
+
+ private Gtk.Widget create_widget_func (Object item) {
+ Machine machine = item as Machine;
+ return_if_fail (machine != null);
+
+ var child = new Gtk.FlowBoxChild ();
+ var box = new IconViewRow (machine);
+ var pixbuf = machine.thumbnailer.thumbnail;
+ box.add (new Gtk.Image.from_pixbuf (pixbuf));
+
+ box.add (new Gtk.Label (machine.name));
+ box.show_all ();
+
+ child.add(box);
+
+ return child;
}
private void setup_view () {
- store = new Gtk.ListStore (ModelColumns.LAST,
+ list_store = new GLib.ListStore (typeof (CollectionItem));
+ /*store = new Gtk.ListStore (ModelColumns.LAST,
typeof (string),
typeof (string),
typeof (string),
@@ -324,7 +360,8 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
view_selection_changed.connect (() => {
queue_draw ();
App.app.notify_property ("selected-items");
- });
+ });*/
+ bind_model (list_store, create_widget_func);
show_all ();
}
@@ -399,25 +436,28 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
if (event.type != Gdk.EventType.BUTTON_RELEASE || event.button != 3)
return false;
- var generic_view = get_generic_view () as Gd.MainViewGeneric;
+/* var generic_view = get_generic_view () as Gd.MainViewGeneric;
var path = generic_view.get_path_at_pos ((int) event.x, (int) event.y);
if (path == null)
- return false;
+ return false;*/
- return launch_context_popover_for_path (path);
+ //return launch_context_popover_for_path (path);
+ return false;
}
private bool on_key_press_event (Gdk.EventKey event) {
if (event.keyval != Gdk.Key.Menu)
return false;
- var icon_view = get_generic_view () as Gtk.IconView;
+ return false;
+
+/* var icon_view = get_generic_view () as Gtk.IconView;
Gtk.TreePath path;
Gtk.CellRenderer cell;
if (!icon_view.get_cursor (out path, out cell))
return false;
- return launch_context_popover_for_path (path);
+ return launch_context_popover_for_path (path);*/
}
private bool launch_context_popover_for_path (Gtk.TreePath path) {
@@ -425,14 +465,14 @@ private class Boxes.IconView: Gd.MainView, Boxes.ICollectionView, Boxes.UI {
if (item == null)
return false;
- var icon_view = get_generic_view () as Gtk.IconView;
+/* var icon_view = get_generic_view () as Gtk.IconView;
Gdk.Rectangle rect;
icon_view.get_cell_rect (path, null, out rect);
context_popover.update_for_item (item);
rect.height /= 2; // Show in the middle
context_popover.pointing_to = rect;
- context_popover.show ();
+ context_popover.show ();*/
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]