Skip to content
Merged
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
72 changes: 25 additions & 47 deletions src/Widgets/SourceView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -578,72 +578,50 @@ namespace Scratch.Widgets {
private void on_context_menu (Gtk.Menu menu) {
scroll_mark_onscreen (buffer.get_mark ("insert"));

var sort_item = new Gtk.MenuItem ();
sort_item.sensitive = get_selected_line_count () > 1;
sort_item.add (new Granite.AccelLabel.from_action_name (
_("Sort Selected Lines"),
MainWindow.ACTION_PREFIX + MainWindow.ACTION_SORT_LINES
));
sort_item.activate.connect (sort_selected_lines);

menu.add (sort_item);
var sort_item = new Gtk.MenuItem.with_label (_("Sort Lines")) {
action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_SORT_LINES
};

var add_edit_item = new Gtk.MenuItem () {
var add_edit_item = new Gtk.MenuItem.with_label (_("Mark Line")) {
action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_ADD_MARK
};
add_edit_item.add (new Granite.AccelLabel.from_action_name (
_("Mark Current Line"),
add_edit_item.action_name

));
menu.add (add_edit_item);

var previous_edit_item = new Gtk.MenuItem () {
sensitive = navmark_gutter_renderer.has_marks,
var previous_edit_item = new Gtk.MenuItem.with_label (_("Previous Mark")) {
action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_PREVIOUS_MARK
};
previous_edit_item.add (new Granite.AccelLabel.from_action_name (
_("Goto Previous Edit Mark"),
previous_edit_item.action_name

));
menu.add (previous_edit_item);

var next_edit_item = new Gtk.MenuItem () {
sensitive = navmark_gutter_renderer.has_marks,
var next_edit_item = new Gtk.MenuItem.with_label (_("Next Mark")) {
action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_NEXT_MARK
};
next_edit_item.add (new Granite.AccelLabel.from_action_name (
_("Goto Next Edit Mark"),
next_edit_item.action_name

));
menu.add (sort_item);
menu.add (add_edit_item);
menu.add (previous_edit_item);
menu.add (next_edit_item);

if (!navmark_gutter_renderer.has_marks) {
previous_edit_item.action_name = "";
previous_edit_item.sensitive = false;
next_edit_item.action_name = "";
next_edit_item.sensitive = false;
}

if (buffer is Gtk.SourceBuffer) {
var can_comment = CommentToggler.language_has_comments (((Gtk.SourceBuffer) buffer).get_language ());
var comment_item = new Gtk.MenuItem.with_label (_("Toggle Comment")) {
action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_COMMENT
};

var comment_item = new Gtk.MenuItem ();
comment_item.sensitive = can_comment;
comment_item.add (new Granite.AccelLabel.from_action_name (
_("Toggle Comment"),
MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_COMMENT
));
comment_item.activate.connect (() => {
CommentToggler.toggle_comment ((Gtk.SourceBuffer) buffer);
});
var can_comment = CommentToggler.language_has_comments (((Gtk.SourceBuffer) buffer).get_language ());
if (!can_comment) {
comment_item.action_name = "";
}

menu.add (comment_item);
}

menu.show_all ();

if (!(get_selected_line_count () > 1)) {
sort_item.action_name = "";
}

if (!navmark_gutter_renderer.has_marks) {
previous_edit_item.action_name = "";
next_edit_item.action_name = "";
}
}

private static int calculate_bottom_margin (int height_in_px) {
Expand Down