Fix some errors

This commit is contained in:
daleclack 2023-05-14 00:00:20 +08:00
parent e10e2d0d63
commit a3793aed83
11 changed files with 403 additions and 555 deletions

View File

@ -24,7 +24,7 @@ include_directories (${GTKMM_INCLUDE_DIRS})
link_directories (${GTKMM_LIBRARY_DIRS})
set(SOURCES src/core/main.cc src/core/MyWin.cc src/core/MyStack.cc
src/ui/MyDock.cc src/ui/MyFinder.cc)
src/ui/MyDock.cc src/ui/MyFinder.cc src/ui/MyPrefs.cc)
#Compile resources with GCR_CMake

View File

@ -2,12 +2,14 @@
<!DOCTYPE cambalache-project SYSTEM "cambalache-project.dtd">
<cambalache-project version="0.10.3" target_tk="gtk-4.0">
<ui>
(1,None,"test.ui","test.ui",None,None,None,None,None,None)
(1,None,"test.ui","test.ui",None,None,None,None,None,None),
(2,None,None,"test2.ui",None,None,None,None,None,None)
</ui>
<object>
(1,1,"GtkWindow",None,None,None,None,None,None),
(1,2,"GtkButton",None,1,None,None,None,None),
(1,3,"GtkImage","image1",None,None,None,None,None)
(1,3,"GtkImage","image1",None,None,None,None,None),
(2,1,"GtkWindow",None,None,None,None,None,None)
</object>
<object_property>
(1,2,"GtkButton","child","3",None,None,None,None,None),

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<requires lib="gtk" version="4.0"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">9999</property>
<property name="value">1024</property>
@ -15,452 +14,25 @@
<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="hexpand">1</property>
<property name="vexpand">1</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>
<object class="GtkStackPage">
<property name="title" translatable="1">Background Preferences</property>
<property name="child">
<object class="GtkBox" id="back_page">
<property name="orientation">vertical</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>
<item translatable="yes">1366x768</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>
<child>
<object class="GtkBox" id="dock_page">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</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="GtkCheckButton" id="mode_check">
<property name="label" translatable="yes">Use panel mode:expand the dock</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">0</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Position:</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_left">
<property name="label" translatable="yes">Left</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>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_right">
<property name="label" translatable="yes">Right</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">radio_left</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_bottom">
<property name="label" translatable="yes">Bottom</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">radio_left</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">4</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>
<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="btnapply1">
<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>
<placeholder/>
</child>
<child>
<placeholder/>
@ -469,26 +41,318 @@
<placeholder/>
</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>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="title" translatable="1">Window Size Config</property>
<property name="child">
<object class="GtkBox" id="winsize_page">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage">
<property name="pixel-size">128</property>
<property name="icon-name">display_prefs</property>
</object>
</child>
<child>
<object class="GtkGrid">
<property name="row-spacing">5</property>
<property name="column-spacing">5</property>
<child>
<object class="GtkComboBoxText" id="combo_default">
<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>
<item translatable="yes">1366x768</item>
</items>
<layout>
<property name="column">1</property>
<property name="row">1</property>
<property name="column-span">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="radio_default">
<property name="label" translatable="1">Use default window size</property>
<property name="focusable">1</property>
<property name="active">1</property>
<property name="group">radio_custom</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
<property name="column-span">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="radio_custom">
<property name="label" translatable="1">User defined window size</property>
<property name="focusable">1</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
<property name="column-span">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="spin_width">
<property name="sensitive">0</property>
<property name="focusable">1</property>
<property name="adjustment">adjustment1</property>
<property name="value">1024</property>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="spin_height">
<property name="sensitive">0</property>
<property name="focusable">1</property>
<property name="adjustment">adjustment2</property>
<property name="value">576</property>
<layout>
<property name="column">3</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="1">x</property>
<layout>
<property name="column">2</property>
<property name="row">3</property>
</layout>
</object>
</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>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkButton" id="btnapply">
<property name="label" translatable="1">Apply</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">end</property>
</object>
</child>
<child>
<object class="GtkButton" id="btnGet">
<property name="label" translatable="1">Get Current</property>
<property name="sensitive">0</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label_size">
<property name="label" translatable="1">Current Config: </property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="title" translatable="1">Dock Preferences</property>
<property name="child">
<object class="GtkBox" id="dock_page">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage">
<property name="pixel-size">128</property>
<property name="icon-name">display_prefs</property>
</object>
</child>
<child>
<object class="GtkGrid">
<property name="row-spacing">5</property>
<property name="column-spacing">5</property>
<child>
<object class="GtkCheckButton" id="mode_check">
<property name="label" translatable="1">Use panel mode:expand the dock</property>
<property name="focusable">1</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
<property name="column-span">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="1">Position:</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="radio_left">
<property name="label" translatable="1">Left</property>
<property name="focusable">1</property>
<property name="active">1</property>
<layout>
<property name="column">2</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="radio_right">
<property name="label" translatable="1">Right</property>
<property name="focusable">1</property>
<property name="group">radio_left</property>
<layout>
<property name="column">2</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="radio_bottom">
<property name="label" translatable="1">Bottom</property>
<property name="focusable">1</property>
<property name="group">radio_left</property>
<layout>
<property name="column">2</property>
<property name="row">4</property>
</layout>
</object>
</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>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkButton" id="btnapply1">
<property name="label" translatable="1">Apply</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">end</property>
</object>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</property>
</object>
<packing>
<property name="name">dock_prefs</property>
<property name="title" translatable="yes">Dock Preferences</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>

View File

@ -21,7 +21,7 @@ MyWin::MyWin()
// Add background
// auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(winpe);
// auto sized = pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
// auto sized = pixbuf->scale_simple(width, height, Gdk::InterpType::BILINEAR);
// gtk_image_set_from_pixbuf(m_background.gobj(), sized->gobj());
m_overlay.set_child(m_background);
// pixbuf.reset();

View File

@ -6,9 +6,9 @@ Drawing::Drawing()
: fill_check("Enable Fill Color"),
main_label("Select a color"),
size_label("Pen Size"),
left_box(Gtk::ORIENTATION_VERTICAL, 5),
left_box(Gtk::Orientation::VERTICAL, 5),
main_box(Gtk::Orientation::HORIZONTAL, 5),
btn_box(Gtk::ORIENTATION_VERTICAL, 5),
btn_box(Gtk::Orientation::VERTICAL, 5),
btn_clear("Clear Board"),
btn_save("Save to png"),
btn_exit("Exit")

View File

@ -3,9 +3,9 @@
FileWindow::FileWindow()
:parent_str("/"),
vbox(Gtk::ORIENTATION_VERTICAL,5),
vbox(Gtk::Orientation::VERTICAL,5),
btnbox(Gtk::Orientation::HORIZONTAL,5),
menubox(Gtk::ORIENTATION_VERTICAL,5),
menubox(Gtk::Orientation::VERTICAL,5),
show_hidden("Show hidden files")
{
//Initalize Window
@ -15,10 +15,10 @@ show_hidden("Show hidden files")
//Load Pixbufs
auto pixbuf1 = Gdk::Pixbuf::create_from_resource("/org/gtk/daleclack/gnome-fs-regular.svg");
file_pixbuf = pixbuf1->scale_simple(48,48,Gdk::INTERP_BILINEAR);
file_pixbuf = pixbuf1->scale_simple(48,48,Gdk::InterpType::BILINEAR);
pixbuf1.reset();
pixbuf1 = Gdk::Pixbuf::create_from_resource("/org/gtk/daleclack/folder.svg");
folder_pixbuf = pixbuf1->scale_simple(48,48,Gdk::INTERP_BILINEAR);
folder_pixbuf = pixbuf1->scale_simple(48,48,Gdk::InterpType::BILINEAR);
pixbuf1.reset();
//Create Child Widgets

View File

@ -1,7 +1,7 @@
#include "ImageApp.hh"
ImageApp::ImageApp()
: main_box(Gtk::ORIENTATION_VERTICAL, 5),
: main_box(Gtk::Orientation::VERTICAL, 5),
btnbox(Gtk::Orientation::HORIZONTAL, 5),
btnopen("Open Image")
{

View File

@ -3,7 +3,7 @@
#include <iostream>
MineSweeper::MineSweeper()
: main_box(Gtk::ORIENTATION_VERTICAL, 5),
: main_box(Gtk::Orientation::VERTICAL, 5),
btn_box(Gtk::Orientation::HORIZONTAL, 5),
cell(nullptr)
{

View File

@ -8,7 +8,7 @@
using json = nlohmann::json;
TextEditor::TextEditor()
: vbox(Gtk::ORIENTATION_VERTICAL, 5),
: vbox(Gtk::Orientation::VERTICAL, 5),
hbox(Gtk::Orientation::HORIZONTAL, 5),
searchbox(Gtk::Orientation::HORIZONTAL, 5),
file_opened(false)

View File

@ -6,7 +6,7 @@
#include <fstream>
MyPrefs::MyPrefs()
: main_box(Gtk::ORIENTATION_VERTICAL, 10),
: main_box(Gtk::Orientation::VERTICAL, 10),
views_box(Gtk::Orientation::HORIZONTAL, 5),
btnbox(Gtk::Orientation::HORIZONTAL, 5),
width(1024),
@ -22,81 +22,81 @@ MyPrefs::MyPrefs()
// Load config file
load_winsize_config();
// 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));
// // 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));
// 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);
folder_pixbuf = pixbuf->scale_simple(24, 24, Gdk::InterpType::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);
image_pixbuf = pixbuf->scale_simple(24, 24, Gdk::InterpType::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);
imagefile_pixbuf = pixbuf->scale_simple(24, 24, Gdk::InterpType::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;
// // 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_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;
// 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 folders from config file
if(!back_list.empty()){
for(auto iter = back_list.begin(); iter != back_list.end(); iter++){
// Get pair value from vector
std::pair<std::string, std::string> temp;
temp = *iter;
// // Append folders from config file
// if(!back_list.empty()){
// for(auto iter = back_list.begin(); iter != back_list.end(); iter++){
// // Get pair value from vector
// std::pair<std::string, std::string> temp;
// temp = *iter;
// Append folder to the folders store
auto row = *(folders_store->append());
row[n_columns.m_col_path] = temp.second;
row[n_columns.m_col_name] = temp.first;
row[n_columns.m_col_pixbuf] = folder_pixbuf;
row[n_columns.m_col_internal] = false;
}
}
// // Append folder to the folders store
// auto row = *(folders_store->append());
// row[n_columns.m_col_path] = temp.second;
// row[n_columns.m_col_name] = temp.first;
// row[n_columns.m_col_pixbuf] = folder_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);
// // 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 images view
default_folders_view();
images_view.append_column(" ", n_columns.m_col_pixbuf);
images_view.append_column("Images", n_columns.m_col_name);
// // Default Value for images 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.append(views_box);
sw_folders.add(folders_view);
sw_folders.set_child(folders_view);
views_box.append(sw_folders);
sw_images.add(images_view);
sw_images.set_child(images_view);
views_box.append(sw_images);
// Allow Selection
@ -173,15 +173,15 @@ MyPrefs::MyPrefs()
}
back_page->append(main_box);
add(*stack_box);
show_all_children();
set_child(*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");
Gtk::FileChooser::Action::SELECT_FOLDER, "OK", "Cancel");
dialog->signal_response().connect(sigc::mem_fun(*this, &MyPrefs::dialog_response));
@ -190,18 +190,18 @@ void MyPrefs::btnadd_clicked()
void MyPrefs::dialog_response(int response_id)
{
if (response_id == Gtk::RESPONSE_ACCEPT)
if (response_id == Gtk::ResponseType::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;
// // 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;
// Add for json file
save_config_file();
@ -401,7 +401,7 @@ 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);
auto sized = pixbuf->scale_simple(width, height, Gdk::InterpType::BILINEAR);
gtk_image_set_from_pixbuf(background1->gobj(), sized->gobj());
pixbuf.reset();
sized.reset();
@ -413,7 +413,7 @@ void MyPrefs::set_background_file()
// Set Background from a file
try{
auto pixbuf = Gdk::Pixbuf::create_from_file(path);
auto sized = pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
auto sized = pixbuf->scale_simple(width, height, Gdk::InterpType::BILINEAR);
gtk_image_set_from_pixbuf(background1->gobj(), sized->gobj());
pixbuf.reset();
sized.reset();

View File

@ -31,25 +31,7 @@ public:
DockPos get_dock_pos();
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<std::string> 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:
@ -67,7 +49,7 @@ private:
// 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::CheckButton *radio_default, *radio_custom;
Gtk::ComboBoxText *combo_default;
Gtk::SpinButton *spin_width, *spin_height;
Gtk::Button *btnapply, *btnGet;
@ -76,10 +58,10 @@ private:
// Dock Preferences
Gtk::Button *btnapply1;
Gtk::CheckButton *mode_check;
// Gtk::RadioButton *radio_left, *radio_right, *radio_bottom;
Gtk::CheckButton *radio_left, *radio_right, *radio_bottom;
// Child Widgets
Gtk::TreeView folders_view, images_view;
Gtk::ListView folders_view, images_view;
Gtk::ScrolledWindow sw_folders, sw_images;
Gtk::Box main_box, views_box, btnbox;
Gtk::Button btnadd, btnremove;