Why can I not use GtkSourceView in GtkBuilder, loading a file by Glade?

370 Views Asked by At

I made a *.ui file in glade, and it won't load with GtkBuilder. "Invalid object type 'GtkSourceView'"

GEdit uses GtkSourceMap, and I was not able to do that either. I've scoured the internet, and none of the answers worked, i.e., installing libgtksourceviewmm, etc.

...
<object class="GtkSourceMap" id="editor">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="editable">False</property>
                <property name="left_margin">2</property>
                <property name="right_margin">2</property>
                <property name="monospace">True</property>
                <property name="show_line_numbers">True</property>
                <property name="show_line_marks">True</property>
                <property name="tab_width">4</property>
                <property name="indent_width">4</property>
                <property name="auto_indent">True</property>
                <property name="insert_spaces_instead_of_tabs">True</property>
                <property name="smart_home_end">always</property>
                <property name="highlight_current_line">True</property>
                <property name="smart_backspace">True</property>
              </object>
...
gtk_builder_add_from_file (builder, SHARE "main.ui", &error);
// share is the prefix for the file, right now it's the 
//  project dir, but it will be "/usr/share/"
cmake_minimum_required(VERSION 3.3)
project(textpad)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

file(GLOB_RECURSE textpad_SOURCES "src/*.cpp")
file(GLOB_RECURSE textpad_HEADERS "src/*.h")
file(GLOB_RECURSE textpad_SOURCES "dep/gtksourceview-4.0.0/*.cpp")
file(GLOB_RECURSE textpad_HEADERS "dep/gtksourceview-4.0.0/*.h")
add_executable(textpad src/main.cpp)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(GTK3 REQUIRED gtksourceview-4)

include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})

add_definitions(${GTK3_CFLAGS_OTHER})

target_link_libraries(textpad ${GTK3_LIBRARIES})

set(PREFIX /)

I expected to be able to use it, but it failed with an error: Invalid object type 'GtkSourceView'.

EDIT: Added cmake file

0

There are 0 best solutions below