~tintou/slingshot/fix_rtl

« back to all changes in this revision

Viewing changes to src/SlingshotView.vala

  • Committer: Giulio Collura
  • Date: 2011-08-29 10:49:05 UTC
  • Revision ID: random.cpp@gmail.com-20110829104905-wkj00e0t0j9uvcko
Now page_switcher works perfectly, added --silent argument to start slingshot without showing it

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
            read_settings ();
51
51
 
52
52
            // Window properties
53
 
            this.title = "Slingshot"; // Do I need this?
 
53
            this.title = "Slingshot";
54
54
            this.skip_pager_hint = true;
55
55
            this.skip_taskbar_hint = true;
56
56
            this.set_type_hint (Gdk.WindowTypeHint.NORMAL);
57
57
            this.set_keep_above (true);
 
58
 
 
59
            // No time to have slingshot resizable.
58
60
            this.resizable = false;
59
61
            this.app_paintable = true;
60
62
 
68
70
                apps.set (cat.get_name (), AppSystem.get_apps (cat));
69
71
            }
70
72
 
 
73
            // Slingshot should have only one CssProvider
71
74
            style_provider = new CssProvider ();
72
75
 
73
76
            try {
76
79
                warning ("Could not add css provider. Some widgets won't look as intended. %s", e.message);
77
80
            }
78
81
 
79
 
 
80
82
            setup_ui ();
81
83
            connect_signals ();
82
84
 
84
86
 
85
87
        private void setup_ui () {
86
88
            
87
 
            // Add container wrapper
88
 
            wrapper = new EventBox ();
89
 
            wrapper.set_visible_window (false);
90
 
 
91
 
            // Add container
 
89
            // Create the base container
92
90
            var container = new VBox (false, 0);
93
 
            wrapper.add (container);
94
91
 
95
92
            // Add top bar
96
93
            var top = new HBox (false, 10);
102
99
            }
103
100
            category_switcher.set_active (0);
104
101
 
105
 
 
106
102
            searchbar = new SearchBar (_("Start typing to search"));
107
103
            
108
104
            //top.pack_start (category_switcher, true, true, 15);
109
105
            top.pack_start (searchbar, false, true, 0);
110
106
 
111
 
            container.pack_start (top, false, true, 15);
112
 
 
113
107
            // Get the current size of the view
114
108
            int width, height;
115
109
            get_size (out width, out height);
116
110
            
117
111
            // Make icon grid and populate
118
112
            grid = new Widgets.Grid (height / 180, width / 128);
 
113
 
 
114
            // Create the layout which works like pages
119
115
            pages = new Layout (null, null);
120
116
            pages.put (grid, 0, 0);
121
 
            pages.app_paintable = true;
122
 
            pages.set_visual (get_screen ().get_rgba_visual());
123
117
            pages.get_style_context ().add_provider (style_provider, 600);
124
118
            pages.get_style_context ().add_class ("scrollwindow");
125
119
 
126
 
            pages.set_visual (get_screen ().get_rgba_visual());
127
 
 
128
 
            container.pack_start (Utils.set_padding (pages, 0, 9, 0, 9), true, true, 0);
129
 
 
 
120
            // Create the page switcher
130
121
            page_switcher = new Switcher ();
131
122
            page_switcher.append ("1");
 
123
            
 
124
            // This function must be after creating the page switcher
 
125
            populate_grid ();
 
126
 
 
127
            container.pack_start (top, false, true, 15);
 
128
            container.pack_start (Utils.set_padding (pages, 0, 9, 0, 9), true, true, 0);
132
129
            container.pack_start (page_switcher, false, true, 15);
133
 
 
134
 
            populate_grid ();            
135
 
 
136
 
            this.add (Utils.set_padding (wrapper, 15, 15, 1, 15));
 
130
            this.add (Utils.set_padding (container, 15, 15, 1, 15));
137
131
 
138
132
        }
139
133
 
146
140
            this.draw.connect (this.draw_background);
147
141
            searchbar.changed.connect (this.search);
148
142
 
 
143
            page_switcher.active_changed.connect (() => {
 
144
 
 
145
                if (page_switcher.active > page_switcher.old_active)
 
146
                    this.page_right (page_switcher.active - page_switcher.old_active);
 
147
                else
 
148
                    this.page_left (page_switcher.old_active - page_switcher.active);
 
149
 
 
150
            });
 
151
 
149
152
            // Auto-update settings when changed
150
153
            Slingshot.settings.changed.connect (read_settings);
151
154
 
168
171
            cr.line_to (35.0, 0.0 + offset);
169
172
            cr.line_to (50.0, 15.0 + offset);
170
173
            // Create the rounded square
171
 
                    cr.arc (0 + size.width - radius - offset, 15.0 + radius + offset, 
 
174
            cr.arc (0 + size.width - radius - offset, 15.0 + radius + offset, 
172
175
                         radius, Math.PI * 1.5, Math.PI * 2);
173
 
                    cr.arc (0 + size.width - radius - offset, 0 + size.height - radius - offset, 
 
176
            cr.arc (0 + size.width - radius - offset, 0 + size.height - radius - offset, 
174
177
                         radius, 0, Math.PI * 0.5);
175
 
                    cr.arc (0 + radius + offset, 0 + size.height - radius - offset, 
 
178
            cr.arc (0 + radius + offset, 0 + size.height - radius - offset, 
176
179
                         radius, Math.PI * 0.5, Math.PI);
177
 
                    cr.arc (0 + radius + offset, 15 + radius + offset, radius, Math.PI, Math.PI * 1.5);
 
180
            cr.arc (0 + radius + offset, 15 + radius + offset, radius, Math.PI, Math.PI * 1.5);
178
181
 
179
182
            cr.set_source_rgba (0.1, 0.1, 0.1, 0.95);
180
183
            cr.fill_preserve ();
181
184
 
182
 
            // Add a little vertical gradient
183
 
            /*var linear_stroke = new Cairo.Pattern.linear (0, 0, 0, size.height);
184
 
                linear_stroke.add_color_stop_rgba (0.0,  1.0, 1.0, 1.0, 0.0);
185
 
                linear_stroke.add_color_stop_rgba (0.5,  1.0, 1.0, 1.0, 0.0);
186
 
                linear_stroke.add_color_stop_rgba (1.0,  0.9, 0.9, 0.9, 0.2);
187
 
            cr.set_source (linear_stroke);
188
 
            cr.fill_preserve ();
189
 
            */ // I don't like it anymore
190
 
 
191
185
            // Paint a little lighter border
192
186
            cr.set_source_rgba (1.0, 1.0, 1.0, 1.0);
193
187
            cr.set_line_width (1.0);
228
222
            switch (event.direction.to_string ()) {
229
223
                case "GDK_SCROLL_UP":
230
224
                case "GDK_SCROLL_LEFT":
231
 
                    page_left ();
 
225
                    page_switcher.set_active (page_switcher.active - 1);
232
226
                    break;
233
227
                case "GDK_SCROLL_DOWN":
234
228
                case "GDK_SCROLL_RIGHT":
235
 
                    page_right ();
 
229
                    page_switcher.set_active (page_switcher.active + 1);
236
230
                    break;
237
231
 
238
232
            }
244
238
        public void hide_slingshot () {
245
239
            
246
240
            // Show the first page
247
 
            pages.move (grid, 0, 0);
248
241
            page_switcher.set_active (0);
249
242
            current_position = 0;
250
243
 
267
260
                current_position += 5*130*step;
268
261
            }
269
262
 
270
 
            page_switcher.set_active (page_switcher.active - 1);
271
 
 
272
263
        }
273
264
 
274
265
        private void page_right (int step = 1) {
278
269
                current_position -= 5*130*step;
279
270
            }
280
271
 
281
 
            page_switcher.set_active (page_switcher.active + 1);
282
 
 
283
272
        }
284
273
 
285
274
        private void search () {