mirror of https://github.com/daleclack/My_GtkUi
Update Panel
This commit is contained in:
parent
a6bd92c6af
commit
90ad1d80b0
|
@ -2,19 +2,10 @@
|
||||||
<!-- Generated with glade 3.38.2 -->
|
<!-- Generated with glade 3.38.2 -->
|
||||||
<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="icon-name">window-close</property>
|
|
||||||
</object>
|
|
||||||
<object class="GtkImage" id="image2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="icon-name">window-minimize</property>
|
|
||||||
</object>
|
|
||||||
<object class="GtkWindow" id="window">
|
<object class="GtkWindow" id="window">
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="border-width">15</property>
|
<property name="border-width">15</property>
|
||||||
|
<property name="title" translatable="yes">Guess Game</property>
|
||||||
<property name="window-position">center</property>
|
<property name="window-position">center</property>
|
||||||
<property name="destroy-with-parent">True</property>
|
<property name="destroy-with-parent">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -229,33 +220,5 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="titlebar">
|
|
||||||
<object class="GtkHeaderBar">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="title" translatable="yes">Guess Game</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="win_close">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">True</property>
|
|
||||||
<property name="image">image1</property>
|
|
||||||
<property name="relief">none</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="win_mini">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">True</property>
|
|
||||||
<property name="image">image2</property>
|
|
||||||
<property name="relief">none</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
|
@ -342,7 +342,7 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="panel_editor">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<file>icons/48x48/actions/user_home.png</file>
|
<file>icons/48x48/actions/user_home.png</file>
|
||||||
<file>icons/48x48/actions/my_user.png</file>
|
<file>icons/48x48/actions/my_user.png</file>
|
||||||
<file>icons/48x48/actions/gedit.png</file>
|
<file>icons/48x48/actions/gedit.png</file>
|
||||||
|
<file>icons/48x48/actions/gedit_running.png</file>
|
||||||
<file>icons/scalable/status/graphics.svg</file>
|
<file>icons/scalable/status/graphics.svg</file>
|
||||||
<file>icons/scalable/status/log_out.svg</file>
|
<file>icons/scalable/status/log_out.svg</file>
|
||||||
<file>icons/scalable/status/system.svg</file>
|
<file>icons/scalable/status/system.svg</file>
|
||||||
|
|
|
@ -5,14 +5,11 @@
|
||||||
|
|
||||||
Game::Game()
|
Game::Game()
|
||||||
:running(false),
|
:running(false),
|
||||||
minimized(false),
|
|
||||||
game_index{0,1,2,3}
|
game_index{0,1,2,3}
|
||||||
{
|
{
|
||||||
//Ininalize Window
|
//Ininalize Window
|
||||||
game_builder=Gtk::Builder::create_from_resource("/GtkUI/game1.ui");
|
game_builder=Gtk::Builder::create_from_resource("/GtkUI/game1.ui");
|
||||||
game_builder->get_widget("window",game_window);
|
game_builder->get_widget("window",game_window);
|
||||||
game_builder->get_widget("win_mini",win_mini);
|
|
||||||
game_builder->get_widget("win_close",win_close);
|
|
||||||
game_builder->get_widget("btn_exit",btnexit);
|
game_builder->get_widget("btn_exit",btnexit);
|
||||||
game_builder->get_widget("btn_go",btngo);
|
game_builder->get_widget("btn_go",btngo);
|
||||||
game_builder->get_widget("label",game_label);
|
game_builder->get_widget("label",game_label);
|
||||||
|
@ -25,9 +22,8 @@ game_index{0,1,2,3}
|
||||||
}
|
}
|
||||||
//Link Signals
|
//Link Signals
|
||||||
btngo->signal_clicked().connect(sigc::mem_fun(*this,&Game::btngo_clicked));
|
btngo->signal_clicked().connect(sigc::mem_fun(*this,&Game::btngo_clicked));
|
||||||
win_mini->signal_clicked().connect(sigc::mem_fun(*this,&Game::win_minimized));
|
|
||||||
win_close->signal_clicked().connect(sigc::mem_fun(*this,&Game::win_closed));
|
|
||||||
btnexit->signal_clicked().connect(sigc::mem_fun(*this,&Game::win_closed));
|
btnexit->signal_clicked().connect(sigc::mem_fun(*this,&Game::win_closed));
|
||||||
|
game_window->signal_delete_event().connect(sigc::mem_fun(*this,&Game::on_delete_event));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::gamebtn_clicked(int *index){
|
void Game::gamebtn_clicked(int *index){
|
||||||
|
@ -56,23 +52,30 @@ void Game::btngo_clicked(){
|
||||||
game_label->set_label("Select a button");
|
game_label->set_label("Select a button");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::hide_game_window(){
|
|
||||||
minimized=true;
|
|
||||||
game_window->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::win_minimized(){
|
|
||||||
minimized=true;
|
|
||||||
game_window->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::win_closed(){
|
|
||||||
game_window->hide();
|
|
||||||
running=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::show_game_window(Gtk::Window &parent){
|
void Game::show_game_window(Gtk::Window &parent){
|
||||||
game_window->set_transient_for(parent);
|
game_window->set_transient_for(parent);
|
||||||
running=true;
|
running=true;
|
||||||
game_window->show_all();
|
game_window->show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Glib::RefPtr<Gdk::Window> Game::get_window(){
|
||||||
|
return game_window->get_window();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::iconify(){
|
||||||
|
game_window->iconify();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::deiconify(){
|
||||||
|
game_window->deiconify();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::win_closed(){
|
||||||
|
//Change State and close
|
||||||
|
game_window->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Game::on_delete_event(GdkEventAny *event){
|
||||||
|
running=false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -6,9 +6,11 @@ class Game{
|
||||||
public:
|
public:
|
||||||
Game();
|
Game();
|
||||||
bool running;
|
bool running;
|
||||||
bool minimized;
|
|
||||||
void show_game_window(Gtk::Window &parent);
|
void show_game_window(Gtk::Window &parent);
|
||||||
void hide_game_window();
|
Glib::RefPtr<Gdk::Window> get_window();
|
||||||
|
//Behaver like Gtk::Window::iconify and Gtk::Window::deiconify
|
||||||
|
void iconify();
|
||||||
|
void deiconify();
|
||||||
private:
|
private:
|
||||||
//The main builder
|
//The main builder
|
||||||
Glib::RefPtr<Gtk::Builder> game_builder;
|
Glib::RefPtr<Gtk::Builder> game_builder;
|
||||||
|
@ -21,7 +23,7 @@ private:
|
||||||
//Signal Handlers
|
//Signal Handlers
|
||||||
void gamebtn_clicked(int *index);
|
void gamebtn_clicked(int *index);
|
||||||
void btngo_clicked();
|
void btngo_clicked();
|
||||||
void win_minimized();
|
|
||||||
void win_closed();
|
|
||||||
void btnexit_clicked();
|
void btnexit_clicked();
|
||||||
|
void win_closed();
|
||||||
|
bool on_delete_event(GdkEventAny *event);
|
||||||
};
|
};
|
|
@ -16,6 +16,7 @@ LeftPanel::LeftPanel(){
|
||||||
panel_builder->get_widget("panel_game",panelgame);
|
panel_builder->get_widget("panel_game",panelgame);
|
||||||
panel_builder->get_widget("btnrun",btnrun);
|
panel_builder->get_widget("btnrun",btnrun);
|
||||||
panel_builder->get_widget("btneditor",btneditor);
|
panel_builder->get_widget("btneditor",btneditor);
|
||||||
|
panel_builder->get_widget("panel_editor",panel_editor);
|
||||||
|
|
||||||
//Add timer
|
//Add timer
|
||||||
paneltimer=Glib::signal_timeout().connect(sigc::mem_fun(*this,&LeftPanel::on_timeout),100);
|
paneltimer=Glib::signal_timeout().connect(sigc::mem_fun(*this,&LeftPanel::on_timeout),100);
|
||||||
|
@ -30,6 +31,7 @@ LeftPanel::LeftPanel(){
|
||||||
panelgame->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btngame_clicked));
|
panelgame->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btngame_clicked));
|
||||||
btnrun->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnrun_clicked));
|
btnrun->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnrun_clicked));
|
||||||
btneditor->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnedit_clicked));
|
btneditor->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnedit_clicked));
|
||||||
|
panel_editor->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnedit_clicked));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeftPanel::add_panel(Gtk::Window *parent1,Gtk::Overlay &overlay){
|
void LeftPanel::add_panel(Gtk::Window *parent1,Gtk::Overlay &overlay){
|
||||||
|
@ -74,12 +76,23 @@ void LeftPanel::winvlc_clicked(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeftPanel::btngame_clicked(){
|
void LeftPanel::btngame_clicked(){
|
||||||
if(game1.minimized==true||game1.running==false){
|
//Simulate the panel by Gdk::Window Proprties
|
||||||
|
auto game_win=game1.get_window();
|
||||||
|
if(game_win){
|
||||||
|
auto state=game_win->get_state();
|
||||||
|
switch(state){
|
||||||
|
case Gdk::WINDOW_STATE_ICONIFIED:
|
||||||
|
game1.deiconify();
|
||||||
|
break;
|
||||||
|
case Gdk::WINDOW_STATE_WITHDRAWN:
|
||||||
game1.show_game_window(*parent);
|
game1.show_game_window(*parent);
|
||||||
game1.minimized=false;
|
break;
|
||||||
|
default:
|
||||||
|
game1.iconify();
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
game1.hide_game_window();
|
game1.show_game_window(*parent);
|
||||||
game1.minimized=true;
|
game1.running=true;
|
||||||
}
|
}
|
||||||
popover->popdown();
|
popover->popdown();
|
||||||
}
|
}
|
||||||
|
@ -91,6 +104,11 @@ bool LeftPanel::on_timeout(){
|
||||||
}else{
|
}else{
|
||||||
panelgame->set_image_from_icon_name("game",Gtk::ICON_SIZE_DIALOG);
|
panelgame->set_image_from_icon_name("game",Gtk::ICON_SIZE_DIALOG);
|
||||||
}
|
}
|
||||||
|
if(editor1.running){
|
||||||
|
panel_editor->set_image_from_icon_name("gedit_running",Gtk::ICON_SIZE_DIALOG);
|
||||||
|
}else{
|
||||||
|
panel_editor->set_image_from_icon_name("gedit",Gtk::ICON_SIZE_DIALOG);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +118,24 @@ void LeftPanel::btnrun_clicked(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeftPanel::btnedit_clicked(){
|
void LeftPanel::btnedit_clicked(){
|
||||||
|
//Simulate the panel by Gdk::Window Proprties
|
||||||
|
auto editor_win=editor1.get_window();
|
||||||
|
if(editor_win){
|
||||||
|
auto state=editor_win->get_state();
|
||||||
|
switch(state){
|
||||||
|
case Gdk::WINDOW_STATE_ICONIFIED:
|
||||||
|
editor1.deiconify();
|
||||||
|
break;
|
||||||
|
case Gdk::WINDOW_STATE_WITHDRAWN:
|
||||||
editor1.show();
|
editor1.show();
|
||||||
|
editor1.running=true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
editor1.iconify();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
editor1.show();
|
||||||
|
editor1.running=true;
|
||||||
|
}
|
||||||
popover->popdown();
|
popover->popdown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ private:
|
||||||
//Child widgets
|
//Child widgets
|
||||||
Gtk::Box *btnbox;
|
Gtk::Box *btnbox;
|
||||||
Gtk::Popover *popover;
|
Gtk::Popover *popover;
|
||||||
Gtk::Button *btnaud,*btngedit,*btnvlc,*btnnote,*btnvlc_win32,*btngame,*panelgame,*btnrun,*btneditor;
|
Gtk::Button *btnaud,*btngedit,*btnvlc,*btnnote,*btnvlc_win32,*btngame,
|
||||||
|
*panelgame,*btnrun,*btneditor,*panel_editor;
|
||||||
//Parent Window
|
//Parent Window
|
||||||
Gtk::Window *parent;
|
Gtk::Window *parent;
|
||||||
Game game1;
|
Game game1;
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
TextEditor::TextEditor()
|
TextEditor::TextEditor()
|
||||||
:vbox(Gtk::ORIENTATION_VERTICAL,5),
|
:running(false),
|
||||||
|
vbox(Gtk::ORIENTATION_VERTICAL,5),
|
||||||
hbox(Gtk::ORIENTATION_HORIZONTAL,5),
|
hbox(Gtk::ORIENTATION_HORIZONTAL,5),
|
||||||
btnbox(Gtk::ORIENTATION_VERTICAL,5),
|
btnbox(Gtk::ORIENTATION_VERTICAL,5),
|
||||||
btn_copy("Copy"),
|
btn_copy("Copy"),
|
||||||
|
@ -190,3 +191,8 @@ void TextEditor::btnclear_clicked(){
|
||||||
void TextEditor::infobar_response(int response){
|
void TextEditor::infobar_response(int response){
|
||||||
infobar.hide();
|
infobar.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TextEditor::on_delete_event(GdkEventAny *event){
|
||||||
|
running=false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
class TextEditor : public Gtk::Window{
|
class TextEditor : public Gtk::Window{
|
||||||
public:
|
public:
|
||||||
TextEditor();
|
TextEditor();
|
||||||
|
bool running;
|
||||||
private:
|
private:
|
||||||
//Child widgets
|
//Child widgets
|
||||||
Gtk::Box vbox,hbox,btnbox,*infobox;
|
Gtk::Box vbox,hbox,btnbox,*infobox;
|
||||||
|
@ -27,4 +28,5 @@ private:
|
||||||
void buffer1_changed();
|
void buffer1_changed();
|
||||||
void clipboard_receive(const Glib::ustring &text);
|
void clipboard_receive(const Glib::ustring &text);
|
||||||
void infobar_response(int response);
|
void infobar_response(int response);
|
||||||
|
bool on_delete_event(GdkEventAny *event);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue