Guest User

Untitled

a guest
Jan 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 12.10 KB | None | 0 0
  1. === modified file 'src/SlingshotView.vala'
  2. --- src/SlingshotView.vala  2011-10-12 19:59:16 +0000
  3. +++ src/SlingshotView.vala  2011-10-14 16:26:16 +0000
  4. @@ -42,14 +42,36 @@
  5.          private Gtk.Window window;
  6.          public Switcher page_switcher;
  7.          public ModeButton view_selector;
  8. -        public HBox bottom;
  9.  
  10.          // Views
  11.          public Widgets.Grid grid_view;
  12.          public SearchView search_view;
  13.          public CategoryView category_view;
  14.  
  15. -        private VBox container;
  16. +        private HBox padding;
  17. +        private bool _show_padding;
  18. +        public bool show_padding {
  19. +            get {
  20. +                return _show_padding;
  21. +            }
  22. +            set {
  23. +                if (value) {
  24. +                    if (padding.get_parent () == null) {
  25. +                        center.pack_start (padding, false, false, 0);
  26. +                        padding.show_all ();
  27. +                    }
  28. +                } else {
  29. +                    if (padding.get_parent () != null)
  30. +                        center.remove (padding);
  31. +                }
  32. +                _show_padding = value;
  33. +            }
  34. +        }
  35. +
  36. +        private HBox top;
  37. +        public HBox center;
  38. +        public HBox bottom;
  39. +        public VBox container;
  40.  
  41.          public AppSystem app_system;
  42.          private ArrayList<TreeDirectory> categories;
  43. @@ -73,6 +95,12 @@
  44.          private int default_columns;
  45.          private int default_rows;
  46.  
  47. +        public int view_height {
  48. +            get {
  49. +                return (int) (rows*130 + rows*grid_view.row_spacing + 35);
  50. +            }
  51. +        }
  52. +
  53.          public SlingshotView (Slingshot app) {
  54.  
  55.              // Window properties
  56. @@ -111,6 +139,9 @@
  57.  
  58.          private void setup_ui () {
  59.  
  60. +            padding = new HBox (false, 0);
  61. +            padding.width_request = 22;
  62. +
  63.              debug ("In setup_ui ()");
  64.              window = new Gtk.Window ();
  65.              window.get_style_context ().add_class ("slingshot");
  66. @@ -119,7 +150,7 @@
  67.              container = new VBox (false, 0);
  68.  
  69.              // Add top bar
  70. -            var top = new HBox (false, 10);
  71. +            top = new HBox (false, 10);
  72.  
  73.              view_selector = new ModeButton ();
  74.              view_selector.append (new Image.from_icon_name ("slingshot-view-list-icons-symbolic", IconSize.MENU));
  75. @@ -135,12 +166,10 @@
  76.              }
  77.              top.pack_end (searchbar, false, false, 0);
  78.  
  79. +            center = new HBox (false, 0);
  80.              // Create the layout which works like view_manager
  81.              view_manager = new Layout (null, null);
  82. -
  83. -            // Get the current size of the view
  84. -            int width, height;
  85. -            get_size (out width, out height);
  86. +            center.pack_end (Utils.set_padding (view_manager, 0, 22, 0, 0), true, true, 0);
  87.  
  88.              // Create the "NORMAL_VIEW"
  89.              grid_view = new Widgets.Grid (default_rows, default_columns);
  90. @@ -166,14 +195,16 @@
  91.              bottom.pack_start (page_switcher, false, false, 10);
  92.              bottom.pack_start (new Label (""), true, true, 0); // A fake label
  93.  
  94. -            container.pack_start (top, false, true, 15);
  95. -            container.pack_start (Utils.set_padding (view_manager, 0, 10, 24, 10), true, true, 0);
  96. -            container.pack_start (Utils.set_padding (bottom, 0, 9, 15, 9), false, false, 0);
  97. -            this.add (Utils.set_padding (container, 15, 15, 1, 15));
  98. +            container.pack_start (Utils.set_padding (top, 0, 15, 0, 15), false, true, 15);
  99. +            container.pack_start (Utils.set_padding (center, 0, 3, 24, 3), true, true, 0);
  100. +            container.pack_start (Utils.set_padding (bottom, 0, 24, 15, 24), false, false, 0);
  101. +            this.add (Utils.set_padding (container, 15, 0, 1, 0));
  102.  
  103.              set_modality (Modality.NORMAL_VIEW);
  104.              debug ("Ui setup completed");
  105.  
  106. +            show_padding = true;
  107. +
  108.          }
  109.  
  110.          private void connect_signals () {
  111. @@ -515,7 +546,7 @@
  112.                      count += val;
  113.                      return true;
  114.                      
  115. -                });
  116. +                }, Priority.DEFAULT_IDLE);
  117.              }
  118.  
  119.          }
  120. @@ -547,6 +578,7 @@
  121.  
  122.              switch (modality) {
  123.                  case Modality.NORMAL_VIEW:
  124. +                    category_view.show_sidebar (false);
  125.                      view_manager.move (search_view, -130*columns, 0);
  126.                      view_manager.move (category_view, 130*columns, 0);
  127.                      bottom.show_all ();
  128. @@ -564,9 +596,11 @@
  129.                      view_manager.move (grid_view, columns*130, 0);
  130.                      view_manager.move (search_view, -columns*130, 0);
  131.                      view_manager.move (category_view, 0, 0);
  132. +                    category_view.show_sidebar (true);
  133.                      return;
  134.  
  135.                  case Modality.SEARCH_VIEW:
  136. +                    category_view.show_sidebar (false);
  137.                      view_selector.hide ();
  138.                      bottom.hide (); // Hide the switcher
  139.                      view_manager.move (grid_view, columns*130, 0); // Move the grid_view away
  140.  
  141. === modified file 'src/Widgets/CategoryView.vala'
  142. --- src/Widgets/CategoryView.vala   2011-10-09 13:52:23 +0000
  143. +++ src/Widgets/CategoryView.vala   2011-10-14 16:26:56 +0000
  144. @@ -29,7 +29,10 @@
  145.          private Sidebar category_switcher;
  146.          private Widgets.Grid app_view;
  147.          private Layout layout;
  148. +        private Switcher page_switcher;
  149.          private SlingshotView view;
  150. +        private Label empty_cat_label;
  151. +        private HBox bottom;
  152.  
  153.          private const string ALL_APPLICATIONS = _("All Applications");
  154.          private const string MOST_USED_APPS = _("Most Used Apps");
  155. @@ -44,7 +47,7 @@
  156.              connect_events ();
  157.              category_switcher.select_first ();
  158.  
  159. -            set_size_request (view.columns*130, view.rows * 130 + 190);
  160. +            set_size_request (view.columns*130, view.view_height);
  161.  
  162.          }
  163.  
  164. @@ -52,6 +55,10 @@
  165.  
  166.              container = new HBox (false, 0);
  167.  
  168. +            empty_cat_label = new Label (_("<b><span size=\"larger\">This Category is empty</span></b>"));
  169. +            empty_cat_label.use_markup = true;
  170. +            empty_cat_label.xalign = 0.5f;
  171. +
  172.              category_switcher = new Sidebar ();
  173.              category_switcher.can_focus = false;
  174.              //category_switcher.add_category (ALL_APPLICATIONS);
  175. @@ -64,14 +71,42 @@
  176.  
  177.              app_view = new Widgets.Grid (view.rows, view.columns - 1);
  178.              layout.put (app_view, 0, 0);
  179. -
  180. -            container.pack_start (category_switcher, false, false, 0);
  181. +            layout.put (empty_cat_label, view.rows*130*2, view.columns * 130 / 2);
  182. +
  183. +            // Create the page switcher
  184. +            page_switcher = new Switcher ();
  185. +
  186. +            // A bottom widget to keep the page switcher center
  187. +            bottom = new HBox (false, 0);
  188. +            bottom.pack_start (new Label (""), true, true, 0); // A fake label
  189. +            bottom.pack_start (page_switcher, false, false, 10);
  190. +            bottom.pack_start (new Label (""), true, true, 0); // A fake label
  191. +
  192. +            container.pack_start (new Separator (Orientation.VERTICAL), false, true, 0);
  193.              container.pack_end (layout, true, true, 0);
  194.  
  195.              add (container);
  196.  
  197.          }
  198.  
  199. +        public void show_sidebar (bool show) {
  200. +
  201. +            if (show) {
  202. +                view.show_padding = false;
  203. +                if (category_switcher.get_parent () == null) {
  204. +                    view.center.pack_start (category_switcher, false, false, 0);
  205. +                    category_switcher.show_all ();
  206. +                }
  207. +            } else {
  208. +                if (category_switcher.get_parent () != null) {
  209. +                    view.show_padding = true;
  210. +                    category_switcher.hide ();
  211. +                    view.center.remove (category_switcher);
  212. +                }
  213. +            }
  214. +
  215. +        }
  216. +
  217.          private void connect_events () {
  218.  
  219.              category_switcher.selection_changed.connect ((category) => {
  220. @@ -92,16 +127,27 @@
  221.                  switch (event.direction.to_string ()) {
  222.                      case "GDK_SCROLL_UP":
  223.                      case "GDK_SCROLL_LEFT":
  224. -                        page_left ();
  225. +                        page_switcher.set_active (page_switcher.active - 1);
  226.                          break;
  227.                      case "GDK_SCROLL_DOWN":
  228.                      case "GDK_SCROLL_RIGHT":
  229. -                        page_right ();
  230. +                        page_switcher.set_active (page_switcher.active + 1);
  231.                          break;
  232.                  }
  233.                  return false;
  234.              });
  235.  
  236. +            app_view.new_page.connect (page_switcher.append);
  237. +
  238. +            page_switcher.active_changed.connect (() => {
  239. +
  240. +                if (page_switcher.active > page_switcher.old_active)
  241. +                    page_right (page_switcher.active - page_switcher.old_active);
  242. +                else
  243. +                    page_left (page_switcher.old_active - page_switcher.active);
  244. +
  245. +            });
  246. +
  247.          }
  248.  
  249.          private void add_app (App app) {
  250. @@ -127,6 +173,10 @@
  251.  
  252.          private void show_filtered_apps (string category) {
  253.  
  254. +            page_switcher.clear_children ();
  255. +            page_switcher.append ("1");
  256. +            page_switcher.set_active (0);
  257. +
  258.              app_view.clear ();
  259.  
  260.              if (category == MOST_USED_APPS) {
  261. @@ -137,8 +187,13 @@
  262.  
  263.              } else {
  264.      
  265. -                foreach (App app in view.apps[category])
  266. -                    add_app (app);
  267. +                if (view.apps[category].size == 0) {
  268. +                    layout.move (empty_cat_label, (view.columns - 2)*130/2, view.rows*130 / 2);
  269. +                } else {
  270. +                    layout.move (empty_cat_label, view.columns*130*2, view.rows*130 / 2);
  271. +                    foreach (App app in view.apps[category])
  272. +                        add_app (app);
  273. +                }
  274.  
  275.              }
  276.  
  277. @@ -147,33 +202,49 @@
  278.  
  279.          }
  280.  
  281. -        private void page_left () {
  282. +        private void page_left (int step = 1) {
  283.  
  284.              int columns = app_view.get_page_columns ();
  285.  
  286.              if (current_position < 0) {
  287.  
  288. -                layout.move (app_view, current_position + columns*130, 0);
  289. -                current_position += columns*130;
  290. +                layout.move (app_view, current_position + columns*130*step, 0);
  291. +                current_position += columns*130*step;
  292.  
  293.              }
  294.              
  295.          }
  296.  
  297. -        private void page_right () {
  298. +        private void page_right (int step = 1) {
  299.  
  300.              int columns = app_view.get_page_columns ();
  301.              int pages = app_view.get_n_pages ();
  302.              
  303.              if ((- current_position) < (columns*(pages - 1)*130)) {
  304.  
  305. -                layout.move (app_view, current_position - columns*130, 0);
  306. -                current_position -= columns*130;
  307. +                layout.move (app_view, current_position - columns*130*step, 0);
  308. +                current_position -= columns*130*step;
  309.                      
  310.              }
  311.  
  312.          }
  313.  
  314. +        protected override void drag_begin (Gdk.DragContext context) {
  315. +
  316. +            message ("Test");
  317. +            base.drag_begin (context);
  318. +
  319. +        }
  320. +
  321. +        protected override bool drag_motion (Gdk.DragContext context, int x, int y, uint time) {
  322. +
  323. +            layout.move (app_view, x, 0);
  324. +            message (x.to_string ());
  325. +
  326. +            return true;
  327. +
  328. +        }
  329. +
  330.      }
  331.  
  332.  }
  333.  
  334. === modified file 'src/Widgets/Sidebar.vala'
  335. --- src/Widgets/Sidebar.vala    2011-10-09 13:52:23 +0000
  336. +++ src/Widgets/Sidebar.vala    2011-10-14 16:21:32 +0000
  337. @@ -37,9 +37,9 @@
  338.  
  339.              set_headers_visible (false);
  340.              set_show_expanders (false);
  341. -            set_level_indentation (5);
  342. +            set_level_indentation (8);
  343.  
  344. -            set_size_request (130, -1);
  345. +            set_size_request (151, -1);
  346.              get_style_context ().add_class ("sidebar");
  347.  
  348.              var cell = new CellRendererText ();
Add Comment
Please, Sign In to add comment