1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: interface.cxx,v $
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 ************************************************************************/
30 #include <interface.hxx>
38 WizardPage::~WizardPage()
46 WizardDialog::WizardDialog()
48 m_pStatusDialog
= NULL
;
49 m_pTopLevel
= gtk_window_new( GTK_WINDOW_TOPLEVEL
);
50 gtk_window_set_title( GTK_WINDOW(m_pTopLevel
), StringResource::get( "%WELCOME_CAPTION%" ) );
52 m_pVBox
= gtk_vbox_new( FALSE
, 5 );
53 gtk_widget_show( m_pVBox
);
54 gtk_container_add( GTK_CONTAINER(m_pTopLevel
), m_pVBox
);
56 m_pViewPort
= gtk_viewport_new( NULL
, NULL
);
57 gtk_widget_show( m_pViewPort
);
59 // set wizard title style
60 gtk_widget_ensure_style( m_pViewPort
);
61 GtkStyle
* pStyle
= gtk_style_copy( gtk_widget_get_style( m_pViewPort
) );
62 for( int i
= 0; i
< 5; i
++ )
64 pStyle
->bg
[i
] = pStyle
->white
;
65 pStyle
->text
[i
] = pStyle
->black
;
66 pStyle
->bg_gc
[i
] = pStyle
->white_gc
;
67 pStyle
->text_gc
[i
] = pStyle
->black_gc
;
69 gint nFontSize
= pango_font_description_get_size( pStyle
->font_desc
);
70 nFontSize
= nFontSize
* 3 / 2;
71 pango_font_description_set_size( pStyle
->font_desc
, nFontSize
);
72 gtk_widget_set_style( m_pViewPort
, pStyle
);
73 gtk_viewport_set_shadow_type( GTK_VIEWPORT(m_pViewPort
), GTK_SHADOW_NONE
);
74 gtk_box_pack_start( GTK_BOX(m_pVBox
), m_pViewPort
, FALSE
, FALSE
, 0 );
76 m_pWizardTitle
= gtk_label_new( "Wizard" ); // to be replaced by resp. page titles
77 gtk_widget_show( m_pWizardTitle
);
78 gtk_label_set_justify( GTK_LABEL(m_pWizardTitle
), GTK_JUSTIFY_LEFT
);
79 gtk_misc_set_alignment( GTK_MISC(m_pWizardTitle
), 0, 1 );
80 gtk_misc_set_padding( GTK_MISC(m_pWizardTitle
), 10, 10 );
81 gtk_widget_set_style( m_pWizardTitle
, pStyle
);
82 gtk_container_add( GTK_CONTAINER(m_pViewPort
), m_pWizardTitle
);
84 // prepare the area for the single pages
85 m_pPageArea
= gtk_vbox_new( FALSE
, 1);
86 gtk_widget_show( m_pPageArea
);
87 gtk_box_pack_start( GTK_BOX(m_pVBox
), m_pPageArea
, TRUE
, TRUE
, 0 );
89 m_pSeparator
= gtk_hseparator_new();
90 gtk_widget_show( m_pSeparator
);
91 gtk_box_pack_start( GTK_BOX(m_pVBox
), m_pSeparator
, FALSE
, FALSE
, 0 );
93 m_pButtonBox
= gtk_hbutton_box_new();
94 gtk_widget_show( m_pButtonBox
);
95 gtk_box_pack_start( GTK_BOX(m_pVBox
), m_pButtonBox
, FALSE
, FALSE
, 0 );
96 gtk_button_box_set_layout( GTK_BUTTON_BOX(m_pButtonBox
), GTK_BUTTONBOX_END
);
97 gtk_button_box_set_spacing( GTK_BUTTON_BOX(m_pButtonBox
), 0 );
99 m_pBackButton
= gtk_button_new_with_mnemonic( StringResource::get( "%BACK_BUTTON%" ) );
100 gtk_widget_show( m_pBackButton
);
101 gtk_container_add( GTK_CONTAINER(m_pButtonBox
), m_pBackButton
);
102 gtk_container_set_border_width( GTK_CONTAINER(m_pBackButton
), 5 );
103 GTK_WIDGET_SET_FLAGS( m_pBackButton
, GTK_CAN_DEFAULT
);
105 m_pNextButton
= gtk_button_new_with_mnemonic( StringResource::get( "%NEXT_BUTTON%" ) );
106 gtk_widget_show( m_pNextButton
);
107 gtk_container_add( GTK_CONTAINER(m_pButtonBox
), m_pNextButton
);
108 gtk_container_set_border_width( GTK_CONTAINER(m_pNextButton
), 5 );
109 GTK_WIDGET_SET_FLAGS( m_pNextButton
, GTK_CAN_DEFAULT
);
111 m_pSendButton
= gtk_button_new_with_mnemonic( StringResource::get( "%SEND_BUTTON%" ) );
112 gtk_widget_show( m_pSendButton
);
113 gtk_container_add( GTK_CONTAINER(m_pButtonBox
), m_pSendButton
);
114 gtk_container_set_border_width( GTK_CONTAINER(m_pSendButton
), 5 );
115 GTK_WIDGET_SET_FLAGS( m_pSendButton
, GTK_CAN_DEFAULT
);
117 m_pCancelButton
= gtk_button_new_with_mnemonic( StringResource::get( "%DONOT_SEND_BUTTON%" ) );
118 gtk_widget_show( m_pCancelButton
);
119 gtk_container_add( GTK_CONTAINER(m_pButtonBox
), m_pCancelButton
);
120 gtk_container_set_border_width( GTK_CONTAINER(m_pCancelButton
), 5 );
121 GTK_WIDGET_SET_FLAGS( m_pCancelButton
, GTK_CAN_DEFAULT
);
123 gtk_signal_connect( GTK_OBJECT(m_pTopLevel
), "delete-event", G_CALLBACK(gtk_main_quit
), NULL
);
124 gtk_signal_connect( GTK_OBJECT(m_pCancelButton
), "clicked", G_CALLBACK(gtk_main_quit
), NULL
);
125 gtk_signal_connect( GTK_OBJECT(m_pNextButton
), "clicked", G_CALLBACK(button_clicked
), this );
126 gtk_signal_connect( GTK_OBJECT(m_pBackButton
), "clicked", G_CALLBACK(button_clicked
), this );
127 gtk_signal_connect( GTK_OBJECT(m_pSendButton
), "clicked", G_CALLBACK(button_clicked
), this );
128 gtk_widget_set_sensitive( m_pSendButton
, FALSE
);
133 WizardDialog::~WizardDialog()
135 int nPages
= m_aPages
.size();
137 delete m_aPages
[nPages
];
140 void WizardDialog::show_messagebox( const std::string
& rMessage
)
142 GtkWidget
* messagebox
= NULL
;
143 GtkMessageType eType
= GTK_MESSAGE_ERROR
;
145 messagebox
= gtk_message_dialog_new( NULL
,
153 gtk_dialog_run( GTK_DIALOG(messagebox
) );
154 gtk_widget_destroy( GTK_WIDGET(messagebox
) );
159 // bInProgress: true=sending, false=finished
160 gint
WizardDialog::show_sendingstatus( bool bInProgress
)
162 m_pStatusDialog
= gtk_dialog_new_with_buttons( StringResource::get( "%SENDING_REPORT_HEADER%" ),
165 bInProgress
? GTK_STOCK_CANCEL
: GTK_STOCK_OK
,
166 bInProgress
? GTK_RESPONSE_REJECT
: GTK_RESPONSE_OK
,
169 gtk_window_set_default_size( GTK_WINDOW(m_pStatusDialog
), 350, 130 );
171 GtkWidget
*pLabel
= gtk_label_new( bInProgress
? StringResource::get( "%SENDING_REPORT_STATUS%" ) :
172 StringResource::get( "%SENDING_REPORT_STATUS_FINISHED%" ) );
173 gtk_widget_show( pLabel
);
174 gtk_label_set_justify( GTK_LABEL(pLabel
), GTK_JUSTIFY_CENTER
);
175 gtk_misc_set_alignment( GTK_MISC(pLabel
), 0, 0 );
177 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(m_pStatusDialog
)->vbox
), pLabel
);
179 gint ret
= gtk_dialog_run( GTK_DIALOG(m_pStatusDialog
) );
180 gtk_widget_destroy( m_pStatusDialog
);
181 m_pStatusDialog
= NULL
;
186 void WizardDialog::hide_sendingstatus()
188 if( m_pStatusDialog
)
190 gtk_dialog_response( GTK_DIALOG(m_pStatusDialog
), GTK_RESPONSE_OK
);
194 memset( &event
, 0, sizeof(event
) );
196 event
.xexpose
.type
= Expose
;
197 event
.xexpose
.display
= GDK_DISPLAY();
198 event
.xexpose
.window
= GDK_WINDOW_XWINDOW( m_pStatusDialog
->window
);
199 event
.xexpose
.width
= event
.xexpose
.height
= 10;
203 GDK_WINDOW_XWINDOW( m_pStatusDialog
->window
),
208 XFlush( GDK_DISPLAY() );
213 gint
WizardDialog::button_clicked( GtkWidget
* pButton
, WizardDialog
* pThis
)
215 if( pButton
== pThis
->m_pNextButton
)
217 else if( pButton
== pThis
->m_pBackButton
)
219 else if( pButton
== pThis
->m_pSendButton
)
221 if( pThis
->m_nCurrentPage
!= -1 )
222 pThis
->m_aPages
[pThis
->m_nCurrentPage
]->update();
224 if( send_crash_report( pThis
, pThis
->getSettings() ) )
231 void WizardDialog::insertPage( WizardPage
* pPage
)
233 m_aPages
.push_back( pPage
);
234 if( m_nCurrentPage
== -1 )
237 gtk_label_set_text( GTK_LABEL(m_pWizardTitle
), pPage
->getTitle() );
238 gtk_box_pack_start( GTK_BOX(m_pPageArea
), pPage
->getContents(), TRUE
, TRUE
, 0 );
239 gtk_widget_set_sensitive( m_pNextButton
, FALSE
);
240 gtk_widget_set_sensitive( m_pBackButton
, FALSE
);
244 gtk_widget_set_sensitive( m_pNextButton
, TRUE
);
248 void WizardDialog::nextPage()
250 if( m_aPages
.empty() || m_nCurrentPage
>= (int)m_aPages
.size()-1 )
253 m_aPages
[m_nCurrentPage
]->update();
255 gtk_container_remove( GTK_CONTAINER(m_pPageArea
), m_aPages
[m_nCurrentPage
]->getContents() );
257 gtk_label_set_text( GTK_LABEL(m_pWizardTitle
), m_aPages
[m_nCurrentPage
]->getTitle() );
258 gtk_box_pack_start( GTK_BOX(m_pPageArea
), m_aPages
[m_nCurrentPage
]->getContents(), TRUE
, TRUE
, 0 );
260 if( m_nCurrentPage
== (int)m_aPages
.size()-1 )
262 gtk_widget_set_sensitive( m_pNextButton
, FALSE
);
263 gtk_widget_set_sensitive( m_pSendButton
, TRUE
);
265 if( m_aPages
.size() > 1 )
266 gtk_widget_set_sensitive( m_pBackButton
, TRUE
);
269 void WizardDialog::lastPage()
271 if( m_aPages
.empty() || m_nCurrentPage
<= 0 )
274 m_aPages
[m_nCurrentPage
]->update();
276 gtk_container_remove( GTK_CONTAINER(m_pPageArea
), m_aPages
[m_nCurrentPage
]->getContents() );
278 gtk_label_set_text( GTK_LABEL(m_pWizardTitle
), m_aPages
[m_nCurrentPage
]->getTitle() );
279 gtk_box_pack_start( GTK_BOX(m_pPageArea
), m_aPages
[m_nCurrentPage
]->getContents(), TRUE
, TRUE
, 0 );
281 if( m_nCurrentPage
== 0 )
282 gtk_widget_set_sensitive( m_pBackButton
, FALSE
);
283 if( m_aPages
.size() > 1 )
284 gtk_widget_set_sensitive( m_pNextButton
, TRUE
);
287 void WizardDialog::show( bool bShow
)
290 gtk_widget_show( m_pTopLevel
);
292 gtk_widget_hide( m_pTopLevel
);
299 MainPage::MainPage( WizardDialog
* pParent
) : WizardPage( pParent
)
301 hash_map
< string
, string
>& rSettings
= m_pDialog
->getSettings();
302 m_aWizardTitle
= StringResource::get( "%REPORT_HEADER%" );
304 m_pPageContents
= gtk_vbox_new( FALSE
, 0 );
305 gtk_widget_show( m_pPageContents
);
307 m_pInfo
= gtk_label_new( StringResource::get( "%REPORT_BODY%" ) );
308 gtk_widget_show( m_pInfo
);
309 gtk_label_set_line_wrap( GTK_LABEL(m_pInfo
), TRUE
);
310 gtk_label_set_justify( GTK_LABEL(m_pInfo
), GTK_JUSTIFY_LEFT
);
311 gtk_misc_set_alignment( GTK_MISC(m_pInfo
), 0, 1 );
312 gtk_misc_set_padding( GTK_MISC(m_pInfo
), 5, 5);
313 gtk_box_pack_start( GTK_BOX(m_pPageContents
), m_pInfo
, FALSE
, FALSE
, 0 );
315 m_pHBox
= gtk_hbox_new( FALSE
, 0 );
316 gtk_widget_show( m_pHBox
);
317 gtk_box_pack_start( GTK_BOX(m_pPageContents
), m_pHBox
, TRUE
, TRUE
, 0 );
319 m_pLeftColumn
= gtk_vbox_new( FALSE
, 5 );
320 gtk_widget_show( m_pLeftColumn
);
321 gtk_container_set_border_width( GTK_CONTAINER(m_pLeftColumn
), 5 );
322 gtk_box_pack_start( GTK_BOX(m_pHBox
), m_pLeftColumn
, TRUE
, TRUE
, 0 );
324 m_pRightColumn
= gtk_vbutton_box_new();
325 gtk_widget_show( m_pRightColumn
);
326 gtk_button_box_set_layout( GTK_BUTTON_BOX(m_pRightColumn
), GTK_BUTTONBOX_END
);
327 gtk_box_pack_start( GTK_BOX(m_pHBox
), m_pRightColumn
, FALSE
, FALSE
, 0 );
329 m_pEditLabel
= gtk_label_new_with_mnemonic( StringResource::get( "%ENTER_TITLE%" ) );
330 gtk_widget_show( m_pEditLabel
);
331 gtk_label_set_justify( GTK_LABEL(m_pEditLabel
), GTK_JUSTIFY_LEFT
);
332 gtk_misc_set_alignment( GTK_MISC(m_pEditLabel
), 0, 1 );
333 gtk_box_pack_start( GTK_BOX(m_pLeftColumn
), m_pEditLabel
, FALSE
, FALSE
, 0 );
335 m_pEdit
= gtk_entry_new();
336 gtk_widget_show( m_pEdit
);
337 gtk_box_pack_start( GTK_BOX(m_pLeftColumn
), m_pEdit
, FALSE
, FALSE
, 0 );
339 gtk_label_set_mnemonic_widget( GTK_LABEL(m_pEditLabel
), m_pEdit
);
341 hash_map
<string
, string
>::iterator aIter
;
342 aIter
= rSettings
.find( "TITLE" );
343 if( aIter
!= rSettings
.end() )
344 gtk_entry_set_text( GTK_ENTRY(m_pEdit
), aIter
->second
.c_str() );
346 m_pEntryVBox
= gtk_vbox_new( FALSE
, 5 );
347 gtk_widget_show( m_pEntryVBox
);
348 gtk_box_pack_start( GTK_BOX(m_pLeftColumn
), m_pEntryVBox
, TRUE
, TRUE
, 0 );
350 m_pEntryLabel
= gtk_label_new_with_mnemonic( StringResource::get( "%ENTER_DESCRIPTION%" ) );
351 gtk_widget_show( m_pEntryLabel
);
352 gtk_label_set_justify( GTK_LABEL(m_pEntryLabel
), GTK_JUSTIFY_LEFT
);
353 gtk_misc_set_alignment( GTK_MISC(m_pEntryLabel
), 0, 1 );
354 gtk_box_pack_start( GTK_BOX(m_pEntryVBox
), m_pEntryLabel
, FALSE
, FALSE
, 0 );
356 m_pScrolledEntry
= gtk_scrolled_window_new( NULL
, NULL
);
357 gtk_widget_show( m_pScrolledEntry
);
358 gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_pScrolledEntry
), GTK_SHADOW_IN
);
359 gtk_box_pack_start( GTK_BOX(m_pEntryVBox
), m_pScrolledEntry
, TRUE
, TRUE
, 0 );
361 m_pEntry
= gtk_text_view_new();
362 gtk_widget_show( m_pEntry
);
363 gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW(m_pEntry
), GTK_WRAP_WORD
);
364 gtk_container_add( GTK_CONTAINER(m_pScrolledEntry
), m_pEntry
);
366 aIter
= rSettings
.find( "DESCRIPTION" );
367 if( aIter
!= rSettings
.end() )
369 GtkTextBuffer
* pBuffer
= gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_pEntry
) );
370 gtk_text_buffer_set_text( pBuffer
, aIter
->second
.c_str(), -1 );
374 gtk_label_set_mnemonic_widget( GTK_LABEL(m_pEntryLabel
), m_pEntry
);
376 m_pDetails
= gtk_button_new_with_mnemonic( StringResource::get( "%SHOW_REPORT_BUTTON%" ) );
377 gtk_widget_show(m_pDetails
);
378 gtk_container_set_border_width( GTK_CONTAINER(m_pDetails
), 5 );
379 gtk_container_add( GTK_CONTAINER(m_pRightColumn
), m_pDetails
);
381 m_pOptions
= gtk_button_new_with_mnemonic( StringResource::get( "%OPTIONS_BUTTON%" ) );
382 gtk_widget_show(m_pOptions
);
383 gtk_container_set_border_width( GTK_CONTAINER(m_pOptions
), 5 );
384 gtk_container_add( GTK_CONTAINER(m_pRightColumn
), m_pOptions
);
386 // check env var for save button
387 const char *szUserType
= getenv( "STAROFFICE_USERTYPE" );
388 if( szUserType
&& *szUserType
)
390 m_pSave
= gtk_button_new_with_mnemonic( StringResource::get( "%SAVE_REPORT_BUTTON%" ) );
391 gtk_widget_show(m_pSave
);
392 gtk_container_set_border_width( GTK_CONTAINER(m_pSave
), 5 );
393 gtk_container_add( GTK_CONTAINER(m_pRightColumn
), m_pSave
);
399 m_pCheck
= gtk_check_button_new_with_mnemonic( StringResource::get( "%ALLOW_CONTACT%" ) );
400 gtk_widget_show( m_pCheck
);
401 gtk_container_set_border_width( GTK_CONTAINER(m_pCheck
), 5 );
402 //gtk_box_pack_start( GTK_BOX(m_pPageContents), m_pCheck, FALSE, FALSE, 5 );
403 gtk_box_pack_start( GTK_BOX(m_pLeftColumn
), m_pCheck
, FALSE
, FALSE
, 5 );
405 aIter
= rSettings
.find( "CONTACT" );
406 if( aIter
!= rSettings
.end() )
408 const char *str
= aIter
->second
.c_str();
409 if( str
&& !strcasecmp(str
, "true") )
410 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(m_pCheck
), TRUE
);
413 m_pAddressLabel
= gtk_label_new_with_mnemonic( StringResource::get( "%ENTER_EMAIL%" ) );
414 gtk_widget_show( m_pAddressLabel
);
415 gtk_label_set_justify( GTK_LABEL(m_pAddressLabel
), GTK_JUSTIFY_LEFT
);
416 gtk_misc_set_alignment( GTK_MISC(m_pAddressLabel
), 0, 1 );
417 gtk_box_pack_start( GTK_BOX(m_pLeftColumn
), m_pAddressLabel
, FALSE
, FALSE
, 5 );
419 m_pAddress
= gtk_entry_new();
420 gtk_widget_show( m_pAddress
);
421 gtk_box_pack_start( GTK_BOX(m_pLeftColumn
), m_pAddress
, FALSE
, FALSE
, 5 );
423 aIter
= rSettings
.find( "EMAIL" );
424 if( aIter
!= rSettings
.end() )
425 gtk_entry_set_text( GTK_ENTRY(m_pAddress
), aIter
->second
.c_str() );
427 gtk_signal_connect( GTK_OBJECT(m_pDetails
), "clicked", G_CALLBACK(button_clicked
), this );
428 gtk_signal_connect( GTK_OBJECT(m_pOptions
), "clicked", G_CALLBACK(button_clicked
), this );
429 if(m_pSave
) // optional
430 gtk_signal_connect( GTK_OBJECT(m_pSave
), "clicked", G_CALLBACK(button_clicked
), this );
432 gtk_signal_connect( GTK_OBJECT(m_pCheck
), "toggled", G_CALLBACK(button_toggled
), this );
433 button_toggled( m_pCheck
, this );
435 g_object_ref( G_OBJECT(m_pPageContents
) );
438 MainPage::~MainPage()
440 g_object_unref( G_OBJECT(m_pPageContents
) );
443 void MainPage::update()
445 hash_map
< string
, string
>& rSettings
= m_pDialog
->getSettings();
447 GtkTextIter start
, end
;
448 GtkTextBuffer
* pTextBuffer
= gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_pEntry
) );
449 gtk_text_buffer_get_bounds( pTextBuffer
, &start
, &end
);
450 rSettings
[ "DESCRIPTION" ] = gtk_text_buffer_get_text( pTextBuffer
, &start
, &end
, 1 );
451 rSettings
[ "TITLE" ] = gtk_entry_get_text( GTK_ENTRY(m_pEdit
) );
452 rSettings
[ "CONTACT" ] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(m_pCheck
) ) ? "true" : "false";
453 rSettings
[ "EMAIL" ] = gtk_entry_get_text( GTK_ENTRY(m_pAddress
) );
456 gint
MainPage::button_toggled( GtkWidget
* pButton
, MainPage
* pThis
)
458 if ( GTK_TOGGLE_BUTTON (pThis
->m_pCheck
)->active
)
460 gtk_widget_set_sensitive( pThis
->m_pAddressLabel
, TRUE
);
461 gtk_widget_set_sensitive( pThis
->m_pAddress
, TRUE
);
465 gtk_widget_set_sensitive( pThis
->m_pAddressLabel
, FALSE
);
466 gtk_widget_set_sensitive( pThis
->m_pAddress
, FALSE
);
471 gint
MainPage::button_clicked( GtkWidget
* pButton
, MainPage
* pThis
)
473 if( pButton
== pThis
->m_pSave
)
475 GtkWidget
* pFile
= gtk_file_selection_new( StringResource::get( "%SAVE_REPORT_TITLE%" ) );
476 gint nRet
= gtk_dialog_run( GTK_DIALOG(pFile
) );
477 if( nRet
== GTK_RESPONSE_OK
)
479 string aFile
= gtk_file_selection_get_filename( GTK_FILE_SELECTION(pFile
) );
481 if( save_crash_report( aFile
, pThis
->m_pDialog
->getSettings() ) )
486 gtk_widget_destroy( pFile
);
488 else if( pButton
== pThis
->m_pDetails
)
492 GtkWidget
* pDialog
= gtk_dialog_new_with_buttons( StringResource::get( "%REPORT_CAPTION%" ),
493 pThis
->m_pDialog
->getTopLevel(),
499 gtk_window_set_default_size( GTK_WINDOW(pDialog
), 500, 300 );
500 GtkWidget
* pScroll
= gtk_scrolled_window_new( NULL
, NULL
);
501 gtk_widget_show( pScroll
);
502 gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(pScroll
), GTK_SHADOW_IN
);
503 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(pDialog
)->vbox
), pScroll
);
505 string aText
= crash_get_details( pThis
->m_pDialog
->getSettings() );
506 GtkWidget
* pView
= gtk_text_view_new();
507 gtk_widget_show( pView
);
508 gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW(pView
), GTK_WRAP_WORD
);
509 gtk_text_view_set_editable( GTK_TEXT_VIEW(pView
), FALSE
);
510 GtkTextBuffer
* pBuffer
= gtk_text_view_get_buffer( GTK_TEXT_VIEW(pView
) );
511 gtk_text_buffer_set_text( pBuffer
, aText
.data(), aText
.size() );
512 gtk_container_add( GTK_CONTAINER(pScroll
), pView
);
514 gtk_dialog_run( GTK_DIALOG(pDialog
) );
515 gtk_widget_destroy( pDialog
);
517 else if( pButton
== pThis
->m_pOptions
)
519 OptionsDialog
aOptions( pThis
->m_pDialog
->getTopLevel(), pThis
->m_pDialog
->getSettings() );
520 //pThis->m_pDialog->show_sendingstatus( true );
521 //pThis->m_pDialog->show_sendingstatus( false );
523 //pThis->m_pDialog->hide_sendingstatus();
530 * OptionsDialog (Proxy-Settings)
533 OptionsDialog::OptionsDialog( GtkWindow
*pParent
,hash_map
< string
, string
>& rSettings
)
535 m_pDialog
= gtk_dialog_new_with_buttons( StringResource::get( "%OPTIONS_TITLE%" ),
538 GTK_STOCK_OK
, GTK_RESPONSE_OK
,
539 GTK_STOCK_CANCEL
, GTK_RESPONSE_REJECT
,
542 gtk_window_set_default_size( GTK_WINDOW(m_pDialog
), 500, 300 );
544 m_pPage
= gtk_vbox_new( FALSE
, 0 );
545 m_pLeftColumn
= gtk_vbox_new( FALSE
, 5 );
547 gtk_widget_show( m_pPage
);
548 gtk_widget_show( m_pLeftColumn
);
550 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(m_pDialog
)->vbox
), m_pPage
);
552 gtk_container_set_border_width( GTK_CONTAINER(m_pLeftColumn
), 5 );
553 gtk_box_pack_start( GTK_BOX(m_pPage
), m_pLeftColumn
, FALSE
, FALSE
, 5 );
555 // frame for proxy settings
556 m_pFrame
= gtk_frame_new(StringResource::get( "%PROXY_SETTINGS_HEADER%" ));
557 gtk_frame_set_shadow_type( GTK_FRAME(m_pFrame
), GTK_SHADOW_ETCHED_IN
);
558 gtk_widget_show(m_pFrame
);
559 gtk_box_pack_start(GTK_BOX (m_pLeftColumn
), m_pFrame
, TRUE
, TRUE
, 0);
561 m_pVBox
= gtk_vbox_new( FALSE
, 0 );
562 gtk_widget_show( m_pVBox
);
563 gtk_container_add( GTK_CONTAINER( m_pFrame
), m_pVBox
);
566 m_pDirect
= gtk_radio_button_new_with_mnemonic( NULL
,
567 StringResource::get( "%PROXY_SETTINGS_DIRECT%" ) );
568 gtk_widget_show(m_pDirect
);
569 gtk_box_pack_start(GTK_BOX (m_pVBox
), m_pDirect
, FALSE
, FALSE
, 0);
571 m_pManual
= gtk_radio_button_new_with_mnemonic( gtk_radio_button_group( GTK_RADIO_BUTTON(m_pDirect
) ),
572 StringResource::get( "%PROXY_SETTINGS_MANUAL%" ) );
573 gtk_widget_show(m_pManual
);
574 gtk_box_pack_start(GTK_BOX (m_pVBox
), m_pManual
, FALSE
, FALSE
, 0);
576 hash_map
<string
, string
>::iterator aIter
;
577 const char *str
= NULL
;
578 aIter
= rSettings
.find( "USEPROXY" );
579 if( aIter
!= rSettings
.end() )
580 str
= aIter
->second
.c_str();
581 if( str
&& !strcasecmp(str
, "true") )
582 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(m_pManual
), TRUE
);
584 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(m_pDirect
), TRUE
);
586 // the server and port edit controls
587 m_pHBox
= gtk_hbox_new( FALSE
, 0 );
588 gtk_widget_show( m_pHBox
);
589 gtk_box_pack_start(GTK_BOX (m_pVBox
), m_pHBox
, FALSE
, FALSE
, 10);
591 m_pVBoxServer
= gtk_vbox_new( FALSE
, 5 );
592 gtk_widget_show( m_pVBoxServer
);
593 gtk_box_pack_start(GTK_BOX (m_pHBox
), m_pVBoxServer
, TRUE
, TRUE
, 10);
595 m_pVBoxPort
= gtk_vbox_new( FALSE
, 5 );
596 gtk_widget_show( m_pVBoxPort
);
597 gtk_box_pack_start(GTK_BOX (m_pHBox
), m_pVBoxPort
, FALSE
, FALSE
, 10);
599 m_pServerLabel
= gtk_label_new_with_mnemonic( StringResource::get( "%PROXY_SETTINGS_ADDRESS%" ) );
600 gtk_widget_show( m_pServerLabel
);
601 gtk_label_set_justify( GTK_LABEL(m_pServerLabel
), GTK_JUSTIFY_LEFT
);
602 gtk_misc_set_alignment( GTK_MISC(m_pServerLabel
), 0, 1 );
603 gtk_box_pack_start( GTK_BOX(m_pVBoxServer
), m_pServerLabel
, FALSE
, FALSE
, 0 );
605 m_pServer
= gtk_entry_new();
606 gtk_widget_show( m_pServer
);
607 gtk_box_pack_start( GTK_BOX(m_pVBoxServer
), m_pServer
, FALSE
, FALSE
, 0 );
608 gtk_label_set_mnemonic_widget( GTK_LABEL(m_pServerLabel
), m_pServer
);
609 aIter
= rSettings
.find( "SERVER" );
610 if( aIter
!= rSettings
.end() )
611 gtk_entry_set_text( GTK_ENTRY(m_pServer
), aIter
->second
.c_str() );
613 m_pPortLabel
= gtk_label_new_with_mnemonic( StringResource::get( "%PROXY_SETTINGS_PORT%" ) );
614 gtk_widget_show( m_pPortLabel
);
615 gtk_label_set_justify( GTK_LABEL(m_pPortLabel
), GTK_JUSTIFY_LEFT
);
616 gtk_misc_set_alignment( GTK_MISC(m_pPortLabel
), 0, 1 );
617 gtk_box_pack_start( GTK_BOX(m_pVBoxPort
), m_pPortLabel
, FALSE
, FALSE
, 0 );
619 m_pPort
= gtk_entry_new();
620 gtk_widget_show( m_pPort
);
621 gtk_box_pack_start( GTK_BOX(m_pVBoxPort
), m_pPort
, FALSE
, FALSE
, 0 );
622 gtk_label_set_mnemonic_widget( GTK_LABEL(m_pPortLabel
), m_pPort
);
623 aIter
= rSettings
.find( "PORT" );
624 if( aIter
!= rSettings
.end() )
625 gtk_entry_set_text( GTK_ENTRY(m_pPort
), aIter
->second
.c_str() );
628 m_pNote
= gtk_label_new( StringResource::get( "%PROXY_SETTINGS_DESCRIPTION%" ) );
629 gtk_widget_show( m_pNote
);
630 gtk_label_set_justify( GTK_LABEL(m_pNote
), GTK_JUSTIFY_LEFT
);
631 gtk_misc_set_alignment( GTK_MISC(m_pNote
), 0, 1 );
632 gtk_box_pack_start(GTK_BOX (m_pLeftColumn
), m_pNote
, FALSE
, FALSE
, 5);
633 gtk_label_set_line_wrap (GTK_LABEL (m_pNote
), TRUE
);
636 gtk_signal_connect( GTK_OBJECT(m_pDirect
), "toggled", G_CALLBACK(button_toggled
), this );
637 gtk_signal_connect( GTK_OBJECT(m_pManual
), "toggled", G_CALLBACK(button_toggled
), this );
639 button_toggled( m_pDirect
, this );
641 if( gtk_dialog_run( GTK_DIALOG(m_pDialog
) ) == GTK_RESPONSE_OK
)
643 rSettings
[ "SERVER" ] = getServer();
644 rSettings
[ "PORT" ] = getPort();
645 rSettings
[ "USEPROXY" ] = getUseProxy();
647 g_object_ref( G_OBJECT(m_pDialog
) );
650 OptionsDialog::~OptionsDialog()
652 gtk_widget_destroy( m_pDialog
);
653 g_object_unref( G_OBJECT(m_pDialog
) );
656 gint
OptionsDialog::button_toggled( GtkWidget
* pButton
, OptionsDialog
* pThis
)
658 if ( GTK_TOGGLE_BUTTON (pThis
->m_pManual
)->active
)
660 gtk_widget_set_sensitive( pThis
->m_pServerLabel
, TRUE
);
661 gtk_widget_set_sensitive( pThis
->m_pServer
, TRUE
);
662 gtk_widget_set_sensitive( pThis
->m_pPortLabel
, TRUE
);
663 gtk_widget_set_sensitive( pThis
->m_pPort
, TRUE
);
667 gtk_widget_set_sensitive( pThis
->m_pServerLabel
, FALSE
);
668 gtk_widget_set_sensitive( pThis
->m_pServer
, FALSE
);
669 gtk_widget_set_sensitive( pThis
->m_pPortLabel
, FALSE
);
670 gtk_widget_set_sensitive( pThis
->m_pPort
, FALSE
);
676 string
OptionsDialog::getUseProxy()
678 return gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(m_pDirect
) ) ? "false" : "true";
680 string
OptionsDialog::getServer()
682 return gtk_entry_get_text( GTK_ENTRY(m_pServer
) );
684 string
OptionsDialog::getPort()
686 return gtk_entry_get_text( GTK_ENTRY(m_pPort
) );
692 WelcomePage::WelcomePage( WizardDialog
* pParent
) : WizardPage( pParent
)
694 m_aWizardTitle
= StringResource::get( "%WELCOME_HEADER%" );
696 string aBody
= StringResource::get( "%WELCOME_BODY1%" );
697 aBody
+= StringResource::get( "%WELCOME_BODY2%" );
698 aBody
+= StringResource::get( "%WELCOME_BODY3%" );
700 aBody
+= StringResource::get( "%PRIVACY_URL%" );
701 m_pPageContents
= gtk_label_new( aBody
.c_str() );
702 gtk_widget_show( m_pPageContents
);
703 gtk_label_set_line_wrap( GTK_LABEL(m_pPageContents
), TRUE
);
704 gtk_label_set_justify( GTK_LABEL(m_pPageContents
), GTK_JUSTIFY_LEFT
);
705 gtk_misc_set_alignment( GTK_MISC(m_pPageContents
), 0, 1 );
706 gtk_misc_set_padding( GTK_MISC(m_pPageContents
), 5, 5);
708 g_object_ref( G_OBJECT(m_pPageContents
) );
711 WelcomePage::~WelcomePage()
713 g_object_unref( G_OBJECT(m_pPageContents
) );
716 void WelcomePage::update()