merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / gtk / app / gtksys.cxx
blob78c112f1cd041c3be9e1a73cf1cd3d8fed2e99d5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gtksys.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <svunx.h>
35 #include <vcl/svdata.hxx>
36 #include <vcl/window.hxx>
37 #include <plugins/gtk/gtkinst.hxx>
38 #include <cstdio>
39 #include <gdk/gdk.h>
40 #include <gtk/gtk.h>
41 #include <X11/Xlib.h>
43 SalSystem *GtkInstance::CreateSalSystem()
45 return new GtkSalSystem();
48 GtkSalSystem::~GtkSalSystem()
52 int GtkSalSystem::ShowNativeDialog( const String& rTitle,
53 const String& rMessage,
54 const std::list< String >& rButtons,
55 int nDefButton )
58 ImplSVData* pSVData = ImplGetSVData();
59 if( pSVData->mpIntroWindow )
60 pSVData->mpIntroWindow->Hide();
62 #if OSL_DEBUG_LEVEL > 1
63 std::fprintf( stderr, "GtkSalSystem::ShowNativeDialog\n");
64 #endif
66 ByteString aTitle( rTitle, RTL_TEXTENCODING_UTF8 );
67 ByteString aMessage( rMessage, RTL_TEXTENCODING_UTF8 );
69 /* Create the dialogue */
70 GtkWidget* mainwin = gtk_message_dialog_new
71 ( NULL, (GtkDialogFlags)0, GTK_MESSAGE_WARNING,
72 GTK_BUTTONS_NONE, aMessage.GetBuffer(), NULL );
73 gtk_window_set_title( GTK_WINDOW( mainwin ), aTitle.GetBuffer() );
75 gint nButtons = 0, nResponse;
77 int nButton = 0;
78 for( std::list< String >::const_iterator it = rButtons.begin(); it != rButtons.end(); ++it )
80 ByteString aLabel( *it, RTL_TEXTENCODING_UTF8 );
82 if( nButton == nDefButton )
84 gtk_dialog_add_button( GTK_DIALOG( mainwin ), aLabel.GetBuffer(), nButtons );
85 gtk_dialog_set_default_response( GTK_DIALOG( mainwin ), nButtons );
87 else
88 gtk_dialog_add_button( GTK_DIALOG( mainwin ), aLabel.GetBuffer(), nButtons );
89 nButtons++;
92 nResponse = gtk_dialog_run( GTK_DIALOG(mainwin) );
93 if( nResponse == GTK_RESPONSE_NONE || nResponse == GTK_RESPONSE_DELETE_EVENT )
94 nResponse = -1;
96 gtk_widget_destroy( GTK_WIDGET(mainwin) );
98 return nResponse;