Merge branch 'master' of ssh://pege77@mercury.wipsl.com/var/git/irreco-theme-editor
[irreco.git] / backend / browser / src / browser_backend_dlg.c
blobf85701d7f8429a9d539fede8e9c01ed4877e8391
1 /*
2 * irreco-backend-browser
3 * Copyright (C) 2008 Arto Karppinen <arto.karppinen@iki.fi>
4 *
5 * irreco-backend-browser is free software: you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * irreco-backend-browser is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "browser_backend.h"
20 #include "browser_backend_dlg.h"
21 #include "browser_enum_types.h"
22 #include "browser_run.h"
25 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
26 /* Datatypes */
27 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
29 enum
31 PROP_0,
32 PROP_STORE,
33 PROP_BROWSER_TYPE,
34 PROP_DESCRIPTION
37 enum
39 BROWSER_RESPONSE_ADD = 10,
40 BROWSER_RESPONSE_DELETE,
41 BROWSER_RESPONSE_TEST
44 typedef struct _BrowserBackendDlgPrivate BrowserBackendDlgPrivate;
45 struct _BrowserBackendDlgPrivate {
46 GtkListStore *store;
47 GtkTreeSelection *selection;
49 GtkWidget *scrolled_set;
50 GtkWidget *browser_radio;
51 GtkWidget *wget_radio;
52 GtkWidget *description_entry;
54 gint url_tab_id;
55 gint settings_tab_id;
58 #define _GET_PRIVATE(_self) \
59 G_TYPE_INSTANCE_GET_PRIVATE( \
60 BROWSER_BACKEND_DLG(_self), \
61 BROWSER_TYPE_BACKEND_DLG, \
62 BrowserBackendDlgPrivate);
66 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
67 /* Prototypes */
68 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
69 static void
70 browser_backend_dlg_add_column( BrowserBackendDlg *self,
71 GtkWidget *treeview,
72 const gchar *name,
73 gint store_column );
74 static gboolean
75 browser_backend_dlg_signal_switch_page( GtkNotebook *notebook,
76 GtkNotebookPage *page,
77 guint page_num,
78 BrowserBackendDlg *self );
79 static void
80 browser_backend_dlg_signal_selection_changed(GtkTreeSelection *treeselection,
81 BrowserBackendDlg *self );
82 static void
83 browser_backend_dlg_signal_text_edited( GtkCellRendererText *renderer,
84 gchar *path_str,
85 gchar *new_text,
86 BrowserBackendDlg *self );
87 static void
88 browser_backend_dlg_signal_setting_vadj_changed( GtkAdjustment *adjustment,
89 BrowserBackendDlg *self );
93 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
94 /* Construction & Destruction */
95 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
97 G_DEFINE_TYPE( BrowserBackendDlg, browser_backend_dlg, GTK_TYPE_DIALOG )
99 static void
100 browser_backend_dlg_init (BrowserBackendDlg *object)
102 /* TODO: Add initialization code here */
105 static void
106 browser_backend_dlg_finalize (GObject *object)
108 /* TODO: Add deinitalization code here */
110 G_OBJECT_CLASS (browser_backend_dlg_parent_class)->finalize (object);
113 static void
114 browser_backend_dlg_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
116 BrowserBackendDlg *self = NULL;
117 BrowserBackendDlgPrivate *priv = NULL;
119 g_return_if_fail (BROWSER_IS_BACKEND_DLG (object));
121 self = BROWSER_BACKEND_DLG( object );
122 priv = _GET_PRIVATE( self );
124 switch (prop_id)
126 case PROP_STORE:
127 priv->store = GTK_LIST_STORE( g_value_get_object( value ));
128 break;
130 case PROP_BROWSER_TYPE:
131 switch ( g_value_get_enum( value )) {
132 case BROWSER_APPLICATION_MAEMO:
133 gtk_toggle_button_set_active(
134 GTK_TOGGLE_BUTTON( priv->browser_radio ),
135 TRUE );
136 break;
138 case BROWSER_APPLICATION_WGET:
139 gtk_toggle_button_set_active(
140 GTK_TOGGLE_BUTTON( priv->wget_radio ),
141 TRUE );
142 break;
144 break;
146 case PROP_DESCRIPTION:
147 gtk_entry_set_text( GTK_ENTRY( priv->description_entry ),
148 g_value_get_string( value ));
149 break;
151 default:
152 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
153 break;
157 static void
158 browser_backend_dlg_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
160 BrowserBackendDlg *self = NULL;
161 BrowserBackendDlgPrivate *priv = NULL;
163 g_return_if_fail (BROWSER_IS_BACKEND_DLG (object));
165 self = BROWSER_BACKEND_DLG( object );
166 priv = _GET_PRIVATE( self );
168 switch (prop_id)
170 case PROP_STORE:
171 g_value_set_object( value, priv->store );
172 break;
174 case PROP_BROWSER_TYPE:
175 if ( gtk_toggle_button_get_active(
176 GTK_TOGGLE_BUTTON( priv->browser_radio ))) {
177 g_value_set_enum( value, BROWSER_APPLICATION_MAEMO );
179 } else if ( gtk_toggle_button_get_active(
180 GTK_TOGGLE_BUTTON( priv->wget_radio ))) {
181 g_value_set_enum( value, BROWSER_APPLICATION_WGET );
183 break;
185 case PROP_DESCRIPTION:
186 g_value_set_string( value,
187 gtk_entry_get_text(
188 GTK_ENTRY( priv->description_entry )));
189 break;
191 default:
192 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
193 break;
197 static void
198 browser_backend_dlg_constructed(GObject *object)
200 BrowserBackendDlg *self = NULL;
201 BrowserBackendDlgPrivate *priv = NULL;
202 GtkWidget *notebook = NULL;
203 GtkWidget *treeview = NULL;
204 GtkWidget *scrolled_url = NULL;
205 GtkWidget *settings = NULL;
206 GtkWidget *scrolled_pad = NULL;
207 GtkWidget *settings_pad = NULL;
208 GtkWidget *open_label = NULL;
209 GtkWidget *description_label = NULL;
210 GtkAdjustment *adjustment = NULL;
211 IRRECO_ENTER
213 self = BROWSER_BACKEND_DLG( object );
214 priv = _GET_PRIVATE( self );
216 /* Setup dialog. */
217 gtk_window_set_title( GTK_WINDOW( self ),
218 _( "Web Browser Configuration" ));
219 gtk_window_set_modal( GTK_WINDOW( self), TRUE );
220 gtk_window_set_destroy_with_parent( GTK_WINDOW( self), TRUE );
221 gtk_dialog_set_has_separator( GTK_DIALOG(self), FALSE );
222 gtk_dialog_add_buttons( GTK_DIALOG( self ),
223 GTK_STOCK_ADD, BROWSER_RESPONSE_ADD,
224 GTK_STOCK_DELETE, BROWSER_RESPONSE_DELETE,
225 _( "Test" ), BROWSER_RESPONSE_TEST,
226 GTK_STOCK_OK, GTK_RESPONSE_OK,
227 NULL );
229 /* Build URL tab. */
230 treeview = gtk_tree_view_new_with_model( GTK_TREE_MODEL( priv->store ));
231 gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( treeview ), TRUE );
232 browser_backend_dlg_add_column( self, treeview, "Name", COL_NAME );
233 browser_backend_dlg_add_column( self, treeview, "URL", COL_URL );
235 priv->selection = gtk_tree_view_get_selection(
236 GTK_TREE_VIEW( treeview ));
237 gtk_tree_selection_set_mode( priv->selection, GTK_SELECTION_SINGLE );
238 browser_backend_dlg_signal_selection_changed( priv->selection, self );
239 g_signal_connect( G_OBJECT( priv->selection ), "changed",
240 G_CALLBACK( browser_backend_dlg_signal_selection_changed ),
241 self );
243 scrolled_url = gtk_scrolled_window_new( NULL, NULL );
244 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_url ),
245 GTK_POLICY_AUTOMATIC,
246 GTK_POLICY_AUTOMATIC );
247 gtk_container_add( GTK_CONTAINER( scrolled_url ), GTK_WIDGET( treeview ));
249 /* Build Settings tab. */
250 settings = gtk_vbox_new( FALSE, 4 );
251 open_label = irreco_gtk_label_bold( _( "How should URL's be opened?" ),
252 0, 0.5, 0, 0, 0, 0 );
253 priv->browser_radio = gtk_radio_button_new( NULL );
254 priv->wget_radio = gtk_radio_button_new_from_widget(
255 GTK_RADIO_BUTTON( priv->browser_radio ));
256 gtk_button_set_label( GTK_BUTTON( priv->browser_radio ),
257 _( "Inside the Web Browser." ));
258 gtk_button_set_label( GTK_BUTTON( priv->wget_radio ),
259 _( "Hidden in the background using wget." ));
261 description_label = irreco_gtk_label_bold( _( "Description" ),
262 0, 0.5, 8, 0, 0, 0 );
263 priv->description_entry = gtk_entry_new();
265 priv->scrolled_set = gtk_scrolled_window_new( NULL, NULL );
266 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( priv->scrolled_set ),
267 GTK_POLICY_NEVER,
268 GTK_POLICY_AUTOMATIC );
269 adjustment = gtk_scrolled_window_get_vadjustment(
270 GTK_SCROLLED_WINDOW( priv->scrolled_set ));
271 g_signal_connect( G_OBJECT( adjustment ), "changed",
272 G_CALLBACK( browser_backend_dlg_signal_setting_vadj_changed ),
273 self );
275 gtk_container_add( GTK_CONTAINER( settings ),
276 GTK_WIDGET( open_label ));
277 gtk_container_add( GTK_CONTAINER( settings ),
278 irreco_gtk_pad( GTK_WIDGET( priv->browser_radio ),
279 0, 0, 8, 0 ));
280 gtk_container_add( GTK_CONTAINER( settings ),
281 irreco_gtk_pad( GTK_WIDGET( priv->wget_radio ),
282 0, 0, 8, 0 ));
283 gtk_container_add( GTK_CONTAINER( settings ),
284 GTK_WIDGET( description_label ));
285 gtk_container_add( GTK_CONTAINER( settings ),
286 irreco_gtk_pad( GTK_WIDGET( priv->description_entry ),
287 0, 0, 8, 0 ));
288 gtk_scrolled_window_add_with_viewport(
289 GTK_SCROLLED_WINDOW( priv->scrolled_set ),
290 irreco_gtk_align( GTK_WIDGET( settings ),
291 0, 0, 1, 0, 0, 0, 0, 0 ));
293 /* Build notebook. */
294 notebook = gtk_notebook_new();
295 scrolled_pad = irreco_gtk_pad( GTK_WIDGET( scrolled_url ),
296 8, 8, 8, 8 );
297 priv->url_tab_id =
298 gtk_notebook_append_page( GTK_NOTEBOOK( notebook ),
299 scrolled_pad,
300 gtk_label_new( _( "Addresses" )));
301 settings_pad = irreco_gtk_align( GTK_WIDGET( priv->scrolled_set ),
302 0, 0, 1, 1, 8, 8, 8, 8 );
303 priv->settings_tab_id =
304 gtk_notebook_append_page( GTK_NOTEBOOK( notebook ),
305 settings_pad,
306 gtk_label_new( _( "Settings" )));
307 g_signal_connect( G_OBJECT( notebook ), "switch-page",
308 G_CALLBACK( browser_backend_dlg_signal_switch_page ),
309 self );
311 /* Build dialog. */
312 gtk_container_add( GTK_CONTAINER( GTK_DIALOG( self )->vbox ),
313 irreco_gtk_pad( GTK_WIDGET( notebook ),
314 8, 8, 8, 8 ));
315 gtk_window_resize( GTK_WINDOW( self ), 1, 400 );
316 gtk_widget_show_all( GTK_WIDGET( self ));
317 IRRECO_RETURN
320 static void
321 browser_backend_dlg_class_init (BrowserBackendDlgClass *klass)
323 GObjectClass* object_class = G_OBJECT_CLASS (klass);
324 /* GtkDialogClass* parent_class = GTK_DIALOG_CLASS (klass); */
326 object_class->finalize = browser_backend_dlg_finalize;
327 object_class->set_property = browser_backend_dlg_set_property;
328 object_class->get_property = browser_backend_dlg_get_property;
329 object_class->constructed = browser_backend_dlg_constructed;
331 g_type_class_add_private( klass, sizeof( BrowserBackendDlgPrivate ));
333 g_object_class_install_property( object_class,
334 PROP_STORE,
335 g_param_spec_object( BROWSER_BACKEND_DLG_PROP_STORE,
336 "store",
337 "store",
338 GTK_TYPE_LIST_STORE,
339 G_PARAM_READWRITE
340 | G_PARAM_CONSTRUCT_ONLY ));
342 g_object_class_install_property( object_class,
343 PROP_BROWSER_TYPE,
344 g_param_spec_enum( BROWSER_BACKEND_DLG_PROP_BROWSER_TYPE,
345 "browser-type",
346 "browser-type",
347 BROWSER_TYPE_APPLICATION_TYPE,
348 BROWSER_APPLICATION_MAEMO,
349 G_PARAM_READWRITE ));
351 g_object_class_install_property( object_class,
352 PROP_DESCRIPTION,
353 g_param_spec_string( BROWSER_BACKEND_DLG_PROP_DESCRIPTION,
354 "description",
355 "description",
357 G_PARAM_READWRITE ));
361 GtkWidget *
362 browser_backend_dlg_new( GtkListStore *store )
364 BrowserBackendDlg *self = NULL;
365 IRRECO_ENTER
367 self = g_object_new( BROWSER_TYPE_BACKEND_DLG, "store", store, NULL );
368 IRRECO_RETURN_PTR( self );
373 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
374 /* Private Functions */
375 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
377 static void
378 browser_backend_dlg_add_column( BrowserBackendDlg *self,
379 GtkWidget *treeview,
380 const gchar *name,
381 gint store_column )
383 GtkTreeViewColumn *column = NULL;
384 GtkCellRenderer *renderer = NULL;
385 IRRECO_ENTER
387 /* Create renderer. */
388 renderer = gtk_cell_renderer_text_new();
389 g_object_set( G_OBJECT( renderer ),
390 "editable", TRUE,
391 NULL);
392 g_object_set_data( G_OBJECT( renderer ), "column",
393 GINT_TO_POINTER( store_column ));
394 g_signal_connect( G_OBJECT( renderer ), "edited",
395 G_CALLBACK( browser_backend_dlg_signal_text_edited ),
396 self );
398 /* Add column to treeview. */
399 gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( treeview ), TRUE );
400 column = gtk_tree_view_column_new_with_attributes( name,
401 renderer,
402 "text", store_column,
403 NULL );
404 gtk_tree_view_append_column( GTK_TREE_VIEW( treeview ), column );
405 IRRECO_RETURN
408 static void
409 browser_backend_dlg_responce_add( BrowserBackendDlg *self )
411 BrowserBackendDlgPrivate *priv = NULL;
412 GtkWidget *dialog = NULL;
413 GtkWidget *table = NULL;
414 GtkWidget *name = NULL;
415 GtkWidget *url = NULL;
416 GtkAttachOptions opts = 0;
417 IRRECO_ENTER
419 priv = _GET_PRIVATE( self );
421 /* Create objects. */
422 dialog = gtk_dialog_new_with_buttons(
423 _( "Add URL" ), GTK_WINDOW( self ),
424 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT |
425 GTK_DIALOG_NO_SEPARATOR,
426 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
427 GTK_STOCK_OK, GTK_RESPONSE_OK,
428 NULL);
429 table = gtk_table_new( 2, 2, FALSE );
430 name = gtk_entry_new();
431 url = gtk_entry_new();
433 /* Build table. */
434 opts = GTK_SHRINK | GTK_FILL;
435 gtk_entry_set_text( GTK_ENTRY( url ), "http://" );
436 gtk_table_attach( GTK_TABLE( table ),
437 irreco_gtk_label( _( "Name:" ), 0, 0.5, 0, 0, 0, 0 ),
438 0, 1, 0, 1, opts, opts, 0, 0 );
439 gtk_table_attach_defaults( GTK_TABLE( table ), name, 1, 2, 0, 1 );
440 gtk_table_attach( GTK_TABLE( table ),
441 irreco_gtk_label( _( "URL:" ), 0, 0.5, 0, 0, 0, 0 ),
442 0, 1, 1, 2, opts, opts, 0, 0 );
443 gtk_table_attach_defaults( GTK_TABLE( table ), url, 1, 2, 1, 2 );
445 /* Build dialog. */
446 gtk_table_set_row_spacings( GTK_TABLE( table ), 4 );
447 gtk_table_set_col_spacings( GTK_TABLE( table ), 4 );
448 gtk_container_add( GTK_CONTAINER( GTK_DIALOG( dialog )->vbox ),
449 irreco_gtk_pad( GTK_WIDGET( table ), 8, 8, 8, 8 ));
450 gtk_window_resize( GTK_WINDOW( dialog ), 550, 1 );
451 gtk_widget_show_all( dialog );
453 /* Run dialog. */
454 while ( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_OK ) {
456 const gchar *name_str = NULL;
457 const gchar *url_str = NULL;
459 name_str = gtk_entry_get_text( GTK_ENTRY( name ));
460 url_str = gtk_entry_get_text( GTK_ENTRY( url ));
462 if ( irreco_str_isempty( name_str )) {
463 irreco_error_dlg( GTK_WINDOW( dialog ),
464 _( "Name is empty!" ));
465 } else if ( irreco_str_isempty( url_str )) {
466 irreco_error_dlg( GTK_WINDOW( dialog ),
467 _( "URL is empty!" ));
468 } else {
469 GtkTreeIter iter;
470 gtk_list_store_append( priv->store, &iter);
471 gtk_list_store_set( priv->store, &iter,
472 COL_NAME, name_str,
473 COL_URL, url_str,
474 -1 );
475 break;
479 gtk_widget_destroy(dialog);
480 IRRECO_RETURN
483 static void
484 browser_backend_dlg_responce_delete( BrowserBackendDlg *self )
486 BrowserBackendDlgPrivate *priv = NULL;
487 GtkTreeIter iter;
488 IRRECO_ENTER
490 priv = _GET_PRIVATE( self );
492 if ( gtk_tree_selection_get_selected( priv->selection, NULL, &iter )) {
496 IRRECO_RETURN
499 static void
500 browser_backend_dlg_responce_test( BrowserBackendDlg *self )
502 BrowserBackendDlgPrivate *priv = NULL;
503 gchar *url = NULL;
504 BrowserApplicationType type = 0;
505 IrrecoBackendStatus status = 0;
506 GtkTreeIter iter;
507 IRRECO_ENTER
509 priv = _GET_PRIVATE( self );
511 if ( gtk_tree_selection_get_selected( priv->selection, NULL, &iter )) {
513 gtk_tree_model_get( GTK_TREE_MODEL( priv->store ), &iter,
514 COL_URL, &url,
515 -1 );
516 g_object_get( G_OBJECT( self ),
517 BROWSER_BACKEND_DLG_PROP_BROWSER_TYPE,
518 &type,
519 NULL );
521 status = browser_run( type, url );
522 g_free( url );
524 if ( status == IRRECO_BACKEND_OK ) {
525 irreco_info_dlg( GTK_WINDOW( self ),
526 _( "Success!" ));
527 } else {
528 irreco_error_dlg( GTK_WINDOW( self ),
529 _( browser_get_error_msg( status )));
533 IRRECO_RETURN
538 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
539 /* Public Functions */
540 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
542 void
543 browser_backend_dlg_run( BrowserBackendDlg *self )
545 BrowserBackendDlgPrivate *priv = NULL;
546 gint response = 0;
547 gboolean loop = TRUE;
548 IRRECO_ENTER
550 priv = _GET_PRIVATE( self );
551 while ( loop ) {
553 response = gtk_dialog_run( GTK_DIALOG( self ));
555 switch ( response ) {
556 case GTK_RESPONSE_OK:
557 loop = FALSE;
558 break;
560 case BROWSER_RESPONSE_ADD:
561 browser_backend_dlg_responce_add( self );
562 break;
564 case BROWSER_RESPONSE_DELETE:
565 browser_backend_dlg_responce_delete( self );
566 break;
568 case BROWSER_RESPONSE_TEST:
569 browser_backend_dlg_responce_test( self );
570 break;
574 IRRECO_RETURN
579 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
580 /* Events and Callbacks */
581 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
583 static gboolean
584 browser_backend_dlg_signal_switch_page( GtkNotebook *notebook,
585 GtkNotebookPage *page,
586 guint page_num,
587 BrowserBackendDlg *self )
589 BrowserBackendDlgPrivate *priv = NULL;
590 GtkWidget *add = NULL;
591 GtkWidget *del = NULL;
592 GtkWidget *test = NULL;
593 IRRECO_ENTER
595 priv = _GET_PRIVATE( self );
596 add = irreco_gtk_dialog_get_button( GTK_WIDGET( self ), 0 );
597 del = irreco_gtk_dialog_get_button( GTK_WIDGET( self ), 1 );
598 test = irreco_gtk_dialog_get_button( GTK_WIDGET( self ), 2 );
600 if ( page_num == priv->url_tab_id ) {
601 gtk_widget_show( add );
602 gtk_widget_show( del );
603 gtk_widget_show( test );
604 } else {
605 gtk_widget_hide( add );
606 gtk_widget_hide( del );
607 gtk_widget_hide( test );
610 IRRECO_RETURN_BOOL( FALSE )
613 static void
614 browser_backend_dlg_signal_selection_changed(GtkTreeSelection *treeselection,
615 BrowserBackendDlg *self )
617 BrowserBackendDlgPrivate *priv = NULL;
618 GtkWidget *del = NULL;
619 GtkWidget *test = NULL;
620 IRRECO_ENTER
622 priv = _GET_PRIVATE( self );
623 del = irreco_gtk_dialog_get_button( GTK_WIDGET( self ), 1 );
624 test = irreco_gtk_dialog_get_button( GTK_WIDGET( self ), 2 );
626 if ( gtk_tree_selection_get_selected( priv->selection, NULL, NULL )) {
627 gtk_widget_set_sensitive( del, TRUE );
628 gtk_widget_set_sensitive( test, TRUE );
629 } else {
630 gtk_widget_set_sensitive( del, FALSE );
631 gtk_widget_set_sensitive( test, FALSE );
633 IRRECO_RETURN
636 static void
637 browser_backend_dlg_signal_text_edited( GtkCellRendererText *renderer,
638 gchar *path_str,
639 gchar *new_text,
640 BrowserBackendDlg *self )
642 BrowserBackendDlgPrivate *priv = NULL;
643 GtkTreePath* path;
644 GtkTreeIter iter;
645 gint column;
646 IRRECO_ENTER
648 priv = _GET_PRIVATE( self );
649 column = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( renderer ),
650 "column" ));
651 path = gtk_tree_path_new_from_string(path_str);
652 gtk_tree_model_get_iter( GTK_TREE_MODEL( priv->store ), &iter, path );
653 gtk_list_store_set( priv->store, &iter, column, new_text, -1);
654 gtk_tree_path_free( path );
656 IRRECO_RETURN
660 * This function is, in effect, called when the vertical size of setting
661 * GtkScrolledWindow is changed.
663 static void
664 browser_backend_dlg_signal_setting_vadj_changed( GtkAdjustment *adjustment,
665 BrowserBackendDlg *self )
667 BrowserBackendDlgPrivate *priv = NULL;
668 GtkWidget *vscroll = NULL;
669 gdouble value = 0;
670 gdouble upper = 0;
671 IRRECO_ENTER
673 priv = _GET_PRIVATE( self );
675 /* If description entry widget has focus, attempt to adjust
676 * scrollbars so that the widget is visible. By default clicking on
677 * the widget causes maemo keyboard to be shown, which is turn causes
678 * the window to be resized, and that causes the vidget to be hidden.
680 if ( GTK_WIDGET_HAS_FOCUS( GTK_WIDGET( priv->description_entry ) )) {
681 IRRECO_PRINTF( "focus\n" );
683 g_object_get( G_OBJECT( adjustment ),
684 "value", &value,
685 "upper", &upper,
686 NULL );
687 IRRECO_DEBUG( "value %f, upper %f\n", value, upper );
689 vscroll = gtk_scrolled_window_get_vscrollbar(
690 GTK_SCROLLED_WINDOW( priv->scrolled_set ));
691 gtk_range_set_value( GTK_RANGE( vscroll ), upper );
694 IRRECO_RETURN