1
1
public class Tuba.Views.ContentBase : Views .Base {
2
-
3
- #if USE_LISTVIEW
4
- protected Gtk . ListView content;
5
- #else
6
- protected Gtk . ListBox content;
7
- #endif
2
+ protected Gtk . ListBox content;
8
3
protected signal void reached_close_to_top ();
9
4
public GLib . ListStore model;
10
5
private bool bottom_reached_locked = false ;
@@ -16,32 +11,21 @@ public class Tuba.Views.ContentBase : Views.Base {
16
11
construct {
17
12
model = new GLib .ListStore (typeof (Widgetizable ));
18
13
19
- #if USE_LISTVIEW
20
- Gtk . SignalListItemFactory signallistitemfactory = new Gtk .SignalListItemFactory ();
21
- signallistitemfactory. bind. connect (bind_listitem_cb);
22
-
23
- content = new Gtk .ListView (new Gtk .NoSelection (model), signallistitemfactory) {
24
- css_classes = { " contentbase" , " content" , " background" },
25
- single_click_activate = true
26
- };
27
-
28
- content. activate. connect (on_content_item_activated);
29
- model. items_changed. connect (on_content_changed);
30
- #else
31
- model. items_changed. connect (on_content_changed);
32
- content = new Gtk .ListBox () {
33
- selection_mode = Gtk . SelectionMode . NONE ,
34
- css_classes = { " content" , " background" }
35
- };
36
-
37
- content. row_activated. connect (on_content_item_activated);
38
- content. bind_model (model, on_create_model_widget);
39
- #endif
14
+ model. items_changed. connect (on_content_changed);
15
+
16
+ content = new Gtk .ListBox () {
17
+ selection_mode = Gtk . SelectionMode . NONE ,
18
+ css_classes = { " fake-content" , " background" }
19
+ };
20
+
21
+ content. row_activated. connect (on_content_item_activated);
22
+ content. bind_model (model, on_create_model_widget);
40
23
content_box. child = content;
41
24
42
25
scrolled. vadjustment. value_changed. connect (on_scrolled_vadjustment_value_change);
43
26
scroll_to_top_rev. bind_property (" child-revealed" , scroll_to_top_rev, " visible" , GLib . BindingFlags . SYNC_CREATE );
44
27
}
28
+
45
29
~ContentBase () {
46
30
debug (" Destroying ContentBase" );
47
31
}
@@ -71,26 +55,9 @@ public class Tuba.Views.ContentBase : Views.Base {
71
55
scroll_to_top_rev. reveal_child = reveal;
72
56
}
73
57
74
- #if USE_LISTVIEW
75
- protected virtual void bind_listitem_cb (GLib .Object item ) {
76
- ((Gtk . ListItem ) item). child = on_create_model_widget (((Gtk . ListItem ) item). item);
77
-
78
- var gtklistitemwidget = ((Gtk . ListItem ) item). child. get_parent ();
79
- if (gtklistitemwidget != null ) {
80
- gtklistitemwidget. add_css_class (" card" );
81
- gtklistitemwidget. add_css_class (" card-spacing" );
82
- gtklistitemwidget. focusable = true ;
83
-
84
- // Thread lines overflow slightly
85
- gtklistitemwidget. overflow = Gtk . Overflow . HIDDEN ;
86
- }
87
- }
88
- #endif
89
58
90
59
public override void dispose () {
91
- #if ! USE_LISTVIEW
92
- unbind_listboxes ();
93
- #endif
60
+ unbind_listboxes ();
94
61
base . dispose ();
95
62
}
96
63
@@ -114,31 +81,25 @@ public class Tuba.Views.ContentBase : Views.Base {
114
81
}
115
82
}
116
83
117
- #if ! USE_LISTVIEW
118
- public override void unbind_listboxes () {
119
- if (content != null )
120
- content. bind_model (null , null );
121
- base . unbind_listboxes ();
122
- }
123
- #endif
84
+ public override void unbind_listboxes () {
85
+ if (content != null )
86
+ content. bind_model (null , null );
87
+ base . unbind_listboxes ();
88
+ }
124
89
125
90
public virtual Gtk .Widget on_create_model_widget (Object obj ) {
126
91
var obj_widgetable = obj as Widgetizable ;
127
92
if (obj_widgetable == null )
128
93
Process . exit (0 );
129
94
try {
130
- #if ! USE_LISTVIEW
131
- Gtk . Widget widget = obj_widgetable. to_widget ();
132
- widget. add_css_class (" card" );
133
- widget. add_css_class (" card-spacing" );
134
- widget. focusable = true ;
135
-
136
- // Thread lines overflow slightly
137
- widget. overflow = Gtk . Overflow . HIDDEN ;
138
- return widget;
139
- #else
140
- return obj_widgetable. to_widget ();
141
- #endif
95
+ Gtk . Widget widget = obj_widgetable. to_widget ();
96
+ widget. add_css_class (" card" );
97
+ widget. add_css_class (" card-spacing" );
98
+ widget. focusable = true ;
99
+
100
+ // Thread lines overflow slightly
101
+ widget. overflow = Gtk . Overflow . HIDDEN ;
102
+ return widget;
142
103
} catch (Oopsie e) {
143
104
warning (@" Error on_create_model_widget: $(e.message)" );
144
105
Process . exit (0 );
@@ -155,13 +116,7 @@ public class Tuba.Views.ContentBase : Views.Base {
155
116
}, Priority . LOW );
156
117
}
157
118
158
- #if USE_LISTVIEW
159
- public virtual void on_content_item_activated (uint pos ) {
160
- ((Widgetizable ) ((ListModel ) content. model). get_item (pos)). open ();
161
- }
162
- #else
163
- public virtual void on_content_item_activated (Gtk .ListBoxRow row ) {
164
- Signal . emit_by_name (row, " open" );
165
- }
166
- #endif
119
+ public virtual void on_content_item_activated (Gtk .ListBoxRow row ) {
120
+ Signal . emit_by_name (row, " open" );
121
+ }
167
122
}
0 commit comments