Author: tian
Date: Tue Apr 12 22:21:06 2016
New Revision: 2278

URL: http://svn.gna.org/viewcvs/gcstar?rev=2278&view=rev
Log:
Handle locked version + code cleanup

Modified:
    trunk/gcstar/lib/gcstar/GCGraphicComponents/GCPictureWidgets.pm

Modified: trunk/gcstar/lib/gcstar/GCGraphicComponents/GCPictureWidgets.pm
URL: 
http://svn.gna.org/viewcvs/gcstar/trunk/gcstar/lib/gcstar/GCGraphicComponents/GCPictureWidgets.pm?rev=2278&r1=2277&r2=2278&view=diff
==============================================================================
--- trunk/gcstar/lib/gcstar/GCGraphicComponents/GCPictureWidgets.pm     
(original)
+++ trunk/gcstar/lib/gcstar/GCGraphicComponents/GCPictureWidgets.pm     Tue Apr 
12 22:21:06 2016
@@ -872,8 +872,6 @@
         
                my $hboxActions = new Gtk2::HBox(0,0);
 
-        #$self->{box} = new Gtk2::VBox(0,0);
-
         # If list belongs to an expander, set box size to a reasonable size
         $self->{signalHandler} = $self->signal_connect('size-allocate' => sub {
             if (($self->{realParent}) && 
($self->{realParent}->isa('GCExpander')))
@@ -884,7 +882,6 @@
             }
         });
 
-        #$self->{list} = new Gtk2::VBox;
         $self->{list} = Gtk2::Table->new(1,2,1);
         my $scroll = new Gtk2::ScrolledWindow;
         $scroll->set_policy ('automatic', 'automatic');
@@ -903,48 +900,13 @@
                 $self->setChanged;
                 $self->forceDisplay;                
             });
-            #$self->{removeButton} = GCButton->newFromStock('gtk-remove', 0);
             $hboxActions->pack_start($self->{addButton}, 0, 0, 6);
-            #$hboxActions->pack_start($self->{removeButton}, 0, 0, 6);
         }
         else
         {
-            #$self->{removeButton} = GCButton->newFromStock('gtk-remove', 0);
-            #$self->{clearButton} = GCButton->newFromStock('gtk-clear', 0);
-            #$self->{clearButton}->signal_connect('clicked' => sub {
-            #    $self->clear;
-            #});            
-            #$hboxActions->pack_start($self->{removeButton}, 1, 0, 6);
-            #$hboxActions->pack_start($self->{clearButton}, 1, 0, 6);
         }
         $self->pack_start($hboxActions, 0, 0, 6)
             if $readonly < 2;
-
-        #$self->{removeButton}->signal_connect('clicked' => sub {
-        #    my @idx = $self->{list}->get_selected_indices;
-        #    my $selected = $idx[0];
-        #    splice @{$self->{list}->{data}}, $selected, 1;
-        #    $selected-- if ($selected >= scalar(@{$self->{list}->{data}}));
-        #    $selected = 0 if $selected < 0 ;
-        #    $self->{list}->select($selected);
-        #});
-        
-        #$self->{list}->signal_connect('key-press-event' => sub {
-        #    my ($widget, $event) = @_;
-        #    my $key = Gtk2::Gdk->keyval_name($event->keyval);
-        #    if ((!$self->{readonly}) && ($key eq 'Delete'))
-        #    {
-        #        $self->{removeButton}->activate;
-        #        return 1;
-        #    }
-        #    # Let key be managed by Gtk2
-        #    return 0;
-        #});
-        
-
-        #$self->pack_start($self->{box},1,$self->{readonly},0);
-        
-
 
         bless ($self, $class);
         return $self;
@@ -961,30 +923,10 @@
         });
     }
 
-    sub activateStateTracking
-    {
-        my $self = shift;
-#        $self->{list}->get_model->signal_connect('row-inserted' => sub {
-#            $self->setChanged;
-#        });
-#        $self->{list}->get_model->signal_connect('row-deleted' => sub {
-#            $self->setChanged;
-#        });
-#        $self->{list}->get_model->signal_connect('row-changed' => sub {
-#            $self->setChanged;
-#        });
-    }
-
     sub notifyImgChange
     {
         my ($self,  $img) = @_;
         $self->setChanged;
-    }
-
-    sub expand
-    {
-        my $self = shift;
-        $self->set_child_packing($self,1,1,0,'start');
     }
 
     sub addImage
@@ -1012,37 +954,6 @@
             $self->removeImage($widget);
         });
 
-
-
-        
-#        if (!$self->{readonly})
-#        {
-#            for my $i (0..($self->{number} - 1))
-#            {
-#                $values[$i] = $self->{entries}->[$i]->getValue if 
!$values[$i];
-#                $self->{entries}->[$i]->addHistory($values[$i])
-#                    if $self->{withHistory} && 
$self->{withHistoryField}->[$i];
-#                $self->{entries}->[$i]->clear;
-#            }
-#        }
-#        # Check that at least one value is not empty
-#        my $isEmpty = 1;
-#        for my $val (@values)
-#        {
-#            if ($val)
-#            {
-#                $isEmpty = 0;
-#                last;
-#            }
-#        }
-#        if (!$isEmpty)
-#        {
-#            push @{$self->{list}->{data}}, \@values;
-#            $self->{list}->select($#{$self->{list}->{data}});
-#            my $path = $self->{list}->get_selection->get_selected_rows;
-#            $self->{list}->scroll_to_cell($path) if $path;
-#        }
-
         return $widget;
     }
     
@@ -1064,13 +975,9 @@
     sub removeImage
     {
         my ($self, $imgToRemove) = @_;
-        #print "REMOVING $line : $col\n";
         
         my @imgs = $self->getOrderedChildren;
         my $imgIdx = 0;
-        #print "IDX : $imgIdx\n";
-        #$self->{list}->remove($imgs[$imgIdx]);
-        #$imgIdx++;
         my $found = 0;
         while ($imgIdx <= $#imgs)
         {
@@ -1115,63 +1022,19 @@
     sub getValue
     {
         my $self = shift;
-#        my $formated = shift;
 
         my @value;
-         #for my $img($self->{list}->get_children)
-        #{
-        #    my ($x, $y) = $self->{list}->child_get($img, qw(left-attach 
top-attach));
-        #    $value[($y * $self->{itemsPerRow}) + $x] = [$img->getValue];
-        #}
         for my $img($self->getOrderedChildren)
         {
             push @value, [$img->getValue]
         }
         
         return \@value;
-
-
-#        if ($formated)
-#        {
-#            return GCPreProcess::multipleList($self->{list}->{data}, 
$self->{number});
-#        }
-#        else
-#        {
-#            # As data in list is a tied array, we need to copy all the values
-#            my @value;
-#            foreach (@{$self->{list}->{data}})
-#            {
-#                push @value, [];
-#                foreach my $col(@$_)
-#                {
-#                    push @{$value[-1]}, $col;
-#                }
-#            }
-#            return \@value;
-#        }
     }
     
     sub setValue
     {
         my ($self, $value) = @_;
-
-#        if (ref($value) eq 'ARRAY')
-#        {
-#            @{$self->{list}->{data}} = @{$value};
-#        }
-#        else
-#        {
-#            # The separator used was ; instead of ,
-#            $value =~ s/;/,/g if $value !~ /,/;
-#            @{$self->{list}->{data}} = ();
-#            my @values = split m/,/, $value;
-#            foreach my $entry (@values)
-#            {
-#                my @items = split m/;/, $entry;
-#                s/^\s*// foreach(@items);
-#                push @{$self->{list}->{data}}, \@items;
-#            }
-#        }
 
         $self->clear;
 
@@ -1182,7 +1045,7 @@
             $value =~ s/;/,/g if $value !~ /,/;
             my @values = split m/,/, $value;
             #TODO
-            
+            push @arrayValues, [$_] foreach @values;
             $value = \@arrayValues;
         }
 
@@ -1198,7 +1061,6 @@
     sub clear
     {
         my $self = shift;
-        #$self->setValue('');
         
         for my $img($self->{list}->get_children)
         {
@@ -1212,93 +1074,11 @@
         my ($self, $locked) = @_;
         return if $self->{readonly};
         $self->{addButton}->set_sensitive(!$locked);
-        $self->{removeButton}->set_sensitive(!$locked);
-        foreach (@{$self->{entries}})
+        foreach ($self->getOrderedChildren)
         {
             $_->lock($locked);
         }
-    }
-
-    sub addHistory
-    {
-        my $self = shift;
-        my $value = (scalar @_) ? shift : $self->getValue;
-        my $noUpdate = shift;
-
-        return if $self->{readonly};
-        my $i;
-        my $item;
-        if (ref($value) eq 'ARRAY')
-        {
-            foreach (@$value)
-            {
-                $i = 0;
-                foreach $item(@$_)
-                {
-                    $self->{entries}->[$i]->addHistory($item, $noUpdate) if 
$self->{withHistoryField}->[$i];
-                    $i++;
-                }
-            }
-        }
-        else
-        {
-            # The separator used was ; instead of ,
-            $value =~ s/;/,/g if $value !~ /,/;
-            my @values = split m/,/, $value;
-            foreach (@values)
-            {
-                my @items = split m/;/;
-                $i = 0;
-                foreach my $item(@items)
-                {
-                    $self->{entries}->[$i]->addHistory($item, $noUpdate) if 
$self->{withHistoryField}->[$i];
-                    $i++;
-                }
-                #push @{$self->{list}->{data}}, \@items;
-            }
-        }
-    }
-
-    sub setDropDown
-    {
-        my $self = shift;
-        
-        my $i = 0;
-        foreach (@{$self->{entries}})
-        {
-            $_->setDropDown if $self->{withHistoryField}->[$i];
-            $i++;
-        }
-    }
-
-    sub getValues
-    {
-        my $self = shift;
-        return [] if $self->{readonly};
-        my @array;
-        my $i=0;
-        foreach (@{$self->{entries}})
-        {
-            my $val=[];
-            $val=$_->getValues if ($self->{withHistoryField}->[$i++]);
-            push @array, $val;
-        }
-        # = sort keys %{$self->{history}};
-        return \@array;
-    }
-    
-    sub setValues
-    {
-        my ($self, $values) = @_;
-        return if $self->{readonly};
-        my $i = 0;
-        foreach (@$values)
-        {
-            $self->{entries}->[$i]->setValues($_) if 
($self->{withHistoryField}->[$i]);
-            $i++;
-        }
-    }
-    
+    }    
     
 }
 


_______________________________________________
GCstar-commits mailing list
[email protected]
https://mail.gna.org/listinfo/gcstar-commits

Reply via email to