Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === modified file 'src/SlingshotView.vala'
- --- src/SlingshotView.vala 2011-10-12 19:59:16 +0000
- +++ src/SlingshotView.vala 2011-10-14 16:26:16 +0000
- @@ -42,14 +42,36 @@
- private Gtk.Window window;
- public Switcher page_switcher;
- public ModeButton view_selector;
- - public HBox bottom;
- // Views
- public Widgets.Grid grid_view;
- public SearchView search_view;
- public CategoryView category_view;
- - private VBox container;
- + private HBox padding;
- + private bool _show_padding;
- + public bool show_padding {
- + get {
- + return _show_padding;
- + }
- + set {
- + if (value) {
- + if (padding.get_parent () == null) {
- + center.pack_start (padding, false, false, 0);
- + padding.show_all ();
- + }
- + } else {
- + if (padding.get_parent () != null)
- + center.remove (padding);
- + }
- + _show_padding = value;
- + }
- + }
- +
- + private HBox top;
- + public HBox center;
- + public HBox bottom;
- + public VBox container;
- public AppSystem app_system;
- private ArrayList<TreeDirectory> categories;
- @@ -73,6 +95,12 @@
- private int default_columns;
- private int default_rows;
- + public int view_height {
- + get {
- + return (int) (rows*130 + rows*grid_view.row_spacing + 35);
- + }
- + }
- +
- public SlingshotView (Slingshot app) {
- // Window properties
- @@ -111,6 +139,9 @@
- private void setup_ui () {
- + padding = new HBox (false, 0);
- + padding.width_request = 22;
- +
- debug ("In setup_ui ()");
- window = new Gtk.Window ();
- window.get_style_context ().add_class ("slingshot");
- @@ -119,7 +150,7 @@
- container = new VBox (false, 0);
- // Add top bar
- - var top = new HBox (false, 10);
- + top = new HBox (false, 10);
- view_selector = new ModeButton ();
- view_selector.append (new Image.from_icon_name ("slingshot-view-list-icons-symbolic", IconSize.MENU));
- @@ -135,12 +166,10 @@
- }
- top.pack_end (searchbar, false, false, 0);
- + center = new HBox (false, 0);
- // Create the layout which works like view_manager
- view_manager = new Layout (null, null);
- -
- - // Get the current size of the view
- - int width, height;
- - get_size (out width, out height);
- + center.pack_end (Utils.set_padding (view_manager, 0, 22, 0, 0), true, true, 0);
- // Create the "NORMAL_VIEW"
- grid_view = new Widgets.Grid (default_rows, default_columns);
- @@ -166,14 +195,16 @@
- bottom.pack_start (page_switcher, false, false, 10);
- bottom.pack_start (new Label (""), true, true, 0); // A fake label
- - container.pack_start (top, false, true, 15);
- - container.pack_start (Utils.set_padding (view_manager, 0, 10, 24, 10), true, true, 0);
- - container.pack_start (Utils.set_padding (bottom, 0, 9, 15, 9), false, false, 0);
- - this.add (Utils.set_padding (container, 15, 15, 1, 15));
- + container.pack_start (Utils.set_padding (top, 0, 15, 0, 15), false, true, 15);
- + container.pack_start (Utils.set_padding (center, 0, 3, 24, 3), true, true, 0);
- + container.pack_start (Utils.set_padding (bottom, 0, 24, 15, 24), false, false, 0);
- + this.add (Utils.set_padding (container, 15, 0, 1, 0));
- set_modality (Modality.NORMAL_VIEW);
- debug ("Ui setup completed");
- + show_padding = true;
- +
- }
- private void connect_signals () {
- @@ -515,7 +546,7 @@
- count += val;
- return true;
- - });
- + }, Priority.DEFAULT_IDLE);
- }
- }
- @@ -547,6 +578,7 @@
- switch (modality) {
- case Modality.NORMAL_VIEW:
- + category_view.show_sidebar (false);
- view_manager.move (search_view, -130*columns, 0);
- view_manager.move (category_view, 130*columns, 0);
- bottom.show_all ();
- @@ -564,9 +596,11 @@
- view_manager.move (grid_view, columns*130, 0);
- view_manager.move (search_view, -columns*130, 0);
- view_manager.move (category_view, 0, 0);
- + category_view.show_sidebar (true);
- return;
- case Modality.SEARCH_VIEW:
- + category_view.show_sidebar (false);
- view_selector.hide ();
- bottom.hide (); // Hide the switcher
- view_manager.move (grid_view, columns*130, 0); // Move the grid_view away
- === modified file 'src/Widgets/CategoryView.vala'
- --- src/Widgets/CategoryView.vala 2011-10-09 13:52:23 +0000
- +++ src/Widgets/CategoryView.vala 2011-10-14 16:26:56 +0000
- @@ -29,7 +29,10 @@
- private Sidebar category_switcher;
- private Widgets.Grid app_view;
- private Layout layout;
- + private Switcher page_switcher;
- private SlingshotView view;
- + private Label empty_cat_label;
- + private HBox bottom;
- private const string ALL_APPLICATIONS = _("All Applications");
- private const string MOST_USED_APPS = _("Most Used Apps");
- @@ -44,7 +47,7 @@
- connect_events ();
- category_switcher.select_first ();
- - set_size_request (view.columns*130, view.rows * 130 + 190);
- + set_size_request (view.columns*130, view.view_height);
- }
- @@ -52,6 +55,10 @@
- container = new HBox (false, 0);
- + empty_cat_label = new Label (_("<b><span size=\"larger\">This Category is empty</span></b>"));
- + empty_cat_label.use_markup = true;
- + empty_cat_label.xalign = 0.5f;
- +
- category_switcher = new Sidebar ();
- category_switcher.can_focus = false;
- //category_switcher.add_category (ALL_APPLICATIONS);
- @@ -64,14 +71,42 @@
- app_view = new Widgets.Grid (view.rows, view.columns - 1);
- layout.put (app_view, 0, 0);
- -
- - container.pack_start (category_switcher, false, false, 0);
- + layout.put (empty_cat_label, view.rows*130*2, view.columns * 130 / 2);
- +
- + // Create the page switcher
- + page_switcher = new Switcher ();
- +
- + // A bottom widget to keep the page switcher center
- + bottom = new HBox (false, 0);
- + bottom.pack_start (new Label (""), true, true, 0); // A fake label
- + bottom.pack_start (page_switcher, false, false, 10);
- + bottom.pack_start (new Label (""), true, true, 0); // A fake label
- +
- + container.pack_start (new Separator (Orientation.VERTICAL), false, true, 0);
- container.pack_end (layout, true, true, 0);
- add (container);
- }
- + public void show_sidebar (bool show) {
- +
- + if (show) {
- + view.show_padding = false;
- + if (category_switcher.get_parent () == null) {
- + view.center.pack_start (category_switcher, false, false, 0);
- + category_switcher.show_all ();
- + }
- + } else {
- + if (category_switcher.get_parent () != null) {
- + view.show_padding = true;
- + category_switcher.hide ();
- + view.center.remove (category_switcher);
- + }
- + }
- +
- + }
- +
- private void connect_events () {
- category_switcher.selection_changed.connect ((category) => {
- @@ -92,16 +127,27 @@
- switch (event.direction.to_string ()) {
- case "GDK_SCROLL_UP":
- case "GDK_SCROLL_LEFT":
- - page_left ();
- + page_switcher.set_active (page_switcher.active - 1);
- break;
- case "GDK_SCROLL_DOWN":
- case "GDK_SCROLL_RIGHT":
- - page_right ();
- + page_switcher.set_active (page_switcher.active + 1);
- break;
- }
- return false;
- });
- + app_view.new_page.connect (page_switcher.append);
- +
- + page_switcher.active_changed.connect (() => {
- +
- + if (page_switcher.active > page_switcher.old_active)
- + page_right (page_switcher.active - page_switcher.old_active);
- + else
- + page_left (page_switcher.old_active - page_switcher.active);
- +
- + });
- +
- }
- private void add_app (App app) {
- @@ -127,6 +173,10 @@
- private void show_filtered_apps (string category) {
- + page_switcher.clear_children ();
- + page_switcher.append ("1");
- + page_switcher.set_active (0);
- +
- app_view.clear ();
- if (category == MOST_USED_APPS) {
- @@ -137,8 +187,13 @@
- } else {
- - foreach (App app in view.apps[category])
- - add_app (app);
- + if (view.apps[category].size == 0) {
- + layout.move (empty_cat_label, (view.columns - 2)*130/2, view.rows*130 / 2);
- + } else {
- + layout.move (empty_cat_label, view.columns*130*2, view.rows*130 / 2);
- + foreach (App app in view.apps[category])
- + add_app (app);
- + }
- }
- @@ -147,33 +202,49 @@
- }
- - private void page_left () {
- + private void page_left (int step = 1) {
- int columns = app_view.get_page_columns ();
- if (current_position < 0) {
- - layout.move (app_view, current_position + columns*130, 0);
- - current_position += columns*130;
- + layout.move (app_view, current_position + columns*130*step, 0);
- + current_position += columns*130*step;
- }
- }
- - private void page_right () {
- + private void page_right (int step = 1) {
- int columns = app_view.get_page_columns ();
- int pages = app_view.get_n_pages ();
- if ((- current_position) < (columns*(pages - 1)*130)) {
- - layout.move (app_view, current_position - columns*130, 0);
- - current_position -= columns*130;
- + layout.move (app_view, current_position - columns*130*step, 0);
- + current_position -= columns*130*step;
- }
- }
- + protected override void drag_begin (Gdk.DragContext context) {
- +
- + message ("Test");
- + base.drag_begin (context);
- +
- + }
- +
- + protected override bool drag_motion (Gdk.DragContext context, int x, int y, uint time) {
- +
- + layout.move (app_view, x, 0);
- + message (x.to_string ());
- +
- + return true;
- +
- + }
- +
- }
- }
- === modified file 'src/Widgets/Sidebar.vala'
- --- src/Widgets/Sidebar.vala 2011-10-09 13:52:23 +0000
- +++ src/Widgets/Sidebar.vala 2011-10-14 16:21:32 +0000
- @@ -37,9 +37,9 @@
- set_headers_visible (false);
- set_show_expanders (false);
- - set_level_indentation (5);
- + set_level_indentation (8);
- - set_size_request (130, -1);
- + set_size_request (151, -1);
- get_style_context ().add_class ("sidebar");
- var cell = new CellRendererText ();
Add Comment
Please, Sign In to add comment