Add background switch
This commit is contained in:
parent
a8b4e28c6f
commit
872d866516
|
@ -6,24 +6,35 @@
|
|||
<attribute name='label'>Config</attribute>
|
||||
<item>
|
||||
<attribute name='label'>Change Xe-lts config</attribute>
|
||||
<attribute name='action'>app.config1</attribute>
|
||||
<attribute name='action'>win.config1</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>Change Xe-stable config</attribute>
|
||||
<attribute name='action'>app.config2</attribute>
|
||||
<attribute name='action'>win.config2</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>Change Xe-devel config</attribute>
|
||||
<attribute name='action'>app.config3</attribute>
|
||||
<attribute name='action'>win.config3</attribute>
|
||||
</item>
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name='label'>Backgrounds</attribute>
|
||||
<item>
|
||||
<attribute name='label'>XeRelease8-9</attribute>
|
||||
<attribute name='action'>win.back1</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>XeRelease10-12</attribute>
|
||||
<attribute name='action'>win.back2</attribute>
|
||||
</item>
|
||||
</submenu>
|
||||
<item>
|
||||
<attribute name='label'>About</attribute>
|
||||
<attribute name='action'>app.about</attribute>
|
||||
<attribute name='action'>win.about</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>Exit</attribute>
|
||||
<attribute name='action'>app.quit</attribute>
|
||||
<attribute name='action'>win.quit</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "MyWin.hh"
|
||||
#include "img7.xpm"
|
||||
#include "winpe.xpm"
|
||||
|
||||
MyWin::MyWin()
|
||||
:btn_box(Gtk::ORIENTATION_VERTICAL,5),
|
||||
|
@ -8,23 +9,7 @@ btn_ver("Xe-Ver")
|
|||
//Initalize window
|
||||
set_icon_name("Xe-Release");
|
||||
set_default_size(640,360);
|
||||
|
||||
//Add HeaderBar
|
||||
header.set_title("Xe Release 12");
|
||||
header.set_show_close_button();
|
||||
header.set_decoration_layout("close,minimize:menu");
|
||||
set_titlebar(header);
|
||||
|
||||
//Initalize Menu
|
||||
menu_builder=Gtk::Builder::create_from_resource("/XeRelease/menubar.xml");
|
||||
auto object=menu_builder->get_object("app-menu");
|
||||
auto gmenu=Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
|
||||
popover.bind_model(gmenu);
|
||||
|
||||
//Initalize MenuButton
|
||||
menubtn.set_image_from_icon_name("open-menu");
|
||||
menubtn.set_popover(popover);
|
||||
header.pack_end(menubtn);
|
||||
titlebar_init();
|
||||
|
||||
//Set Background Image
|
||||
auto pixbuf=Gdk::Pixbuf::create_from_xpm_data(img7);
|
||||
|
@ -53,3 +38,49 @@ btn_ver("Xe-Ver")
|
|||
pixbuf.reset();
|
||||
sized.reset();
|
||||
}
|
||||
|
||||
void MyWin::titlebar_init(){
|
||||
//Add HeaderBar
|
||||
header.set_title("Xe Release 12");
|
||||
header.set_show_close_button();
|
||||
header.set_decoration_layout("close,minimize:menu");
|
||||
set_titlebar(header);
|
||||
|
||||
//Initalize Menu
|
||||
menu_builder=Gtk::Builder::create_from_resource("/XeRelease/menubar.xml");
|
||||
auto object=menu_builder->get_object("app-menu");
|
||||
auto gmenu=Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
|
||||
popover.bind_model(gmenu);
|
||||
|
||||
//Add Menu Actions
|
||||
add_action("back1",sigc::mem_fun(*this,&MyWin::background1));
|
||||
add_action("back2",sigc::mem_fun(*this,&MyWin::background2));
|
||||
add_action("quit",sigc::mem_fun(*this,&MyWin::hide));
|
||||
|
||||
//Initalize MenuButton
|
||||
menubtn.set_image_from_icon_name("open-menu");
|
||||
menubtn.set_popover(popover);
|
||||
header.pack_end(menubtn);
|
||||
}
|
||||
|
||||
void MyWin::background1(){
|
||||
//Set Background Image
|
||||
auto pixbuf=Gdk::Pixbuf::create_from_xpm_data(winpe);
|
||||
auto sized=pixbuf->scale_simple(640,360,Gdk::INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(background.gobj(),sized->gobj());
|
||||
//overlay.add(background);
|
||||
//Free Memory
|
||||
pixbuf.reset();
|
||||
sized.reset();
|
||||
}
|
||||
|
||||
void MyWin::background2(){
|
||||
//Set Background Image
|
||||
auto pixbuf=Gdk::Pixbuf::create_from_xpm_data(img7);
|
||||
auto sized=pixbuf->scale_simple(640,360,Gdk::INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(background.gobj(),sized->gobj());
|
||||
//overlay.add(background);
|
||||
//Free Memory
|
||||
pixbuf.reset();
|
||||
sized.reset();
|
||||
}
|
||||
|
|
|
@ -8,14 +8,21 @@ public:
|
|||
private:
|
||||
//Child Widgets
|
||||
Glib::RefPtr<Gtk::Builder> menu_builder;
|
||||
|
||||
//Main window
|
||||
Gtk::Image background;
|
||||
Gtk::Overlay overlay;
|
||||
Gtk::Box btn_box;
|
||||
Gtk::ComboBoxText combo;
|
||||
Gtk::Button btn_ver;
|
||||
|
||||
//TitleBar and menu
|
||||
Gtk::HeaderBar header;
|
||||
Gtk::MenuButton menubtn;
|
||||
Gtk::PopoverMenu popover;
|
||||
void titlebar_init();
|
||||
|
||||
//Backgrounds
|
||||
void background1();
|
||||
void background2();
|
||||
};
|
Loading…
Reference in New Issue