[latexila] Create TabLabel class, a subclass of TeplTabLabel
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Create TabLabel class, a subclass of TeplTabLabel
- Date: Sat, 12 Aug 2017 13:18:58 +0000 (UTC)
commit ce498ff22ce21a464975473bec258c91da96f293
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Aug 12 14:40:55 2017 +0200
Create TabLabel class, a subclass of TeplTabLabel
po/POTFILES.in | 1 +
po/POTFILES.skip | 1 +
src/Makefile.am | 1 +
src/document_tab.vala | 44 ++------------------------------
src/tab_label.vala | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 73 insertions(+), 41 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 176ec7b..51b6488 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -62,6 +62,7 @@ src/structure_model.vala
src/structure.vala
src/symbols.vala
src/symbols_view.vala
+src/tab_label.vala
[type: gettext/glade]src/ui/menus.ui
[type: gettext/glade]src/ui/preferences_dialog.ui
src/utils.vala
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index b1f56b6..443f15d 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -43,6 +43,7 @@ src/structure_model.c
src/symbols.c
src/symbols_view.c
src/synctex.c
+src/tab_label.c
src/templates.c
src/templates_dialogs.c
src/utils.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 0b75eee..b916083 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,6 +60,7 @@ vala_files = \
structure.vala \
symbols.vala \
symbols_view.vala \
+ tab_label.vala \
utils.vala
latexila_SOURCES = \
diff --git a/src/document_tab.vala b/src/document_tab.vala
index a337ff7..68c43d5 100644
--- a/src/document_tab.vala
+++ b/src/document_tab.vala
@@ -31,7 +31,7 @@ public class DocumentTab : Tepl.Tab
get { return get_buffer () as Document; }
}
- private Tepl.TabLabel _label;
+ private TabLabel _label;
private bool ask_if_externally_modified = false;
@@ -123,15 +123,11 @@ public class DocumentTab : Tepl.Tab
{
document.tab = this;
- document.notify["location"].connect (update_label_tooltip);
- document.notify["project-id"].connect (update_label_tooltip);
-
document_view.focus_in_event.connect (view_focused_in);
view.show_all ();
- _label = new Tepl.TabLabel (this);
- update_label_tooltip ();
+ _label = new TabLabel (this);
_label.show ();
/* auto save */
@@ -151,45 +147,11 @@ public class DocumentTab : Tepl.Tab
});
}
- public Tepl.TabLabel get_label ()
+ public TabLabel get_label ()
{
return _label;
}
- private void update_label_tooltip ()
- {
- if (document.location == null)
- {
- _label.tooltip_markup = "";
- return;
- }
-
- _label.tooltip_markup = document.get_uri_for_display ();
-
- Project? project = document.get_project ();
- if (project == null)
- return;
-
- if (project.main_file.equal (document.location))
- _label.tooltip_markup += "\n<b>" + _("Project main file") + "</b>";
- else
- _label.tooltip_markup += "\n<b>" + _("Project main file:") + "</b> "
- + get_main_file_relative_path ();
- }
-
- private string? get_main_file_relative_path ()
- {
- Project? project = document.get_project ();
- if (project == null)
- return null;
-
- File origin = document.location;
- File target = project.main_file;
- File common_dir = project.directory;
-
- return Utils.get_relative_path (origin, target, common_dir);
- }
-
public string get_menu_tip ()
{
return _("Activate '%s'").printf (document.get_uri_for_display ());
diff --git a/src/tab_label.vala b/src/tab_label.vala
new file mode 100644
index 0000000..39e5703
--- /dev/null
+++ b/src/tab_label.vala
@@ -0,0 +1,67 @@
+/*
+ * This file is part of LaTeXila.
+ *
+ * Copyright © 2017 Sébastien Wilmet
+ *
+ * LaTeXila is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LaTeXila is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LaTeXila. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+public class TabLabel : Tepl.TabLabel
+{
+ public TabLabel (DocumentTab tab)
+ {
+ Object (tab: tab);
+
+ Document doc = tab.get_buffer () as Document;
+ doc.notify["project-id"].connect (update_tooltip);
+ }
+
+ public override string get_tooltip_markup ()
+ {
+ string base_tooltip = base.get_tooltip_markup ();
+
+ Document doc = tab.get_buffer () as Document;
+ File? location = doc.get_file ().get_location ();
+ if (location == null)
+ return base_tooltip;
+
+ Project? project = doc.get_project ();
+ if (project == null)
+ return base_tooltip;
+
+ if (base_tooltip == null)
+ base_tooltip = "";
+
+ if (project.main_file.equal (location))
+ return base_tooltip + Markup.printf_escaped ("\n<b>%s</b>",
+ _("Project main file"));
+
+ return base_tooltip + Markup.printf_escaped ("\n<b>%s</b> %s",
+ _("Project main file:"), get_main_file_relative_path ());
+ }
+
+ private string? get_main_file_relative_path ()
+ {
+ Document doc = tab.get_buffer () as Document;
+ Project? project = doc.get_project ();
+ if (project == null)
+ return "";
+
+ File origin = doc.get_file ().get_location ();
+ File target = project.main_file;
+ File common_dir = project.directory;
+
+ return Utils.get_relative_path (origin, target, common_dir);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]