Skip to content
Merged
23 changes: 23 additions & 0 deletions src/FolderManager/FileView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ namespace Scratch.FolderManager {
write_settings ();
}

public void collapse_all () {
foreach (var child in root.children) {
(child as ProjectFolderItem).collapse_all ();
}
}

public void order_folders () {
var list = new Gee.ArrayList<ProjectFolderItem> ();

foreach (var child in root.children) {
root.remove (child as ProjectFolderItem);
list.add (child as ProjectFolderItem);
}

list.sort ( (a, b) => {
return a.name.down () > b.name.down () ? 0 : -1;
});

foreach (var item in list) {
root.add (item);
}
}

public void select_path (string path) {
selected = find_path (root, path);
}
Expand Down
12 changes: 12 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace Scratch {
public const string ACTION_FIND_PREVIOUS = "action_find_previous";
public const string ACTION_OPEN = "action_open";
public const string ACTION_OPEN_FOLDER = "action_open_folder";
public const string ACTION_COLLAPSE_ALL_FOLDERS = "action_collapse_all_folders";
public const string ACTION_ORDER_FOLDERS = "action_order_folders";
public const string ACTION_GO_TO = "action_go_to";
public const string ACTION_NEW_VIEW = "action_new_view";
public const string ACTION_SORT_LINES = "action_sort_lines";
Expand Down Expand Up @@ -97,6 +99,8 @@ namespace Scratch {
{ ACTION_FIND_PREVIOUS, action_find_previous },
{ ACTION_OPEN, action_open },
{ ACTION_OPEN_FOLDER, action_open_folder },
{ ACTION_COLLAPSE_ALL_FOLDERS, action_collapse_all_folders },
{ ACTION_ORDER_FOLDERS, action_order_folders },
{ ACTION_PREFERENCES, action_preferences },
{ ACTION_REVERT, action_revert },
{ ACTION_SAVE, action_save },
Expand Down Expand Up @@ -815,6 +819,14 @@ namespace Scratch {
chooser.destroy ();
}

private void action_collapse_all_folders () {
folder_manager_view.collapse_all ();
}

private void action_order_folders () {
folder_manager_view.order_folders ();
}

private void action_save () {
var doc = get_current_document (); /* may return null */
if (doc != null) {
Expand Down
30 changes: 25 additions & 5 deletions src/Widgets/Pane.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,32 @@ public class Code.Pane : Gtk.Grid {
toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);
toolbar.icon_size = Gtk.IconSize.SMALL_TOOLBAR;

var add_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("folder-open-symbolic", Gtk.IconSize.BUTTON), null);
add_button.action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_FOLDER;
add_button.tooltip_text = _("Add Project Folder…");
var add_folder_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("folder-open-symbolic", Gtk.IconSize.BUTTON), null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we're setting this to a symbolic icon, but for some reason it's not rendering as symbolic… any idea what's up here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danrabbit mentioned this is due to the stylesheet, and not something within Code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint: Long line

add_folder_button.action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_FOLDER;
add_folder_button.tooltip_text = _("Add Project Folder…");

toolbar.add (add_button);
var project_more_button = new Gtk.MenuToolButton (null, null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect a "open-menu" symbolic icon rather than the default down arrow which I associate with downloading or a combobox. A "hamburger" type icon would be nice but I am not sure that one is available.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just using the default icon which I believe is used in other similar "dropdown" contexts, but I'd be fine to change to something else. I wanted to avoid using a settings-type icon because this is not necessarily settings, it's actions. view-more-symbolic might work. Thoughts from @elementary/ux?

project_more_button.tooltip_text = _("Manage project folders…");

var collapse_all_menu_item = new Gtk.MenuItem.with_label (_("Collapse All"));
collapse_all_menu_item.action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_COLLAPSE_ALL_FOLDERS;

var order_projects_menu_item = new Gtk.MenuItem.with_label (_("Alphabetize"));
order_projects_menu_item.action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_ORDER_FOLDERS;

var project_menu = new Gtk.Menu ();
project_menu.append (collapse_all_menu_item);
project_menu.append (order_projects_menu_item);
project_menu.show_all ();
project_more_button.set_menu (project_menu);

var separator_tool_item = new Gtk.SeparatorToolItem ();
separator_tool_item.set_expand (true);
separator_tool_item.draw = false;

toolbar.add (add_folder_button);
toolbar.add (separator_tool_item);
toolbar.add (project_more_button);

add (stack_switcher);
add (stack);
Expand Down Expand Up @@ -88,4 +109,3 @@ public class Code.Pane : Gtk.Grid {
});
}
}