Add background

This commit is contained in:
daleclack 2021-09-12 09:43:39 +08:00
parent de3fb36639
commit f15965a269
6 changed files with 1064 additions and 3 deletions

View File

@ -17,8 +17,9 @@
<object class="GtkDialog" id="prefs">
<property name="can-focus">False</property>
<property name="modal">True</property>
<property name="default-width">300</property>
<property name="default-height">70</property>
<property name="type-hint">normal</property>
<property name="use-header-bar">1</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
@ -44,6 +45,8 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Width:</property>
</object>
<packing>
@ -56,6 +59,8 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Height:</property>
</object>
<packing>
@ -67,6 +72,8 @@
<object class="GtkSpinButton" id="width_spin">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="adjustment">adjustment2</property>
</object>
<packing>
@ -78,6 +85,8 @@
<object class="GtkSpinButton" id="height_spin">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="adjustment">adjustment1</property>
</object>
<packing>

View File

@ -12,13 +12,20 @@
<property name="default-width">640</property>
<property name="default-height">480</property>
<child>
<placeholder/>
<object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="show-close-button">True</property>
<property name="decoration-layout">close,minimize,maximize:menu</property>
<child>
<object class="GtkButton" id="btnprefs">
<property name="visible">True</property>
@ -26,6 +33,9 @@
<property name="receives-default">True</property>
<property name="image">image1</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object>
</child>

View File

@ -8,6 +8,10 @@ m_builder(builder)
m_builder->get_widget("width_spin",m_width);
m_builder->get_widget("height_spin",m_height);
//Initalize Dialog
set_icon_name("org.gtk.daleclack");
set_title("Preferences");
//Create Settings
m_settings=Gio::Settings::create("org.gtk.daleclack");
m_settings->bind("width",m_width->property_value());

View File

@ -1,19 +1,40 @@
#include "MyWin.hh"
#include "MyPrefs.hh"
#include "winpe.xpm"
MyWin::MyWin(BaseObjectType *cobject,const Glib::RefPtr<Gtk::Builder>& builder)
:Gtk::Window(cobject),
ref_builder(builder)
ref_builder(builder),
btnback("BackGround")
{
int width,height;
//Create Settings
m_settings=Gio::Settings::create("org.gtk.daleclack");
m_settings->bind("width",property_default_width());
m_settings->bind("height",property_default_height());
width=m_settings->get_int("width");
height=m_settings->get_int("height");
//Ininalize Window
set_icon_name("org.gtk.daleclack");
ref_builder->get_widget("btnprefs",btnprefs);
ref_builder->get_widget("overlay",overlay);
btnprefs->signal_clicked().connect(sigc::mem_fun(*this,&MyWin::btnprefs_clicked));
//Add Background
overlay->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(background.gobj(),sized->gobj());
//Add a button
btnback.set_halign(Gtk::ALIGN_CENTER);
btnback.set_valign(Gtk::ALIGN_CENTER);
overlay->add_overlay(btnback);
//Gtkmm3 only,no need for Gtkmm4 Apps
show_all_children();
}
MyWin * MyWin::create(){

View File

@ -11,6 +11,9 @@ class MyWin : public Gtk::Window{
Glib::RefPtr<Gtk::Builder> ref_builder;
Glib::RefPtr<Gio::Settings> m_settings;
Gtk::Button* btnprefs;
Gtk::Overlay* overlay;
Gtk::Image background;
Gtk::Button btnback;
//Signal Handlers
void btnprefs_clicked();

1014
Gtkmm3/winpe.xpm Normal file

File diff suppressed because it is too large Load Diff