/* Copyright (C) 2006 by Marc Maurer * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ // This header defines some functions for Unix dialogs, // like centering them, measuring them, etc. #include "xap_UnixDialogHelper.h" #include "xap_App.h" #include "ap_UnixApp.h" #include "xap_UnixApp.h" #include "xap_Frame.h" #include "ap_UnixDialog_CollaborationService.h" static void s_login_clicked(GtkWidget * widget, AP_UnixDialog_CollaborationService * dlg) { UT_ASSERT(dlg); dlg->event_Login(); } XAP_Dialog * AP_UnixDialog_CollaborationService::static_constructor(XAP_DialogFactory * pFactory, XAP_Dialog_Id id) { return new AP_UnixDialog_CollaborationService(pFactory, id); } // // Need this pointer to find the dialogFactory. Other platforms // should implement this // pt2Constructor ap_CollaborationService_Constructor = &AP_UnixDialog_CollaborationService::static_constructor; AP_UnixDialog_CollaborationService::AP_UnixDialog_CollaborationService(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id) : AP_Dialog_CollaborationService(pDlgFactory, id), m_pWindowMain(NULL) { } AP_UnixDialog_CollaborationService::~AP_UnixDialog_CollaborationService(void) { UT_DEBUGMSG(("AP_UnixDialog_CollaborationService deleted %x \n",this)); } void AP_UnixDialog_CollaborationService::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the dialog's window m_pWindowMain = _constructWindow(); UT_return_if_fail(m_pWindowMain); /*_populateWindowData(); */ switch ( abiRunModalDialog ( GTK_DIALOG(m_pWindowMain), pFrame, this, GTK_RESPONSE_CLOSE, false ) ) { case GTK_RESPONSE_CLOSE: m_answer = AP_UnixDialog_CollaborationService::a_CLOSE; break; case GTK_RESPONSE_OK: m_answer = AP_UnixDialog_CollaborationService::a_CONNECT; break; default: m_answer = AP_UnixDialog_CollaborationService::a_CLOSE; break; } abiDestroyWidget ( m_pWindowMain ) ; } /*****************************************************************/ GtkWidget * AP_UnixDialog_CollaborationService::_constructWindow(void) { GtkWidget* window; const XAP_StringSet * pSS = m_pApp->getStringSet(); // get the path where our glade file is located XAP_UnixApp * pApp = static_cast(m_pApp); UT_String glade_path( pApp->getAbiSuiteAppGladeDir() ); glade_path += "/ap_UnixDialog_CollaborationService.glade"; // load the dialog from the glade file GladeXML *xml = abiDialogNewFromXML( glade_path.c_str() ); if (!xml) return NULL; // Update our member variables with the important widgets that // might need to be queried or altered later window = glade_xml_get_widget(xml, "ap_UnixDialog_CollaborationService"); m_pUsername = glade_xml_get_widget(xml, "edUsername"); m_pPassword = glade_xml_get_widget(xml, "edPassword"); // set the dialog title // TODO // localize the strings in our dialog, and set tags for some widgets // TODO g_signal_connect(G_OBJECT(glade_xml_get_widget(xml, "btLogin")), "clicked", G_CALLBACK(s_login_clicked), reinterpret_cast(this)); return window; } void AP_UnixDialog_CollaborationService::event_Login() { m_sUsername = gtk_entry_get_text(GTK_ENTRY(m_pUsername)); m_sPassword = gtk_entry_get_text(GTK_ENTRY(m_pPassword)); }