Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data/icons/git-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion data/io.elementary.code.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/io/elementary/code">
<file alias="Application.css" compressed="true">Application.css</file>
<file alias="git.svg" compressed="true" preprocess="xml-stripblanks">icons/48/git.svg</file>
<file alias="lang-class-abstract.svg" compressed="true" preprocess="xml-stripblanks">icons/SymbolOutline/abstractclass.svg</file>
<file alias="lang-method-abstract.svg" compressed="true" preprocess="xml-stripblanks">icons/SymbolOutline/abstractmethod.svg</file>
<file alias="lang-property-abstract.svg" compressed="true" preprocess="xml-stripblanks">icons/SymbolOutline/abstractproperty.svg</file>
Expand Down Expand Up @@ -30,8 +29,10 @@
<file alias="scalable/actions/panel-right-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/panel-right-symbolic.svg</file>
</gresource>
<gresource prefix="/io/elementary/code/icons">
<file alias="48x48/actions/git.svg" compressed="true" preprocess="xml-stripblanks">icons/48/git.svg</file>
<file alias="48x48/actions/open-project.svg" compressed="true" preprocess="xml-stripblanks">icons/48/open-project.svg</file>
<file alias="scalable/actions/filter-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/filter-symbolic.svg</file>
<file alias="scalable/actions/git-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/git-symbolic.svg</file>
<file alias="scalable/emblems/emblem-git-modified-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/emblem-git-modified-symbolic.svg</file>
<file alias="scalable/emblems/emblem-git-new-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/emblem-git-new-symbolic.svg</file>
</gresource>
Expand Down
11 changes: 0 additions & 11 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,4 @@ namespace Scratch.Utils {
warning ("Accelerators were not found for the action: %s", detailed_action_name);
return "";
}

public Gtk.Button make_button_with_icon_and_label (string icon_name, string text) {
var box = new Gtk.Box (HORIZONTAL, 3);
var image = new Gtk.Image.from_icon_name (icon_name, BUTTON);
var label = new Gtk.Label (text);
box.add (image);
box.add (label);
return new Gtk.Button () {
child = box
};
}
}
14 changes: 14 additions & 0 deletions src/Widgets/ChooseProjectButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,23 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {

project_scrolled.add (project_listbox);

var add_folder_button = new PopoverMenuItem (_("Open Folder…")) {
action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_FOLDER,
action_target = new Variant.string (""),
icon_name = "folder-open-symbolic"
};

var clone_button = new PopoverMenuItem (_("Clone Git Repository…")) {
action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_CLONE_REPO,
icon_name = "git-symbolic"
};

var popover_content = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
popover_content.add (project_filter);
popover_content.add (project_scrolled);
popover_content.add (new Gtk.Separator (HORIZONTAL));
popover_content.add (add_folder_button);
popover_content.add (clone_button);

popover_content.show_all ();

Expand Down
48 changes: 48 additions & 0 deletions src/Widgets/PopoverMenuItem.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-FileCopyrightText: 2017-2023 elementary, Inc. (https://elementary.io)
*/

public class Code.PopoverMenuItem : Gtk.Button {
/**
* The label for the button
*/
public string text { get; construct; }

/**
* The icon name for the button
*/
public string icon_name { get; set; }

public PopoverMenuItem (string text) {
Object (text: text);
}

class construct {
set_css_name ("modelbutton");
}

construct {
var image = new Gtk.Image ();

var label = new Granite.AccelLabel (text);

var box = new Gtk.Box (HORIZONTAL, 6);
box.add (image);
box.add (label);

child = box;

get_accessible ().accessible_role = MENU_ITEM;

clicked.connect (() => {
var popover = (Gtk.Popover) get_ancestor (typeof (Gtk.Popover));
if (popover != null) {
popover.popdown ();
}
});

bind_property ("action-name", label, "action-name");
bind_property ("icon-name", image, "icon-name");
}
}
29 changes: 7 additions & 22 deletions src/Widgets/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ public class Code.Sidebar : Gtk.Grid {
var actionbar = new Gtk.ActionBar ();
actionbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);

var add_folder_button = Scratch.Utils.make_button_with_icon_and_label ("folder-open-symbolic", _("Open…"));
add_folder_button.action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_FOLDER;
add_folder_button.action_target = new Variant.string ("");

var clone_button = Scratch.Utils.make_button_with_icon_and_label ("folder-download-symbolic", _("Clone…"));
clone_button.action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_CLONE_REPO;

var collapse_all_menu_item = new GLib.MenuItem (_("Collapse All"), Scratch.MainWindow.ACTION_PREFIX
+ Scratch.MainWindow.ACTION_COLLAPSE_ALL_FOLDERS);

Expand All @@ -74,23 +67,15 @@ public class Code.Sidebar : Gtk.Grid {
project_menu.append_item (order_projects_menu_item);
project_menu_model = project_menu;

var project_more_button = new Gtk.MenuButton ();
project_more_button.image = new Gtk.Image.from_icon_name ("view-more-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
project_more_button.use_popover = false;
project_more_button.menu_model = project_menu_model;
project_more_button.tooltip_text = _("Manage project folders");

var tool_flowbox = new Gtk.FlowBox () {
orientation = HORIZONTAL,
var project_more_button = new Gtk.MenuButton () {
hexpand = true,
selection_mode = NONE,
column_spacing = 0,
max_children_per_line = 2
use_popover = false,
menu_model = project_menu_model,
label = _("Manage project folders…"),
xalign = 0.0f
};
tool_flowbox.add (add_folder_button);
tool_flowbox.add (clone_button);
actionbar.add (tool_flowbox);
actionbar.pack_end (project_more_button);

actionbar.pack_start (project_more_button);

add (headerbar);
add (stack_switcher);
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ code_files = files(
'Widgets/HeaderBar.vala',
'Widgets/Sidebar.vala',
'Widgets/PaneSwitcher.vala',
'Widgets/PopoverMenuItem.vala',
'Widgets/SearchBar.vala',
'Widgets/SourceList/CellRendererBadge.vala',
'Widgets/SourceList/CellRendererExpander.vala',
Expand Down