Re: GTK and KDE compatibility

2006-03-02 Thread Chris Vine
On Wednesday 01 March 2006 01:33, Daniel Espinosa wrote:
 GTK and KDE has it's own bucle to manage events, there a project working
 around it at:

 http://gparts.blogspot.com/

 2006/2/27, Colossus [EMAIL PROTECTED]:
  Hi,
 
  I connected the signal drag_data_received to the window of my app.
  However when dragging not from a GTK window ( kde konqueror for
  example ) my app doesn't receive the signal. Is GTK compatible with
  event generated from other GUIs such as QT upon which KDE is based ?

Dragging simple data (such as text) from a KDE widget to a GTK+ widget is no 
problem at all.  (gparts is only relevant if you want to glue bonobo and 
kparts together).  Try for example dragging a URL link from konqueror to a 
GTK+ label.

You probably haven't set the drag target correctly.

Chris

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


Re: GTK and KDE compatibility

2006-03-02 Thread Chris Vine
On Thursday 02 March 2006 09:30, Chris Vine wrote:
 On Wednesday 01 March 2006 01:33, Daniel Espinosa wrote:
  GTK and KDE has it's own bucle to manage events, there a project working
  around it at:
 
  http://gparts.blogspot.com/
 
  2006/2/27, Colossus [EMAIL PROTECTED]:
   Hi,
  
   I connected the signal drag_data_received to the window of my app.
   However when dragging not from a GTK window ( kde konqueror for
   example ) my app doesn't receive the signal. Is GTK compatible with
   event generated from other GUIs such as QT upon which KDE is based ?

 Dragging simple data (such as text) from a KDE widget to a GTK+ widget is
 no problem at all.  (gparts is only relevant if you want to glue bonobo and
 kparts together).  Try for example dragging a URL link from konqueror to a
 GTK+ label.

 You probably haven't set the drag target correctly.

I meant, try for example dragging a URL link from konqueror to a GtkEntry.

Chris

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


Re: GTK and KDE compatibility

2006-03-02 Thread Chris Vine
On Thursday 02 March 2006 11:01, Colossus wrote:
 Chris Vine wrote:
  You probably haven't set the drag target correctly.

 Chris, thank you so much for replying me. Could you give me some
 examples, source code or a gtk program you know whose drag and drop
 works from KDE ?

You can just make a GtkWindow object, put a GtkEntry object in it, and then 
drag to the entry object.

I suggest you look at the gtk_entry.c to see how it sets the target up, but as 
konqueror drags URLs as text/plain (if that is what you are interested in) 
you could just set the target to STRING (for old DND) and 
text/plain (for mime-based DND, which is what kde will use).

In fact any byte-stream can be dragged as text/plain but you will need to know 
how to interpret it at the receiving end if it is not in fact plain text.  
The main point is that the source mime type and the target mime type must 
match for the drag to successfully register itself.

Chris

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


Re: GTK and KDE compatibility

2006-03-02 Thread Colossus

Chris Vine wrote:

In fact any byte-stream can be dragged as text/plain but you will need to know 
how to interpret it at the receiving end if it is not in fact plain text.  
The main point is that the source mime type and the target mime type must 
match for the drag to successfully register itself.


I use text/uri-list instead of text/plain, maybe this causes my app 
not to receive the drag data ?


--
Colossus
Xarchiver, a Linux GTK+2 only archive manager - 
http://xarchiver.sourceforge.net

Cpsed, a Linux OpenGL 3D scene editor - http://cpsed.sourceforge.net
Mizio, a QT proxy hunter scanner tool - http://mizio.sourceforge.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 and KDE compatibility

2006-03-02 Thread Matthias Clasen
On 3/2/06, Colossus [EMAIL PROTECTED] wrote:
 Chris Vine wrote:

  In fact any byte-stream can be dragged as text/plain but you will need to 
  know
  how to interpret it at the receiving end if it is not in fact plain text.
  The main point is that the source mime type and the target mime type must
  match for the drag to successfully register itself.

 I use text/uri-list instead of text/plain, maybe this causes my app
 not to receive the drag data ?



Somebody (was it Ross Burton ?) had a useful little app to help
debugging this kind
of stuff, by listing the targets which are offered/accepted. I don't
have a link though.
If you find it, please post the link so that we can add it to www.gtk.org.

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


Re: GTK and KDE compatibility

2006-03-02 Thread Santhosh

 Somebody (was it Ross Burton ?) had a useful little app to help
 debugging this kind
 of stuff, by listing the targets which are offered/accepted. I don't
 have a link though.
 If you find it, please post the link so that we can add it to www.gtk.org.


The following pygtk program does the intended task... I dont know who
actually wrote it.. I think I have got it from some mailing lists some
time back...

#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk

def motion_cb(wid, context, x, y, time):
context.drag_status(gtk.gdk.ACTION_COPY, time)
return True

def drop_cb(wid, context, x, y, time):
l.set_text('\n'.join([str(t) for t in context.targets]))
return True

w = gtk.Window()
w.set_size_request(200, 150)
w.drag_dest_set(0, [], 0)
w.connect('drag_motion', motion_cb)
w.connect('drag_drop', drop_cb)
w.connect('destroy', lambda w: gtk.main_quit())
l = gtk.Label()
w.add(l)
w.show_all()

gtk.main()

Based on this I had developed some application which worked fine in
Linux but not in windows. The drag and drop in a single application
worked but between applications doesn't work...

BTW, does anybody knows that drag and drop works in windows(between apps)?

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


Re: mapping keys to functions

2006-03-02 Thread Christian Neumair
Am Donnerstag, den 02.03.2006, 17:23 -0600 schrieb Matt Hull:

 is it possible to get an integer from a key press ?  are there any
 standard integers for common keys ?  like enter, arrowup ?
 
 working on a game and want the user to be able to map keys to
 functions
 using an array.  seems like the keys are enumerated. 

Keyboard-related events are handled by GdkEventKey structures, which
inter alia provide a keyval, which is an unsigned integer.
gdk/gdkkeysyms.h contains the relevant #defines. If you also want to
check which modifiers were pressed (shift, alt etc.) you'll have to
query the state member in the GdkEventKey struct.

-- 
Christian Neumair [EMAIL PROTECTED]

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


Re: tooltips

2006-03-02 Thread Freddie Unpenstein

Original message written by someone, somewhen...

 I wish it was possible to control tooltips position (they are
 always at the bottom of the widget an I cannot visually tie them
 to the appropriate `area') and use marked up text, like bold and
 stuff.

The tooltips code is really quite straight forward.  I ended up a while back, 
derriving my own tooltip object from the GTK source, which added support for 
Pango markup and tooltip shown/hidden signals.

Adding Pango markup support was fairly simple, I just found the line that sets 
the tooltip label, and made it check the start of the string for the markup 
tag.  If it was found, then it checked the string for valid markup (or just 
tried to render it with a function that returns an error if it fails anything, 
I can't remember exactly off-hand).  But at any rate, if the text contained a 
LEADING markup tag, then it was rendered as markup.  If not, it went through 
the usual set text function which doesn't look for tags or any of the other 
things markup tries to interpret (angled brackets, for example).

Likewise the tooltip shown signal (I included as an argument, the tooltip 
object being shown, or NULL if the tooltip was being hidden) was just a case of 
defining a new signal, and dropping a few emits around the place.  By including 
a pointer to the tooltip object being displayed, my program could check the 
pointer against the one it saved when it created the tooltip, and set or clear 
a flag or whatever else it wanted to do.  What I did with it, when the tooltip 
object pointer matched the one I was interested in, was to call a function to 
update the text (there was a reasonable amount of humming around every second 
to generate the new tooltip, and the the signal was emitted just before the 
text was rendered), and then set a timeout to call that function every second 
there-after to update with any changes.  Likewise if the pointer didn't match, 
the handler simply de-registered the timeout if it was currently active.  A 
more specific show/hide callback would certainly have 
been a better way to go (every handler was being called for every time the 
tooltip changed to a new widget), but I only had a few tooltips in the only 
program I have that actually uses those signals (the only other one that needs 
to update tooltips, only does so once each half hour, so it just goes ahead and 
does it regardless).

What you want, being able to position the tooltip, would undoubtedly be a 
little more involved.  The easiest option there may be just to swipe the code 
for building the little window, and do it yourself.  Or, if you particularly 
want it to fit in smoothly with the tooltip mechanism, then something like what 
I did to be informed just before a tooltip opened up on my widget, might work 
for you too.  You could catch the creation/update of the tooltip window, and 
allow your program to manage it itself.

In either case, it pretty much means building your own tooltip widget out of 
the GTK sources, unless they've made the tooltip widget a whole lot more 
derrivation-friendly since I last looked at it.  But it's perfectly do-able.  
And last I saw, you can have two tooltip objects going at a time, or even 
perhaps just create a popup tooltip-like window widget by canibilizing the 
relevant parts of the GTK source for your positioned one.  (If they're really 
nice, maybe they'll make it easier sometime...)


Fredderic

___
Join Excite! - http://www.excite.com
The most personalized portal on the Web!


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


error in GtkTreeView using GtkTreeModelFilter

2006-03-02 Thread Ignacio Martín
Hi,
Sometimes GtkTreeView throws this error when I use a
GtkTreeModelFilter when I add a new element to the child model (a
GtkTreeStore).

Gtk-CRITICAL **: file gtktreeview.c: line 3966
(gtk_tree_view_bin_expose): assertion `has_next' failed.
There is a disparity between the internal view of the GtkTreeView,
and the GtkTreeModel.  This generally means that the model has changed
without letting the view know.  Any display from now on is likely to
be incorrect.

I don´t use threads and this is the custom simple filter function I use.

static gboolean
tree_filter_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
g_return_if_fail(model != NULL);
g_return_if_fail(iter != NULL);

gboolean ret = TRUE;
GValue is_folder = {0};
gtk_tree_model_get_value(model,iter,  COL_ISFOLDER, is_folder);
ret = g_value_get_boolean(is_folder);
g_value_unset(is_folder);
return ret;
}

If I return always TRUE it obviously works, but with function it
doen´t and I don´t understand why. I have seen that when I add a new
element, the parent node and the new element are filtered. But it
seems that the new element is filtered more than once.
Any help would be welcome.
Regards,
Ignacio
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Fwd: GTK and KDE compatibility

2006-03-02 Thread Daniel Espinosa
-- Forwarded message --
From: Daniel Espinosa [EMAIL PROTECTED]
Date: 02-mar-2006 22:16
Subject: Re: GTK and KDE compatibility
To: Santhosh [EMAIL PROTECTED]

Have any check the freedesktop.org specification about drag and drop?

2006/3/2, Santhosh [EMAIL PROTECTED] :

 
  Somebody (was it Ross Burton ?) had a useful little app to help
  debugging this kind
  of stuff, by listing the targets which are offered/accepted. I don't
  have a link though.
  If you find it, please post the link so that we can add it to
 www.gtk.org.
 

 The following pygtk program does the intended task... I dont know who
 actually wrote it.. I think I have got it from some mailing lists some
 time back...

 #!/usr/bin/env python

 import pygtk
 pygtk.require('2.0')
 import gtk

 def motion_cb(wid, context, x, y, time):
 context.drag_status(gtk.gdk.ACTION_COPY, time)
 return True

 def drop_cb(wid, context, x, y, time):
 l.set_text('\n'.join([str(t) for t in context.targets]))
 return True

 w = gtk.Window()
 w.set_size_request(200, 150)
 w.drag_dest_set(0, [], 0)
 w.connect('drag_motion', motion_cb)
 w.connect('drag_drop', drop_cb)
 w.connect('destroy', lambda w: gtk.main_quit())
 l = gtk.Label()
 w.add(l)
 w.show_all()

 gtk.main()

 Based on this I had developed some application which worked fine in
 Linux but not in windows. The drag and drop in a single application
 worked but between applications doesn't work...

 BTW, does anybody knows that drag and drop works in windows(between apps)?

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




--
Trabajar, la mejor arma para tu superación
de grano en grano, se hace la arena (R) (entrámite, pero para los cuates:
LIBRE)


--
Trabajar, la mejor arma para tu superación
de grano en grano, se hace la arena (R) (entrámite, pero para los cuates:
LIBRE)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re g_error() in g_private_new_win32_impl

2006-03-02 Thread Tor Lillqvist
Tim Janik writes:
  i'd recommend to move to some other error mechanism (stderr printf +
  abort(), etc.) for the scope of this function. 

OK. I'll change it to throw up a MessageBox() instead (printing to
stderr would go unnoticed for most real applications), then abort().

I'll also take away the Use GStaticPrivate instead part of the error
message. That isn't useful to an end user, and for developers the Too
many GPrivate allocated. Their number is limited to %d should be
enough.

  also, i think the private-max setting is rather small:
  gthread/gthread-win32.c:#define G_PRIVATE_MAX 16

I'll increase it to, uh, let's say 100?

  for what it's worth, glibc allowes around 1024 keys to be created
  with pthread_key_create().

BTW, the pthreads-win32 POSIX thread implementation from
http://sourceware.org/pthreads-win32/ just uses native thread-local
storage slots as allocated by TlsAlloc() in its implementation of
pthread_key_create(). The number of those is 1088 per process in
Windows 2000 and newer, and under 100 in Win9x. Maybe gthread-win32
should do the same.

On the other hand, instead of thus rewriting significant parts of
gthread-win32.c, maybe it would make sense to simply start using the
pthreads-win32 implementation underneath, i.e. use gthread-posix.c on
Windows, too?

pthreads-win32 seems to be much more carefully written than
gthread-win32, for instance the recently fixed problem related to the
details of GPrivate destructor calling wouldn't have happened with
pthreads-win32. Using it would mean one more external dependency,
though, although it's just one DLL at run-time.

(In much earlier times pthreads-win32 was indeed used. I can't recall
why it was dropped and gthread-win32.c written instead. Maybe
pthreads-win32 was too buggy at that time (2001), or it was just felt
that the external depencency was bad.)

--tml

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


Re: Re g_error() in g_private_new_win32_impl

2006-03-02 Thread Dominic Lachowicz
Hi Tor,

 BTW, the pthreads-win32 POSIX thread implementation from
 http://sourceware.org/pthreads-win32/ just uses native thread-local
 storage slots as allocated by TlsAlloc() in its implementation of
 pthread_key_create(). The number of those is 1088 per process in
 Windows 2000 and newer, and under 100 in Win9x. Maybe gthread-win32
 should do the same.

 On the other hand, instead of thus rewriting significant parts of
 gthread-win32.c, maybe it would make sense to simply start using the
 pthreads-win32 implementation underneath, i.e. use gthread-posix.c on
 Windows, too?

FWIW, my company makes heavy use of pthreads-win32 in our server
products without any issues. It just works.

They ship 4 DLLs - GCC, MSVC, GCC+SEH, MSVC+SEH (SEH = structured
exception handling). If we decided to use this, we'd probably want to
use the non-SEH version, as that bit isn't portable across pthreads
implementations or across GCC/MSVC compilers. The authors also
recommend against using SEH for these reasons. AFAIK, the GCC/MSVC
non-SEH DLLs are binary compatible with each other; they're just built
using different compilers.

http://sourceware.org/pthreads-win32/faq.html

The library is actively maintained, FOSS, has gotten a lot more
attention than gthread-win32.c (especially, as Tor mentions, with
respect to corner cases), and could piggy-back on glib's robust
gthread-posix implemenation.

 pthreads-win32 seems to be much more carefully written than
 gthread-win32, for instance the recently fixed problem related to the
 details of GPrivate destructor calling wouldn't have happened with
 pthreads-win32. Using it would mean one more external dependency,
 though, although it's just one DLL at run-time.

Adding one more DLL to the Win32 GTK+ installers shouldn't be an
issue. gladewin32 ships with at least 52 DLLs in its bin directory
alone, for instance. This includes iconv, intl, zlib, bz2, charset,
gettext, asprintf, and other glib/gtk dependencies.

Best,
Dom
--
Counting bodies like sheep to the rhythm of the war drums.
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


GtkTextBuffer crash

2006-03-02 Thread mikecorn

On Feb 28 I posted a message about GtkTextBuffer crashing from too much data.
This was wrong. The crash comes from unusual text that was being inserted
into the buffer.

In particular, the following text, if used in gtk_text_buffer_insert_text(),
will cause a crash: file:%2F%2F%2Fhome.xml. This is the name of a file
found in /home/userxxx/.nautilus/metafiles (my app was listing a bunch of
file names in a text window).

Can anyone explain why this text crashes the function, and what I should do
to avoid this?

--
View this message in context: 
http://www.nabble.com/GtkTextBuffer-crash-t1212958.html#a3206916
Sent from the Gtk+ - Dev - General forum at Nabble.com.

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


Re: GtkTextBuffer crash

2006-03-02 Thread Owen Taylor
On Thu, 2006-03-02 at 09:31 -0800, mikecorn wrote:
 On Feb 28 I posted a message about GtkTextBuffer crashing from too much data.
 This was wrong. The crash comes from unusual text that was being inserted
 into the buffer.
 
 In particular, the following text, if used in gtk_text_buffer_insert_text(),
 will cause a crash: file:%2F%2F%2Fhome.xml. This is the name of a file
 found in /home/userxxx/.nautilus/metafiles (my app was listing a bunch of
 file names in a text window).
 
 Can anyone explain why this text crashes the function, and what I should do
 to avoid this?

I'd suggest testing your code with valgrind for memory corruption
elsewhere. While virtually any bug is *possible* the above seems a
little improbable.

If it is happening, then you need to create a minimal test case, and put
it in bugzilla. Providing the backtrace would also be useful in case
other people can't reproduce the problem using your test case.

Owen


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


Character Table

2006-03-02 Thread dwolfe

I was wondering if someone could help me figure out how to display characters
in a label widget.  I was trying to build a character table to add symbols
and other characters to a document in a program I was building.  I have
spent quite a few hours to no avail.   Basically, I have a table that I want
to add buttons with labels displaying a character, so the user can choose
the character that they wish to use.  I have been able to generate the
characters, but the g_utf8_validate function recognizes most of them as
invalid(except the ASCII charaters).  I figure that I am screwing up the
encoding somehow.  I am new to c and I would appreciate any help.

Here is the code:
int n, r, c;
r=0;
c=0;
for(n=32; n1000; n++)
{
static gchar buf[8];
g_sprintf(buf, %c, n);
printf(string:%s, buf);

gchar *end;
if(g_utf8_validate (buf,  -1, end))
{
g_print( added\n);
if (strcmp(buf, ))
{
GtkWidget *btnChar;
btnChar = gtk_button_new_with_label (buf);

gtk_table_attach_defaults   (tableSymbol,
 btnChar,
 c,
 c+1,
 r,
 r+1);
c += 1;
if (c  10)
{
c = 0;
r += 1;
}
gtk_widget_show(btnChar);
}
}
else
{
g_print( invalid\n);
}
}
--
View this message in context: 
http://www.nabble.com/Character-Table-t1214436.html#a3211774
Sent from the Gtk+ - Dev - General forum at Nabble.com.

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


Re: Character Table

2006-03-02 Thread Alan M. Evans
On Thu, 2006-03-02 at 14:24, dwolfe wrote:

   for(n=32; n1000; n++)
   {
   static gchar buf[8];
   g_sprintf(buf, %c, n);
   printf(string:%s, buf);
 
   gchar *end;
   if(g_utf8_validate (buf,  -1, end))

Check man 7 utf8 and perhaps you will understand why you are mostly
failing to produce valid UTF-8 characters this way.

Wrong list, by the way; try gtk-app-devel-list instead.


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