]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
-pregunta si quiere guardar antes de salir, solo si no estaba guardado
authorNicolás Dimov <ndimov@gmail.com>
Tue, 2 Dec 2003 06:18:38 +0000 (06:18 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Tue, 2 Dec 2003 06:18:38 +0000 (06:18 +0000)
-pero no pude hacer que al terminar de guardar salga de la aplicacion,
porque se me cerraba apenas aparecia el dialogo de guardar, medio raro
pero anda, a medias... :(

Constructor/dialogs/constructor.glade
Constructor/include/constructor.h
Constructor/src/constructor.cpp

index 8d197adf9c755784a1ab2c98c76cb7a70f3656fe..3c76e38c1ef244732f5f43c6297bb7d9af98186f 100644 (file)
@@ -2315,4 +2315,83 @@ Ingrese un nombre distinto para este elemento</property>
   </child>
 </widget>
 
+<widget class="GtkDialog" id="dlg_quit">
+  <property name="width_request">230</property>
+  <property name="height_request">98</property>
+  <property name="title" translatable="yes">dialog1</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_CENTER</property>
+  <property name="modal">True</property>
+  <property name="resizable">False</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox6">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="dialog-action_area5">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
+
+         <child>
+           <widget class="GtkButton" id="btn_dlg_quit_cancel">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-cancel</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="response_id">-6</property>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="btn_dlg_quit_ok">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-ok</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="response_id">-5</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkLabel" id="label34">
+         <property name="visible">True</property>
+         <property name="label" translatable="yes">El archivo no fue guardado
+¿Desea guardarlo antes de salir?</property>
+         <property name="use_underline">False</property>
+         <property name="use_markup">False</property>
+         <property name="justify">GTK_JUSTIFY_CENTER</property>
+         <property name="wrap">False</property>
+         <property name="selectable">False</property>
+         <property name="xalign">0.5</property>
+         <property name="yalign">0.5</property>
+         <property name="xpad">0</property>
+         <property name="ypad">0</property>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
index 55f1ffd17b720d9c8c63c051ae9b442829715c56..3d371ea79e0b983d359497d6cfc5f31c3e26b659 100644 (file)
@@ -78,12 +78,13 @@ class Constructor : public Gtk::Window {
        int id;
        /// Defino los elementos de la ventana.
        Gtk::Button *btn_canio, *btn_codo, *btn_y, *btn_tanque, *btn_bomba, *btn_exclusa, *btn_drain, *btn_file_ok, *btn_file_cancel, *btn_check, *btn_dlg_close,
-                                               *btn_and, *btn_or, *btn_not, *btn_open_ok, *btn_open_cancel, *quick_btn_clear, *quick_btn_save, *quick_btn_open, *quick_btn_new, *btn_find;
+                                               *btn_and, *btn_or, *btn_not, *btn_open_ok, *btn_open_cancel, *quick_btn_clear, *quick_btn_save, *quick_btn_open, *quick_btn_new, *btn_find,
+                                               *btn_dlg_quit_ok, *btn_dlg_quit_cancel;
        Gtk::ImageMenuItem *main_menu_quit,*main_menu_new, *edit_menu_del, *edit_menu_delete_all, *main_menu_save, *main_menu_open;
        Gtk::CheckButton *chk_btn_logica;
        Gtk::FileSelection *file_selection, *file_open_selection;
        Gtk::Combo *combo_entry;
-       Gtk::Dialog *dlg_connect, *dlg_about;
+       Gtk::Dialog *dlg_connect, *dlg_about, *dlg_quit;
        Gtk::Label *dlg_label;
        Gtk::Statusbar *status_bar;
        Glib::RefPtr<Gdk::Pixbuf> ico_canio, ico_y, ico_codo, ico_tanque, ico_bomba, ico_exclusa, ico_drain, ico_and, ico_or, ico_not;
@@ -122,6 +123,8 @@ class Constructor : public Gtk::Window {
        virtual void on_quick_btn_save_clicked();
        virtual void on_quick_btn_new_clicked();
        virtual void on_btn_find_clicked();
+       virtual void on_btn_dlg_quit_ok_clicked();
+       virtual void on_btn_dlg_quit_cancel_clicked();
        
        ///Verifica la conexion de todos los items iterando en la listaItems.
        bool check_connection(Glib::ustring& name);
index facfd8d1164204df6534c893cf7ba48d62857360..ab4dacf336d8e1eb0b93a10d89d0455e4ba6203d 100644 (file)
@@ -22,7 +22,7 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        rev = rev.substr(6, rev.length() - 8);
        std::string s = "PlaQui Constructor versión " VERSION " (revisión ";
        s += rev + ")"; 
-       lbl_plaqui_version->set_text(Glib::locale_to_utf8(s));
+//     lbl_plaqui_version->set_text(Glib::locale_to_utf8(s));
        
        refGlade->get_widget("dlgAbout", dlg_about);
        refGlade->get_widget("close_about", close_about);
@@ -70,6 +70,9 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        refGlade->get_widget("edit_menu_delete_all", edit_menu_delete_all);
        refGlade->get_widget("btn_find", btn_find);
        refGlade->get_widget("status_bar", status_bar);
+       refGlade->get_widget("dlg_quit", dlg_quit);
+       refGlade->get_widget("btn_dlg_quit_ok", btn_dlg_quit_ok);
+       refGlade->get_widget("btn_dlg_quit_cancel", btn_dlg_quit_cancel);
        
        //Obtengo el area de trabajo, la cual tiene definida su propia clase.
        refGlade->get_widget_derived("workplace", workplace);  //fixed
@@ -112,6 +115,8 @@ Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
        quick_btn_new->signal_clicked().connect(SigC::slot(*this, &Constructor::on_quick_btn_new_clicked));
        quick_btn_save->signal_clicked().connect(SigC::slot(*this, &Constructor::on_quick_btn_save_clicked));
        quick_btn_open->signal_clicked().connect(SigC::slot(*this, &Constructor::on_main_menu_open));
+       btn_dlg_quit_ok->signal_clicked().connect(SigC::slot(*this, &Constructor::on_btn_dlg_quit_ok_clicked));
+       btn_dlg_quit_cancel->signal_clicked().connect(SigC::slot(*this, &Constructor::on_btn_dlg_quit_cancel_clicked));
        
        main_menu_quit->signal_activate().connect(SigC::slot(*this, &Constructor::on_main_menu_quit));
        main_menu_new->signal_activate().connect(SigC::slot(*this, &Constructor::on_quick_btn_new_clicked));
@@ -207,14 +212,30 @@ void Constructor::on_btn_not_drag_get(const Glib::RefPtr<Gdk::DragContext>& cont
        gtk_selection_data_set(selection_data, selection_data->target, 8,(const guchar*)"not_e.png",9);
 }
 
-//Sale del programa.
+//Sale del programa. Pregunta si desea salvar antes de salir.
 void Constructor::on_main_menu_quit()
 {
-       delete this;
+       if ( !saved ) 
+               dlg_quit->show();
+       else 
+               Gtk::Main::quit();
+}
+
+//Sale del programa guardando el archivo.
+void Constructor::on_btn_dlg_quit_ok_clicked()
+{
+       dlg_quit->hide();
+       on_quick_btn_save_clicked();
+}
+
+//Sale del programa sin guardar el archivo.
+void Constructor::on_btn_dlg_quit_cancel_clicked()
+{
+       dlg_quit->hide();
        Gtk::Main::quit();
-       //hide();
 }
 
+
 // Carga de un archivo XML
 void Constructor::on_main_menu_open()
 {