[glom/gtkmm4v4] Revert "gtkmm4: Remove use of gtksourceview, regrettably."
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/gtkmm4v4] Revert "gtkmm4: Remove use of gtksourceview, regrettably."
- Date: Sat, 10 Feb 2018 14:56:51 +0000 (UTC)
commit 19a672d31c90dd4716c1ab860825c1c86f83b5d1
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Feb 10 15:48:30 2018 +0100
Revert "gtkmm4: Remove use of gtksourceview, regrettably."
This reverts commit a6f98b7b2524f9e6b09afc2c0b6ae755741a5ff1.
Because gtksourceview and gtksourceviewmm now have versions for GTK+ 4.
configure.ac | 5 ++---
.../ui/developer/dialog_database_preferences.glade | 3 ++-
data/ui/developer/dialog_script_library.glade | 3 ++-
data/ui/developer/window_button_script.glade | 3 ++-
data/ui/developer/window_field_calculation.glade | 3 ++-
.../developer/window_field_definition_edit.glade | 3 ++-
glom/main.cc | 2 ++
glom/mode_design/dialog_database_preferences.cc | 17 ++++++++++++++---
glom/mode_design/dialog_database_preferences.h | 4 ++--
glom/mode_design/fields/dialog_fieldcalculation.cc | 16 +++++++++++++---
glom/mode_design/fields/dialog_fieldcalculation.h | 4 ++--
glom/mode_design/fields/dialog_fielddefinition.h | 4 ++--
.../layout_item_dialogs/dialog_buttonscript.cc | 17 ++++++++++++++---
.../layout_item_dialogs/dialog_buttonscript.h | 5 +++--
.../script_library/dialog_script_library.cc | 15 ++++++++++++---
.../script_library/dialog_script_library.h | 4 ++--
tests/ui/glade_toplevels_instantiation.cc | 2 ++
tests/ui/test_glade_derived_instantiation.cc | 2 ++
18 files changed, 82 insertions(+), 30 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e106997..0c7ded2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -174,9 +174,8 @@ AS_IF([test "x$glom_enable_client_only" != xyes && test "x$glom_host_win32" != x
[REQUIRED_GLOM_LIBS="$REQUIRED_GLOM_LIBS iso-codes"])
# Do not require gtksourceviewmm in client only mode
-# TODO: Re-enable this when there is a version of gtksourceview that builds with GTK+-4.0:
-#AS_IF([test "x$glom_enable_client_only" != xyes],
-# [REQUIRED_GLOM_LIBS="$REQUIRED_GLOM_LIBS gtksourceviewmm-4.0 >= 3.18.0"])
+AS_IF([test "x$glom_enable_client_only" != xyes],
+ [REQUIRED_GLOM_LIBS="$REQUIRED_GLOM_LIBS gtksourceviewmm-4.0 >= 3.18.0"])
AS_IF([test "x$glom_enable_sqlite" = xyes],
[REQUIRED_GLOM_LIBS="$REQUIRED_GLOM_LIBS libgda-sqlite-6.0"])
diff --git a/data/ui/developer/dialog_database_preferences.glade
b/data/ui/developer/dialog_database_preferences.glade
index 9892cf1..3381f3a 100644
--- a/data/ui/developer/dialog_database_preferences.glade
+++ b/data/ui/developer/dialog_database_preferences.glade
@@ -2,6 +2,7 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.6"/>
+ <requires lib="gtksourceview" version="0.0"/>
<object class="GtkDialog" id="dialog_database_preferences">
<property name="can_focus">False</property>
<property name="margin">6</property>
@@ -498,7 +499,7 @@
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkTextView" id="textview_calculation">
+ <object class="GtkSourceView" id="textview_calculation">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="left_margin">2</property>
diff --git a/data/ui/developer/dialog_script_library.glade b/data/ui/developer/dialog_script_library.glade
index 68c698d..6ddc094 100644
--- a/data/ui/developer/dialog_script_library.glade
+++ b/data/ui/developer/dialog_script_library.glade
@@ -2,6 +2,7 @@
<!-- Generated with glade 3.16.0 on Fri Oct 25 10:59:22 2013 -->
<interface>
<!-- interface-requires gtk+ 3.6 -->
+ <!-- interface-requires gtksourceview 0.0 -->
<object class="GtkDialog" id="dialog_script_library">
<property name="can_focus">False</property>
<property name="margin">6</property>
@@ -148,7 +149,7 @@
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTextView" id="textview_script">
+ <object class="GtkSourceView" id="textview_script">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="left_margin">2</property>
diff --git a/data/ui/developer/window_button_script.glade b/data/ui/developer/window_button_script.glade
index d716490..85a9634 100644
--- a/data/ui/developer/window_button_script.glade
+++ b/data/ui/developer/window_button_script.glade
@@ -2,6 +2,7 @@
<!-- Generated with glade 3.16.0 on Fri Oct 25 10:57:19 2013 -->
<interface>
<!-- interface-requires gtk+ 3.6 -->
+ <!-- interface-requires gtksourceview 0.0 -->
<object class="GtkDialog" id="window_button_script">
<property name="can_focus">False</property>
<property name="margin">6</property>
@@ -156,7 +157,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkTextView" id="textview_calculation">
+ <object class="GtkSourceView" id="textview_calculation">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="left_margin">2</property>
diff --git a/data/ui/developer/window_field_calculation.glade
b/data/ui/developer/window_field_calculation.glade
index e57cdf9..c51578a 100644
--- a/data/ui/developer/window_field_calculation.glade
+++ b/data/ui/developer/window_field_calculation.glade
@@ -2,6 +2,7 @@
<!-- Generated with glade 3.15.4 on Wed Oct 23 11:19:51 2013 -->
<interface>
<!-- interface-requires gtk+ 3.6 -->
+ <!-- interface-requires gtksourceview 0.0 -->
<object class="GtkDialog" id="window_field_calculation">
<property name="can_focus">False</property>
<property name="margin">6</property>
@@ -122,7 +123,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkTextView" id="textview_calculation">
+ <object class="GtkSourceView" id="textview_calculation">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="left_margin">2</property>
diff --git a/data/ui/developer/window_field_definition_edit.glade
b/data/ui/developer/window_field_definition_edit.glade
index 8350453..760fc12 100644
--- a/data/ui/developer/window_field_definition_edit.glade
+++ b/data/ui/developer/window_field_definition_edit.glade
@@ -2,6 +2,7 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.6"/>
+ <requires lib="gtksourceview" version="0.0"/>
<object class="GtkWindow" id="window_field_definition_edit">
<property name="can_focus">False</property>
<property name="margin">12</property>
@@ -356,7 +357,7 @@
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTextView" id="textview_calculate">
+ <object class="GtkSourceView" id="textview_calculate">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
diff --git a/glom/main.cc b/glom/main.cc
index e5ea7c9..1309ad4 100644
--- a/glom/main.cc
+++ b/glom/main.cc
@@ -55,6 +55,7 @@
#include <glom/python_embed/glom_python.h>
#ifndef GLOM_ENABLE_CLIENT_ONLY
+#include <gtksourceviewmm/init.h>
#include <goocanvasmm/init.h>
#endif // !GLOM_ENABLE_CLIENT_ONLY
@@ -494,6 +495,7 @@ main(int argc, char* argv[])
Glom::Application::create();
#ifndef GLOM_ENABLE_CLIENT_ONLY
+ Gsv::init();
Goocanvas::init();
#endif //!GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/mode_design/dialog_database_preferences.cc b/glom/mode_design/dialog_database_preferences.cc
index dd1e2c4..3bff9d7 100644
--- a/glom/mode_design/dialog_database_preferences.cc
+++ b/glom/mode_design/dialog_database_preferences.cc
@@ -25,6 +25,7 @@
#include <libglom/db_utils.h>
#include <glom/bakery/busy_cursor.h>
#include <glom/utils_ui.h>
+#include <gtksourceviewmm/languagemanager.h>
#include <glibmm/i18n.h>
#include <iostream>
@@ -86,9 +87,19 @@ Dialog_Database_Preferences::Dialog_Database_Preferences(BaseObjectType* cobject
//Dialog_Properties::set_modified(false);
- //Create a new buffer and set it, instead of getting the default buffer, in case libglade has tried to set
it, using the wrong buffer type:
- auto buffer = Gtk::TextBuffer::create();
- m_text_view_script->set_buffer(buffer);
+ //Tell the SourceView to do syntax highlighting for Python:
+ auto languages_manager =
+ Gsv::LanguageManager::get_default();
+
+ auto language =
+ languages_manager->get_language("python"); //This is the GtkSourceView language ID.
+ if(language)
+ {
+ //Create a new buffer and set it, instead of getting the default buffer, in case libglade has tried to
set it, using the wrong buffer type:
+ auto buffer = Gsv::Buffer::create(language);
+ buffer->set_highlight_syntax();
+ m_text_view_script->set_buffer(buffer);
+ }
}
void Dialog_Database_Preferences::on_treeview_cell_edited_next_value(const Glib::ustring& path_string, const
Glib::ustring& new_text)
diff --git a/glom/mode_design/dialog_database_preferences.h b/glom/mode_design/dialog_database_preferences.h
index af7055c..7390ac9 100644
--- a/glom/mode_design/dialog_database_preferences.h
+++ b/glom/mode_design/dialog_database_preferences.h
@@ -28,7 +28,7 @@
#include <gtkmm/label.h>
#include <gtkmm/treeview.h>
#include <gtkmm/liststore.h>
-#include <gtkmm/textview.h>
+#include <gtksourceviewmm/view.h>
#include <glom/base_db.h>
#include <libglom/data_structure/system_prefs.h>
#include <libglom/connectionpool.h>
@@ -82,7 +82,7 @@ private:
ImageGlom* m_image;
Gtk::Button* m_button_choose_image;
- Gtk::TextView* m_text_view_script;
+ Gsv::View* m_text_view_script;
Gtk::Button* m_button_test_script;
SystemPrefs m_system_prefs;
diff --git a/glom/mode_design/fields/dialog_fieldcalculation.cc
b/glom/mode_design/fields/dialog_fieldcalculation.cc
index 5137130..5ba087e 100644
--- a/glom/mode_design/fields/dialog_fieldcalculation.cc
+++ b/glom/mode_design/fields/dialog_fieldcalculation.cc
@@ -26,6 +26,7 @@
#include <glom/utils_ui.h>
#include <glom/appwindow.h>
#include <libglom/data_structure/glomconversions.h>
+#include <gtksourceviewmm/languagemanager.h>
//#include <libgnome/gnome-i18n.h>
#include <glibmm/i18n.h>
@@ -48,9 +49,18 @@ Dialog_FieldCalculation::Dialog_FieldCalculation(BaseObjectType* cobject, const
if(m_text_view)
{
- //Createa a new buffer and set it, instead of getting the default buffer, in case libglade has tried to
set it, using the wrong buffer type:
- auto buffer = Gtk::TextBuffer::create();
- m_text_view->set_buffer(buffer);
+ m_text_view->set_highlight_current_line(true);
+
+ auto languages_manager = Gsv::LanguageManager::get_default();
+
+ auto language = languages_manager->get_language("python"); //This is the GtkSourceView language ID.
+ if(language)
+ {
+ //Createa a new buffer and set it, instead of getting the default buffer, in case libglade has tried
to set it, using the wrong buffer type:
+ auto buffer = Gsv::Buffer::create(language);
+ buffer->set_highlight_syntax();
+ m_text_view->set_buffer(buffer);
+ }
}
//Dialog_Properties::set_modified(false);
diff --git a/glom/mode_design/fields/dialog_fieldcalculation.h
b/glom/mode_design/fields/dialog_fieldcalculation.h
index 27f3f04..e9da789 100644
--- a/glom/mode_design/fields/dialog_fieldcalculation.h
+++ b/glom/mode_design/fields/dialog_fieldcalculation.h
@@ -25,9 +25,9 @@
#include <gtkmm/button.h>
#include <gtkmm/label.h>
#include <gtkmm/builder.h>
-#include <gtkmm/textview.h>
#include <libglom/data_structure/field.h>
#include <glom/base_db.h>
+#include <gtksourceviewmm/view.h>
namespace Glom
{
@@ -50,7 +50,7 @@ private:
void on_button_test();
bool check_for_return_statement(const Glib::ustring& calculation);
- Gtk::TextView* m_text_view;
+ Gsv::View* m_text_view;
Gtk::Button* m_button_test;
Gtk::Label* m_label_triggered_by;
diff --git a/glom/mode_design/fields/dialog_fielddefinition.h
b/glom/mode_design/fields/dialog_fielddefinition.h
index b807689..311c993 100644
--- a/glom/mode_design/fields/dialog_fielddefinition.h
+++ b/glom/mode_design/fields/dialog_fielddefinition.h
@@ -25,7 +25,6 @@
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/entry.h>
-#include <gtkmm/textview.h>
#include <glom/mode_design/layout/combobox_relationship.h>
#include "combo_fieldtype.h"
//#include "../../utility_widgets/entry_numerical.h"
@@ -34,6 +33,7 @@
#include <libglom/data_structure/field.h>
#include <glom/mode_design/layout/layout_item_dialogs/box_formatting.h>
#include <glom/base_db.h>
+#include <gtksourceviewmm/view.h>
namespace Glom
{
@@ -84,7 +84,7 @@ private:
Gtk::RadioButton* m_radio_calculate;
Gtk::Box* m_alignment_calculate;
- Gtk::TextView* m_textView_calculation;
+ Gsv::View* m_textView_calculation;
Gtk::Button* m_button_edit_calculation;
Gtk::Entry* m_entry_title;
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
index 5c90f6d..fb550af 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
@@ -25,6 +25,7 @@
#include <glom/appwindow.h>
#include <glom/utils_ui.h>
#include <libglom/data_structure/glomconversions.h>
+#include <gtksourceviewmm/languagemanager.h>
//#include <libgnome/gnome-i18n.h>
@@ -51,9 +52,19 @@ Dialog_ButtonScript::Dialog_ButtonScript(BaseObjectType* cobject, const Glib::Re
//Dialog_Properties::set_modified(false);
- //Create a new buffer and set it, instead of getting the default buffer, in case libglade has tried to set
it, using the wrong buffer type:
- auto buffer = Gtk::TextBuffer::create();
- m_text_view_script->set_buffer(buffer);
+ //Tell the SourceView to do syntax highlighting for Python:
+ auto languages_manager =
+ Gsv::LanguageManager::get_default();
+
+ auto language =
+ languages_manager->get_language("python"); //This is the GtkSourceView language ID.
+ if(language)
+ {
+ //Create a new buffer and set it, instead of getting the default buffer, in case libglade has tried to
set it, using the wrong buffer type:
+ auto buffer = Gsv::Buffer::create(language);
+ buffer->set_highlight_syntax();
+ m_text_view_script->set_buffer(buffer);
+ }
}
void Dialog_ButtonScript::set_script(const std::shared_ptr<const LayoutItem_Button>& script, const
Glib::ustring& table_name)
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.h
b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.h
index 0fdcf9d..78abea7 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.h
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.h
@@ -24,10 +24,11 @@
#include <gtkmm/dialog.h>
#include <gtkmm/entry.h>
#include <gtkmm/builder.h>
-#include <gtkmm/textview.h>
#include <libglom/data_structure/layout/layoutitem_button.h>
#include <glom/base_db.h>
+#include <gtksourceviewmm/view.h>
+
namespace Glom
{
@@ -50,7 +51,7 @@ private:
void on_button_test_script();
Gtk::Entry* m_entry_title;
- Gtk::TextView* m_text_view_script;
+ Gsv::View* m_text_view_script;
Gtk::Button* m_button_test_script;
std::shared_ptr<LayoutItem_Button> m_script;
diff --git a/glom/mode_design/script_library/dialog_script_library.cc
b/glom/mode_design/script_library/dialog_script_library.cc
index 7788ccf..dbe3960 100644
--- a/glom/mode_design/script_library/dialog_script_library.cc
+++ b/glom/mode_design/script_library/dialog_script_library.cc
@@ -24,6 +24,7 @@
#include <glom/glade_utils.h>
#include <glom/utils_ui.h>
#include <glom/mode_design/script_library/dialog_new_script.h>
+#include <gtksourceviewmm/languagemanager.h>
#include <glom/appwindow.h>
@@ -55,9 +56,17 @@ Dialog_ScriptLibrary::Dialog_ScriptLibrary(BaseObjectType* cobject, const Glib::
//Dialog_Properties::set_modified(false);
- //Create a new buffer and set it, instead of getting the default buffer, in case libglade has tried to set
it, using the wrong buffer type:
- auto buffer = Gtk::TextBuffer::create();
- m_text_view->set_buffer(buffer);
+ //Set the SourceView to do syntax highlighting for Python:
+ auto languages_manager = Gsv::LanguageManager::get_default();
+
+ auto language = languages_manager->get_language("python"); //This is the GtkSourceView language ID.
+ if(language)
+ {
+ //Create a new buffer and set it, instead of getting the default buffer, in case libglade has tried to
set it, using the wrong buffer type:
+ auto buffer = Gsv::Buffer::create(language);
+ buffer->set_highlight_syntax();
+ m_text_view->set_buffer(buffer);
+ }
}
void Dialog_ScriptLibrary::on_button_check()
diff --git a/glom/mode_design/script_library/dialog_script_library.h
b/glom/mode_design/script_library/dialog_script_library.h
index 138b527..1232e69 100644
--- a/glom/mode_design/script_library/dialog_script_library.h
+++ b/glom/mode_design/script_library/dialog_script_library.h
@@ -23,9 +23,9 @@
#include <gtkmm/dialog.h>
#include <gtkmm/builder.h>
-#include <gtkmm/textview.h>
#include <libglom/data_structure/layout/layoutitem_button.h>
#include <glom/base_db.h>
+#include <gtksourceviewmm/view.h>
#include <glom/utility_widgets/combo_textglade.h>
namespace Glom
@@ -58,7 +58,7 @@ private:
Combo_TextGlade* m_combobox_name;
- Gtk::TextView* m_text_view;
+ Gsv::View* m_text_view;
Gtk::Button* m_button_check;
Gtk::Button* m_button_add;
Gtk::Button* m_button_remove;
diff --git a/tests/ui/glade_toplevels_instantiation.cc b/tests/ui/glade_toplevels_instantiation.cc
index d747822..671a209 100644
--- a/tests/ui/glade_toplevels_instantiation.cc
+++ b/tests/ui/glade_toplevels_instantiation.cc
@@ -20,6 +20,7 @@
#include <gtkmm/builder.h>
#include <gtkmm/dialog.h>
#include <gtkmm/application.h>
+#include <gtksourceviewmm/init.h>
#include <libxml++/libxml++.h>
#include <iostream>
@@ -91,6 +92,7 @@ int main(int argc, char* argv[])
{
auto app =
Gtk::Application::create("org.glom.test_glade_toplevels_instantiation");
+ Gsv::init(); //Our .glade files contain gtksourceview widgets too.
std::string filepath;
if(argc > 1 )
diff --git a/tests/ui/test_glade_derived_instantiation.cc b/tests/ui/test_glade_derived_instantiation.cc
index 11693bd..228bb48 100644
--- a/tests/ui/test_glade_derived_instantiation.cc
+++ b/tests/ui/test_glade_derived_instantiation.cc
@@ -73,6 +73,7 @@
#include <glom/dialog_invalid_data.h>
#include <gtkmm/builder.h>
#include <gtkmm/application.h>
+#include <gtksourceviewmm/init.h>
const int GLOM_MAX_WINDOW_WIDTH = 800;
const int GLOM_MAX_WINDOW_HEIGHT = 600;
@@ -130,6 +131,7 @@ int main()
{
auto app =
Gtk::Application::create("org.glom.test_glade_derived_instantiation");
+ Gsv::init(); //Our .glade files contain gtksourceview widgets too.
using namespace Glom;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]