Add support for pack dock to left and right

This commit is contained in:
daleclack 2023-01-09 13:08:29 +08:00
parent 7da9607c2d
commit 4f2694df74
5 changed files with 327 additions and 271 deletions

View File

@ -2,203 +2,6 @@
<!-- Generated with glade 3.40.0 --> <!-- Generated with glade 3.40.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.24"/> <requires lib="gtk+" version="3.24"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">My_GtkUI</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">audacious_whitesur</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">file-app</property>
</object>
<object class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">game</property>
</object>
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">image_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image16">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image17">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">vlc_whitesur</property>
</object>
<object class="GtkImage" id="image18">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">vlc_whitesur</property>
</object>
<object class="GtkImage" id="image19">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">myrunner</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">drawing_app</property>
</object>
<object class="GtkImage" id="image20">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_prefs</property>
</object>
<object class="GtkImage" id="image21">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_trash</property>
</object>
<object class="GtkImage" id="image22">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">24game</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image23">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">24game</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image24">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">calcapp</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image25">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">calcapp</property>
</object>
<object class="GtkImage" id="image26">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">mines_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image27">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">mines_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">file-app</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">game</property>
</object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">image_app</property>
</object>
<object class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_prefs</property>
</object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">btnabout</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">drawing_app</property>
</object>
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="finder_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="baseline-position">top</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="launchpad_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkBox" id="dock_box"> <object class="GtkBox" id="dock_box">
<property name="width-request">54</property> <property name="width-request">54</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -480,6 +283,217 @@
<placeholder/> <placeholder/>
</child> </child>
</object> </object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">My_GtkUI</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">audacious_whitesur</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">file-app</property>
</object>
<object class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">game</property>
</object>
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">image_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image16">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image17">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">vlc_whitesur</property>
</object>
<object class="GtkImage" id="image18">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">vlc_whitesur</property>
</object>
<object class="GtkImage" id="image19">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">myrunner</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">drawing_app</property>
</object>
<object class="GtkImage" id="image20">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_prefs</property>
</object>
<object class="GtkImage" id="image21">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_trash</property>
</object>
<object class="GtkImage" id="image22">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">24game</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image23">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">24game</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image24">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">calcapp</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image25">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">calcapp</property>
</object>
<object class="GtkImage" id="image26">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">mines_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image27">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">mines_app</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">file-app</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">game</property>
</object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
<object class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">image_app</property>
</object>
<object class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">my_prefs</property>
</object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">btnabout</property>
<property name="icon_size">6</property>
</object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">drawing_app</property>
</object>
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="finder_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="baseline-position">top</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="launchpad_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkBox" id="dock_left">
<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> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@ -969,9 +983,27 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkBox" id="dock_right">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -13,6 +13,8 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
// Get Widgets // Get Widgets
ref_builder->get_widget("finder_box", finder_box); ref_builder->get_widget("finder_box", finder_box);
ref_builder->get_widget("dock_box", dock_box); ref_builder->get_widget("dock_box", dock_box);
ref_builder->get_widget("dock_left", dock_left);
ref_builder->get_widget("dock_right", dock_right);
ref_builder->get_widget("btnlaunch", btnlaunch); ref_builder->get_widget("btnlaunch", btnlaunch);
ref_builder->get_widget("btndraw", btndraw); ref_builder->get_widget("btndraw", btndraw);
ref_builder->get_widget("btnfiles", btnfiles); ref_builder->get_widget("btnfiles", btnfiles);
@ -134,6 +136,22 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
break; break;
} }
// Set dock position
// The dock can be positioned at the left, right and the bottom of the window
auto dock_pos = prefs_win.get_dock_pos();
switch (dock_pos)
{
case DockPos::POS_LEFT:
dock_left->pack_start(*dock_box);
break;
case DockPos::POS_RIGHT:
dock_right->pack_start(*dock_box);
break;
case DockPos::POS_BOTTOM:
default:
dock_right->pack_start(*dock_box);
}
show_all_children(); show_all_children();
} }

View File

@ -24,7 +24,7 @@ public:
private: private:
// Child widgets // Child widgets
Gtk::Box *finder_box, *dock_box; Gtk::Box *finder_box, *dock_box, *dock_left, *dock_right;
Gtk::Button *btnlaunch, *btndraw, *btnfiles, *btncalc, Gtk::Button *btnlaunch, *btndraw, *btnfiles, *btncalc,
*btngame, *btnedit, *btnimage, *btnset, *btngame24, *btnmine; *btngame, *btnedit, *btnimage, *btnset, *btngame24, *btnmine;
Gtk::Separator *separator_start, *separator_end; Gtk::Separator *separator_start, *separator_end;

View File

@ -489,6 +489,11 @@ void MyPrefs::btnGet_clicked()
spin_height->set_value(height); spin_height->set_value(height);
} }
DockPos MyPrefs::get_dock_pos(){
// Get config for dock position
return dock_pos;
}
void MyPrefs::load_winsize_config() void MyPrefs::load_winsize_config()
{ {
// Read the config // Read the config

View File

@ -25,6 +25,7 @@ public:
void set_background(Gtk::Image *back); void set_background(Gtk::Image *back);
void load_winsize_config(); void load_winsize_config();
void update_background_size(); void update_background_size();
DockPos get_dock_pos();
protected: protected:
class ModelColumns : public Gtk::TreeModelColumnRecord class ModelColumns : public Gtk::TreeModelColumnRecord