Re: Question about modal dialog in gtk application

2010-04-11 Thread Jim George
You can use gtk_widget_show to bring up your dialog, and then use
gtk_set_transient_for to mark it modal to only one window, to get
behavior similar to firefox.
-Jim

On Sun, Apr 11, 2010 at 10:36 AM, silverburgh
silverburgh.me...@gmail.com wrote:
 On Sun, Apr 11, 2010 at 11:04 AM, Nicola Fontana n...@entidi.it wrote:
 Il giorno Sun, 11 Apr 2010 10:37:18 -0500
 silverburgh silverburgh.me...@gmail.com ha scritto:

 Hi,

 In my gtk application, I can create 2 windows.
 But when I open a dialog in one of my window using gtk_dialog_run(),
 why the other window is frozen?

 Because this is the intended behavior of gtk_dialog_run():
 http://library.gnome.org/devel/gtk/stable/GtkDialog.html#gtk-dialog-run

 How can I code it so that one modal dialog do not freeze the other window?

 I don't know how to make a modal dialog that does not freeze the
 other windows but if you want a non-modal dialog you can use
 gtk_widget_show() instead of gtk_dialog_run().


 But how can Firefox on linux implements that?
 If I have a popup alert in 1 Firefox window, it does not freeze the
 other Firefox window and I can scroll up and down in the other window.



 --
 Nicola

 ___
 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: Crash processing g_object_new arguments

2009-11-09 Thread Jim George
I've never come across this problem since I've never used any headers
that re-define NULL, nor have I used gobject with C++, but it seems
like enough of a gotcha that it might make sense to define another
constant (G_ARG_TERM?) that always maps to (void *) and use that with
all the glib functions that expect a (void *) to terminate the
argument list.

-Jim

On Mon, Nov 9, 2009 at 8:17 AM,  ern...@comcast.net wrote:
 David Nečas wrote:

 On Mon, Nov 09, 2009 at 03:24:04AM -0500, Braden McDaniel wrote:
 OpenvrmlXembedBrowser * const browser =
 OPENVRML_XEMBED_BROWSER(
 g_object_new(OPENVRML_XEMBED_TYPE_BROWSER,
 control-host-proxy, host_proxy,
 control-host-name, host_name,
 dbus-thread-context, dbus_thread_context,
 expect-initial-stream, expect_initial_stream,
 0));

 0 is not NULL.
 0 has the size of int while NULL has the size of void*.
 Matters a lot in vararg list.

 This requires clarification.

 0 *is* NULL, in pointer contexts.  In fact, some compilers define NULL
 using

   #define NULL 0

 So using NULL instead of 0, by itself, won't necessarily address the
 problem, although it will if the definition happens to be

   #define NULL (void *)0

 The problem is that this particular NULL appears in the arguments of a
 function that accepts a variable number of arguments.  The compiler
 therefore doesn't know that any particular argument is a pointer and
 can't perform the proper type conversion.

 Arguably, the real problem is the design of g_object_new(), and another
 way to avoid it is the use of g_object_newv().

 - Ernie
 ___
 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: How to forbid people to change GtkCheckButton's status manually?

2009-08-26 Thread Jim George
I use a GtkImage, and choose among GTK_STOCK_YES and GTK_STOCK_NO. At
least for all the themes I've tried it with, it either shows a
green/red ball, a check/cross or some variation, but imo, it gets the
message across.

2009/8/26 David Nečas y...@physics.muni.cz:
 On Wed, Aug 26, 2009 at 01:07:33PM -0400, Boggess Rod wrote:
 Although, if you want to be 3133t programmer, go with the
 custom image.

 A custom image is the last resort.  You need to make it look good with
 light themes, dark themes, large fonts, etc.

 Yeti

 ___
 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

Copying widgets

2009-07-12 Thread Jim George
Hi all,
I'm writing a program that, like gimp, has a control window, from
which users can open one or more viewer windows that present different
aspects of a data set (it's a weather radar display program). The
sub-windows are identical, and I'm using libglade and glade-3 to do
the interface layouts. Currently, I call glade_xml_new each time I
want to create a new window. Is there a better way, which prevents
libglade from having to parse the XML each time?

Also, I'm interested in moving to GtkBuilder. Do I use different xml
files for each window and create a new GtkBuilder object for each new
viewer window, or is there a smarter way?
Thanks in advance.
-Jim
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Copying widgets

2009-07-12 Thread Jim George
On Sun, Jul 12, 2009 at 3:46 PM, Tristan Van Berkomt...@gnome.org wrote:
 On Sun, Jul 12, 2009 at 3:27 PM, Jim Georgejimgeo...@gmail.com wrote:
 Hi all,
 I'm writing a program that, like gimp, has a control window, from
 which users can open one or more viewer windows that present different
 aspects of a data set (it's a weather radar display program). The
 sub-windows are identical, and I'm using libglade and glade-3 to do
 the interface layouts. Currently, I call glade_xml_new each time I
 want to create a new window. Is there a better way, which prevents
 libglade from having to parse the XML each time?


 Sure, you can build the dialog at startup time or on demand
 the first time, but just hide it and show it on demand.

That's how I handle things like properties dialog boxes. The display
windows, however, are different in that there can be more than one
open at a time, and I have no way to predict how many the user would
like to have open. Currently, I'm forced to call glade_xml_new for
each new display window the user would like. If there was a clone
function, though, I could have done something like create a window on
startup, then clone it for each new window that the user wanted.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Bringing a GtkWindow to the current desktop with libwnck

2009-07-03 Thread Jim George
Hi all,
I'm writing a program that needs to be single-instance. The program
will only run on gnome desktop machines. I'm using dbus to ensure
this, by having the program try a dbus rpc each time it starts. If
there's a running instance, it responds to the rpc by calling
gtk_window_present on the main window. However, if the user switches
desktops and tries to run another instance, gtk_window_present will
only cause the window to appear on the previous desktop, not the
current one.

I tried to get around this using libwnck. I call
wnck_window_get(GDK_WINDOW_XID(main_window-window)), but the
WnckWindow returned is always NULL. The X window ID seems to make
sense (it's a large integer), so what am I doing wrong?

Any alternate solutions to this problem are also welcome.
Thanks,
Jim
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Continuous variable updation in a text box

2009-03-10 Thread Jim George
It wouldn't matter too much, since most screens would only have a 
refresh rate of 60-120 Hz, which is also much higher than what most 
people can even see.


I've handled such cases by using g_idle_add when I get an update of the 
variable's status, and have the idle function update the text box. I 
preserve the event source ID for the next call, and check if that source 
is still available. If so, I remove the event using g_source_remove and 
add a new idle event. This way, the most recent update is shown on 
screen the next time my program goes idle. The idle function then marks 
the source as free, by setting it to zero.


-Jim

Ardhan Madras wrote:

So you will need call textbox insertion (update) 1000 times per second or the 
textbox get updated every 1ms, my question is: Can you see it changes correctly 
with given cycle?

--- adeelmali...@yahoo.com wrote:

From: Adeel Malik adeelmali...@yahoo.com
To: gtk-app-devel-list@gnome.org
Subject: Continuous variable updation in a text box
Date: Tue, 10 Mar 2009 02:48:15 -0700 (PDT)

I intend to monitor the variable's value (acquired via data acquisition 
hardware) at a rate of around 1,000 times per second.
I haven't used textboxes before in GTK+. Could anyone suggest how to update the 
value of a variable in a textbox etc., at this rate.
 
Thanks,

Adeel


  
___

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




_
Listen to KNAC, Hit the Home page and Tune In Live! --- http://www.knac.com
___
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: How to realize a battery-indicator with a trayicon? How to show the current capacity

2008-11-16 Thread Jim George
2008/11/16 Rorschach [EMAIL PROTECTED]:
 Hi,
 I wanna write a little battery-indicator in C with GTK. It's already working 
 nicly in the console and I know how to write a trayicon with gtk but what I 
 don't know is: how can I show the current capacity of the battery? I mean 
 shall I do 100 pictures (1-100%) and if the capacity changes just show the 
 corresponding new picture? This is imo a bad solution because I have to ship 
 100 pictures with my application.

Why not ship 10 images?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


How to tell the difference between a minimize and a switch desktop?

2008-10-27 Thread Jim George
Hi All,
I'm trying to write a program that will minimize to a tray icon. I do
this by writing a handler for the window-state-event, and checking
the changed mask and new window state for the
GDK_WINDOW_STATE_ICONIFIED flag. It all works well, and I also add a
handler for the activate callback of the status icon to bring the
window back.

However, it seems like my window-state-event handler is getting
called when I switch desktops. Is there some way to detect this? I'm
using the default Gnome setup with Fedora 9, not using compiz.

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


Re: Finding a widget in a Glade interface

2008-07-31 Thread Jim George
 I should have mentioned that by time I want to call
 glade_xml_get_widget() the GladeXML *xml created by xml =
 glade_xml_new(filename.glade, NULL, NULL); is out of scope.  If I call
  open the file again to get the widget it has no affect on the running
 window.  I need to get the widget from the running window from some
 callback.  Any ideas?

 Make 'GladeXML *xml' static or otherwise accessible from all parts of the
 sourcecode.

 tom


Not a good idea. I had a similar question some time back, the xml
structure returned by glade_xml_new is too heavyweight to be
retained for a long time by your program, and it contains no useful
information aside from being able to pull out pointers to widgets. A
more apt way to do this would be to store pointers to all the widgets
you need soon after glade_xml_new (perhaps as members of a struct),
then dereference the GladeXML object. When you set up your callbacks,
have this structure passed as the user pointer. Now all callbacks
have access to the widgets in your window.

In addition to the examples posted earlier, you can also download the
source to any standard gtk program for additional examples. I used the
devhelp source for this.
-Jim
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problem writing pixels to GdkPixbuf data buffer

2008-07-15 Thread Jim George
2008/7/15 Luka Napotnik [EMAIL PROTECTED]:
 Hello.

 I encounter a strange problem when I'm writing image data to the
 GdkPixbuf data buffer.

 I create an empty pixbuf and get the data buffer. Then I use:

 pixel = pixbuf_data + i * n_channels

 , where pixel is a pointer to the pixel, pixbuf_data is the pixbuf data
 buffer, i is a counter in a for loop with a condition:

 for (i = 0; i  width*height; i++)

 This for loop should iterate throught all pixel in the image. The
 n_channels variable is 4 because I use a RGBA pixbuf.
 When I have this pixel pointer, I use pixel[0], pixel[1], pixel[2] and
 pixel[3] to modify the RGBA values.

 I then handle the expose-event, create a cairo surface using the
 GdkPixbuf and display the surface onto the drawing area. The problem is
 when I display the pixbuf the image is shifted to the right for exacly
 two pixels. Meaning the first two pixels in the upper left are two
 places to the right, making the last two pixels of the row appear in the
 second row. I hope you understand.

 Am I making something wrong when writing data to the pixbuf? Or is there
 any other explanation. Please help.

 Greets,
 Luka


Luka,
You should change this to something like this:
pixel = gdk_pixbuf_get_pixels(pixbuf);
rowstride = gdk_pixbuf_get_rowstride(pixbuf);
for(y=0;yheight;y++) {
  for(x=0;xwidth;x++) {
/* do something with 'pixel' */
pixel += n_channels;
  }
  pixel += (rowstride - n_channels*width);
}

Rowstride can be something other than n_channels*width, which could
cause problems similar to what you're describing.
-Jim
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Going fullscreen and back

2008-04-27 Thread Jim George
Why not use gtk_window_fullscreen? I've only tried it on a Gnome
desktop, it works well.

On Sun, Apr 27, 2008 at 11:37 AM, Carlos Pereira
[EMAIL PROTECTED] wrote:
 Hi there,

  The small working code below shows
  how my app goes fullscreen and back.

  1) Is there a better way of doing this?

  2) This code works fine in Enlightenment,
  KDE, BlackBox, IceWM, etc. In Gnome and XFCE
  it works, but the desktop bars are still visible
  (I suppose it should be possible to change this?).

  However, in GNOME and only in GNOME, I have to
  subtract 1 pixel, on width or height, for this to work.
  In other words, if I replace this:

  gdk_window_move_resize (window-window,
  0, 0, gdk_screen_width (), gdk_screen_height () - 1);

  by this:
  gdk_window_move_resize (window-window,
  0, 0, gdk_screen_width (), gdk_screen_height ());

  poor Gnome WM gets confused, indeed goes fullscreen,
  but does not come back... :-(

  What is the best way to handle this?
  going fullscreen is a very useful feature
  in many scientific/engineering apps.

  Many thanks,
  Carlos

  *** working code: going fullscreen and back ***
  #include gtk/gtk.h
  #include gdk/gdkkeysyms.h

  int x, y, w, h;

  int press_event (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
  {
  static int fullscreen = FALSE;

  switch (event-keyval)
   {
   case GDK_Escape:
   if (fullscreen == FALSE)
 {
 gtk_window_get_position (GTK_WINDOW (window), x, y);
 gtk_window_get_size (GTK_WINDOW (window), w, h);

 gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
 gdk_window_raise (window-window);
 gdk_window_move_resize (window-window,
 0, 0, gdk_screen_width (), gdk_screen_height () - 1);
 fullscreen = TRUE;
 }
   else
 {
 gtk_window_set_decorated (GTK_WINDOW (window), TRUE);
 gdk_window_move_resize (window-window, x, y, w, h);
 fullscreen = FALSE;
 }
   }

  return FALSE;
  }

  int main (int argc, char **argv)
  {
  GtkWidget *window;

  gtk_init (argc, argv);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_size_request (window, 200, 200);
  g_signal_connect_after (G_OBJECT (window),
  key_press_event, G_CALLBACK (press_event), window);
  gtk_widget_show (window);

  gtk_main ();
  return 0;
  }

  ___
  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: newbie doubt with gtktutorial

2008-01-19 Thread Jim George
On Jan 20, 2008 12:35 AM, dev new [EMAIL PROTECTED] wrote:
 hi
 i am trying out the gtk tutorial with gcc (cygwin on winXP) and wanted
 to run the first example in gtktutorial (to show blank window)..i
 copied the code and compiled it with
 gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`

 using the backticks( ` ) works in cygwin shell (but not in DOS)
 anyway compilation gave a base.exe in my code folder,
 when i try to run it it asks for some dlls (mostly starting cygX*.dll )
 so i copied these dlls to the code directory and again tried to run it in DOS
 then base.exe tries to access the internet and then exits without
 opening a window
 it gives an error likw
 (base:2664): Gtk-WARNING **: cannot open display:

You need to run this from a cygwin shell, since that's what provides
the X display. If you want a native Win32 binary, you need to use the
native Win32 port of GTK with gcc (mingw) or Visual C++.

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


Re: IP address entry widget

2008-01-06 Thread Jim George
On Jan 6, 2008 7:13 PM, Bin Chen [EMAIL PROTECTED] wrote:
 Hi,

 Is there any type of IP address entry widget existed? I want to let
 user input the IP address in dot form, and strict their input to
 0-255.


Use a GtkEntry widget with a handler for changed, validate input there.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to use GList Double Link List

2007-12-25 Thread Jim George
On Dec 25, 2007 9:50 PM, sumit kumar [EMAIL PROTECTED] wrote:
 Hi All,
 I am trying to use GLib double link list in my application.But I have a
 problem. I run the GList sample program from Gtk+-2.0 FAQ:-

*snip*

 *gint pos;
 g_print(Enter Number1\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);

 g_print(Enter Number2\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);

 g_print(Enter Number3\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);

 g_print(Enter Number4\n);
 scanf(%d,pos);
 list = g_list_append(list, (gpointer)pos);
 *
 It prints only last element I appened 4 times... 44, 44 ,44 ,44 if I
 appended 44 as last element.
 Whats wrong with this code??


This is not a GTK question, so wouldn't this be the wrong list?

Anyway, your code will read in a number (using scanf) into a variable
called pos, which is overwritten by the next call to scanf. Since
your list only stores pointers to pos, you have four pointers to the
same variable, which stores the last number entered by the user.
Change your list to directly store the numbers themselves, or allocate
new memory for each integer.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: how to destroy window if ptr to mainWindow not known

2007-12-06 Thread Jim George
On Dec 6, 2007 4:46 AM, Lukasz Gromotowicz [EMAIL PROTECTED] wrote:
 Hi all,

 the problem is when loading windows from the xml file:

   glade_xml = glade_xml_new(ami.glade,NULL,NULL);

 I need to know the reference to main window (GtkWindow) to be able to
 destroy it, yes?
 I can get it like this:
window = glade_xml_get_widget(glade_xml,window1);
 and destroy:
   gtk_widget_destroy(window);

 But what if there is no window1 in the glade file? Let's say updated xml
 changed the name to mainWindow?

 Window exists on the screen, but how to delete it?

I don't think the glade file should be edited while the program is
running... or is that what you are doing?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Question about the realize signal

2007-12-04 Thread Jim George
On Dec 4, 2007 3:06 AM, Dan H [EMAIL PROTECTED] wrote:
 Hello,

 I like to build my GUIs with Glade, but as Glade is quite limited in what it 
 can do I usually write routines that finalize the GUI after the Glade stuff 
 has been set up. For example, in a current project I have a table which is 
 full of radiobuttons, but Glade always creates those with a label, and to 
 remove that label I have to call gtk_container_remove() on each button in 
 that table. Or in another dialog I like to use custom widgets, so I build the 
 window in Glade using dummy widgets and then call a routine that finds and 
 removes the dummies and replaces them with what I want.

 Usually I place the fixup code in routines that connect to the realize 
 signal for the containing widget (in the first example, for instance, the 
 realize signal for the table that contains all the radiobuttons). This 
 always works, but what got me thinking was: Is it safe? Can't the table be 
 realized first without buttons, so my routine that iterates over all 
 contained buttons finds nothing? Am I relying on some particular oder here in 
 which Glade builds the GUI elements?

 In short: What's the best way of doing what I need to do?


Don't know how to handle the first issue, but the second one may be
handled by using the Custom Widget option in glade (under GTK+
Additional. There are four generic properties (string 12, integer
12) that you can use. When glade parses the xml file, it will try to
execute the specified
creation function (search Devhelp for GladeXMLCustomWidgetHandler),
which is responsible for actually constructing the widget. This
function will receive the widget name and the four parameters.

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


Re: how to set widget background?

2007-12-03 Thread Jim George
On Dec 3, 2007 3:57 AM, Guenther Meyer [EMAIL PROTECTED] wrote:
 hi,

 I have a hbox that looks like this:

 -
 |  ||
 |      |    |
 |      |    |
 |  ||
 -

  is a gtkimage
  is text in gtklabel

 how can I set the background color for the whole hbox?
 gtk_widget_modify_bg won't work.

 I need the color for the whole hbox. when I set the background of the text,
 only the background of the letters is drawn in the specified color...

Add a GtkEventBox, then add your hbox to the event box. Set the
background color for the event box.

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


Re: is there a memory leak problem with gtk_widget_queue_draw()?

2007-09-07 Thread Jim George
On 9/6/07, okty [EMAIL PROTECTED] wrote:

 Hi,

 I am using GLib's memory profiling to check memory usage of my program. I
 noticed that for each refresh in my screen with gtk_widget_queue_draw(), I
 am checking my allocated memory and each refresh increases the size of
 allocated memory. Do you know any memory leak problem in
 gtk_widget_queue_draw()?

The page http://live.gnome.org/Valgrind has some info on providing
flags to glib, making it use less efficient (but memcheck-friendly)
memory allocation code. Also, try writing a bare-bones program that
does nothing except call gtk_widget_queue_draw code periodically, and
see if you can replicate the problem.

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


Re: Display grayscale image

2007-08-31 Thread Jim George
On 8/30/07, Marco Brambilla [EMAIL PROTECTED] wrote:
 Hello everybody,

 Firs of all I'm a newbye both to GTK and to this mailing list, so I apologize 
 for the triviality of the post.
 I'm writing a very simple application (language: C) which should grab frames 
 from a ccd camera and show them on the screen.
 The ccd images are stored as a 1D array of unsigned char, single channel 
 grayscale images.
 Looking around inside the API docs, I tried to use something like:

 pixbuf = gtk_pixbuf_new_from_data(.);
 image = gtk_image_new_from_pixbuf(pixbuf);

 The problem is that this way, the displayed image is messed up, since (for 
 what I understand) gtk_pixbuf_new_from_data needs
 the three RGB channels.
 Is there a easy way of displaying such an image as is (single channel) ? Or 
 must I convert it each pixel to
 the a RGB triplet needed by gtk_pixbuf_new_from_data ?
 Any advice is very welcome.

 Thanks in advance to everybody.

 Marco

You could possibly use gdk_image, but it's easier to use a pixbuf and
just copy the grayscale value thrice into R, G and B. Remember to use
the rowstride, and not the width of the image when creating a pointer
to go from one row to the next.

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


Differences of GIOChannel between Linux and win32

2007-08-29 Thread Jim George
I have a question about the cross-platform compatibility of
GIOChannels, between win32 (using mingw32) and Linux, when using
pipes. I am using g_spawn_async_with_pipes to spawn a series of
programs that do some processing and deliver results. Specifically,
I'm using the Generic Mapping Tools (GMT).

My initial development on Linux worked well, I set up a single
callback with an event mask of G_IO_IN | G_IO_HUP, and when I got
IO_IN, I'd read data in from the stdout pipe. When I got a HUP, I'd
know the program is done, and move on to the next program that I need
to call.

Under Win32, I don't seem to get the HUP with this approach. I had
heard anecdotal stories that the win32 implementation of IOChannels
doesn't let you combine events in the event mask, so I split the
callbacks into two functions. This time it worked, but I'd randomly
get cases where the HUP event is generated *before* all the data is
read in through the channel. I finally got it to work by not using the
HUP event at all, but checking to see if I get an error when reading
the IO Channel (g_io_channel_get_chars would return G_IO_STATUS_EOF).
This works on win32, but not Linux, the program would never see an eof

My question is: is there some documentation on what part of GIOChannel
is broken on win32 and what's not?

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


Re: GtkDialog problems again

2007-08-27 Thread Jim George
On 8/27/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi everybody.
 I need a dialog in my application that simply show a label (so without any
 button) and then hide itself after some processing occurred.
 The problem is that I can't send any :response signal to the dialog, so it
 remains blocked in the loop after gtk_dialog_run has been called.
 I tried to use the example posted in the GTK+ reference manual, but without
 success.


Just in case Yeti's comment didn't make it clear, it's still important
to yield control of the program back to GTK once the progress window
is shown, otherwise nothing appears to happen. So your code might look
like this:

do_long_task_step_1(struct task_params *p)
{
  gtk_widget_show(p-progress_window);
  g_idle_add(do_long_task_step_2, p);
}

do_long_task_step_2(struct task_params *p)
{
  /* do part of the task here */
  g_idle_add(do_long_task_step_3, p);
}

do_long_task_step_3(struct task_params *p)
{
  /* finish up the task here */

  gtk_widget_hide(p-progress_window);
}

For file/device I/O, you would use something like g_io_channel, so you
wouldn't need to rely on g_idle_add.

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


Re: alpha channel with Gdk/Gtk+ color

2007-08-27 Thread Jim George
Not sure how you'd do this in gdk directly, but I can think of two alternatives:
a. Use Cairo (supports alpha channels, and gives you awesome-looking
antialiased triangles to boot)
b. Use gdk to render to 30 different GdkPixbufs, then composite them
together. The composite functions take an alpha parameter. I doubt the
performance would be very good, though.

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


Re: How to communicate between two GtkWindow widgets?

2007-08-23 Thread Jim George
 But, I wonder how can I communicate between two GtkWindow widgets.

Can you describe what you're trying to do?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Re: How to communicate between two GtkWindow widgets?

2007-08-23 Thread Jim George
On 8/23/07, 张散集 [EMAIL PROTECTED] wrote:


 Hi Jim,

 Thanks for your reply. There is a  figure.

 Well, on the picture above, win_A  is the main GtkWindow, win_B is a child 
 GtkWindow.
 When I click the button on win_B I  want to change the label_A's text.
 That's it. If know how to do this,  I will do other things to accomplish my 
 task.

 Thanks


Please send your replies to the list as well (use reply-all).

You need to pass a pointer to the second widget in the user parameters
when connecting to the first widget. A simple example would be:

g_signal_connect(win_b_button, clicked, win_b_clicked_cb, win_a_label);

void win_b_clicked_cb(GtkButton *b, gpointer *user_data)
{
  gtk_label_set_label(GTK_LABEL(user_data), Button was clicked);
}


Typically, programs will create a structure containing pointers for
all widgets they use, then pass a pointer to this structure to all the
signal handlers.

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

Re: Libglade resource consuming question.

2007-08-09 Thread Jim George
On 8/9/07, Carlos Savoretti [EMAIL PROTECTED] wrote:
 Hi all!


 Several objects within a program has a Xml buffer taken from
 xmlDocDumpFormatMemory (), one for each of them. Only one of
 those objects will be displayed at a time.

 Question is:
 Is it saved a lot a memory if I just keep the xml buffer and
 use glade_xml_new_from_buffer () when the object would must to
 be shown; or (easier from the programming point of view) rightly
 use glade keeping a lot of glade built trees possibly not used
 any more but now the xml buffer can be freed.

 Do I be clear ? (When doubt appears it's probably not...)
 Shortly: GladeXml objects with a moderate amount of widgets are
 very resource consuming ? or not compared against
 xmlDocDumpFormatMemory () result ?

 Thanks a lot.


 Carlos Savoretti.

I'm not sure if it's exactly what you're asking, but I asked a
question on this list about keeping the GladeXML object and calling
glade_xml_get_widget each time I need a widget. In general, that seems
like a bad idea, just call glade_xml_get_widget once for each widget
you need, store the pointers, and unref the GladeXML. So in your case,
I think you'd free the data returned by xmlDocDumpFormatMemory as
well, so the only things actually in memory are the widgets
themselves. Rather than destroying them when they're not needed, just
hide them, and show again when needed.

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


Re: dynamic combo entry

2007-08-07 Thread Jim George
On 8/7/07, Dave Howorth [EMAIL PROTECTED] wrote:
 Users need to choose from a very long list of possibilities (approx half
 million).

 A neat interface that I saw for this (in Javascript IIRC) is to have a
 combo box entry. As the user types the beginning of the name, the combo
 box displays the first few possibilities that match and can select one
 as soon as it appears.

 I've been trying to implement this using gtk+ but it feels like I'm
 fighting the widget set, which sometimes means I'm trying to do the
 wrong thing! At the moment, I'm trying to get the popup list to appear
 while the focus stays on the text entry widget, for example.

 Does anybody have any example code of this type of interface? Or have
 any suggestions for good alternative interfaces for this situation?

 Thanks, Dave

It may not be exactly what you want, but gtk_entry_set_completion might help.

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


Re: dynamic combo entry

2007-08-07 Thread Jim George
On 8/7/07, Dave Howorth [EMAIL PROTECTED] wrote:
 Jim George wrote:
  It may not be exactly what you want, but gtk_entry_set_completion might 
  help.

 It looks interesting. I've found the page in the reference manual and it
 says lots of things that sound intriguing but I'm having trouble
 grasping exactly what a GtkEntryCompletion can do :(  Are there any
 tutorials or examples to help me understand what it's capable of?

 Cheers, Dave


Here's a quick example:
...

GtkTreeIter iter;
GtkListStore *model = gtk_list_store_new(1, G_TYPE_STRING);
for (ctr = 0; ctr  NUM_ENTRIES; ctr++) {
gtk_list_store_append (model, iter);
/* Assume that 'entries' contains NUM_ENTRIES char *s */
gtk_list_store_set (model, iter, 0, entries[ctr], -1);
}

gtk_entry_set_text(entry_widget, default_text);

GtkEntryCompletion *entry_comp = gtk_entry_completion_new();
gtk_entry_set_completion(entry_widget, entry_comp);
/* We can unref the completion object since the entry holds a ref anyway */
g_object_unref(entry_comp);

gtk_entry_completion_set_model(entry_comp, GTK_TREE_MODEL(model));
/* Now when the widget is destroyed, model is automatically freed */
g_object_unref(model);
/* All the entries are in column 0 */
gtk_entry_completion_set_text_column(entry_comp, 0);

...

I use this when asking the user for a remote host name. I store a list
of most-recently-used hosts, which populates the completion list. When
the user types in a host name, if the first few characters match, a
list pops up with all the remaining matches. Unfortunately, unlike a
combo box, there's no way for the user to force this list to be shown
(feature request?) In your case though (with 0.5e6 entries), this may
actually be A Good Thing.

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


Re: How to set signal_data via Glade for glade_xml_signal_autoconnect_full

2007-07-20 Thread Jim George
 I'm trying to understand using Glade + libglade to build UIs. As I
 understand it, if I use the glade_xml_signal_autoconnect_full call, my
 signal connect function will be called for every defined signal in the XML
 tree I am processing.

 One of the parameters passed to my connect functions is signal_data,
 which is defined in the libglade references as signal_data :the string
 value of the signal data given in the XML file. There seems to be no way
 to set this value via Glade-2.

 How do I set this? Do I have to edit the XML outside of Glade (YUK!)?

The way I'm going is to avoid using autoconnect completely and
instead, manually connect the signals to the appropriate handlers, and
at that time, specify the right data. One way to make this process
simpler may be found in the source code for Devhelp, which uses a
function with a variable argument list to take a bunch of tuples of
widget names, signal names and functions to associate them to. Fixed
parameters provide the name of the glade file to use, as well as the
signal_data to pass to each signal handler.

You can then do something like this:

connect_signal_handlers(path/to/filename.glade, my_data,
  my_button, clicked, on_my_button_clicked,
  your_button, clicked, on_your_button_clicked,
  NULL);

Perhaps glade-3 has a better way of doing this?

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


Re: waveform display in gtk

2007-07-11 Thread Jim George
On 7/11/07, bert [EMAIL PROTECTED] wrote:
 Hi all,

 Is there a GTK widget to display audio or signal waveforms?

 If not, is there a related project in which such a widget is available?

If you needed to display relatively short signals (a few seconds),
something like GtkDatabox would work. GtkDatabox is not suited for
long audio clips, since you'd have to only show the signal envelope
after resampling, otherwise refreshing takes too long.

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


Re: shifting focus between multiple text entries.

2007-07-03 Thread Jim George
On 7/3/07, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hi all,
 i am working on an embeded application over the TI OMAP 2430 SDP
 and new to GTK.

 i have a window with multiple text entries over it.

 In my application since we dont have a keboard but only a keypad over the
 target.. i m handling all the key press events myself.
 while creating the text entries i call a function which returns me a
 horizontal box with a label and text entry..which i add to a vertical box
 which in turn is added to the window..
 my question is ..how can i implement the shifting of focus between the
 text entries..i have seen dat by default TAB key shifts the focus..but in
 my case i m handling all the key press events..
 i want to know how can i acces the individual text entries on my window as
 i m not maintaing them individualy.

 any help will be of great importance..

 if one needs any clarification on this plz let me know..


Just a guess, but if your application runs GTK atop X (not directFB,
etc), then use Xmodmap to map some key to TAB.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Getting a GDK_CONFIGURE event from a GtkImage

2007-06-26 Thread Jim George
On 6/26/07, Jim George [EMAIL PROTECTED] wrote:
  [...] caused an infinite loop, because I'm trying to
  do the following:
  
  gboolean solar_cal_pixbuf_resize(GtkWidget *widget, GtkAllocation
  *alloc, gpointer user_data)
  {
GtkImage *img_widget = user_data;
GdkPixbuf *pixbuf = gtk_image_get_pixbuf(img_widget);
if (pixbuf) g_object_unref(pixbuf);
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, alloc-width,
  alloc-height);
gtk_image_set_from_pixbuf(img_widget, pixbuf);
  }
  
  The call to gtk_image_set_from_pixbuf causes a size-alloc to be
  emitted, leading to the infinite loop. I don't see why the
  size-request signal is not being emitted.
 
  Just put a call to g_signal_handlers_block_by_func() before
  gtk_Image_set_from_pixbuf(), and then after, a call to
  g_signal_handlers_unblock_by_func().  There may be a more elegant way
  of handling that, but this'll work.
 
  -brian

 Thanks, Brian, it works now.


I'll take that back, the handler keeps getting called even if I block
it before calling gtk_image_set_from_pixbuf. If I disconnect it, it
doesn't get called again. Seems like the allocate-event occurs with
some delay after gtk_image_set_from_pixbuf is called.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Getting a GDK_CONFIGURE event from a GtkImage

2007-06-26 Thread Jim George
 I do not follow this thread, but can't you just compare the
 new allocation to the current one and do nothing when they
 are equal?

That doesn't work, they seem to always be equal. I'm comparing the
allocation being passed to the alloc-event handler in the second
parameter and the allocation of the widget itself using something like
GTK_WIDGET(object)-allocation.width. Seems like alloc-event gets
called after the widget is allocated space, so that's the correct
behaviour.

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


Getting a GDK_CONFIGURE event from a GtkImage

2007-06-25 Thread Jim George
Is there some way I can obtain a GDK_CONFIGURE event from a GtkImage
widget? I tried putting the GtkImage inside a GtkEventBox and
connecting a handler to configure-event, without success. I also
manually enabled GDK_STRUCTURE_MASK, even though GTK is supposed to do
that by default. I would like to know when the image size has changed,
so that I can assign a new GdkPixbuf to the GtkImage and draw to the
GdkPixbuf.

TIA

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


Re: Getting a GDK_CONFIGURE event from a GtkImage

2007-06-25 Thread Jim George
On 6/25/07, Brian J. Tarricone [EMAIL PROTECTED] wrote:
 On Mon, 25 Jun 2007 15:13:30 -0600 Jim George wrote:

 Is there some way I can obtain a GDK_CONFIGURE event from a GtkImage
 widget? I tried putting the GtkImage inside a GtkEventBox and
 connecting a handler to configure-event, without success. I also
 manually enabled GDK_STRUCTURE_MASK, even though GTK is supposed to do
 that by default. I would like to know when the image size has changed,
 so that I can assign a new GdkPixbuf to the GtkImage and draw to the
 GdkPixbuf.

 AFAIR, configure events are only useful for toplevel windows.  You'll
 probably want to look at the size-request and/or size-allocate signals
 (on GtkWidget).

 -brian

That's true (although GtkDrawingArea will emit it too). I tried using
size-request, and nothing happened (callback never got called).
size-allocate, however, caused an infinite loop, because I'm trying to
do the following:

gboolean solar_cal_pixbuf_resize(GtkWidget *widget, GtkAllocation
*alloc, gpointer user_data)
{
  GtkImage *img_widget = user_data;
  GdkPixbuf *pixbuf = gtk_image_get_pixbuf(img_widget);
  if (pixbuf) g_object_unref(pixbuf);
  pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, alloc-width,
alloc-height);
  gtk_image_set_from_pixbuf(img_widget, pixbuf);
}

The call to gtk_image_set_from_pixbuf causes a size-alloc to be
emitted, leading to the infinite loop. I don't see why the
size-request signal is not being emitted.

Baah, maybe I should just stick to using a GtkDrawingArea instead...

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


Deriving from GtkWindow and libglade

2007-06-08 Thread Jim George
I want to derive a new class from GtkWindow to represent a top-level
window which contains objects from a Glade XML file. Since the
glade_xml_get_widget functions returns a new object, I'm not sure what
to do in the object's init_instance function to copy the properties
(and children) of the returned top-level window to the object itself.

I thought of using child = glade_xml_get_widget to get the child of
the top-level window, then use gtk_container_add(self, child).
However, the new top-level window won't have the properties set within
the glade file.

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


Re: multi thread app and often variable accessing

2007-06-08 Thread Jim George
 On 6/8/07, Tomasz Jankowski [EMAIL PROTECTED]  wrote:
 
  Hi!
 
  I'm working on small multi thread application based on Gobject. In one of
  my
  objects I have integer variable, which determine current object's status.
  The problem is, that I need to read it's status really often, so it will
  be
  to expensive to lock and unlock mutex all the time. Can I use there atomic
  operations provided by GLib instead of mutex locking and unlocking system?
  I
  mean, if g_atomic_get and g_atomic_set would not occur any problems, when
  I
  will try to access the same variable from two thread at the same time?
 
  --
  Cya!
  Tom

On 6/8/07, Jonathan Winterflood [EMAIL PROTECTED] wrote:
 Hi,

 As far as I understand, g_atomic_int_get/set will do the job
 just fine, as long as you're sure the only part that needs to be
 atomic is the getting and setting.
 However, if the hardware you are running on does not provide an atomic way
 of getting/setting an int, (eg: int is an int32 and the hardware is 8-bit),
 you will end up locking and unlocking mutexes anyways (but most systems
 nowadays are 32bit+ anyways)

 Jonathan


Also, the hardware must have something like the Pentium CMPXCHG8B or
it's newer cousins to do this efficiently. I'm not sure exactly how
it's done in glib, but normally, if such instructions dont exist, you
need to issue standard MOV instructions with a bus-lock prefix, which
is slow.

-Jim

PS, please don't top-post.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: multi thread app and often variable accessing

2007-06-08 Thread Jim George
 Begin Curiosity:
  Also, the hardware must have something like the Pentium CMPXCHG8B [...]
 Is it not
 sufficient to be able to write an int in one single bus access? ie
 have a 32-bit wide data bus
 Or is that exactly the point? :D

No, in most cases, if you want to atomically increment or decrement a
value (for example, a semaphore or ref count) without locking, you
have to read the value, increment it, then write it only if it's not
changed. The write and check to see if it's not changed must be
atomic, this is where CMPXCHG comes in.

 MOV instructions with a bus-lock prefix, which is slow.
 OK, I guess it'd be faster (and leaner) than using a mutex though
 But that can't be done in pure C, right?

Maybe, but I don't see how any end-user program (such as one with a
GTK interface) would benefit from the small speed increase. Put such
stuff in another program which merely reports its progress to the gtk
GUI program through a socket or pipe.

 End curiosity

And Yeti's right, this stuff can lead to months of head scratching
unless you know what you're doing. I know I don't, so I'll not
potentially mislead you any more.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Global GladeXML

2007-05-26 Thread Jim George
On 5/26/07, Felipe Balbi [EMAIL PROTECTED] wrote:
 Hello all,

 my problem is the folowing...
 I have a glade xml file being opened in my code...

 I wanna use the same pointer to this XML file in other functions...
 how could I do it??
 I have the implementation below, but my signals are not connecting.. why??
 (maybe this IS a newbie question... but I'm not figuring this out...
 the purpose here is to make it easier if I wanna port the application
 to other Graphical Interface Toolkit such as Maemo/Hildon, QT or even
 text...)

Apparently there's no standard way of doing this, my approach is to
have a structure of data associated with the main_window widget using
g_object_set_data, then retrieve the structure wherever I need it,
using g_object_get_data. One of the structure items is the glade XML
object. You can also pass the structure (or just the glade XML ptr) as
a parameter to your signal handlers. This seems to be a more common
approach.

Where are the calls to g_signal_connect. Maybe you forgot to include
it in the post?

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


Re: Global GladeXML

2007-05-26 Thread Jim George
On 5/26/07, Felipe Balbi [EMAIL PROTECTED] wrote:
 it's the glade_xml_signal_autoconnect

 I define the name in the xml file and code the same name in the C language...

 libglade does the connections :-p

 easier.. and let my code be cleaner...


You need to pass -export-dynamic to ld in order to let libglade see
the symbols in your binary.

This is being pedantic, but I didn't see glade_xml_signal_autoconnect
in your code either :-)

-Jim

PS, do a reply all, otherwise the mail only gets sent to me and not
the mailing list.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Global GladeXML

2007-05-26 Thread Jim George
 Note that this is definitely not a recommended practice, GladeXML
 objects should be dispensed with as soon as possible after interface
 construction, its a heap of allocated strings that represents the
 parsed state of the glade file; not only a practical hash table by
 widget name thing.

 See the DevHelp sources for a good example of libglade usage.

   - Each interface component has a GObject control object as
 an api to that component
   - Each component holds pointers to only the needed widgets
 from the interface.
   - Each component parses a glade file (or portion of the glade
 file) at initialization and passes the control object itself
 to signal callbacks as data.

 Note many progams use this paradigm but not all of them go so
 far as to use a GObject as the control data for a UI component -
 and many apps use a global data structure for the whole UI
 as well.

 My main pointer for libglade usage is just free up that bloated
 GladeXML memory hog as soon as possible at initialization time, its
 just not meant to be kept around.

Thanks, Tristan. I didn't realize the xml object consumes a lot of
memory. Devhelp handles the extraction of pointers from the xml in a
very elegant manner. However, confusingly enough, they decide to use
both a global pointer to the control object *and* to pass it to the
signal handlers as a parameter (see dh-preferences.c).
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Accessing a GtkTable's children.

2007-04-07 Thread Jim George
On 4/7/07, Craig Pemberton [EMAIL PROTECTED] wrote:
 I just discovered lookup_widget()!
If you're using lookup_widget(), that means you're using Glade's code
generation, which is going away in glade 3. Use libglade instead,
especially if you're not too far into your project.

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


Re: trying to launch a dialog from outside the main gui thread by emiting a signal to the thread.

2007-03-07 Thread Jim George
On 3/7/07, Kevin Lambert [EMAIL PROTECTED] wrote:
 I ended up modifying my class such that the information for the dialog gets
 added to a vector and I added a timer which looks at the vector and if there
 is something new to be displayed it pops it off and launches the appropriate
 dialog, thus keeping everything happening within the GUI thread (or at least
 that is what I am assuming is happening now that the code works).

 Kevin

GLib already has GAsyncQueue for this. Usually, you can get away with
using g_idle_add, it's simpler.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk-app-devel-list Digest, Vol 34, Issue 43

2007-02-27 Thread Jim George
On 2/27/07, Saroz Kumar [EMAIL PROTECTED] wrote:
 Hi All,

 I need to disable minimize, close options on top - right side of the window.
 I already built the window with gtk_window_new() call. Is it possible to do
 the reqd. changes?
 Note: i cannot remove that frame in the window.
AFAIK, this is not a GTK function, it is handled by the window
manager. You can use gdk_window_set_type_hint to set a hint for the WM
to render the decoration and gdk_window_set_decorations to hint the WM
to turn on/off some decorations, but there is no guarantee that the
close and minimize options disappear with all WMs.

From the documentation of gdk_window_set_decorations:
Most window managers honor a decorations hint of 0 to disable all
decorations, but very few honor all possible combinations of bits.

For example, if I run your GTK program under Beryl, I could have Beryl
configured to *always* show the minimize, maximize, close and
window-shade buttons (window-shade is normally not shown in Metacity,
and there is no direct equivalent in vanilla Windows).

Another option is to disable WM decoration and draw a frame yourself,
but this is non-standard and will look ugly on systems where users
have other WMs selected. For embedded apps, etc. this doesn't matter.

 Is it possible to display a scroll text (like marquee text in html ) in the
 window?

Not directly. As a piece of unsolicited advice, please don't use a
marquee, it's very annoying!

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


Re: A few drawing questions

2007-02-20 Thread Jim George
Correct me if I'm wrong, but if you're using GDK, I think you should
use pixmaps instead of GdkPixBufs. The docs say that pixbufs are
client-side, while pixmaps are server side, so redrawing a pixbuf will
be more expensive. I also take this to mean that it's possible for an
X server to store a pixmap in on-screen memory, which can then be
copied very fast. However, when I tried some experiments to see which
was faster, I could not make out a difference on my box (which has an
nvidia accellerated server). My app (a radar data display) doesn't
need the speed of a game, though.

Anyway, to get a semi-transparent floating overlay atop the tiled
background, you could consider using GdkPixBuf's composite functions.
They're fairly slow, but if you only need to redraw when the tiles
beneath the overlay change, you can probably get acceptable speeds.

About tile redrawing, there should be lots of text files from the
fidonet era, written by various sceners describing how you can do
4-way scrolling with a limited amount of redrawing of all the tiles
(see www.scene.org ). In a nutshell, most of them ended up with a
bitmap slightly larger than the screen size, which could be panned
around when the user wanted to scroll. When you reach the edge of the
larger bitmap, repaint the edge which just got uncovered. Fullscreen
VGA games used the hardware to show a part of the video memory and to
implement the scrolling, with GTK I guess you can emulate it with the
various bitmap copy functions.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: libglade frustration

2007-02-14 Thread Jim George
 So you want to know how to use it and you intentionally
 avoid one of the most efficient ways to learn it.  Well, if
 it works for you...

What is so inefficient about taking an example (that already exists)
and including it in the HTML/online documentation that more people
read than source code in tarballs?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk_widget_size_request v. reality

2007-01-18 Thread Jim George
On 1/18/07, v4r4n [EMAIL PROTECTED] wrote:

 It appears that the 'size-request' signal only happens once, and is not
 called when the user resizes the window.  I couldn't find a 'resize' signal
 definition so I'm not sure what other signals I need to set up for this to
 happen all the time.
Sorry, I meant 'configure_event', not size-request. By poking around
the documentation for PyGTK (info not found in the original docs for
the C API... *grumble*), I found that configure_event gets sent when
the window changes size. It's still not perfect, there's a question I
sent to this list regarding this a few days back

OK, I'll give you an example of using an HPane, which I realize *is* a
visible split between the two sections of the container widget... it's
just a bit easier to follow. I have a function set up as a signal
handler for 'configure_event' for the main window as follows:

gboolean on_ppiw_configure_cb(GtkWidget *widget, GdkEventConfigure
*event, gpointer data)
{
window_info_t *wi;
GtkWidget *hpane;

wi = g_object_get_data(G_OBJECT(widget);
g_assert(wi != NULL);

float ratio = gtk_paned_get_position(wi-hpane) /
(float)widget-allocation.width;
gtk_paned_set_position(wi-hpane, event-width * ratio);

return FALSE;
}

window_info_t is a structure that contains pointers to each control
within the window, including the hpane separating the two sections. I
attach this to the window with g_object_set_data, so I can retrieve it
within callbacks -- this is just my approach, feel free to use any
method you like to get access to your controls.

Since the callback is linked to the main window, each time it's
resized, I find out how big the window's old size is using
widget-allocation.width, and the split ratio. Now, I set the hpane's
position using the same ratio but with the new width, obtained from
event-width (note that at this point, the window still hasn't
actually been resized). This will maintain the same ratio between the
two split sides as before.

In your case, you can emulate the functionality of the hpane using an
hbox filled with two GtkAlignments and setting the widths using
event-width * ratio for the left alignment, event-width * (1-ratio)
for the right alignment.

 If the parameter was 0.3, the 1st widget would take up 30% of the parent's
 width while the 2nd would take up the remaining 70%.  No matter what the
 user does to the window, this ratio should be constant.
In the handler, rather than computing 'ratio', you can use a constant.
I compute a ratio in my code since I use a GtkHPane that the user can
resize.

-Jim

PS, I'm quite new to GTK (been at it for only about 6 months now), so
there's probably a better way to do this that I don't know about.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkDrawingArea mouse events

2007-01-17 Thread Jim George
My program has a GtkDrawingArea in a resizable window. The drawing
area needs a 2D array of integers, sized so that there is 1 integer
per pixel. When the user moves his mouse over the DrawingArea, I want
the program status bar to show the value from the array corresponding
to the pixel under the mouse.

I have two questions:
1) I am currently trapping the configure-event signal and resizing
the array there. Is this the best approach? In my past life, I used to
program for the Windows API, I'm basically looking for a replacement
for WM_SIZE.
2) I had a bug in my program in which I would occasionally get a mouse
cursor position outside the drawing area (for eg: the last time
configure-event was called, I got a 400x400 window, but I'd get pixel
values of, say, x = 403). I handle these by bounds-checking before I
access the array, but why would I get such values in the first place?
This is why I wonder if trapping configure-event was the right thing
to do.

Thanks, all.

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


Re: cannot set tooltips over a picker widget?

2007-01-14 Thread Jim George
On 1/14/07, Francesco Montorsi [EMAIL PROTECTED] wrote:
 GTK+ 2.10.3


 Hi,
 I'm trying to set a tooltip on a GtkFileChooserButton widget without
 success... maybe it's simply not possible?

 I've done a minimal change to the attached pickers.c file of the
 gtk-demo app in order to show it... just drop it over your original
 one and recompile the gtk-demo: I can't see any tooltip...


I know that glade doesn't let you set tooltips for many different
controls (such as a GtkComboBoxEntry -- is this a bug?). My fix is to
put the combobox inside an event box and assign the event box a
tooltip.

-Jim

PS, sorry the mail didn't get sent to the mailing list last time. I
think the mailing list should set a Reply-To header pointing to
itself. Replying to the sender, rather than the list seems like too
common a mistake.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkFileChooser and select() interaction

2006-12-31 Thread Jim George
I have an app with two threads, one runs the GUI, one receives network
data and uses a select() call to watch for data. The network thread
does not touch the GUI at all. My problem is that when I create a
dialog box with a GtkFileChooser in it, the select function returns
several times with errno == EINTR. On most machines I've tested this
on, the program correctly handles this behavior. Unfortunately, on a
few machines, select() crashes intead of returning EINTR (at least,
GDB reports the crash as having occured within select(), and I
compiled with -O0 when testing). Oddly, this only seems to happen the
first time I create the dialog box with glade_xml_new. After this,
select runs fine no matter how many times I create or close the dialog
box in question. Seems like some sort of initialization for
GtkFileChooser causes select() to be interrupted.

Any ideas why this would happen? How can I somehow pre-initialize
things before my first call to select() ?

If it helps, the only difference between the machines that crash and
the ones that return EINTR seems to be that the crashing ones are all
i686 kernels, while some of the others are i686 and some are x86_64.

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


Re: g_array_new problem with initializer element

2006-12-24 Thread Jim George
 GtkTreeView.  However, the following line gives an error:

 GArray *serverlist = g_array_new(TRUE, FALSE, sizeof(gchar));

 The error is:

 main.c:58: error: initializer element is not constant

This should work. Check that you don't have errors in the lines
previous to this in your program. Something like leaving out a
terminating brace on an initializer list.

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


Re: A question about deprecated widget

2006-12-18 Thread Jim George
 Actually, that feature is not that important to me, the important part
 is that scrolled window, instead of that long ugly thing that a really
 long list turns GTK_COMBO_BOX into.

I agree that the combo box does look ugly when there are too many
elements, but the solution, to me, seems to be to use a different type
of control instead. It's quite painful for a user to choose one of
hundreds of items from a list, and when that list is transient, it's
even worse. I'd say a GtkTreeView would be a better choice of widget
for such an application. Just my 2c.

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


Re: gtk_widget_size_request v. reality

2006-12-13 Thread Jim George
 How do I force a parent to tell the child how much space will be available
 to the child at this time?  Is it even possible?  Do I really have to call
 gtk_widget_set_size_request()/gtk_widget_size_request() on every parent so
 that the children have something to work with?

Use an alignment and set the Left/Right Padding in a callback for
size-request of the parent.

 I'm new to GTK, but as far as I can tell, most GTK tutorials and
 documentation don't really cover packing widgets when homogeneous, expand,
 and fill are not all set to TRUE (if only I could just let GTK do it all for
 me...).

 Suggestions?

Open up glade, create a dummy project and play around with it. I got
around a bunch of GTK's crummy documentation by doing this. You can
also consider using glade and libglade in your app, instead of just as
an exploration tool.

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


Re: A question about threads

2006-12-11 Thread Jim George
If you use the threads approach and want to make your app portable to
other platforms, you should use the g_thread library. pthreads will
only work under Linux. The biggest problem of using threads is that
the secondary threads must not try to directly update the GUI, unless
you use g_threads_enter/leave, but that (in my limited experience)
doesn't always seem to help (I've seen random crashes, with messages
about asynchronous X messages). You can use a GAsyncQueue to pass data
between the thread and an idle handler which does the actual GUI
updates (I've posted about this a while back). I suppose one advantage
of using threads to do the calculation (as opposed to an idle
callback) is that the app will run smoother on a dual core/dual
processor machine.

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


Re: Scientific widgets

2006-11-29 Thread Jim George
On 11/29/06, Mark Richardson [EMAIL PROTECTED] wrote:
 What was that library that someone was developing for scientific widgets? 
 They were things like analog indicators (or dials), an led, etc.  I thought I 
 saved the link, but can't find it now.

http://www.tesla.eletrica.ufpr.br/giw

I'm using the compass and show (analog panel-meter lookalike)
widgets, they work well. Plenty of warnings when compiling the source,
though.

I'm willing to work with the authors (are you guys on this list?) to
have these widgets render with Cairo (they use gdk now), and wrapped
up as a shared lib package (like gtkdatabox)... except I've never done
it before.

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


Re: Suppressing command window

2006-11-27 Thread Jim George
 I tried using getenv() and putenv(), but it is not working as expected.
That would be the right way. Could you give some more details on why
it doesn't work? Or how it fails? Does setenv return -1? What is errno
set to?


 I've packaged the application along with the required GTK dlls in a zip file.
If this is the only reason you're setting the path, a better option
would be to statically link the app with GTK.


As an aside, I thought Xilinx ISE tools use QT, so why the interest in GTK?

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


Re: run a new application

2006-11-24 Thread Jim George
 cmd.exe is surprisingly more powerful than a lot of people realize
 though I still personally abhor it.
  -jkl


May be so, but you can't do things that you take for granted in Unix,
like running multiple commands in sequence with a semicolon. And, as
far as I know, the system function in most Win32 compilers does not
try to invoke a command interpreter, it just runs the program
specified, with arguments.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to set application icon

2006-11-23 Thread Jim George
Here's how I make it work (not sure if this is the right way):

int register_stock_icon(GtkIconFactory *icon_factory, const char
*name, const char *filename)
{
   GdkPixbuf *pixbuf;
   gchar *pathname;
   GError *error = NULL;

   pathname = g_strdup_printf(%s%s%s, PACKAGE_PIXMAPS_DIR,
G_DIR_SEPARATOR_S, filename);
   pixbuf = gdk_pixbuf_new_from_file(pathname, error);
   g_free(pathname);

   if (pixbuf == NULL) return -1;

   gtk_icon_theme_add_builtin_icon(name, -1, pixbuf);
   g_object_unref(pixbuf);

   return 0;
}

void add_icons()
{
   GtkIconFactory *icon_factory;

   icon_factory = gtk_icon_factory_new();
   register_stock_icon(icon_factory, gtkdisplay-main-icon,
display_icon24.png);
   register_stock_icon(icon_factory, gtkdisplay-main-icon-large,
display_icon48.png);

   gtk_icon_factory_add_default(icon_factory);
}

My makefile is set up so that PACKAGE_PIXMAPS_DIR points to
/usr/local/share/pixmaps/appname

I call add_icons before I create my window.

Finally, in glade-2, I set the named icon to gtkdisplay-main-icon,
which is equivalent to calling gtk_window_set_icon_name.

The advantage of this, over using gtk_window_set_icon_from_file is
that you can add multiple images at different sizes into the icon
factory under the same name, and GTK will pick the appropriate one to
display.

-Jim

(sorry, I sent this to tomas first, instead of the list)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: run a new application

2006-11-23 Thread Jim George
 shell to run the commandline specified.  I'm not sure the behavior on
 Windows, but I imagine it probably uses the windows shell to execute the
 command line.

There is no shell in Windows, and there is no argument parsing of the
command line, AFAIK
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Accompany index of deprecated symbols with GTK+ version?

2006-11-13 Thread Jim George
 However, I learned that for quite a number of methods it is
 a good idea to drop the deprecated ones and instead
 use the replacements (less buggy, better UI, better source code
 readability, less source code, better performance).
 Usually it should indeed make sense, because otherwise there
 would have been no need to implement a replacement ;-)

Why not use the deprecated keyword in the headers? Then at least gcc
will warn you if you use deprecated functions and typedefs. This could
be made as a macro which gets expanded only if you're using gcc, and
if you have something like GTK_WARN_DEPRECATED defined first.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problem with gsignal connect

2006-11-12 Thread Jim George
On 11/12/06, Naveen Kumar [EMAIL PROTECTED] wrote:


   Hi all,

   I am using GTK+-2.2.0 to develop my application in that i am using 5
 entries.. and 2 spin buttons and i have 1 button. When i click the button i
 nned to access all the data of entries and spin buttons to some variables.
 Using g_signal_connect i am able to pass only one object but how can i pass
 all the objects (5 entries + 2 spin buttons ) of click on the button.

   I dont want my objects as globel. I was able to do if i declare as
 globel..


  Plese help me regard this,,

 Thanks in Advance

 Naveen


Make a structure with several pointers, allocate the structure (do not
use a local variable, as you will face problems if the window/dialog
remains on screen when the local variable goes out of scope), fill the
structure with pointers to each control (spin buttons, etc) and pass
it to the button's signal handler.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: canvas, cairo and/or pixbufs? (was Re: Application Approach)

2006-11-05 Thread Jim George
I suppose one problem with the Pixbuf approach is that a Pixbuf is not
a drawable (unlike a Pixmap), so you either need to come up with your
own drawing routines for lines and such, or draw onto a Pixmap and use
gdk_pixbuf_get_from_drawable. If there's a better way, do let me know
(it's one area where my application could use some speedup - I use the
second approach).

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


Re: Passing custom parameters

2006-09-28 Thread Jim George
On 9/28/06, Sumedh [EMAIL PROTECTED] wrote:

 Gtk - C

 how to pass multiple arguments to a function from a widget. eg i have
 two text entry widgets

 and one button. What i want to do is that when i click the button i
 should be able to

 print(terminal) the contents of both the text entry widgets. Right now i
 can print from only one

 widget.



 g_signal_connect accepts only 4 arguments. The last one is the data
 pointer when i pass

 another data pointer as 5 arguments, gtk spits an error which says that
 only 4 arguments

 are valid.

Here's how I'd do it:

struct my_params {
  GtkEntry *e1, *e2;
  int my_other_param;
}

...

struct my_params mp;
mp.e1 = ...;
g_signal_connect(G_OBJECT(button), clicked, callback, mp);

...

void callback(GtkButton *b, gpointer data)
{
  struct my_params *mp = data;

  /* use mp-e1 and mp-e2 */
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Image missdisplayed using GdkPixmap

2006-09-24 Thread Jim George
On 9/24/06, Sebastien Roy [EMAIL PROTECTED] wrote:
 Image is not well written ...
 lines seems to be mixed ... Alignement is incorrect ..
 I suppose this is due to a wrong usage of dithering/depth parameters ...
 data is pointing to a rgb buffer ...
 the same call was working fine when writing directly to a windows instead of
 a newly created
 pixmap.
 Image may not be loaded from a file as it is received from network, that's
 while it's stored in a buffer.

 cnx-pixmap is a GtkPixmap*
 cnx-window is a TOPLEVEL window GtkWidget*


1.   cnx-pixmap = gdk_pixmap_new(0, cnx-data.header.width,
2.cnx-data.header.height, 16);
3.
4.
5.   gdk_draw_rgb_image(cnx-pixmap,
6.  cnx-window-style-fg_gc[GTK_STATE_NORMAL],
7.  0, 0,
8.  cnx-data.header.width,
9.  cnx-data.header.height,
10.  GDK_RGB_DITHER_NORMAL, cnx-data.data,
11.  cnx-data.header.width * 3);
12.
13.   cnx-draw_area = gtk_image_new_from_pixmap(cnx-pixmap, NULL);


 libgtk2.0-dev  2.8.20-1
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


If the goal is to create an offscreen buffer to later be blitted to a
window, you can modify line 1  2 to read

1.   cnx-pixmap = gdk_pixmap_new(GDK_DRAWABLE(cnx-window-window),
2.cnx-data.header.width,
cnx-data.header.height, -1);

PS, this also shows that cnx-window is a confusing name, perhaps
cnx-widget would work better.

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


GtkMenu doesn't recognize it's parents?

2006-08-30 Thread Jim George
In glade, I created a window, with a vbox. In the vbox, I created a
menu bar (called menubar), then add a menu called help and a menu
item called about, and set an event handler for the menu item. In
the menu event handler, I have code which does the following:

void on_about_cb(GtkMenuItem *menuitem, gpointer data)
{
GtkWidget *mainwindow;
GtkWidget *w;
w = GTK_WIDGET(menuitem);
do {
g_print(Widget ID is %s\n, 
gtk_widget_get_name(GTK_WIDGET(w)));
w = gtk_widget_get_parent(w);
} while (w != NULL);
}

The sequence printed out is

about
help_menu
GtkWindow

Somehow, the menu bar itself, the vbox and the main window are not in
the hierarchy.

I wrote this test because a call to gtk_widget_get_toplevel returned a
window that was *not* the top level window into which the vbox is
added.

Am I doing something wrong? Is this a glade bug? I noticed this in
programs which use glade code-generation as well as libglade. Or could
it be because the popup menu is a top-level window in it's own right?
I need a pointer to the parent window to which this menu belongs,
since the window has a structure with information, added using
g_object_set_data. Is there some other way to do this?

Thanks

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