Re: gdk_pixbuf_composite leaves artifacts in the dest pixbuf, if, dest_x is > 0. Help please?

2009-11-11 Thread Todor Todorov

Thank you so much for the answer!

The correct use (yours) is

gdk_pixbuf_composite( interm, result, xOffset, 0, width, height, xOffset, 0, 
1.0, 1.0, GDK_INTERP_NEAREST, 255 );

as opposed to (mine)

gdk_pixbuf_composite( interm, result, xOffset, 0, width, height, /* !!! */ 0, 
0, 1.0, 1.0, GDK_INTERP_NEAREST, 255 );

I didn't quite realize that I need to apply the destination displacement 
as scaling offset as well - the documentation, or rather the nice 
picture showing the use of the function in the GdkPixbuf reference, did 
not explain the relationship between step 1 and step 3 in the transition 
... It is a nice picture though :-)


Thanks again for the help.

Best regards,

Todor

On 11/11/2009 03:20 AM, Tadej Borovšak wrote:

Hello.

Composing function is a bit hard to use at first. Your code should
probably look something like this (I haven't tested it).

 CODE 
gchar *imgSrcName;
GdkPixbuf *src, *interm, *result;
guint width, height, xOffset, yOffset;
int i = 0;
...
src = gdk_pixbuf_load_from_file_at_scale( imgSrcName, 128, 128, TRUE, NULL );
result = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE,
gdk_pixbuf_get_bits_per_sample( src ), 128, 128 );

interm = gdk_pixbuf_apply_embedded_orientation( src );
gdk_pixbuf_unref( src );
width = gdk_pixbuf_get_width( interm );
height = gdk_pixbuf_get_height( interm );
...
while ( i<  2 )
{
gchar *save;

gdk_pixbuf_fill( result, 0xff00 );
xOffset = i++ * ( 128 - width ) / 2;
yOffset = i++ * ( 128 - height ) / 2;
gdk_pixbuf_composite( interm, result, xOffset, yOffset, width,
height, xOffset, yOffset, 1.0, 1.0, GDK_INTERP_NEAREST, 255 );

save = g_strdup_printf( "test%d.jpg", i );
gdk_pixbuf_save( result, save, "jpeg", NULL, "quality", "100", NULL );
g_free( save );
}
gdk_pixbuf_unref( interm );
gdk_pixbuf_unref( result );
 CODE 

BTW, gdk_pixbuf_unref is deprecated in favor of g_object_unref, since
GdkPixbuf is derived from GObject now.

Tadej

   

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

Re: gtk-directfb-crash

2009-11-11 Thread Moutusi De

Hi Roger,
Yes I could ressolve the problem .I have built gtk with target directfb 
with following pacakages.

1.gtk+-2.12.9
2.atk-1.13.2
3.cairo-1.6.4
4.glib-2.22.2
5.pango-1.20.2
6.pixman-0.12.0
7.DirectFB-1.2.0
But I installed everything on pc .

You can  refer to this link https://wiki.mozilla.org/Mobile/DFBPorting
Thanks,
Moutusi

jeeper74 wrote:

Moutusi,

I have built/installed the same packages that you have on an arm system, and
am having the same crash when calling "gtk_widget_show (window)" in
helloworld.c.  Have you been able to resolve the crash?  
Thanks,

Roger


Moutusi De wrote:
  

Hi All,
I have built gtk with target directfb.
I have installed following pacakages:
1.gtk+-2.18.0
2.atk-1.28.0
3.cairo-1.8.0
4.glib-2.22.2
5.pango-1.26.0
6.pixman-0.12.0
7.DirectFB-1.2.7
8.FreeType 2-9.16.3

Now I am trying to run examples programs thats comes with gtk.While 
running the program one window comes with one mouse pointer and it 
freeze.I ran same
program with gtk- x11 where I get a Hello world message  with proper 
window.I am expecting same thing with gtk-direcfb.
Just for debugging I tried putting one exit(0) before "gtk_widget_show 
(window)" function call.Then I got the following error:


/*/
(helloworld:2654): Gdk-CRITICAL **: gdk_drawable_get_colormap: assertion
`GDK_IS_DRAWABLE (drawable)' failed

/*

Could anyone please let me know how to resolve this ?

Below is the code for reference.
int main( int   argc,
  char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *button;

/* This is called in all GTK applications. Arguments are parsed
 * from the command line and are returned to the application. */
gtk_init (&argc, &argv);


/* create a new window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

/* When the window is given the "delete-event" signal (this is given
 * by the window manager, usually by the "close" option, or on the
 * titlebar), we ask it to call the delete_event () function
 * as defined above. The data passed to the callback
 * function is NULL and is ignored in the callback function. */
g_signal_connect (window, "delete-event",
  G_CALLBACK (delete_event), NULL);

/* Here we connect the "destroy" event to a signal handler.
 * This event occurs when we call gtk_widget_destroy() on the window,
 * or if we return FALSE in the "delete_event" callback. */
g_signal_connect (window, "destroy",
  G_CALLBACK (destroy), NULL);

/* Sets the border width of the window. */
gtk_container_set_border_width (GTK_CONTAINER (window), 10);

/* Creates a new button with the label "Hello World". */
button = gtk_button_new_with_label ("Hello World");

/* When the button receives the "clicked" signal, it will call the
 * function hello() passing it NULL as its argument.  The hello()
 * function is defined above. */
g_signal_connect (button, "clicked",
  G_CALLBACK (hello), NULL);
/* This will cause the window to be destroyed by calling
 * gtk_widget_destroy(window) when "clicked".  Again, the destroy
 * signal could come from here, or the window manager. */
g_signal_connect_swapped (button, "clicked",
  G_CALLBACK (gtk_widget_destroy),
  window);

/* This packs the button into the window (a gtk container). */
gtk_container_add (GTK_CONTAINER (window), button);

/* The final step is to display this newly created widget. */
gtk_widget_show (button);

exit(0);
/* and the window */
gtk_widget_show (window);
/* All GTK applications must have a gtk_main(). Control ends here
 * and waits for an event to occur (like a key press or
 * mouse event). */
gtk_main ();

return 0;
}
Thanks,
Moutusi





___
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


Re: code work wrong when i put it in gtk+ application

2009-11-11 Thread Tor Lillqvist
> The radix is locale dependent.  You will need to set a C locale.

To be more specific, call setlocale(LC_NUMERIC, "C")

GTK+ calls setlocale(LC_ALL, "") for you automatically in gtk_init()
unless you call gtk_disable_setlocale() first.

Read your C library's documentation to learn about setlocale().

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

Re: code work wrong when i put it in gtk+ application

2009-11-11 Thread Chris Vine
On Wed, 11 Nov 2009 16:35:23 -0800 (PST)
cet cet  wrote:
> After i updated my system my previously working gtk+ application
> start to print wrong result.The problem is atof() i used in the
> program.The code is working as expected in a standart c console
> version.(Program reads some datas from file and make some
> calculations)The code i used is;
> 
> suppose that at line 62 the file have data;
> 10   5  15 B   15.031103
> 
> the code;
> 
> gchar *temp,cm[11];
> gfloat m;
> gint l00;
> .
> 
> while(!feof(in)){
> fgets(temp,30,in);
> 
> 
> 
> for(i=0;i<10;i++) cm[i]=temp[i+15];
> 
> cm[10]='\0';
> if(l==62) g_print("mass=%s\n",cm);/*prints 15.031103  */
> 
> m=atof(cm);
> 
> if(l==62) g_print("mass=%f\n",m);/*prints 15,00 notice that not
> 15.00 it prints with the comma 15,00 */
> l++;
> }
> 
> I also tried sscanf(cm,"%f",&m) and m=strtof(cm,NULL);
> always gives 15,00 When i try exactly the same code in a standart
> c program it is working as expected.

The radix is locale dependent.  You will need to set a C locale.

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


code work wrong when i put it in gtk+ application

2009-11-11 Thread cet cet
After i updated my system my previously working gtk+ application start to print 
wrong result.The problem is atof() i used in the program.The code is working as 
expected in a standart c console version.(Program reads some datas from file 
and make some calculations)The code i used is;

suppose that at line 62 the file have data;
10   5  15 B   15.031103

the code;

gchar *temp,cm[11];
gfloat m;
gint l00;
.

while(!feof(in)){
fgets(temp,30,in);



for(i=0;i<10;i++) cm[i]=temp[i+15];

cm[10]='\0';
if(l==62) g_print("mass=%s\n",cm);/*prints 15.031103  */

m=atof(cm);

if(l==62) g_print("mass=%f\n",m);/*prints 15,00 notice that not   15.00
 it prints with the comma 15,00 */
l++;
}

I also tried sscanf(cm,"%f",&m) and m=strtof(cm,NULL);
always gives 15,00 When i try exactly the same code in a standart c program 
it is working as expected.


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


GTK-DirectFB Stable Version Combination

2009-11-11 Thread Roger Cullumber

Hey everyone,

I've built GTK-DirectFB on a Debian ARM system with the following setup. 
atk-1.28.0

cairo-1.8.8
DirectFB-1.4.2
fontconfig-2.6.0
glib-2.22.2
pango-1.20.5
pixman-0.16.2
gtk+-2.18.3

I built all from scratch on the ARM system. All the directfb examples 
work great. When trying to run gtk's helloworld.c I get a "Caught signal 
11 (at 0x28, invalid address)".  This happens when the program hits 
"gtk_widget_show (window)".  Any ideas as to why?


Although you might not have an answer to the gtk problem, does anyone 
have a proven package combination that works?


Thanks,

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


Re: Application Ending Before Secondary Thread Ends

2009-11-11 Thread Paul Pogonyshev
Marshall Lake wrote:
> I play audio via g_thread.  If the user quits the application before the 
> thread is completed (and the user executes the application from the 
> command line) the terminal needs reseting.  It's fine if the thread ends 
> before the user quits the application.
> 
> I haven't tried but I expect I can avoid this behavior by doing a 
> g_thread_join() and waiting for the thread to finish before exiting the 
> application.  But I don't really want to do that (some of the audio is 
> very long).  Are there any alternatives?

As I understand, the shell waits for the process to exit.  The only
way to achieve what you want is probably spawning another ("real")
process and terminating the current one.  On unixes you could also
fork(), but this is not portable AFAIK.

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


Application Ending Before Secondary Thread Ends

2009-11-11 Thread Marshall Lake


I play audio via g_thread.  If the user quits the application before the 
thread is completed (and the user executes the application from the 
command line) the terminal needs reseting.  It's fine if the thread ends 
before the user quits the application.


I haven't tried but I expect I can avoid this behavior by doing a 
g_thread_join() and waiting for the thread to finish before exiting the 
application.  But I don't really want to do that (some of the audio is 
very long).  Are there any alternatives?


--
Marshall Lake -- ml...@mlake.net -- http://mlake.net
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk-directfb-crash

2009-11-11 Thread jeeper74

Moutusi,

I have built/installed the same packages that you have on an arm system, and
am having the same crash when calling "gtk_widget_show (window)" in
helloworld.c.  Have you been able to resolve the crash?  
Thanks,
Roger


Moutusi De wrote:
> 
> Hi All,
> I have built gtk with target directfb.
> I have installed following pacakages:
> 1.gtk+-2.18.0
> 2.atk-1.28.0
> 3.cairo-1.8.0
> 4.glib-2.22.2
> 5.pango-1.26.0
> 6.pixman-0.12.0
> 7.DirectFB-1.2.7
> 8.FreeType 2-9.16.3
> 
> Now I am trying to run examples programs thats comes with gtk.While 
> running the program one window comes with one mouse pointer and it 
> freeze.I ran same
> program with gtk- x11 where I get a Hello world message  with proper 
> window.I am expecting same thing with gtk-direcfb.
> Just for debugging I tried putting one exit(0) before "gtk_widget_show 
> (window)" function call.Then I got the following error:
> 
> /*/
> (helloworld:2654): Gdk-CRITICAL **: gdk_drawable_get_colormap: assertion
> `GDK_IS_DRAWABLE (drawable)' failed
> 
> /*
> 
> Could anyone please let me know how to resolve this ?
> 
> Below is the code for reference.
> int main( int   argc,
>   char *argv[] )
> {
> /* GtkWidget is the storage type for widgets */
> GtkWidget *window;
> GtkWidget *button;
> 
> /* This is called in all GTK applications. Arguments are parsed
>  * from the command line and are returned to the application. */
> gtk_init (&argc, &argv);
> 
> 
> /* create a new window */
> window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> 
> /* When the window is given the "delete-event" signal (this is given
>  * by the window manager, usually by the "close" option, or on the
>  * titlebar), we ask it to call the delete_event () function
>  * as defined above. The data passed to the callback
>  * function is NULL and is ignored in the callback function. */
> g_signal_connect (window, "delete-event",
>   G_CALLBACK (delete_event), NULL);
> 
> /* Here we connect the "destroy" event to a signal handler.
>  * This event occurs when we call gtk_widget_destroy() on the window,
>  * or if we return FALSE in the "delete_event" callback. */
> g_signal_connect (window, "destroy",
>   G_CALLBACK (destroy), NULL);
> 
> /* Sets the border width of the window. */
> gtk_container_set_border_width (GTK_CONTAINER (window), 10);
> 
> /* Creates a new button with the label "Hello World". */
> button = gtk_button_new_with_label ("Hello World");
> 
> /* When the button receives the "clicked" signal, it will call the
>  * function hello() passing it NULL as its argument.  The hello()
>  * function is defined above. */
> g_signal_connect (button, "clicked",
>   G_CALLBACK (hello), NULL);
> /* This will cause the window to be destroyed by calling
>  * gtk_widget_destroy(window) when "clicked".  Again, the destroy
>  * signal could come from here, or the window manager. */
> g_signal_connect_swapped (button, "clicked",
>   G_CALLBACK (gtk_widget_destroy),
>   window);
> 
> /* This packs the button into the window (a gtk container). */
> gtk_container_add (GTK_CONTAINER (window), button);
> 
> /* The final step is to display this newly created widget. */
> gtk_widget_show (button);
> 
> exit(0);
> /* and the window */
> gtk_widget_show (window);
> /* All GTK applications must have a gtk_main(). Control ends here
>  * and waits for an event to occur (like a key press or
>  * mouse event). */
> gtk_main ();
> 
> return 0;
> }
> Thanks,
> Moutusi
> 
> 
> 
> 
> 
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
> 

-- 
View this message in context: 
http://old.nabble.com/gtk-directfb-crash-tp26112205p26305354.html
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Re: Control what happens when GtkTextView is resized: keep the bottom part visible

2009-11-11 Thread Eduardo M KALINOWSKI
Eduardo M KALINOWSKI wrote:
> I have a question concerning how to set which part of a GtkTextBuffer is
> displayed when a GtkTextView is resized.
>
> To explain the situation, consider this sample code:
>
> 8<
> /* gcc -o tvtest tvtest.c `pkg-config --libs --cflags gtk+-2.0` */
> #include 
>
> int main(int argc, char *argv[])
> {
>   GtkWidget *window;
>   GtkWidget *vpaned;
>   GtkWidget *text1;
>   GtkWidget *scr1;
>   GtkTextBuffer *buffer;
>   GtkWidget *text2;
>   GtkWidget *scr2;
>
>   gtk_init(&argc, &argv);
>
>   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>   gtk_widget_set_size_request(window, 500, 300);
>   g_signal_connect(G_OBJECT(window), "delete-event",
>G_CALLBACK(gtk_main_quit), NULL);
>
>   vpaned = gtk_vpaned_new();
>
>   text1 = gtk_text_view_new();
>   buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text1));
>   gtk_text_buffer_set_text(buffer,
>"Lorem ipsum dolor sit amet,\n"
>"consectetur adipisicing elit,\n"
>"sed do eiusmod tempor incididunt\n"
>"ut labore et dolore magna aliqua.\n"
>"Ut enim ad minim veniam,\n"
>"quis nostrud exercitation ullamco laboris\n"
>"nisi ut aliquip ex ea commodo consequat.\n"
>"Duis aute irure dolor in reprehenderit\n"
>"in voluptate velit esse cillum dolore\n"
>"eu fugiat nulla pariatur.\n"
>"Excepteur sint occaecat cupidatat non
> proident,\n"
>"sunt in culpa qui officia\n"
>"deserunt mollit anim id est laborum.", -1);
>
>   text2 = gtk_text_view_new_with_buffer(buffer);
>
>   scr1 = gtk_scrolled_window_new(NULL, NULL);
>   gtk_container_add(GTK_CONTAINER(scr1), text1);
>   gtk_paned_add1(GTK_PANED(vpaned), scr1);
>
>   scr2 = gtk_scrolled_window_new(NULL, NULL);
>   gtk_container_add(GTK_CONTAINER(scr2), text2);
>   gtk_paned_add2(GTK_PANED(vpaned), scr2);
>
>   gtk_container_add(GTK_CONTAINER(window), vpaned);
>
>   gtk_widget_show_all(window);
>   gtk_main();
>
>   return 0;
> }
> 8<
>
> When the division in the GtkPaned is moved, what happens is that the top
> of the GtkTextViews remains the same (thus keeps displaying the same
> thing), while the bottom part shrinks, hiding some text at the bottom if
> the widget gets smaller, or displaying more text at the bottom if it is
> enlarged.
>
> What I would like to do is the opposite: for the GtkTextView in the
> bottom, I'd like that the bottom of the widget remains the same, but
> changes in size are reflected at the top: if the widget shrinks, then
> less text at the top should be displayed, if it grows, then more text at
> the top should be displayed. The bottom should remain fixed displaying
> always the same part.
>
> Another way to visualize is that by changing the division in the
> GtkPaned it should cover more of the top of the bottom GtkTextView,
> instead of pushing it down.
>
>   

Sorry to be posting again, but does anyone have any tips?


-- 
Eduardo M KALINOWSKI
edua...@kalinowski.com.br

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


Re: Ctrl-Click keyboard mouse event

2009-11-11 Thread Carlos Pereira

Hi Emmanuel,
thank you very much, that's exactly what I needed,

Best regards,
Carlos


When a button press event is triggered, what is the proper way to know if
the user is pressing down the Ctrl key?



I think that this is what you need:

if (event->button == 1 && (event->state & GDK_CONTROL_MASK) != 0)
{
  /* Button 1 with contro clicked */
}

  

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


Re: gdk_pixbuf_composite leaves artifacts in the dest pixbuf, if, dest_x is > 0. Help please?

2009-11-11 Thread Tadej Borovšak
Hello.

Composing function is a bit hard to use at first. Your code should
probably look something like this (I haven't tested it).

 CODE 
gchar *imgSrcName;
GdkPixbuf *src, *interm, *result;
guint width, height, xOffset, yOffset;
int i = 0;
...
src = gdk_pixbuf_load_from_file_at_scale( imgSrcName, 128, 128, TRUE, NULL );
result = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE,
gdk_pixbuf_get_bits_per_sample( src ), 128, 128 );

interm = gdk_pixbuf_apply_embedded_orientation( src );
gdk_pixbuf_unref( src );
width = gdk_pixbuf_get_width( interm );
height = gdk_pixbuf_get_height( interm );
...
while ( i < 2 )
{
   gchar *save;

   gdk_pixbuf_fill( result, 0xff00 );
   xOffset = i++ * ( 128 - width ) / 2;
   yOffset = i++ * ( 128 - height ) / 2;
   gdk_pixbuf_composite( interm, result, xOffset, yOffset, width,
height, xOffset, yOffset, 1.0, 1.0, GDK_INTERP_NEAREST, 255 );

   save = g_strdup_printf( "test%d.jpg", i );
   gdk_pixbuf_save( result, save, "jpeg", NULL, "quality", "100", NULL );
   g_free( save );
}
gdk_pixbuf_unref( interm );
gdk_pixbuf_unref( result );
 CODE 

BTW, gdk_pixbuf_unref is deprecated in favor of g_object_unref, since
GdkPixbuf is derived from GObject now.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list