Add gtk124
This commit is contained in:
parent
2079356f11
commit
e5d5afb45d
|
@ -25,19 +25,21 @@ set(SOURCE_FILE src/main.cc src/MyWin.cc)
|
|||
|
||||
#Compile Resource
|
||||
|
||||
# set(RESOURCE_LIST
|
||||
# prefs_stack.ui)
|
||||
set(RESOURCE_LIST
|
||||
style.css
|
||||
reset.css
|
||||
main_stack.ui)
|
||||
|
||||
# compile_gresources(RESOURCE_FILE
|
||||
# XML_OUT
|
||||
# TYPE EMBED_C
|
||||
# RESOURCES ${RESOURCE_LIST}
|
||||
# PREFIX "/org/gtk/daleclack"
|
||||
# SOURCE_DIR ${PROJECT_SOURCE_DIR}/res)
|
||||
compile_gresources(RESOURCE_FILE
|
||||
XML_OUT
|
||||
TYPE EMBED_C
|
||||
RESOURCES ${RESOURCE_LIST}
|
||||
PREFIX "/org/gtk/daleclack"
|
||||
SOURCE_DIR ${PROJECT_SOURCE_DIR}/res)
|
||||
|
||||
# Add a custom target to the makefile. Now make builds our resource file.
|
||||
# It depends on the output RESOURCE_FILE.
|
||||
# add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
|
||||
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
|
||||
|
||||
#For win32 platform,use rc resource and .ico icon
|
||||
if(WIN32)
|
||||
|
@ -46,9 +48,9 @@ if(WIN32)
|
|||
set_property(SOURCE ../icon.rc APPEND PROPERTY
|
||||
OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/../icon.ico
|
||||
)
|
||||
add_executable(${PROJECT_NAME} WIN32 ${app_WINRC} ${SOURCE_FILE})
|
||||
add_executable(${PROJECT_NAME} WIN32 ${app_WINRC} ${SOURCE_FILE} ${RESOURCE_FILE})
|
||||
else()
|
||||
add_executable(${PROJECT_NAME} ${SOURCE_FILE})
|
||||
add_executable(${PROJECT_NAME} ${SOURCE_FILE} ${RESOURCE_FILE})
|
||||
|
||||
endif(WIN32)
|
||||
|
||||
|
|
|
@ -0,0 +1,483 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="pixel-size">48</property>
|
||||
<property name="icon-name">gedit</property>
|
||||
<property name="icon_size">6</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">gedit</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">gedit</property>
|
||||
<property name="icon_size">6</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">gedit</property>
|
||||
<property name="icon_size">6</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">start-here</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">start-here</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">gedit</property>
|
||||
<property name="icon_size">6</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="pixel-size">48</property>
|
||||
<property name="icon-name">gedit</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">gedit</property>
|
||||
<property name="icon_size">6</property>
|
||||
</object>
|
||||
<object class="GtkStack" id="main_stack">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<child>
|
||||
<!-- n-columns=7 n-rows=5 -->
|
||||
<object class="GtkGrid" id="start_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="row-homogeneous">True</property>
|
||||
<property name="column-homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="btnstart">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="image">image5</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">3</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>
|
||||
<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>
|
||||
<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>
|
||||
<child>
|
||||
<!-- n-columns=9 n-rows=5 -->
|
||||
<object class="GtkGrid" id="launchpad_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="image">image2</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="image">image3</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">2</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="image">image4</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">3</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="image">image1</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">4</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes"> </property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="image">image7</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">5</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="image">image8</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">6</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="image">image9</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">7</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes"> </property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">8</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btnback">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="image">image6</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">4</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>
|
||||
<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>
|
||||
<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="name">page0</property>
|
||||
<property name="title" translatable="yes">page0</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="default-width">800</property>
|
||||
<property name="default-height">450</property>
|
||||
<child>
|
||||
<object class="GtkOverlay" id="main_overlay">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="background">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="index">-1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,12 @@
|
|||
/* @import this colorsheet to get the default values for every property.
|
||||
* This is useful when writing special CSS tests that should not be
|
||||
* inluenced by themes - not even the default ones.
|
||||
* Keep in mind that the output will be very ugly and not look like
|
||||
* anything GTK.
|
||||
* Also, when adding new style properties, please add them here.
|
||||
*/
|
||||
|
||||
* {
|
||||
all: unset;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
css style for launchpad
|
||||
*/
|
||||
|
||||
@import url("resource://org/gtk/daleclack/reset.css");
|
||||
|
||||
grid{
|
||||
background-color:alpha(black,0.7);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
#include "MyWin.hh"
|
||||
#include "winpe.xpm"
|
||||
|
||||
MyWin::MyWin(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Glade)
|
||||
: Gtk::Window(cobject),
|
||||
ref_builder(ref_Glade)
|
||||
{
|
||||
// Initalize window
|
||||
set_icon_name("org.gtk.daleclack");
|
||||
|
||||
// Get Widgets
|
||||
ref_builder->get_widget("main_overlay", main_overlay);
|
||||
ref_builder->get_widget("main_stack", main_stack);
|
||||
ref_builder->get_widget("start_page", start_page);
|
||||
ref_builder->get_widget("launchpad_page", launchpad_page);
|
||||
ref_builder->get_widget("background", background);
|
||||
ref_builder->get_widget("btnstart", btnstart);
|
||||
ref_builder->get_widget("btnback", btnback);
|
||||
|
||||
// Initalize Background
|
||||
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(winpe);
|
||||
auto sized = pixbuf->scale_simple(800, 450, Gdk::INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(background->gobj(), sized->gobj());
|
||||
pixbuf.reset();
|
||||
sized.reset();
|
||||
|
||||
// Add Overlay widget
|
||||
main_stack->set_halign(Gtk::ALIGN_FILL);
|
||||
main_stack->set_valign(Gtk::ALIGN_FILL);
|
||||
main_overlay->add_overlay(*main_stack);
|
||||
|
||||
// Add style sheet
|
||||
provider = Gtk::CssProvider::create();
|
||||
provider->load_from_resource("/org/gtk/daleclack/style.css");
|
||||
auto context = launchpad_page->get_style_context();
|
||||
context->add_provider(provider,G_MAXUINT);
|
||||
|
||||
// Link Signals
|
||||
btnback->signal_clicked().connect(sigc::mem_fun(*this,&MyWin::btnback_clicked));
|
||||
btnstart->signal_clicked().connect(sigc::mem_fun(*this,&MyWin::btnstart_clicked));
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
void MyWin::btnstart_clicked()
|
||||
{
|
||||
main_stack->set_visible_child(*launchpad_page);
|
||||
}
|
||||
|
||||
void MyWin::btnback_clicked()
|
||||
{
|
||||
main_stack->set_visible_child(*start_page);
|
||||
}
|
||||
|
||||
MyWin *MyWin::create()
|
||||
{
|
||||
MyWin *window = nullptr;
|
||||
|
||||
auto builder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/main_stack.ui");
|
||||
builder->get_widget_derived("window", window);
|
||||
|
||||
return window;
|
||||
}
|
|
@ -2,4 +2,25 @@
|
|||
|
||||
#include <gtkmm.h>
|
||||
|
||||
class MyWin : public Gtk::Window{};
|
||||
class MyWin : public Gtk::Window
|
||||
{
|
||||
public:
|
||||
MyWin(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Glade);
|
||||
static MyWin *create();
|
||||
|
||||
private:
|
||||
// Child widgets
|
||||
Gtk::Stack *main_stack;
|
||||
Gtk::Overlay *main_overlay;
|
||||
Gtk::Grid *start_page, *launchpad_page;
|
||||
Gtk::Image *background;
|
||||
Gtk::Button *btnstart, *btnback;
|
||||
|
||||
// Style Config
|
||||
Glib::RefPtr<Gtk::CssProvider> provider;
|
||||
|
||||
// Builder for widgets
|
||||
Glib::RefPtr<Gtk::Builder> ref_builder;
|
||||
void btnstart_clicked();
|
||||
void btnback_clicked();
|
||||
};
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "MyWin.hh"
|
||||
|
||||
int main(int argc,char ** argv){
|
||||
auto app = Gtk::Application::create(argc,argv,"org.gtk.daleclack");
|
||||
MyWin window;
|
||||
return app->run(window);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
auto app = Gtk::Application::create(argc, argv, "org.gtk.daleclack");
|
||||
auto window = MyWin::create();
|
||||
return app->run(*window);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue