Array of arrays

2010-02-27 Thread Brian Lavender
I was experimenting with creating an array of arrays. Maybe I shouldn't
be using GArray but something different such as pointer arrays and
allocating memory for each element? 

I wrote two sample programs. The first one, just loads one array. The
second, loads an array of arrays. I don't know if I have a problem with
operator precedence or if the GArrays point to just one array. 

The two programs are the following.

simplearray.c - loads just one array
simplearray2.c - loads an array of arrays

Any input is appreciated.

brian
-- 
Brian Lavender
http://www.brie.com/brian/

About 3 million computers get sold every year in China, but people don't
pay for the software. Someday they will, though. As long as they are going
to steal it, we want them to steal ours. They'll get sort of addicted, and
then we'll somehow figure out how to collect sometime in the next decade.

-- Bill Gates (Microsoft) 1998
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Array of arrays

2010-02-27 Thread Brian Lavender
I guess the list stripped the attachments. The code is included in this
message.

brian

On Sat, Feb 27, 2010 at 06:47:30PM -0800, Brian Lavender wrote:
 I was experimenting with creating an array of arrays. Maybe I shouldn't
 be using GArray but something different such as pointer arrays and
 allocating memory for each element? 
 
 I wrote two sample programs. The first one, just loads one array. The
 second, loads an array of arrays. I don't know if I have a problem with
 operator precedence or if the GArrays point to just one array. 
 
 The two programs are the following.
 
 simplearray.c - loads just one array
 simplearray2.c - loads an array of arrays
 
 Any input is appreciated.

=== simplearray.c ===

#include glib.h

#define NUM_ARYS 5

void load_array( GArray **garray)
{
  gint i, storevalue;
  *garray = g_array_new (FALSE, FALSE, sizeof (gint));
  for (i = 0; i  10; i++) {
storevalue = (i + 103) % 45;
g_array_append_val (*garray, storevalue);
  }
}

int main() {
  GArray *garray[NUM_ARYS];
  gint i, storevalue;
  /* We create a new array to store gint values.
 We don't want it zero-terminated or cleared to 0's. */
  load_array(garray[0]);

  for (i = 0; i  10; i++)
  g_print (index %d value %d\n,
   i, g_array_index (garray[0], gint, i));
  g_array_free (garray[0], TRUE);
}

=== simplearray2.c ===


#include glib.h

#define NUM_ARYS 5

void load_array( GArray *(*garray)[NUM_ARYS] )
{
  gint i,j, storevalue;
  for (j=0; j  NUM_ARYS; j++) {
(*garray)[j] = g_array_new (FALSE, FALSE, sizeof (gint));
g_printf(Load Array %d\n, j);
for (i = 0; i  10; i++) {
  storevalue = (i + 103) % ( (j +1) * 2 );
  g_array_append_val ( (*garray)[j], storevalue );
  g_print (load idx %d value %d\n,
   i, storevalue );
}
  }
}

int main() {
  GArray *garray[NUM_ARYS];
  gint i,j, storevalue;
  /* We create a new array to store gint values.
 We don't want it zero-terminated or cleared to 0's. */
  load_array(garray);

  for (j=0; j  NUM_ARYS; j++) {
g_printf(Array %d\n, j);
for (i = 0; i  10; i++)
  g_print (index %d value %d\n,
   i, g_array_index (garray[1], gint, i));
  }

  for (j=0; j  NUM_ARYS; j++)
g_array_free (garray[j], TRUE);

}

-- 
Brian Lavender
http://www.brie.com/brian/

About 3 million computers get sold every year in China, but people don't
pay for the software. Someday they will, though. As long as they are going
to steal it, we want them to steal ours. They'll get sort of addicted, and
then we'll somehow figure out how to collect sometime in the next decade.

-- Bill Gates (Microsoft) 1998
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Array of arrays

2010-02-27 Thread Tristan Van Berkom
On Sat, Feb 27, 2010 at 9:50 PM, Brian Lavender br...@brie.com wrote:
 I guess the list stripped the attachments. The code is included in this
 message.


Hi,
First of all it would be helpful if you told us what is the problem with
your code, off the bat I could tell you that the way you pass a pointer
to an array of pointers is foreign to me, I think I would have just used
GArray ***arrays_p; for that argument.

But on the other hand, you could just save yourself that headache and
use a GPtrArray of GArrays (you could even get carried away and whip
up an api that updates the values of ptrarray-pdata[i] = garray-data
and have a real indexable array in C...).

Cheers,
  -Tristan

 brian

 On Sat, Feb 27, 2010 at 06:47:30PM -0800, Brian Lavender wrote:
 I was experimenting with creating an array of arrays. Maybe I shouldn't
 be using GArray but something different such as pointer arrays and
 allocating memory for each element?

 I wrote two sample programs. The first one, just loads one array. The
 second, loads an array of arrays. I don't know if I have a problem with
 operator precedence or if the GArrays point to just one array.

 The two programs are the following.

 simplearray.c - loads just one array
 simplearray2.c - loads an array of arrays

 Any input is appreciated.

 === simplearray.c ===

 #include glib.h

 #define NUM_ARYS 5

 void load_array( GArray **garray)
 {
  gint i, storevalue;
  *garray = g_array_new (FALSE, FALSE, sizeof (gint));
  for (i = 0; i  10; i++) {
    storevalue = (i + 103) % 45;
    g_array_append_val (*garray, storevalue);
  }
 }

 int main() {
  GArray *garray[NUM_ARYS];
  gint i, storevalue;
  /* We create a new array to store gint values.
     We don't want it zero-terminated or cleared to 0's. */
  load_array(garray[0]);

  for (i = 0; i  10; i++)
      g_print (index %d value %d\n,
               i, g_array_index (garray[0], gint, i));
  g_array_free (garray[0], TRUE);
 }

 === simplearray2.c ===


 #include glib.h

 #define NUM_ARYS 5

 void load_array( GArray *(*garray)[NUM_ARYS] )
 {
  gint i,j, storevalue;
  for (j=0; j  NUM_ARYS; j++) {
    (*garray)[j] = g_array_new (FALSE, FALSE, sizeof (gint));
    g_printf(Load Array %d\n, j);
    for (i = 0; i  10; i++) {
      storevalue = (i + 103) % ( (j +1) * 2 );
      g_array_append_val ( (*garray)[j], storevalue );
      g_print (load idx %d value %d\n,
               i, storevalue );
    }
  }
 }

 int main() {
  GArray *garray[NUM_ARYS];
  gint i,j, storevalue;
  /* We create a new array to store gint values.
     We don't want it zero-terminated or cleared to 0's. */
  load_array(garray);

  for (j=0; j  NUM_ARYS; j++) {
    g_printf(Array %d\n, j);
    for (i = 0; i  10; i++)
      g_print (index %d value %d\n,
               i, g_array_index (garray[1], gint, i));
  }

  for (j=0; j  NUM_ARYS; j++)
    g_array_free (garray[j], TRUE);

 }

 --
 Brian Lavender
 http://www.brie.com/brian/

 About 3 million computers get sold every year in China, but people don't
 pay for the software. Someday they will, though. As long as they are going
 to steal it, we want them to steal ours. They'll get sort of addicted, and
 then we'll somehow figure out how to collect sometime in the next decade.

 -- Bill Gates (Microsoft) 1998
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


PangoF2 in win32 not applying GSUB.

2010-02-27 Thread Ravi Kiran.
Hello,

I have been debugging this issue for the last few days and found that 
when using pango (pango-1.26.2) with ft2 backend, GSUBs are not being applied 
(in telugu using lohit_telugu font). I traced this to harfbuzz. When I use an 
older version of pango (pango-1.12.4) where harfbuzz is not being used, gsub 
works without any issues. I saw a similar issue mentioned for Arabic font where 
pango-cairo was working and pango-ft2 was not. 

http://www.mail-archive.com/gtk-i18n-list@gnome.org/msg01565.html

I tried with cairo backend and it worked since cairo was using Uniscribe. When 
I forced cairo to use FT2 backend, I got back the same results of gsub not 
being applied.

pango-1.26.2 works without any issues in linux so I compared the two using gdb 
and I noticed that in win32,in function indic_engine_shape, ruleset-rules-len 
was returning 0, but in linux it was returning valid value of 7. I traced this 
in hb_ot_layout_table_find_script and found that find_script_index was 
returning error for telugu script. You can reproduce this with the attached 
source file. You will notice that when using pango-1.12.4 you will get one 
glyph (correct) but when using pango-1.26.2 you will get two glyphs.

I am using MinGW and Msys to compile just pango, I am using binary packages 
from GTK site for other packages. I am using the following command for 
compiling.

g++ gTestPango.cpp `pkg-config.exe pangoft2 --cflags --libs`
./a.exe  all.txt

gcc gtestcairo.c `pkg-config.exe pangocairo --cflags --libs`
./a.exe test.png

This is the command I am using for compiling pango.
./configure --with-included-modules --prefix=/mingw
make
make install

Warm Regds,
Ravi Kiran.


  

gtestcairo.c
Description: Binary data


gTestPango.cpp
Description: Binary data
___
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list


Re: [gnome-db] Include Gir file with constant #x1b;[;31;1m

2010-02-27 Thread Vivien Malerba
On 25 February 2010 19:03, Piotr Pokora piotrek.pok...@gmail.com wrote:
 Daniel Espinosa pisze:
 Are there any important reason for this? Because 4.2 will be released
 shorty (I think).

 I am doing my best to have Libgda 4.0.7 included in upcoming Ubuntu
 Lucid (which is Long Term Supported release).
 To make this happen I requested Libgda updates in Debian unstable (which
  migrated to testing release already). If GIR support could be ported to
 4.0 branch and 4.0.8 could be released in reasonable short time, there
 is a chance many people could be happy with stable and easy available
 Libgda for long time.

GIR support has been added to the LIBGDA_4.0 branch, but I haven't
tested it at all (though it's the same as for the master branch and it
works fine), so some minimal testing should be done here.

I can make a 4.0.8 anythime you want. Tell me.

Vivien

Vivien
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Issues with performance of Simple List

2010-02-27 Thread Mike Martin
I am having issues with the performance of simple list in a wierd way

Basicaly I have a simple list object embedded into a window which gets
data from a sqlite database via user defined criteria

If I dont access the simplelist at all changes to the data are nearly
instantaeous however if access the simple list at all there is a delay
between 20-40 seconds

this is the table creation code

any tips appreciated

my $table=Gtk2::SimpleList-new(
'ID'='text',
'Channel'='text',
'Start Time'='text',
'Start Sort'='text',
'Programme'='text',
'End Time'='text',
'End Sort'='text',

'Category'='text'

);

$table-set_headers_clickable(1);
$table-set_headers_visible(1);
$table-set_grid_lines('both');
my $id=$table-get_column(0);
$id-set_visible(0);
my $start=$table-get_column(2);
my $startsort=$table-get_column(3);
my $channel=$table-get_column(1);
my $stop=$table-get_column(5);
my $stopsort=$table-get_column(6);
my $cat=$table-get_column(7);
my $description=$table-get_column(8);
my $programme=$table-get_column(4);

$programme-set_max_width(300);
$startsort-set_visible(0);
$stopsort-set_visible(0);
my $name=$table-get_column(4);
$start-set_sort_column_id(3);
$stop-set_sort_column_id(6);
$channel-set_sort_column_id(1);
$name-set_sort_column_id(4);
$cat-set_sort_column_id(7);

$table-signal_connect (cursor_changed = sub{
show_details;
});

sub show_details {
my ($path,undef)= $table-get_cursor;
my $row_ref = $table-get_row_data_from_path ($path);
$start_record=$$row_ref[3];
$tsid=$dbh-selectcol_arrayref(select distinct tsid from channels
where channel='$$row_ref[1]')-[0];

$end_record=$$row_ref[6];
$rec_channel=$$row_ref[1];
$prog_name=$$row_ref[4];
$rec_id=$$row_ref[0];
my $time=time;
$rec_ids='REC_'.UnixDate(ParseDateString(epoch $time),'%Y_%m_%d_%H_%M_%S');
my $id='%.$$row_ref[0].%';
print $archive_button-get_active;

my @details;
if ($archive_button-get_active == 1){
@details=$dbh-selectrow_array(select start,lang,cat0,stext,name from
guide where id like $id union select start,lang,cat0,stext,name from
archive where id like $id);
}
else
{
@details=$dbh-selectrow_array(select start,lang,cat0,stext,name from
guide where id like $id)
}
my $desc1=wordwrap($details[3],90);
print $desc1;
my $text= join \n, 'time: '.$details[0],'lang:
'.$details[1],'Category: '.$details[2],'Name:
'.$details[4],'Description: '.$desc1;
my $buffer=Gtk2::TextBuffer-new;
use Gtk2::Pango;
$buffer-create_tag('big',size = 15 * PANGO_SCALE);
my $iter = $buffer-get_iter_at_offset (0);
$buffer-insert_with_tags_by_name($iter,$text,'big');
no strict 'refs';
my $reclist=other_channels($$row_ref[1]);
my $text_chan=join \t,@{$reclist};
my $text_show=These Channels can be recorded if you check record
multiplex\n.wordwrap($text_chan,100);
$channel_rec_list-set_markup(span background='yellow'
foreground='red'$text_show/span);
$desc-set_buffer($buffer);
}

my $pid;



$table-signal_connect ('button-press-event' = sub {
but_press

});


sub but_press {
my $record_menu=Gtk2::Menu-new;
my $title=Gtk2::MenuItem-new('Recording');
my $timed=Gtk2::MenuItem-new('Scheduled');
my $manual=Gtk2::MenuItem-new('Manual');
my $sep=Gtk2::SeparatorMenuItem-new;
$sep-set_sensitive(0);
$record_menu-append($title);
$record_menu-append($sep);
$record_menu-append($timed);
$record_menu-append($manual);$title-show;$sep-show;
$timed-show;
$manual-show;
my ($widget,$event)=...@_;
return 0 unless $event-button == 3;

$record_menu-popup(
undef,
undef,
undef,
undef,
$event-button,
$event-time);

#my $path= $widget-get_path_at_pos($event-x, $event-y );
my ($path,undef)= $widget-get_cursor;
$widget-set_cursor($path);

$timed-signal_connect('activate'=sub{
record(timed);
}
);

$manual-signal_connect('activate'=sub{
record(manual);
}
);
}
sub show_details {
my ($path,undef)= $table-get_cursor;
my $row_ref = $table-get_row_data_from_path ($path);
$start_record=$$row_ref[3];
$tsid=$dbh-selectcol_arrayref(select distinct tsid from channels
where channel='$$row_ref[1]')-[0];

$end_record=$$row_ref[6];
$rec_channel=$$row_ref[1];
$prog_name=$$row_ref[4];
$rec_id=$$row_ref[0];
my $time=time;
$rec_ids='REC_'.UnixDate(ParseDateString(epoch $time),'%Y_%m_%d_%H_%M_%S');
my $id='%.$$row_ref[0].%';
print $archive_button-get_active;

my @details;
if ($archive_button-get_active == 1){
@details=$dbh-selectrow_array(select start,lang,cat0,stext,name from
guide where id like $id union select start,lang,cat0,stext,name from
archive where id like $id);
}
else
{
@details=$dbh-selectrow_array(select start,lang,cat0,stext,name from
guide where id like $id)
}
my $desc1=wordwrap($details[3],90);
print $desc1;
my $text= join \n, 'time: '.$details[0],'lang:
'.$details[1],'Category: '.$details[2],'Name:
'.$details[4],'Description: '.$desc1;
my $buffer=Gtk2::TextBuffer-new;
use Gtk2::Pango;
$buffer-create_tag('big',size = 15 * PANGO_SCALE);
my $iter =