Add Input Dialog
This commit is contained in:
parent
beb3c0b938
commit
229c7569ad
|
@ -1,4 +1,43 @@
|
|||
#include "MyDialog.hh"
|
||||
#include <cstdio>
|
||||
|
||||
MyDialog::MyDialog(Gtk::Window &parent)
|
||||
:label2(" ")
|
||||
{
|
||||
//Initalize MsgBox
|
||||
set_icon_name("Xe-Release");
|
||||
set_default_size(300,150);
|
||||
add_button("OK",Gtk::RESPONSE_OK);
|
||||
add_button("Cancel",Gtk::RESPONSE_CANCEL);
|
||||
set_transient_for(parent);
|
||||
//Add Widgets
|
||||
entry.set_text("default config");
|
||||
entry.signal_activate().connect(sigc::bind(sigc::mem_fun(*this,&MyDialog::response),Gtk::RESPONSE_OK));
|
||||
vbox=get_content_area();
|
||||
vbox->pack_start(msg_label,Gtk::PACK_SHRINK);
|
||||
vbox->pack_start(label2,Gtk::PACK_SHRINK);
|
||||
vbox->pack_start(entry,Gtk::PACK_SHRINK);
|
||||
}
|
||||
|
||||
void MyDialog::set_filename(const char *filename){
|
||||
strcpy(filename1,filename);
|
||||
}
|
||||
|
||||
void MyDialog::set_msg(Glib::ustring msg){
|
||||
msg_label.set_label(msg);
|
||||
}
|
||||
|
||||
void MyDialog::on_response(int response_id){
|
||||
//Save Text into file
|
||||
if(response_id==Gtk::RESPONSE_OK){
|
||||
FILE *fp=fopen(filename1,"wt+");
|
||||
Glib::ustring str=entry.get_text();
|
||||
fprintf(fp,"%s",str.c_str());
|
||||
fclose(fp);
|
||||
}
|
||||
entry.set_text("default config");
|
||||
hide();
|
||||
}
|
||||
|
||||
MsgBox::MsgBox(Gtk::Window &parent)
|
||||
:hbox(Gtk::ORIENTATION_HORIZONTAL,5)
|
||||
|
|
|
@ -3,7 +3,19 @@
|
|||
#include <gtkmm.h>
|
||||
|
||||
class MyDialog : public Gtk::Dialog{
|
||||
|
||||
public:
|
||||
MyDialog(Gtk::Window &parent);
|
||||
void set_filename(const char *filename);
|
||||
void set_msg(Glib::ustring msg);
|
||||
protected:
|
||||
void on_response(int response_id) override;
|
||||
private:
|
||||
//Child widgets
|
||||
Gtk::Label msg_label,label2;
|
||||
Gtk::Entry entry;
|
||||
Gtk::Box *vbox;
|
||||
//File Proprties
|
||||
char filename1[57];
|
||||
};
|
||||
|
||||
class MsgBox : public Gtk::Dialog{
|
||||
|
|
|
@ -11,7 +11,8 @@ enum Releases{
|
|||
MyWin::MyWin()
|
||||
:btn_box(Gtk::ORIENTATION_VERTICAL,5),
|
||||
btn_ver("Xe-Ver"),
|
||||
msg_dialog(*this)
|
||||
msg_dialog(*this),
|
||||
input_dialog(*this)
|
||||
{
|
||||
//Initalize window
|
||||
set_icon_name("Xe-Release");
|
||||
|
@ -61,6 +62,9 @@ void MyWin::titlebar_init(){
|
|||
popover.bind_model(gmenu);
|
||||
|
||||
//Add Menu Actions
|
||||
add_action("config1",sigc::mem_fun(*this,&MyWin::config_lts));
|
||||
add_action("config2",sigc::mem_fun(*this,&MyWin::config_stable));
|
||||
add_action("config3",sigc::mem_fun(*this,&MyWin::config_devel));
|
||||
add_action("back1",sigc::mem_fun(*this,&MyWin::background1));
|
||||
add_action("back2",sigc::mem_fun(*this,&MyWin::background2));
|
||||
add_action("about",sigc::mem_fun(*this,&MyWin::about_dialog));
|
||||
|
@ -94,6 +98,24 @@ void MyWin::background2(){
|
|||
sized.reset();
|
||||
}
|
||||
|
||||
void MyWin::config_lts(){
|
||||
input_dialog.set_msg("Input Xe LTS Config");
|
||||
input_dialog.set_filename("config_lts");
|
||||
input_dialog.show_all();
|
||||
}
|
||||
|
||||
void MyWin::config_stable(){
|
||||
input_dialog.set_msg("Input Xe Stable Config");
|
||||
input_dialog.set_filename("config_stable");
|
||||
input_dialog.show_all();
|
||||
}
|
||||
|
||||
void MyWin::config_devel(){
|
||||
input_dialog.set_msg("Input Xe Devel Config");
|
||||
input_dialog.set_filename("config_devel");
|
||||
input_dialog.show_all();
|
||||
}
|
||||
|
||||
void MyWin::main_releases(){
|
||||
int version=combo.get_active_row_number();
|
||||
switch (version)
|
||||
|
|
|
@ -25,11 +25,17 @@ private:
|
|||
|
||||
//Dialogs
|
||||
MsgBox msg_dialog;
|
||||
MyDialog input_dialog;
|
||||
|
||||
//Backgrounds
|
||||
void background1();
|
||||
void background2();
|
||||
|
||||
//Version Configs
|
||||
void config_lts();
|
||||
void config_stable();
|
||||
void config_devel();
|
||||
|
||||
//Signal Handlers
|
||||
void about_dialog();
|
||||
void main_releases();
|
||||
|
|
Loading…
Reference in New Issue