[gnome-latex] Use "win.tepl-goto-line" GAction
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex] Use "win.tepl-goto-line" GAction
- Date: Sat, 25 Apr 2020 13:46:22 +0000 (UTC)
commit 34ba01b3675c31f24cce55df1d453befdd0bee32
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Apr 24 17:15:45 2020 +0200
Use "win.tepl-goto-line" GAction
The magic all happens in Tepl.
src/main_window.vala | 20 +++-----------
src/search.vala | 74 ----------------------------------------------------
2 files changed, 4 insertions(+), 90 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index f4b9e29..34f75a7 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -43,8 +43,6 @@ public class MainWindow : ApplicationWindow
N_("Search for text"), on_search_find },
{ "SearchReplace", "edit-find-replace", N_("Find and _Replace"), "<Control>H",
N_("Search for and replace text"), on_search_replace },
- { "SearchGoToLine", "go-jump", N_("_Go to Line…"), "<Control>L",
- N_("Go to a specific line"), on_search_goto_line },
{ "SearchForward", null, N_("_Jump to PDF"), "<Control><Alt>F",
N_("Jump to the associated position in the PDF file. Another shortcut: Ctrl+click, which works
in both directions."),
on_search_forward },
@@ -85,7 +83,6 @@ public class MainWindow : ApplicationWindow
public string default_location = Environment.get_home_dir ();
private DocumentsPanel _documents_panel;
private Tepl.Statusbar _statusbar;
- private GotoLine _goto_line;
private SearchAndReplace _search_and_replace;
private Tepl.Panel _side_panel;
private Paned _main_hpaned;
@@ -223,7 +220,7 @@ public class MainWindow : ApplicationWindow
_vpaned.show ();
_main_hpaned.add2 (_vpaned);
- /* Vertical grid: documents, goto line, search and replace */
+ /* Vertical grid: documents, search and replace */
Grid docs_vgrid = new Grid ();
docs_vgrid.orientation = Orientation.VERTICAL;
@@ -234,10 +231,6 @@ public class MainWindow : ApplicationWindow
init_documents_panel ();
docs_vgrid.add (_documents_panel);
- // Goto Line
- _goto_line = new GotoLine (this);
- docs_vgrid.add (_goto_line);
-
// Search and Replace
_search_and_replace = new SearchAndReplace (this);
docs_vgrid.add (_search_and_replace.get_widget ());
@@ -269,7 +262,6 @@ public class MainWindow : ApplicationWindow
if (this.active_tab == null)
{
- _goto_line.hide ();
_search_and_replace.hide ();
}
@@ -326,6 +318,9 @@ public class MainWindow : ApplicationWindow
_action_group.add_actions (_action_entries, this);
_action_group.add_toggle_actions (_toggle_action_entries, this);
+ Amtk.utils_create_gtk_action (this, "win.tepl-goto-line",
+ _action_group, "SearchGoToLine");
+
_latex_action_group = new LatexMenu (this);
_ui_manager = new UIManager ();
@@ -962,7 +957,6 @@ public class MainWindow : ApplicationWindow
"ViewZoomReset",
"SearchFind",
"SearchReplace",
- "SearchGoToLine",
"SearchForward",
"ProjectsConfigCurrent"
};
@@ -1049,12 +1043,6 @@ public class MainWindow : ApplicationWindow
_search_and_replace.show_search_and_replace ();
}
- public void on_search_goto_line ()
- {
- return_if_fail (active_tab != null);
- _goto_line.show ();
- }
-
public void on_search_forward ()
{
return_if_fail (active_tab != null);
diff --git a/src/search.vala b/src/search.vala
index 4736304..7a45de2 100644
--- a/src/search.vala
+++ b/src/search.vala
@@ -19,80 +19,6 @@
using Gtk;
-public class GotoLine : Grid
-{
- private unowned MainWindow main_window;
- private Entry entry;
-
- public GotoLine (MainWindow main_window)
- {
- orientation = Orientation.HORIZONTAL;
- set_column_spacing (3);
- this.main_window = main_window;
-
- Button close_button = new Button ();
- add (close_button);
- close_button.set_relief (ReliefStyle.NONE);
- Image img = new Image.from_icon_name ("window-close", IconSize.MENU);
- close_button.add (img);
- close_button.clicked.connect (() => hide ());
-
- Label label = new Label (_("Go to Line:"));
- label.margin_start = 2;
- label.margin_end = 2;
- add (label);
-
- entry = new Entry ();
- add (entry);
- Icon icon = new ThemedIcon.with_default_fallbacks ("go-jump-symbolic");
- entry.set_icon_from_gicon (EntryIconPosition.SECONDARY, icon);
- entry.set_icon_activatable (EntryIconPosition.SECONDARY, true);
- entry.set_tooltip_text (_("Line you want to move the cursor to"));
- entry.set_size_request (100, -1);
- entry.activate.connect (() => hide ());
- entry.icon_press.connect (() => hide ());
- entry.changed.connect (on_changed);
- }
-
- public new void show ()
- {
- entry.text = "";
- show_all ();
- entry.grab_focus ();
- }
-
- private void on_changed ()
- {
- StyleContext style_context = entry.get_style_context ();
-
- if (entry.text_length == 0)
- {
- style_context.remove_class (STYLE_CLASS_ERROR);
- return;
- }
-
- string text = entry.get_text ();
-
- // check if all characters are digits
- for (int i = 0; i < text.length; i++)
- {
- unichar c = text[i];
- if (!c.isdigit ())
- {
- style_context.add_class (STYLE_CLASS_ERROR);
- return;
- }
- }
-
- int line = int.parse (text) - 1;
-
- if (main_window.active_view.goto_line (line))
- style_context.remove_class (STYLE_CLASS_ERROR);
- else
- style_context.add_class (STYLE_CLASS_ERROR);
- }
-}
-
public class SearchAndReplace : GLib.Object
{
private unowned MainWindow _main_window;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]