Set the confirm of quit
This commit is contained in:
parent
a74b26218f
commit
ba5fe3feef
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MainWindows.cpp
|
||||
* @brief Editeur De N'ours : main Windows diplayer
|
||||
* @brief Editeur De N'ours : main Windows diplayer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/01/2011
|
||||
* @par Project
|
||||
@ -28,8 +28,6 @@
|
||||
#include "MainWindows.h"
|
||||
#include "CodeView.h"
|
||||
#include "ClipBoard.h"
|
||||
//#include "SearchData.h"
|
||||
//#include "MsgBroadcast.h"
|
||||
#include "BufferView.h"
|
||||
#include "AccelKey.h"
|
||||
|
||||
@ -48,6 +46,7 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
|
||||
gtk_window_set_default_size(GTK_WINDOW(m_mainWindow), 800, 600);
|
||||
|
||||
// enable the close signal of the windows
|
||||
g_signal_connect(G_OBJECT(m_mainWindow), "delete-event", G_CALLBACK(OnQuit), this);
|
||||
//g_signal_connect(G_OBJECT(m_mainWindow), "destroy", G_CALLBACK(OnQuit), this);
|
||||
|
||||
// Create a vertical box for stacking the menu and editor widgets in.
|
||||
@ -123,13 +122,42 @@ void MainWindows::OnMessage(int32_t id, int32_t dataID)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__QUIT:
|
||||
OnQuit(m_mainWindow, this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindows::OnQuit(GtkWidget *widget, gpointer data)
|
||||
bool MainWindows::OnQuit(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
EDN_INFO("quit requested");
|
||||
// dlg to confirm the quit event :
|
||||
GtkWidget *p_dialog = gtk_dialog_new_with_buttons("Exit",
|
||||
GTK_WINDOW(widget),
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_STOCK_YES, GTK_RESPONSE_YES,
|
||||
GTK_STOCK_NO, GTK_RESPONSE_NO,
|
||||
NULL);
|
||||
GtkWidget *p_label = gtk_label_new ("Do you want exit Edn?");
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show(p_label);
|
||||
|
||||
switch (gtk_dialog_run (GTK_DIALOG (p_dialog)))
|
||||
{
|
||||
case GTK_RESPONSE_YES:
|
||||
gtk_widget_destroy (p_dialog);
|
||||
|
||||
break;
|
||||
case GTK_RESPONSE_NO:
|
||||
gtk_widget_destroy (p_dialog);
|
||||
// do not close the windows
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_main_quit();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ class MainWindows: public Singleton<MainWindows>, public MsgBroadcast
|
||||
public:
|
||||
GtkWidget * GetWidget(void) { return m_mainWindow;};
|
||||
void OnMessage(int32_t id, int32_t dataID);
|
||||
static void OnQuit(GtkWidget *widget, gpointer data);
|
||||
static bool OnQuit(GtkWidget *widget, gpointer data);
|
||||
|
||||
private:
|
||||
void SetTitle(Edn::String &fileName, bool isModify);
|
||||
|
@ -318,6 +318,23 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
|
||||
tmp->AddGen("Copy 9", "ctrl+9", EDN_MSG__CURRENT_COPY, true, 9);
|
||||
tmp->AddGen("Paste 9", "alt+9", EDN_MSG__CURRENT_PASTE, true, 9);
|
||||
m_listMenu.PushBack(tmp);
|
||||
|
||||
tmp = new MenuBarMain("Help", m_mainWidget);
|
||||
tmp->AddGen("help display", NULL, EDN_MSG__OPEN_CTAGS, false);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("About ...", NULL, EDN_MSG__GUI_SHOW_ABOUT, true);
|
||||
/*
|
||||
tmp->AddGen("Gestion Ctags", NULL);
|
||||
tmp->AddGen("Add Ctags Folder", NULL);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Trouver la definition", NULL);
|
||||
tmp->AddGen("Trouver la declaration", NULL);
|
||||
tmp->AddGen("Retour...", NULL);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Tout desactiver", NULL);
|
||||
*/
|
||||
m_listMenu.PushBack(tmp);
|
||||
|
||||
}
|
||||
|
||||
MenuBar::~MenuBar(void)
|
||||
|
@ -153,5 +153,31 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
|
||||
gtk_widget_destroy(dialog); // implicitly hides dialog
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_ABOUT:
|
||||
{
|
||||
// dlg to confirm the quit event :
|
||||
GtkWidget *p_dialog = gtk_dialog_new_with_buttons("About",
|
||||
NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_STOCK_YES, GTK_RESPONSE_YES,
|
||||
GTK_STOCK_NO, GTK_RESPONSE_NO,
|
||||
NULL);
|
||||
GtkWidget *p_label = gtk_label_new ("Do you want exit Edn?");
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show(p_label);
|
||||
int32_t result = gtk_dialog_run (GTK_DIALOG (p_dialog));
|
||||
gtk_widget_destroy(p_dialog);
|
||||
switch (result)
|
||||
{
|
||||
case GTK_RESPONSE_YES:
|
||||
gtk_main_quit();
|
||||
break;
|
||||
case GTK_RESPONSE_NO:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
@ -89,6 +89,7 @@ static char * GetMessageChar(messageType_te Id)
|
||||
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_OPEN_FILE)
|
||||
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_SAVE_AS)
|
||||
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_GOTO_LINE)
|
||||
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_ABOUT)
|
||||
|
||||
MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_REMOVE)
|
||||
MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_REMOVE_ALL)
|
||||
|
@ -52,6 +52,7 @@ typedef enum {
|
||||
EDN_MSG__GUI_SHOW_OPEN_FILE,
|
||||
EDN_MSG__GUI_SHOW_SAVE_AS,
|
||||
EDN_MSG__GUI_SHOW_GOTO_LINE,
|
||||
EDN_MSG__GUI_SHOW_ABOUT,
|
||||
MSG_TO_GUI_MANAGER__STOP,
|
||||
|
||||
// DESTINATION : GUI
|
||||
|
Loading…
x
Reference in New Issue
Block a user