Re: Combox - show one column but two columns in popup



This is how I resolved my issue by connecting to notify::popup-shown signal. It seems really kludgey though (especially having to resize the window)

$widgetsm{tunefile}->signal_connect('notify::popup-shown'=>sub{

     if($widgetsm{tunefile}->get('popup-shown') ==1){
        ($w,$h)= $window->get_size;
           $widgetsm{tunefile}->pack_start ($renderer1, 'FALSE');
           $widgetsm{tunefile}->add_attribute ($renderer1, text => 1);
        }
    elsif ($widgetsm{tunefile}->get('popup-shown') ==0){
        $widgetsm{tunefile}->clear;
        $widgetsm{tunefile}->pack_start ($renderer, 'FALSE');
        $widgetsm{tunefile}->add_attribute ($renderer, text => 0);
        $window->resize($w,$h);
        }
    }
    );

On 20 June 2017 at 00:59, Mike Martin <mike redtux org uk> wrote:
Is this possible?

ie I have a combobox based on a two column liststore
I want only the first column to be shown in the combobox, but both columns to be shown in the popup

The model is populated by an array of filename/directory name

I'm sure I must be missing something obvious

thanks

example

my $channel_file_model=Gtk3::TreeStore->new('Glib::String','Glib::String');
$channel_file_view=Gtk3::Treeview->new

 -- list of files as below;
my @list;
my %dirdvb;
foreach my $prefix_conf (@prefix_conf){
#my $prefix_conf;
my (undef,$prefix_conf_sys,undef)=File::Basename::fileparse($prefix_conf);
$dirdvb{$prefix_conf_sys}=undef;
}
#print 'prefix ',$prefix_conf_sys,"\n";
foreach my $prefix_conf_sys (keys %dirdvb){
        my @listi=`ls -1 $prefix_conf_sys`;
        foreach my $list1 (@listi){
             push @list, [$list1,$prefix_conf_sys]
             }
        }
--setup renderer - otherwise 2nd column doesnt show at all
my $renderer1 = Gtk3::CellRendererText->new;
    
       $channel_file_view->pack_start ($renderer1, 'TRUE');
       $channel_file_view->add_attribute ($renderer1, text => 1);
--finally add lines to combobox

sub add_combo {
    my ($combo,$val1,$val2,$chk)=@_;
    my $iter=$combo->append(undef);

    my $cnt=0;
        foreach my $val ($val1,$val2){
                  $combo->set($iter,$cnt,$val);
                  $cnt++;
                  }
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]