Add gtk156
This commit is contained in:
parent
8c0606a010
commit
ca8bd9fe54
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,74 @@
|
|||
set(CMAKE_CXX_STANDARD 17)
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(gtk156_dyncombo VERSION 1.0.0)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../GCR_CMake/macros)
|
||||
include(GlibCompileResourcesSupport)
|
||||
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||
|
||||
include(CPack)
|
||||
include_directories(.)
|
||||
include_directories(..)
|
||||
|
||||
#Find PkgConfig to use gtkmm3
|
||||
find_package (PkgConfig REQUIRED)
|
||||
pkg_check_modules (GTKMM4 REQUIRED gtkmm-4.0)
|
||||
include_directories (${GTKMM4_INCLUDE_DIRS})
|
||||
link_directories (${GTKMM4_LIBRARY_DIRS})
|
||||
|
||||
# Find Gettext
|
||||
# find_package (Gettext REQUIRED)
|
||||
# set(PO_DIR ${CMAKE_BINARY_DIR}/po/zh_CN/LC_MESSAGES)
|
||||
|
||||
# Source filesa
|
||||
set(SOURCE_FILE src/main.cc src/MainWin.cc)
|
||||
|
||||
# Compile Resource
|
||||
|
||||
# set(RESOURCE_LIST
|
||||
# STRIPBLANKS prefs_stack.ui
|
||||
# STRIPBLANKS mainmenu.xml
|
||||
# )
|
||||
|
||||
# compile_gresources(RESOURCE_FILE
|
||||
# XML_OUT
|
||||
# TYPE EMBED_C
|
||||
# RESOURCES ${RESOURCE_LIST}
|
||||
# PREFIX "/org/gtk/daleclack"
|
||||
# SOURCE_DIR ${PROJECT_SOURCE_DIR}/res)
|
||||
|
||||
# Add a custom target to the makefile. Now make builds our resource file.
|
||||
# It depends on the output RESOURCE_FILE.
|
||||
|
||||
# add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
|
||||
|
||||
#For win32 platform,use rc resource and .ico icon
|
||||
if(WIN32)
|
||||
SET(CMAKE_RC_COMPILER windres)
|
||||
set(app_WINRC ../icon.rc)
|
||||
set_property(SOURCE ../icon.rc APPEND PROPERTY
|
||||
OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/../icon.ico
|
||||
)
|
||||
add_executable(${PROJECT_NAME} WIN32 ${app_WINRC} ${SOURCE_FILE})
|
||||
add_custom_command( TARGET ${PROJECT_NAME}
|
||||
COMMAND echo * > ${CMAKE_BINARY_DIR}/.gitignore
|
||||
COMMAND echo **/* > ${CMAKE_BINARY_DIR}/.hgignore)
|
||||
else()
|
||||
add_executable(${PROJECT_NAME} ${SOURCE_FILE})
|
||||
add_custom_command( TARGET ${PROJECT_NAME}
|
||||
COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore
|
||||
COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore)
|
||||
endif(WIN32)
|
||||
|
||||
#Add command to generate .gitignore and .mo files
|
||||
# add_custom_command( TARGET ${PROJECT_NAME}
|
||||
# COMMAND mkdir -p ${PO_DIR}
|
||||
# COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ${CMAKE_SOURCE_DIR}/po/zh_CN.po -o ${PO_DIR}/${PROJECT_NAME}.mo)
|
||||
|
||||
SET (CMAKE_EXTRA_CXX_FLAGS ${GTKMM4_CFLAGS_OTHER})
|
||||
target_link_libraries (${PROJECT_NAME} ${GTKMM4_LIBRARIES} -lpthread)
|
|
@ -0,0 +1,63 @@
|
|||
#include "MainWin.hh"
|
||||
|
||||
MainWin::MainWin()
|
||||
: main_box(Gtk::Orientation::HORIZONTAL, 5),
|
||||
lists_box(Gtk::Orientation::VERTICAL, 5),
|
||||
drop_frame("Dropdown widget"),
|
||||
list_frame("Items List"),
|
||||
btn_add("Add Item"),
|
||||
btn_remove("Remove Item")
|
||||
{
|
||||
// Initalize window
|
||||
set_icon_name("org.gtk.daleclack");
|
||||
set_default_size(600, 400);
|
||||
set_title("Dynamic Dropdown test");
|
||||
|
||||
// Add overlay widget
|
||||
dropdown.set_halign(Gtk::Align::CENTER);
|
||||
dropdown.set_valign(Gtk::Align::CENTER);
|
||||
drop_overlay.add_overlay(dropdown);
|
||||
drop_frame.set_child(drop_overlay);
|
||||
|
||||
|
||||
|
||||
// Add List widget
|
||||
// Scrolled window for listview widget
|
||||
m_sw.set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
|
||||
m_sw.set_expand();
|
||||
m_sw.set_halign(Gtk::Align::FILL);
|
||||
m_sw.set_valign(Gtk::Align::FILL);
|
||||
m_sw.set_child(main_list_view);
|
||||
lists_box.append(m_sw);
|
||||
|
||||
// Entry and buttons
|
||||
btn_add.set_halign(Gtk::Align::CENTER);
|
||||
btn_remove.set_halign(Gtk::Align::CENTER);
|
||||
lists_box.append(item_entry);
|
||||
lists_box.append(btn_add);
|
||||
lists_box.append(btn_remove);
|
||||
list_frame.set_child(lists_box);
|
||||
|
||||
// Append the frames to the main box
|
||||
main_box.append(drop_frame);
|
||||
main_box.append(list_frame);
|
||||
set_child(main_box);
|
||||
}
|
||||
|
||||
void MainWin::btnadd_clicked()
|
||||
{
|
||||
Glib::ustring entry_str;
|
||||
|
||||
// Get String from entry
|
||||
entry_str = item_entry.get_text();
|
||||
|
||||
// Append text to the list
|
||||
if (!entry_str.empty())
|
||||
{
|
||||
dropdown_list->append(entry_str);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWin::btnremove_clicked()
|
||||
{
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include "../json_nlohmann/json.hpp"
|
||||
#include <vector>
|
||||
#include <gtkmm.h>
|
||||
|
||||
using json = nlohmann::json;
|
||||
typedef std::vector<std::string> str_vec;
|
||||
|
||||
// Main Window Class
|
||||
class MainWin : public Gtk::ApplicationWindow
|
||||
{
|
||||
public:
|
||||
MainWin();
|
||||
|
||||
private:
|
||||
// Use StringList for dropdown and json file
|
||||
Glib::RefPtr<Gtk::StringList> dropdown_list;
|
||||
|
||||
// Child widgets
|
||||
Gtk::DropDown dropdown;
|
||||
Gtk::Overlay drop_overlay;
|
||||
Gtk::Box main_box, lists_box;
|
||||
Gtk::Frame drop_frame, list_frame;
|
||||
Gtk::ScrolledWindow m_sw;
|
||||
Gtk::ListView main_list_view;
|
||||
Gtk::Entry item_entry;
|
||||
Gtk::Button btn_add, btn_remove;
|
||||
|
||||
// Signal Handlers
|
||||
void btnadd_clicked();
|
||||
void btnremove_clicked();
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
#include "MainWin.hh"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Create a window and run
|
||||
auto app = Gtk::Application::create("org.gtk.daleclack");
|
||||
return app->make_window_and_run<MainWin>(argc, argv);
|
||||
}
|
Loading…
Reference in New Issue