Add gtk126

This commit is contained in:
daleclack 2022-03-10 15:12:18 +08:00
parent af6ae70796
commit 9fb942f80a
20 changed files with 1239 additions and 0 deletions

View File

@ -0,0 +1,3 @@
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}

View File

@ -0,0 +1,74 @@
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.0.0)
project(gtk126 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 (GTKMM3 REQUIRED gtkmm-3.0)
include_directories (${GTKMM3_INCLUDE_DIRS})
link_directories (${GTKMM3_LIBRARY_DIRS})
#Find Gettext
find_package (Gettext REQUIRED)
set(PO_DIR ${CMAKE_BINARY_DIR}/po/zh_CN/LC_MESSAGES)
#Source files
set(SOURCE_FILE src/main.cc src/MyWin.cc src/MyPrefs.cc ../cfgfile/cfgfile.cc)
#Compile Resource
set(RESOURCE_LIST
icons/16x16/actions/list-add.svg
icons/16x16/actions/list-remove.svg
icons/scalable/status/display_prefs.svg
folder.svg
folder-images.svg
image_file.svg
prefs_stack.ui)
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 x86_64-w64-mingw32-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} ${RESOURCE_FILE})
else()
add_executable(${PROJECT_NAME} ${SOURCE_FILE} ${RESOURCE_FILE})
endif(WIN32)
#Add command to generate .gitignore and .mo files
add_custom_command(TARGET ${PROJECT_NAME}
COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore
COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore
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 ${GTKMM3_CFLAGS_OTHER})
target_link_libraries (${PROJECT_NAME} ${GTKMM3_LIBRARIES} -lpthread)

View File

@ -0,0 +1,2 @@
# Please keep this list sorted alphabetically
zh_CN

View File

@ -0,0 +1,5 @@
# List of source files containing translatable strings.
# Please keep this file in alphabetical order.
res/prefs_stack.ui
src/MyPrefs.cc
src/MyWin.cc

View File

@ -0,0 +1 @@
src/main.cc

View File

@ -0,0 +1,5 @@
i18n = import('i18n')
i18n.gettext(
'gtk125',
preset:'glib',
)

View File

@ -0,0 +1,68 @@
#: MyPrefs.cc:20 MyWin.cc:22
msgid "Window Preferences"
msgstr "首选项"
#: MyPrefs.cc:52
msgid "Default Backgrounds"
msgstr "默认壁纸"
#: MyPrefs.cc:58
msgid "User's Home"
msgstr "主目录"
#: MyPrefs.cc:64
msgid "User's Pictures Directory"
msgstr "图片"
#: MyPrefs.cc:70
msgid "Name"
msgstr "名称"
#: MyPrefs.cc:75
msgid "Images"
msgstr "图像"
#: MyPrefs.cc:131
msgid "Current Config"
msgstr "当前设置"
#: MyPrefs.cc:144
msgid "Add a folder"
msgstr "添加文件夹"
#: MyPrefs.cc:145
msgid "OK"
msgstr "确定"
#: MyPrefs.cc:145
msgid "Cancel"
msgstr "取消"
#: MyWin.cc:10
msgid "Background Preferences Test"
msgstr ""
#: prefs_stack.ui:57
msgid "Background Preferences"
msgstr "背景首选项"
#: prefs_stack.ui:120
msgid "Use default window size"
msgstr "使用默认窗口大小"
#: prefs_stack.ui:136
msgid "User defined window size"
msgstr "用户自定义窗口大小"
#: prefs_stack.ui:231
msgid "Apply"
msgstr "应用"
#: prefs_stack.ui:246
msgid "Get Current"
msgstr "获取当前配置"
#: prefs_stack.ui:282
msgid "Window Size Config"
msgstr "窗口大小首选项"

View File

@ -0,0 +1,36 @@
<svg width="64" height="64" version="1.1" viewBox="0 0 16.933 16.933" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="linearGradient897-3" x1="6.8792" x2="6.8792" y1="285.36" y2="283.77" gradientTransform="matrix(.99998 0 0 .99998 0 -280.06)" gradientUnits="userSpaceOnUse">
<stop offset="0"/>
<stop stop-opacity="0" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient1769-5" x1="445.28" x2="445.28" y1="179.28" y2="200.07" gradientTransform="matrix(.38956 0 0 .38184 -165.52 -63.44)" gradientUnits="userSpaceOnUse">
<stop stop-color="#60c0f0" offset="0"/>
<stop stop-color="#83d4fb" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient860-6" x1="8.4667" x2="8.4667" y1="293.3" y2="292.77" gradientTransform="translate(0,-280.07)" gradientUnits="userSpaceOnUse">
<stop stop-color="#008ea2" stop-opacity=".25" offset="0"/>
<stop stop-color="#fff" stop-opacity=".15" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient868-1" x1="8.4667" x2="8.4667" y1="294.62" y2="293.56" gradientTransform="matrix(.99998 0 0 .99998 0 -280.06)" gradientUnits="userSpaceOnUse">
<stop stop-color="#008ea2" stop-opacity=".25098" offset="0"/>
<stop stop-color="#008ea2" stop-opacity=".15" offset=".75678"/>
<stop stop-color="#fff" stop-opacity=".15" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient907-9" x1="1.0583" x2="15.875" y1="289.59" y2="289.59" gradientTransform="translate(0,-280.07)" gradientUnits="userSpaceOnUse">
<stop stop-color="#46a2d7" stop-opacity=".5" offset="0"/>
<stop stop-color="#46a2d7" stop-opacity="0" offset=".10783"/>
<stop stop-color="#46a2d7" stop-opacity=".095808" offset=".89398"/>
<stop stop-color="#46a2d7" stop-opacity=".5" offset="1"/>
</linearGradient>
</defs>
<image x=".52916" y="1.969" width="15.875" height="13.229" image-rendering="optimizeQuality" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAAyCAYAAAAA9rgCAAAACXBIWXMAAA7XAAAO1wFxhj+8AAAA GXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAbVJREFUaIHtml9TglAQRw9/jMrR 6a3v//2q0azMFOhhuXJLRgHv5G3dM8PgqHA57C68/BIOSbxtCLW3RUvy63MOFMAESOkvXQMlsAW+ gB2RiifevgDmwANwB2QDz7UD1sASWAEboApzmeHIaSs7Bx6Bmff9EGpgCtwjN2+B3ICSiKqdN/sC qewMaeehsjTH3CCd4UbjBXhHWv0S0gdrukpOkDYeU1kf1y3T5pwF0uJviHTVdREd5+izzilqZMxK vNFyglmznSPrkyKyGdLia2Sm+1T61BsiPXGsYwd8Ijd7TXOzc++PoWT9xSe07V0RpsJD3hwbpMOe kNEq86OHhMG1+SVm2D1TSuR1Wf2FsCN0B/Vd8xZ5GC+Ar2PzoIWMdrSSaxAG7xllwtoxYe2YsHZM WDsmrB0T1o4Ja8eEtWPC2jFh7ZiwdkxYOyasHRPWjglr52qFo48MnsneL6WNDfYJnPxHasStBGon vEWiPdFmJEfislofNJEpl82q+RkzukQAJTROdgU8I3mtKvd+WNJmm8aES2OjRLp2AbzSdG+o+HBs uLndIgXcj2qX0NiAeGx0Bta/AZSga/2YDpsuAAAAAElFTkSuQmCC "/>
<path d="m2.21 2.38h2.695c0.75074 0 0.78302 0.0285 1.5421 0.62962 0.78159 0.5904 0.94779 0.607 1.8636 0.607l6.4126-0.0524c0.638-5e-3 1.1517 0.51363 1.1517 1.1516v6.77c0 0.63802-0.51364 1.1517-1.1517 1.1517h-12.513c-0.63802 0-1.1517-0.51364-1.1517-1.1517v-7.9542c0-0.63802 0.51364-1.1517 1.1517-1.1517z" fill="#46a2d7"/>
<path d="m2.2102 2.3812c-0.63801 0-1.1518 0.51384-1.1518 1.1518v2.8167h14.816v-1.633c0-0.63801-0.51387-1.1563-1.1518-1.1513l-6.4124 0.052194c-0.91582 0-1.0818-0.016798-1.8634-0.60718-0.75908-0.6011-0.79128-0.62941-1.542-0.62941h-2.695z" fill="url(#linearGradient897-3)" opacity=".35" stroke-width=".26458"/>
<rect x="1.0583" y="4.49" width="14.817" height="10.054" rx="1.1517" ry="1.1288" fill="url(#linearGradient1769-5)"/>
<rect x="1.0583" y="12.7" width="14.817" height=".52915" fill="url(#linearGradient860-6)"/>
<path d="m1.0655 13.494c0.03752 0.59168 0.5312 1.0583 1.1446 1.0583h12.513c0.6134 0 1.1071-0.46664 1.1446-1.0583h-14.802z" fill="url(#linearGradient868-1)" stroke-width=".26458"/>
<rect x="1.0583" y="4.49" width="14.817" height="10.054" rx="1.1517" ry="1.1288" fill="url(#linearGradient907-9)"/>
<path d="m2.2102 4.4979c-0.63801 0-1.1518 0.50323-1.1518 1.1286v0.23512c0-0.6089 0.51384-1.0991 1.1518-1.0991h12.513c0.63801 0 1.1518 0.49024 1.1518 1.0991v-0.23512c0-0.62536-0.51384-1.1286-1.1518-1.1286z" fill="#ffffff" opacity=".1" stroke-width=".26458"/>
<path class="ColorScheme-Text" d="m5.78 6.3295c-0.49611 0-0.89549 0.39938-0.89549 0.89549v4.0298c0 0.49611 0.39938 0.89549 0.89549 0.89549h5.3731c0.49611 0 0.89549-0.39938 0.89549-0.89549v-4.0298c0-0.49611-0.39938-0.89549-0.89549-0.89549zm0 0.44775h5.3731c0.24805 0 0.44775 0.1997 0.44775 0.44775v4.0298l-2.2387-2.2387-1.5579 1.791-1.1286-0.89549-1.3432 1.3432v-4.0298c0-0.24805 0.1997-0.44775 0.44775-0.44775zm1.1194 0.89549c-0.37094 0-0.67163 0.30069-0.67163 0.67163 0 0.37094 0.30069 0.67163 0.67163 0.67163 0.37094 0 0.67163-0.30069 0.67163-0.67163 0-0.37094-0.30069-0.67163-0.67163-0.67163z" color="#363636" fill="#000000" opacity=".15" stroke-width=".44775"/>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,35 @@
<svg width="64" height="64" version="1.1" viewBox="0 0 16.933 16.933" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="linearGradient1769" x1="445.28" x2="445.28" y1="179.28" y2="200.07" gradientTransform="matrix(.38956 0 0 .38184 -165.52 -63.44)" gradientUnits="userSpaceOnUse">
<stop stop-color="#60c0f0" offset="0"/>
<stop stop-color="#83d4fb" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient860" x1="8.4667" x2="8.4667" y1="293.3" y2="292.77" gradientTransform="translate(0,-280.07)" gradientUnits="userSpaceOnUse">
<stop stop-color="#008ea2" stop-opacity=".25" offset="0"/>
<stop stop-color="#fff" stop-opacity=".15" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient868" x1="8.4667" x2="8.4667" y1="294.62" y2="293.56" gradientTransform="matrix(.99998 0 0 .99998 0 -280.06)" gradientUnits="userSpaceOnUse">
<stop stop-color="#008ea2" stop-opacity=".25098" offset="0"/>
<stop stop-color="#008ea2" stop-opacity=".15" offset=".75678"/>
<stop stop-color="#fff" stop-opacity=".15" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient897" x1="6.8792" x2="6.8792" y1="285.36" y2="283.77" gradientTransform="matrix(.99998 0 0 .99998 0 -280.06)" gradientUnits="userSpaceOnUse">
<stop offset="0"/>
<stop stop-opacity="0" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient907" x1="1.0583" x2="15.875" y1="289.59" y2="289.59" gradientTransform="translate(0,-280.07)" gradientUnits="userSpaceOnUse">
<stop stop-color="#46a2d7" stop-opacity=".5" offset="0"/>
<stop stop-color="#46a2d7" stop-opacity="0" offset=".10783"/>
<stop stop-color="#46a2d7" stop-opacity=".095808" offset=".89398"/>
<stop stop-color="#46a2d7" stop-opacity=".5" offset="1"/>
</linearGradient>
</defs>
<image x=".52916" y="1.969" width="15.875" height="13.229" image-rendering="optimizeQuality" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAAyCAYAAAAA9rgCAAAACXBIWXMAAA7XAAAO1wFxhj+8AAAA GXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAbVJREFUaIHtml9TglAQRw9/jMrR 6a3v//2q0azMFOhhuXJLRgHv5G3dM8PgqHA57C68/BIOSbxtCLW3RUvy63MOFMAESOkvXQMlsAW+ gB2RiifevgDmwANwB2QDz7UD1sASWAEboApzmeHIaSs7Bx6Bmff9EGpgCtwjN2+B3ICSiKqdN/sC qewMaeehsjTH3CCd4UbjBXhHWv0S0gdrukpOkDYeU1kf1y3T5pwF0uJviHTVdREd5+izzilqZMxK vNFyglmznSPrkyKyGdLia2Sm+1T61BsiPXGsYwd8Ijd7TXOzc++PoWT9xSe07V0RpsJD3hwbpMOe kNEq86OHhMG1+SVm2D1TSuR1Wf2FsCN0B/Vd8xZ5GC+Ar2PzoIWMdrSSaxAG7xllwtoxYe2YsHZM WDsmrB0T1o4Ja8eEtWPC2jFh7ZiwdkxYOyasHRPWjglr52qFo48MnsneL6WNDfYJnPxHasStBGon vEWiPdFmJEfislofNJEpl82q+RkzukQAJTROdgU8I3mtKvd+WNJmm8aES2OjRLp2AbzSdG+o+HBs uLndIgXcj2qX0NiAeGx0Bta/AZSga/2YDpsuAAAAAElFTkSuQmCC "/>
<path d="m2.21 2.38h2.695c0.75074 0 0.78302 0.0285 1.5421 0.62962 0.78159 0.5904 0.94779 0.607 1.8636 0.607l6.4126-0.0524c0.638-5e-3 1.1517 0.51363 1.1517 1.1516v6.77c0 0.63802-0.51364 1.1517-1.1517 1.1517h-12.513c-0.63802 0-1.1517-0.51364-1.1517-1.1517v-7.9542c0-0.63802 0.51364-1.1517 1.1517-1.1517z" fill="#46a2d7"/>
<path d="m2.2102 2.3812c-0.63801 0-1.1518 0.51384-1.1518 1.1518v2.8167h14.816v-1.633c0-0.63801-0.51387-1.1563-1.1518-1.1513l-6.4124 0.052194c-0.91582 0-1.0818-0.016798-1.8634-0.60718-0.75908-0.6011-0.79128-0.62941-1.542-0.62941h-2.695z" fill="url(#linearGradient897)" opacity=".35" stroke-width=".26458"/>
<rect x="1.0583" y="4.49" width="14.817" height="10.054" rx="1.1517" ry="1.1288" fill="url(#linearGradient1769)"/>
<rect x="1.0583" y="12.7" width="14.817" height=".52915" fill="url(#linearGradient860)"/>
<path d="m1.0655 13.494c0.03752 0.59168 0.5312 1.0583 1.1446 1.0583h12.513c0.6134 0 1.1071-0.46664 1.1446-1.0583h-14.802z" fill="url(#linearGradient868)" stroke-width=".26458"/>
<rect x="1.0583" y="4.49" width="14.817" height="10.054" rx="1.1517" ry="1.1288" fill="url(#linearGradient907)"/>
<path d="m2.2102 4.4979c-0.63801 0-1.1518 0.50323-1.1518 1.1286v0.23512c0-0.6089 0.51384-1.0991 1.1518-1.0991h12.513c0.63801 0 1.1518 0.49024 1.1518 1.0991v-0.23512c0-0.62536-0.51384-1.1286-1.1518-1.1286z" fill="#fff" opacity=".1" stroke-width=".26458"/>
</svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="org/gtk/daleclack">
<file>icons/16x16/actions/list-add.svg</file>
<file>icons/16x16/actions/list-remove.svg</file>
<file>icons/scalable/status/display_prefs.svg</file>
<file>folder-images.svg</file>
<file>folder.svg</file>
<file>image_file.svg</file>
<file preprocess="xml-stripblanks">prefs_stack.ui</file>
</gresource>
</gresources>

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#363636;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 7 3.0058594 L 7 8 L 2 8 L 2 8.9980469 L 7 8.9980469 L 7 14.007812 L 8 14.007812 L 8 8.9980469 L 13 8.9980469 L 13 8 L 8 8 L 8 3.0058594 L 7 3.0058594 z "
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 490 B

View File

@ -0,0 +1,8 @@
<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#363636;
}</style>
</defs>
<path class="ColorScheme-Text" d="m3 8v1h10v-1z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 281 B

View File

@ -0,0 +1,54 @@
<svg width="64" height="64" version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<linearGradient id="a">
<stop stop-color="#909090" offset="0"/>
<stop stop-color="#636363" stop-opacity="0" offset="1"/>
</linearGradient>
<radialGradient id="b" cx="199.22" cy="60.978" r="62.148" gradientTransform="matrix(1.0119 3e-8 -1.5e-7 5.0958 -134.28 -251.23)" gradientUnits="userSpaceOnUse">
<stop stop-color="#e6e6e8" offset="0"/>
<stop stop-color="#cbccce" offset="1"/>
</radialGradient>
<radialGradient id="c" cx="199.22" cy="60.978" r="62.148" gradientTransform="matrix(1.3103 -4e-8 1e-7 3.6151 -193.73 -160.94)" gradientUnits="userSpaceOnUse">
<stop stop-color="#ececef" offset="0"/>
<stop stop-color="#cbccce" stop-opacity="0" offset="1"/>
</radialGradient>
<filter id="d" x="-.01448" y="-.016908" width="1.029" height="1.0338" color-interpolation-filters="sRGB">
<feGaussianBlur stdDeviation=".74992302"/>
</filter>
<linearGradient id="e" x1="174.79" x2="174.86" y1="109.47" y2="118.12" gradientUnits="userSpaceOnUse">
<stop stop-color="#909090" offset="0"/>
<stop stop-color="#727272" stop-opacity="0" offset="1"/>
</linearGradient>
<radialGradient id="f" cx="178.79" cy="120.7" r="22.055" gradientTransform="matrix(3.8591 -2.3e-7 0 .1388 -511.17 103.95)" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
<filter id="g" x="-.040865" y="-.504" width="1.0817" height="2.008" color-interpolation-filters="sRGB">
<feGaussianBlur stdDeviation=".32830532"/>
</filter>
<filter id="h" x="-.080467" y="-.24545" width="1.1609" height="1.4909" color-interpolation-filters="sRGB">
<feGaussianBlur stdDeviation="1.4789442"/>
</filter>
<linearGradient id="i" x1="183.06" x2="183.06" y1="129.42" y2="127.06" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
<linearGradient id="j" x1="23.844" x2="23.816" y1="17.574" y2="85.151" gradientUnits="userSpaceOnUse">
<stop stop-color="#1bd2fa" offset="0"/>
<stop stop-color="#1c7ef2" offset="1"/>
</linearGradient>
<g transform="matrix(.48966 0 0 .48209 -.95621 -1.3862)">
<g stroke-width="2.0582">
<rect x="5.1564" y="8.7788" width="124.3" height="103.95" rx="5.6617" fill="#1a1a1a" filter="url(#d)" opacity=".887"/>
<rect x="5.1564" y="8.7788" width="124.3" height="103.95" rx="5.6617" fill="url(#b)"/>
<rect x="5.1564" y="8.7788" width="124.3" height="103.95" rx="5.6617" fill="url(#c)"/>
<path d="m10.818 8.778c-3.1366 0-5.6621 2.5256-5.6621 5.6621v75.664h124.3v-75.664c0-3.1366-2.5256-5.6621-5.6621-5.6621z" fill="#080808"/>
<path d="m10.318 12.353h113.49v73.329h-113.49z" fill="url(#j)"/>
<path d="m5.1558 106.01v1.0566c0 3.1366 2.5256 5.6621 5.6621 5.6621h112.97c3.1366 0 5.6621-2.5256 5.6621-5.6621v-1.0566c0 3.1366-2.5256 5.6621-5.6621 5.6621h-112.97c-3.1366 0-5.6621-2.5256-5.6621-5.6621z" fill="#afafaf"/>
<g transform="translate(-111.48 -1.4739)">
<path d="m194.34 114.95c-0.0882 3.6995-0.94643 7.8217 4.9506 11.334 4.7067 2.9258-2.6114 3.1267-4.4295 3.1267h-5.6672-26.478c-1.8181 0-9.1362-0.20092-4.4295-3.1267 5.8971-3.5127 5.0389-7.6349 4.9506-11.334z" filter="url(#h)"/>
<path d="m194.34 113.47c-0.0882 3.6995-0.94643 7.8217 4.9506 11.334 4.7067 2.9258-2.6114 3.1267-4.4295 3.1267-10.492 0.46272-21.162 0.7623-32.145 0-1.8181 0-9.1362-0.20092-4.4295-3.1267 5.8971-3.5127 5.0389-7.6349 4.9506-11.334z" fill="#e0e1e6"/>
<path d="m194.34 113.47c-0.0882 3.6995-0.94643 7.8217 4.9506 11.334 4.7067 2.9258-2.6114 3.1267-4.4295 3.1267h-5.6672-26.478c-1.8181 0-9.1362-0.20092-4.4295-3.1267 5.8971-3.5127 5.0389-7.6349 4.9506-11.334z" fill="url(#e)"/>
<path d="m194.34 113.47c-0.0882 3.6995-0.94643 7.8217 4.9506 11.334 4.7067 2.9258-2.6114 3.1267-4.4295 3.1267h-5.6672-26.478c-1.8181 0-9.1362-0.20092-4.4295-3.1267 5.8971-3.5127 5.0389-7.6349 4.9506-11.334z" fill="url(#f)"/>
<ellipse cx="178.29" cy="127.15" rx="15.764" ry=".78168" fill="#fff" filter="url(#g)" opacity=".887"/>
<path d="m194.34 113.47c-0.0882 3.6995-0.94643 7.8217 4.9506 11.334 4.7067 2.9258-2.6114 3.1267-4.4295 3.1267h-5.6672-26.478c-1.8181 0-9.1362-0.20092-4.4295-3.1267 5.8971-3.5127 5.0389-7.6349 4.9506-11.334z" fill="url(#i)"/>
</g>
</g>
<path d="m71.574 102.9c-0.16003 0.36969-0.34945 0.70998-0.56891 1.0228-0.29914 0.42652-0.54408 0.72174-0.73285 0.8857-0.29261 0.26911-0.60613 0.4069-0.94186 0.41475-0.24102 0-0.53167-0.0687-0.87001-0.2077-0.33945-0.13848-0.6514-0.20705-0.93664-0.20705-0.29915 0-0.61998 0.0687-0.96315 0.20705-0.3437 0.13913-0.62057 0.21162-0.83226 0.21882-0.32195 0.0137-0.64285-0.12802-0.96316-0.42587-0.20444-0.1783-0.46015-0.48401-0.76648-0.91705-0.32868-0.46244-0.59889-0.99867-0.81058-1.61-0.22671-0.66033-0.34036-1.2998-0.34036-1.9189 0-0.70913 0.15323-1.3207 0.46015-1.8333 0.24121-0.41168 0.56211-0.73643 0.96374-0.97484 0.40163-0.2384 0.83559-0.35988 1.3029-0.36765 0.25572 0 0.59105 0.0791 1.0078 0.23454 0.41554 0.15598 0.68236 0.23507 0.79934 0.23507 0.0875 0 0.38386-0.0925 0.88634-0.27687 0.47518-0.171 0.87622-0.2418 1.2048-0.21391 0.89026 0.0718 1.5591 0.4228 2.0039 1.0551-0.79621 0.48241-1.1901 1.1581-1.1822 2.0249 7e-3 0.6752 0.25212 1.237 0.7335 1.6831 0.21816 0.20707 0.46179 0.36709 0.73285 0.48075-0.0588 0.17044-0.12084 0.33376-0.1868 0.49052zm-2.0418-8.0346c0 0.5292-0.19334 1.0233-0.5787 1.4806-0.46506 0.5437-1.0276 0.85787-1.6376 0.80829-8e-3 -0.0634-0.0123-0.13031-0.0123-0.20052 0-0.50803 0.22116-1.0517 0.61391-1.4963 0.19608-0.22508 0.44546-0.41224 0.74787-0.56153 0.30176-0.14706 0.5872-0.22839 0.85564-0.24232 8e-3 0.07076 0.0112 0.1415 0.0112 0.21169z" fill="#1e1f28" stroke-width=".13443"/>
<path d="m10.318 12.352v73.33h113.49v-73.33zm0.55273 0.50781h112.48v72.361h-112.48z" fill-opacity=".21198" stroke-width="2.0582"/>
<path d="m10.818 9.0273c-3.1366 0-5.6621 2.5256-5.6621 5.6621v75.414h124.3v-75.414c0-3.1366-2.5255-5.6621-5.6621-5.6621zm-0.5 5.3262h113.49v71.328h-113.49z" fill="#080808" stroke-width="2.0582"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -0,0 +1,6 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text { color:#363636; } .ColorScheme-Text { color:#363636; }</style>
</defs>
<path d="m2 1c-1.108 0-2 0.892-2 2v9c0 1.108 0.892 2 2 2h12c1.108 0 2-0.892 2-2v-9c0-1.108-0.892-2-2-2zm0 1h12c0.554 0 1 0.446 1 1v9l-5-5-3.4794 4-2.5206-2-3 3v-9c0-0.554 0.446-1 1-1zm2.5 2c-0.82843 0-1.5 0.67157-1.5 1.5s0.67157 1.5 1.5 1.5 1.5-0.67157 1.5-1.5-0.67157-1.5-1.5-1.5z" style="fill:currentColor" class="ColorScheme-Text"/>
</svg>

After

Width:  |  Height:  |  Size: 592 B

View File

@ -0,0 +1,297 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">9999</property>
<property name="value">1024</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">9999</property>
<property name="value">576</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkBox" id="stack_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkStackSwitcher">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="stack">main_stack</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkStack" id="main_stack">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkBox" id="back_page">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">Background Preferences</property>
</packing>
</child>
<child>
<object class="GtkBox" id="winsize_page">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">128</property>
<property name="icon-name">display_prefs</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<!-- n-columns=4 n-rows=5 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-spacing">5</property>
<property name="column-spacing">5</property>
<child>
<object class="GtkComboBoxText" id="combo_default">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="active">2</property>
<items>
<item translatable="yes">640x360</item>
<item translatable="yes">800x450</item>
<item translatable="yes">1024x576</item>
<item translatable="yes">1280x720</item>
</items>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_default">
<property name="label" translatable="yes">Use default window size</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">radio_custom</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_custom">
<property name="label" translatable="yes">User defined window size</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin_width">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="value">1024</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin_height">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="adjustment">adjustment2</property>
<property name="value">576</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">x</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkButton" id="btnapply">
<property name="label" translatable="yes">Apply</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnGet">
<property name="label" translatable="yes">Get Current</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_size">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Current Config: </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">Window Size Config</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@ -0,0 +1,457 @@
#include "MyPrefs.hh"
#include "winpe.xpm"
#include "../Gtk4/img7.xpm"
#include "image_types.hh"
#include "cfgfile/cfgfile.hh"
#include <iostream>
#include <fstream>
#include <glibmm/i18n.h>
MyPrefs::MyPrefs()
: main_box(Gtk::ORIENTATION_VERTICAL, 10),
views_box(Gtk::ORIENTATION_HORIZONTAL, 5),
btnbox(Gtk::ORIENTATION_HORIZONTAL, 5),
width(1024),
height(576)
{
/*Step 1: Initalize widget that without Gtk::Builder*/
// Initalize Window
set_title(_("Window Preferences"));
set_default_size(800, 450);
// Initalize Stores
folders_store = Gtk::ListStore::create(n_columns);
folders_store->set_default_sort_func(sigc::mem_fun(*this, &MyPrefs::sort_func));
folders_store->set_sort_column(-1, Gtk::SORT_ASCENDING);
folders_view.set_model(folders_store);
folder_selection = folders_view.get_selection();
folder_selection->signal_changed().connect(sigc::mem_fun(*this, &MyPrefs::folders_view_changed));
images_store = Gtk::ListStore::create(n_columns);
images_store->set_default_sort_func(sigc::mem_fun(*this, &MyPrefs::sort_func));
images_store->set_sort_column(-1, Gtk::SORT_ASCENDING);
images_view.set_model(images_store);
image_selection = images_view.get_selection();
image_selection->signal_changed().connect(sigc::mem_fun(*this, &MyPrefs::images_view_changed));
// Load Pixbufs
auto pixbuf = Gdk::Pixbuf::create_from_resource("/org/gtk/daleclack/folder.svg");
folder_pixbuf = pixbuf->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
pixbuf.reset();
pixbuf = Gdk::Pixbuf::create_from_resource("/org/gtk/daleclack/folder-images.svg");
image_pixbuf = pixbuf->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
pixbuf.reset();
pixbuf = Gdk::Pixbuf::create_from_resource("/org/gtk/daleclack/image_file.svg");
imagefile_pixbuf = pixbuf->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
pixbuf.reset();
// Add Default Value for folders view
auto row = *(folders_store->append());
row[n_columns.m_col_path] = "";
row[n_columns.m_col_name] = _("Default Backgrounds");
row[n_columns.m_col_pixbuf] = folder_pixbuf;
row[n_columns.m_col_internal] = true;
row = *(folders_store->append());
row[n_columns.m_col_path] = Glib::get_home_dir();
row[n_columns.m_col_name] = _("User's Home");
row[n_columns.m_col_pixbuf] = folder_pixbuf;
row[n_columns.m_col_internal] = false;
row = *(folders_store->append());
row[n_columns.m_col_path] = Glib::get_user_special_dir(Glib::USER_DIRECTORY_PICTURES);
row[n_columns.m_col_name] = _("User's Pictures Directory");
row[n_columns.m_col_pixbuf] = image_pixbuf;
row[n_columns.m_col_internal] = false;
// Append Column for the folders view
folders_view.append_column(" ", n_columns.m_col_pixbuf);
folders_view.append_column(_("Name"), n_columns.m_col_name);
// Default Value for imags view
default_folders_view();
images_view.append_column(" ", n_columns.m_col_pixbuf);
images_view.append_column(_("Images"), n_columns.m_col_name);
// Add Views
main_box.pack_start(views_box);
sw_folders.add(folders_view);
views_box.pack_start(sw_folders);
sw_images.add(images_view);
views_box.pack_start(sw_images);
// Allow Selection
has_selection = true;
// Add Control Buttons
btnadd.set_image_from_icon_name("list-add");
btnadd.signal_clicked().connect(sigc::mem_fun(*this, &MyPrefs::btnadd_clicked));
btnremove.set_image_from_icon_name("list-remove");
btnremove.signal_clicked().connect(sigc::mem_fun(*this, &MyPrefs::btnremove_clicked));
btnbox.pack_start(btnadd, Gtk::PACK_SHRINK);
btnbox.pack_start(btnremove, Gtk::PACK_SHRINK);
main_box.pack_start(btnbox, Gtk::PACK_SHRINK);
// Add Main Box to window
const int margin_value = 15;
main_box.set_hexpand();
main_box.set_vexpand();
main_box.set_margin_top(margin_value);
main_box.set_margin_bottom(margin_value);
main_box.set_margin_start(margin_value);
main_box.set_margin_end(margin_value);
/*Step 2: Initalize widgets from glade xml file ('.ui' file)*/
// Get Widgets for multi pages
stackbuilder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/prefs_stack.ui");
stackbuilder->get_widget("stack_box", stack_box);
stackbuilder->get_widget("back_page", back_page);
stackbuilder->get_widget("combo_default", combo_default);
stackbuilder->get_widget("radio_default", radio_default);
stackbuilder->get_widget("radio_custom", radio_custom);
stackbuilder->get_widget("spin_width", spin_width);
stackbuilder->get_widget("spin_height", spin_height);
stackbuilder->get_widget("btnapply", btnapply);
stackbuilder->get_widget("btnGet",btnGet);
stackbuilder->get_widget("label_size",label_size);
// Initalize radio buttons
radio_default->set_active();
radio_default->signal_toggled().connect(sigc::mem_fun(*this, &MyPrefs::radiobutton_toggled));
radio_custom->signal_toggled().connect(sigc::mem_fun(*this, &MyPrefs::radiobutton_toggled));
// Initalize other widgets
btnapply->signal_clicked().connect(sigc::mem_fun(*this, &MyPrefs::btnapply_clicked));
btnGet->signal_clicked().connect(sigc::mem_fun(*this,&MyPrefs::btnGet_clicked));
// Initalize Label
load_winsize_config();
const char * cfgstr = _("Current Config");
char * size_str = g_strdup_printf("%s: %d x %d", cfgstr, width, height);
label_size->set_label(size_str);
g_free(size_str);
back_page->pack_start(main_box);
add(*stack_box);
show_all_children();
}
void MyPrefs::btnadd_clicked()
{
// Create a dialog
dialog = Gtk::FileChooserNative::create(_("Add a folder"), *this,
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, _("OK"), _("Cancel"));
dialog->signal_response().connect(sigc::mem_fun(*this, &MyPrefs::dialog_response));
dialog->show();
}
void MyPrefs::dialog_response(int response_id)
{
if (response_id == Gtk::RESPONSE_ACCEPT)
{
// Get File Basename and Path
auto file = dialog->get_file();
auto basename = file->get_basename();
auto filename = file->get_path();
// Add to list
auto row = *(folders_store->append());
row[n_columns.m_col_path] = filename;
row[n_columns.m_col_name] = basename;
row[n_columns.m_col_pixbuf] = folder_pixbuf;
file.reset();
}
dialog.reset();
}
void MyPrefs::btnremove_clicked()
{
// Get the selection and remove the selected item
auto iter = folder_selection->get_selected();
if (iter)
{
folders_store->erase(iter);
}
}
void MyPrefs::folders_view_changed()
{
// Get Selected Folder
auto row = *(folder_selection->get_selected());
if (row[n_columns.m_col_internal])
{
// The default folder
default_folders_view();
}
else
{
// User defined folder
std::string path = row[n_columns.m_col_path];
update_images_view(path);
}
}
void MyPrefs::default_folders_view()
{
// Clear the store
images_store->clear();
// Add Default values
auto row = *(images_store->append());
row[n_columns.m_col_path] = ":1";
row[n_columns.m_col_name] = "winpe.xpm";
row[n_columns.m_col_internal] = true;
row[n_columns.m_col_pixbuf] = imagefile_pixbuf;
row = *(images_store->append());
row[n_columns.m_col_path] = ":2";
row[n_columns.m_col_name] = "img7.xpm";
row[n_columns.m_col_internal] = true;
row[n_columns.m_col_pixbuf] = imagefile_pixbuf;
}
int MyPrefs::sort_func(const Gtk::TreeModel::iterator &a, const Gtk::TreeModel::iterator &b)
{
Glib::ustring name_a, name_b;
// Get file names
auto row_a = *(a);
auto row_b = *(b);
name_a = row_a[n_columns.m_col_name];
name_b = row_b[n_columns.m_col_name];
// Proform sort process
if (name_a[0] != '.' && name_b[0] == '.')
{
return 1;
}
if (name_a[0] == '.' && name_b[0] != '.')
{
return -1;
}
else
{
return g_utf8_collate(name_a.c_str(), name_b.c_str());
}
}
bool MyPrefs::icasecompare(const std::string &a, const std::string &b)
{
if (a.length() == b.length())
{
return std::equal(a.begin(), a.end(), b.begin(),
[](char a, char b)
{
return tolower(a) == tolower(b);
});
}
else
{
return false;
}
}
void MyPrefs::update_images_view(std::string &folder_path)
{
// Unselect everything
has_selection = false;
// Clear the store
images_store->clear();
// Add Files into store
try
{
Glib::Dir dir1(folder_path);
bool is_dir, file_valid;
Glib::ustring display_name;
std::string filename, pathname;
do
{
// Get File Name
filename = dir1.read_name();
// Get Path for a file
pathname = Glib::build_filename(folder_path, filename);
is_dir = Glib::file_test(pathname, Glib::FILE_TEST_IS_DIR);
display_name = Glib::filename_to_utf8(filename);
// Filter the file
// Get Pattern of the file
file_valid = false;
size_t pos = filename.find_last_of('.');
if (pos != std::string::npos)
{
std::string pattern = "*" + filename.substr(pos);
for (int i = 0; supported_globs[i] != NULL; i++)
{
std::string glob = std::string(supported_globs[i]);
if (icasecompare(glob, pattern))
{
file_valid = true;
break;
}
}
}
if (!is_dir && file_valid)
{
// Add item to store
auto row = *(images_store->append());
row[n_columns.m_col_path] = pathname;
row[n_columns.m_col_name] = display_name;
row[n_columns.m_col_internal] = false;
row[n_columns.m_col_pixbuf] = imagefile_pixbuf;
}
} while (filename != "");
has_selection = true;
}
catch (Glib::Error &ex)
{
std::cout << ex.what() << std::endl;
}
}
void MyPrefs::images_view_changed()
{
// Set the background as selected
if (has_selection)
{
auto row = *(image_selection->get_selected());
if (row[n_columns.m_col_internal])
{
path = row[n_columns.m_col_path];
switch (path[1])
{
case '1':
set_background_internal(winpe);
break;
case '2':
set_background_internal(img7);
break;
}
}
else
{
path = row[n_columns.m_col_path];
set_background_file();
}
}
}
void MyPrefs::set_background_internal(const char *const *data)
{
// Set a internal background
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(data);
auto sized = pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
gtk_image_set_from_pixbuf(background1->gobj(), sized->gobj());
pixbuf.reset();
sized.reset();
background_internal = true;
}
void MyPrefs::set_background_file()
{
// Set Background from a file
auto pixbuf = Gdk::Pixbuf::create_from_file(path);
auto sized = pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
gtk_image_set_from_pixbuf(background1->gobj(), sized->gobj());
pixbuf.reset();
sized.reset();
background_internal = false;
}
void MyPrefs::update_background_size()
{}
void MyPrefs::set_background(Gtk::Image *back)
{
background1 = back;
}
void MyPrefs::radiobutton_toggled()
{
// Change sensitive state of buttons
bool mode = radio_default->get_active();
combo_default->set_sensitive(mode);
spin_height->set_sensitive(!mode);
spin_width->set_sensitive(!mode);
btnGet->set_sensitive(!mode);
}
void MyPrefs::btnapply_clicked()
{
// Get Config
if (radio_default->get_active())
{
int mode = combo_default->get_active_row_number();
switch (mode)
{
case 0:
width = 640;
height = 360;
break;
case 1:
width = 800;
height = 576;
break;
case 2:
width = 1024;
height = 576;
break;
case 3:
width = 1280;
height = 720;
break;
}
}
else
{
width = spin_width->get_value_as_int();
height = spin_height->get_value_as_int();
}
// Open the file for configs
std::fstream outfile;
outfile.open("config", std::ios_base::out);
if (outfile.is_open())
{
outfile << "width=" << width << std::endl;
outfile << "height=" << height << std::endl;
outfile.close();
}
}
void MyPrefs::btnGet_clicked()
{
//Get Current Window Size
width = background1->get_width();
height = background1->get_height();
spin_width->set_value(width);
spin_height->set_value(height);
}
void MyPrefs::load_winsize_config(){
std::string height_str, width_str;
// Read values from a file
if (readCfgFile("config", "width", width_str) && readCfgFile("config", "height", height_str))
{
height = atoi(height_str.c_str());
width = atoi(width_str.c_str());
}
}
void MyPrefs::get_winsize_config(int &width1, int &height1)
{
// Apply Config
width1 = width;
height1 = height;
}

View File

@ -0,0 +1,80 @@
#pragma once
#include <gtkmm.h>
#include <string>
class MyPrefs : public Gtk::Window
{
public:
MyPrefs();
void set_background(Gtk::Image *back);
void load_winsize_config();
void get_winsize_config(int &width1,int &height1);
void update_background_size();
protected:
class ModelColumns : public Gtk::TreeModelColumnRecord
{
public:
ModelColumns()
{
add(m_col_pixbuf);
add(m_col_path);
add(m_col_name);
add(m_col_internal);
}
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>> m_col_pixbuf;
Gtk::TreeModelColumn<std::string> m_col_path;
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
Gtk::TreeModelColumn<bool> m_col_internal;
};
ModelColumns n_columns;
Glib::RefPtr<Gtk::ListStore> folders_store, images_store;
Glib::RefPtr<Gtk::TreeSelection> folder_selection, image_selection;
bool has_selection;
private:
// Background widget and properties
int width, height;
Gtk::Image *background1;
std::string path;
bool background_internal;
//Page switcher and another page
Glib::RefPtr<Gtk::Builder> stackbuilder;
Gtk::Box *stack_box, *back_page, *winsize_page;
Gtk::RadioButton *radio_default, *radio_custom;
Gtk::ComboBoxText *combo_default;
Gtk::SpinButton *spin_width, *spin_height;
Gtk::Button *btnapply, *btnGet;
Gtk::Label *label_size;
// Child Widgets
Gtk::TreeView folders_view, images_view;
Gtk::ScrolledWindow sw_folders, sw_images;
Gtk::Box main_box, views_box, btnbox;
Gtk::Button btnadd, btnremove;
// Folder Open Dialog
Glib::RefPtr<Gdk::Pixbuf> folder_pixbuf, image_pixbuf, imagefile_pixbuf;
Glib::RefPtr<Gtk::FileChooserNative> dialog;
void dialog_response(int response_id);
// Sort for ListStore
int sort_func(const Gtk::TreeModel::iterator &a, const Gtk::TreeModel::iterator &b);
bool icasecompare(const std::string &a, const std::string &b);
// Signal Handlers
void btnadd_clicked();
void btnremove_clicked();
void folders_view_changed();
void images_view_changed();
void default_folders_view();
void update_images_view(std::string &folder_path);
void set_background_internal(const char *const *data);
void set_background_file();
void radiobutton_toggled();
void btnapply_clicked();
void btnGet_clicked();
};

View File

@ -0,0 +1,44 @@
#include "MyWin.hh"
#include "winpe.xpm"
MyWin::MyWin()
{
int width, height;
// Initalize Window
set_icon_name("org.gtk.daleclack");
set_title(_("Background Preferences Test"));
prefs_win.get_winsize_config(width, height);
// Add Background
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(winpe);
auto sized = pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
gtk_image_set_from_pixbuf(m_back.gobj(), sized->gobj());
pixbuf.reset();
sized.reset();
// Button for background
btnback.set_label(_("Window Preferences"));
btnback.set_halign(Gtk::ALIGN_CENTER);
btnback.set_valign(Gtk::ALIGN_CENTER);
btnback.set_relief(Gtk::RELIEF_NONE);
m_overlay.add_overlay(btnback);
btnback.signal_clicked().connect(sigc::mem_fun(*this, &MyWin::btnback_clicked));
// Add widgets
m_back.set_hexpand();
m_back.set_vexpand();
m_overlay.add(m_back);
add(m_overlay);
// Initalize MyPrefs
prefs_win.set_background(&m_back);
show_all_children();
}
void MyWin::btnback_clicked()
{
prefs_win.show_all();
}

View File

@ -0,0 +1,23 @@
#pragma once
#include <gtkmm.h>
#include <glibmm/i18n.h>
#include "MyPrefs.hh"
class MyWin : public Gtk::Window
{
public:
MyWin();
private:
//Child Widgets
Gtk::Overlay m_overlay;
Gtk::Image m_back;
Gtk::Button btnback;
//Background Preferences
MyPrefs prefs_win;
//Signal Handlers
void btnback_clicked();
};

View File

@ -0,0 +1,16 @@
#include "MyWin.hh"
#define GETTEXT_PACKAGE "gtk126"
#define PROGRAMNAME_LOCALEDIR "./po"
int main(int argc,char ** argv){
// Initalize gettext
//setlocale(LC_ALL,"");
bindtextdomain(GETTEXT_PACKAGE, PROGRAMNAME_LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
// Create application and run
auto app = Gtk::Application::create(argc,argv,"org.gtk.daleclack");
MyWin window;
return app->run(window);
}