为什么我不能在GtkBuilder中使用GtkSourceView来通过Glade加载文件?

时间:2019-05-31 00:23:29

标签: c++ gtk clion gtksourceview

我在林间空地中创建了一个* .ui文件,该文件不会随GtkBuilder一起加载。 “无效的对象类型'GtkSourceView'”

GEdit使用GtkSourceMap,但我也无法做到这一点。我搜寻了互联网,但没有任何答案,例如安装libgtksourceviewmm等。

...
<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 /)

我希望能够使用它,但是它失败并出现错误:无效的对象类型'GtkSourceView'。

编辑:添加了cmake文件

0 个答案:

没有答案