Add dock expand config

This commit is contained in:
daleclack 2022-02-10 12:51:52 +08:00
parent ad9b91da75
commit e492fb78c9
7 changed files with 36 additions and 3 deletions

View File

@ -26,6 +26,10 @@
<item> <item>
<attribute name="label">Turn Magnification On</attribute> <attribute name="label">Turn Magnification On</attribute>
</item> </item>
<item>
<attribute name="label">Expand</attribute>
<attribute name="action">win.expand</attribute>
</item>
</section> </section>
<section> <section>
<item> <item>

View File

@ -33,3 +33,7 @@ void MyStack::logout(){
void MyStack::btnlogin_clicked(){ void MyStack::btnlogin_clicked(){
stack->set_visible_child(*main_page); stack->set_visible_child(*main_page);
} }
void MyStack::set_mydock_mode(DockMode mode){
main_dock->set_dock_mode(mode);
}

View File

@ -10,6 +10,7 @@ public:
void logout(); void logout();
void mystack_init(Gtk::Window *window, Gtk::Image *m_back); void mystack_init(Gtk::Window *window, Gtk::Image *m_back);
void show_prefs(); void show_prefs();
void set_mydock_mode(DockMode mode);
// Main Widget // Main Widget
Gtk::Stack *stack; Gtk::Stack *stack;

View File

@ -23,7 +23,8 @@ MyWin::MyWin()
add_action("logout", sigc::mem_fun(*this, &MyWin::logout_activated)); add_action("logout", sigc::mem_fun(*this, &MyWin::logout_activated));
add_action("quit", sigc::mem_fun(*this, &MyWin::quit_activated)); add_action("quit", sigc::mem_fun(*this, &MyWin::quit_activated));
add_action("about", sigc::mem_fun(*this, &MyWin::about_activated)); add_action("about", sigc::mem_fun(*this, &MyWin::about_activated));
add_action("back", sigc::mem_fun(*this, &MyWin::back_actiavted)); add_action("back", sigc::mem_fun(*this, &MyWin::back_activated));
add_action("expand",sigc::mem_fun(*this,&MyWin::expand_activated));
// Add Stack // Add Stack
m_overlay.set_size_request(width, height); m_overlay.set_size_request(width, height);
@ -60,11 +61,15 @@ void MyWin::logout_activated()
main_stack.logout(); main_stack.logout();
} }
void MyWin::back_actiavted() void MyWin::back_activated()
{ {
main_stack.show_prefs(); main_stack.show_prefs();
} }
void MyWin::expand_activated(){
main_stack.set_mydock_mode(DockMode::MODE_PANEL);
}
void MyWin::about_activated() void MyWin::about_activated()
{ {
// Authors information // Authors information

View File

@ -25,6 +25,7 @@ private:
void logout_activated(); void logout_activated();
void quit_activated(); void quit_activated();
void about_activated(); void about_activated();
void back_actiavted(); void back_activated();
void expand_activated();
}; };

View File

@ -87,6 +87,18 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
show_all_children(); show_all_children();
} }
void MyDock::set_dock_mode(DockMode mode){
switch(mode){
case DockMode::MODE_DOCK:
set_vexpand(false);
break;
case DockMode::MODE_PANEL:
set_vexpand();
set_valign(Gtk::ALIGN_FILL);
break;
}
}
void MyDock::apply_style(Gtk::Widget &widget){ void MyDock::apply_style(Gtk::Widget &widget){
auto style = widget.get_style_context(); auto style = widget.get_style_context();
style->add_provider(provider,G_MAXUINT); style->add_provider(provider,G_MAXUINT);

View File

@ -10,6 +10,11 @@
#include "Runner.hh" #include "Runner.hh"
#include "TextEditor.hh" #include "TextEditor.hh"
enum class DockMode{
MODE_DOCK,
MODE_PANEL
};
class MyDock : public Gtk::Box class MyDock : public Gtk::Box
{ {
public: public:
@ -17,6 +22,7 @@ public:
static MyDock *create(); static MyDock *create();
void btnset_clicked(); void btnset_clicked();
void mydock_init(Gtk::Window *window, Gtk::Image *background1); void mydock_init(Gtk::Window *window, Gtk::Image *background1);
void set_dock_mode(DockMode mode);
private: private:
// Child widgets // Child widgets