]> www.fi.muni.cz Git - evince.git/commitdiff
Update also the region of the current selected button when clicking on
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 9 Jul 2007 17:14:00 +0000 (17:14 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Mon, 9 Jul 2007 17:14:00 +0000 (17:14 +0000)
2007-07-09  Carlos Garcia Campos  <carlosgc@gnome.org>
* shell/ev-view.c: (ev_view_form_field_button_create_widget):
Update also the region of the current selected button when
clicking on another button if they are radio buttons.

svn path=/trunk/; revision=2566

ChangeLog
shell/ev-view.c

index eeceffe5a4a788be9eec55767f9542680eb760dd..3e8ffd099317d70d352dc35e2f85b06e96d75bdc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-09  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * shell/ev-view.c: (ev_view_form_field_button_create_widget):
+
+       Update also the region of the current selected button when
+       clicking on another button if they are radio buttons.
+       
 2007-07-09  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-pixbuf-cache.[ch]: (ev_pixbuf_cache_class_init),
index 44af42120b8d90cc7ec14644691b2d9dc1acde0f..0bbef7db3ff6738efb2351e357687ac9826d7221 100644 (file)
@@ -1637,14 +1637,13 @@ ev_view_form_field_button_create_widget (EvView      *view,
                                         EvFormField *field)
 {
        EvFormFieldButton *field_button = EV_FORM_FIELD_BUTTON (field);
+       GdkRegion         *field_region;
        
        switch (field_button->type) {
                case EV_FORM_FIELD_BUTTON_PUSH:
-                       break;
-               case EV_FORM_FIELD_BUTTON_CHECK:
-               case EV_FORM_FIELD_BUTTON_RADIO: {
-                       gboolean   state;
-                       GdkRegion *field_region;
+                       return NULL;
+               case EV_FORM_FIELD_BUTTON_CHECK: {
+                       gboolean state;
 
                        field_region = ev_view_form_field_get_region (view, field);
                        
@@ -1652,15 +1651,56 @@ ev_view_form_field_button_create_widget (EvView      *view,
                                                                               field);
                        ev_document_forms_form_field_button_set_state (EV_DOCUMENT_FORMS (view->document),
                                                                       field, !state);
-                       ev_pixbuf_cache_reload_page (view->pixbuf_cache,
-                                                    field_region,
-                                                    field->page,
-                                                    view->rotation,
-                                                    view->scale);
-                       gdk_region_destroy (field_region);
+               }
+                       break;
+                       
+               case EV_FORM_FIELD_BUTTON_RADIO: {
+                       gboolean  state;
+                       GList    *forms_mapping, *l;
+
+                       state = ev_document_forms_form_field_button_get_state (EV_DOCUMENT_FORMS (view->document),
+                                                                              field);
+                       if (state && field_button->state)
+                               return NULL;
+                       
+                       field_region = ev_view_form_field_get_region (view, field);
+
+                       /* For radio buttons we need to update also the region for the
+                        * current selected item
+                        */
+                       forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
+                                                                               field->page);
+                       for (l = forms_mapping; l; l = g_list_next (l)) {
+                               EvFormField *radio = ((EvFormFieldMapping *)(l->data))->field;
+                               GdkRegion   *radio_region;
+
+                               if (radio->id == field->id)
+                                       continue;
+
+                               /* FIXME: only buttons in the same group should be updated */
+                               if (!EV_IS_FORM_FIELD_BUTTON (radio) ||
+                                   EV_FORM_FIELD_BUTTON (radio)->type != EV_FORM_FIELD_BUTTON_RADIO ||
+                                   EV_FORM_FIELD_BUTTON (radio)->state != TRUE)
+                                       continue;
+
+                               radio_region = ev_view_form_field_get_region (view, radio);
+                               gdk_region_union (field_region, radio_region);
+                               gdk_region_destroy (radio_region);
+                       }
+                       
+                       ev_document_forms_form_field_button_set_state (EV_DOCUMENT_FORMS (view->document),
+                                                                      field, TRUE);
+                       field_button->state = TRUE;
                }
                        break;
        }
+
+       ev_pixbuf_cache_reload_page (view->pixbuf_cache,
+                                    field_region,
+                                    field->page,
+                                    view->rotation,
+                                    view->scale);
+       gdk_region_destroy (field_region);
        
        return NULL;
 }