Re: GTK with GCC 4.1 on Fedora Core 5

2006-05-04 Thread David Necas (Yeti)
On Wed, May 03, 2006 at 09:17:59PM -0600, Karihaloo, Ujjval wrote:
> ./configure: line 5028: syntax error near unexpected token `1.2.0,'
> ./configure: line 5028: `AM_PATH_GTK(1.2.0, ,'

configure was generated on a system lacking gtk+-devel,
AM_PATH_GTK() was undefined then and thus left unexpanded.
If you re-generate configure now, it should be OK.

Yeti


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


Re: GTK with GCC 4.1 on Fedora Core 5

2006-05-03 Thread David Necas (Yeti)
On Wed, May 03, 2006 at 05:02:07PM -0600, Karihaloo, Ujjval wrote:
> Here is another Error I am getting:
> 
> undefined reference to `gtk_menu_ensure_uline_accel_group'
> 
> Any idea?

You are trying to compile and link a Gtk+ 1.2 program with
Gtk+ 2.x -- and GCC is innocent here.

Compile and link the program with Gtk+ 1.2.  If you use
pkg-config, the module is called gtk+, not gtk+-2.0.

Yeti


--
Anonyms eat their boogers.
___
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 tell gtk to update only the GUI

2006-05-03 Thread David Necas (Yeti)
On Wed, May 03, 2006 at 10:03:34AM -0400, Tristan Van Berkom wrote:
> 
> If you need your application to refuse button & key press events
> (but still refresh itself graphicly), you should set the sensitivity
> of your buttons during the lengthly operation (and just ignore key
> press events).

I agree the right thing is normally to make the widgets
insensitive but it is possible to do what Mehmet requested
too with gtk_grab_add() on some `passive' widget -- see the
attached example.

Yeti


--
Anonyms eat their boogers.


===
#include 

static void
response(GtkWidget *dialog,
 gint response_id)
{
GtkWidget *progress;
gint i, n = 1000;

if (response_id != GTK_RESPONSE_APPLY) {
gtk_main_quit();
return;
}

progress = g_object_get_data(G_OBJECT(dialog), "progress");
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Calculating...");
gtk_grab_add(progress);

for (i = 0; i < n; i++) {
/* emulate a heavy calculation step */
g_usleep(50);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), i/(n - 1.0));
while (gtk_events_pending())
gtk_main_iteration_do(FALSE);
}
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), 0.0);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), NULL);
while (gtk_events_pending())
gtk_main_iteration_do(FALSE);

gtk_grab_remove(progress);
}

int
main(int argc, char *argv[])
{
GtkWidget *dialog, *widget;
GtkObject *adj;
GtkBox *box;

gtk_init(&argc, &argv);

dialog = gtk_dialog_new_with_buttons("Modal Trick", NULL, 0,
 GTK_STOCK_EXECUTE,
 GTK_RESPONSE_APPLY,
 GTK_STOCK_CLOSE,
 GTK_RESPONSE_CLOSE,
 NULL);
g_signal_connect(dialog, "response", G_CALLBACK(response), NULL);

box = GTK_BOX(GTK_DIALOG(dialog)->vbox);

widget = gtk_check_button_new_with_label("Check me!");
gtk_box_pack_start(box, widget, FALSE, FALSE, 0);

widget = gtk_entry_new();
gtk_box_pack_start(box, widget, FALSE, FALSE, 0);

adj = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_box_pack_start(box, widget, FALSE, FALSE, 0);

widget = gtk_progress_bar_new();
gtk_box_pack_start(box, widget, FALSE, FALSE, 0);
g_object_set_data(G_OBJECT(dialog), "progress", widget);

gtk_widget_show_all(dialog);
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


Re: Changing font of TreeView column header

2006-05-02 Thread David Necas (Yeti)
On Tue, May 02, 2006 at 05:30:49PM +0200, Hannes Mayr wrote:
> I'm looking for a way to set font and font size for the treeview column 
> header. Changing the font of the CellRenderer is no problem, but all 
> attempts to change the font of the treeview header didn't work.

It does not seem possible to get hands on the default column
header widgets, but if you replace them with your own header
widgets (gtk_tree_view_column_set_widget()) you should be
able to do anything you need.

Yeti


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


Re: GTK Image Widget, Inline animation Pixbufs

2006-04-30 Thread David Necas (Yeti)
On Sun, Apr 30, 2006 at 10:25:37PM +0100, Rob Kendrick wrote:
> On Mon, 2006-04-10 at 15:30 +0100, Rob Kendrick wrote:
> > 
> > Is it possible to seed a GdkPixbufAnimation from inline data created by
> > gdk-pixbuf-csource?  There doesn't appear to be the corresponding
> > function to gdk_pixbuf_from_pixdata().
> > 
> > Also, is it possible to stop an animation being displayed in a GtkImage
> > widget, and restart it later, without replacing the image in it with a
> > static one?
> 
> Nobody appeared do - did this message even reach the list?

It did, apparently no one wants to write: No.

The second is a matter of gdk_pixbuf_animation_get_static_image()
+ gtk_image_set_from_pixbuf() however.  Unless you want more
control over *which* animation frame will be displayed.
And in that case you'd better set the static image yourself
anyway.

And the first is a matter of generating csource for all
involved pixbufs and then using gdk_pixbuf_simple_anim_add_frame()
in a loop.  It's 2.8+ only and I have never actually tried
it, but this is what the documentation suggests.

So, not a big deal in either case.

Yeti


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


Re: GKeyFile Struct Missing?

2006-04-28 Thread David Necas (Yeti)
On Fri, Apr 28, 2006 at 09:35:49AM -0400, Brian Clow wrote:
> I'm developing an application that's heavily based on Glib for
> portability reasons.  I'm using GLib 2.10.1, and I'm trying to use the
> GKeyFile parser class, but I'm receiving an error when compiling both
> using visual studio 6.0 and gcc.  The error is "'keyFile' uses undefined
> struct '_GKeyFile'" (running visual studio on windows), or "variable
> 'GKeyFile keyFile' has initializer but incomplete type" (using gcc on
> Fedora).  
> 
> GKeyFile is typedef'd as a _GKeyFile struct in gkeyfile.h, but the
> _GKeyFile structure itself is never defined in any header file within
> the developer package...  Though I can see it's defined in the
> corresponding c file in the glib source package.  Am I missing
> something, or is there a problem with the header?  I've searched the
> mailing list/web and not found any reference to this whatsoever...

This is not a bug, it is a feature.

http://developer.gnome.org/doc/API/2.0/glib/glib-Key-value-file-parser.html#GKeyFile

Citing: The GKeyFile struct contains only private fields and
should not be used directly.

Not only you should not, but you cannot (unless you copy the
definitions to your sources, which obviously breaks badly
every time these internal structures are changed in GLib).
As a side effect you cannot declare GKeyFile variables, only
pointers to GKeyFile -- not that you could correctly
initialize such a variable anyway.

Yeti


--
That's enough.
___
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 catch mouse events from a GtkImage?

2006-04-26 Thread David Necas (Yeti)
On Wed, Apr 26, 2006 at 02:32:18AM -0300, Damián Cinich wrote:
> I have a little piece of code where I connect the signals
> corresponding to the mouse events to a GtkImage, and then the callback
> prints a message when it detect some of these signals, but it doesn't
> seems to work. If I connect them to a GtkWindow it works, but it
> doesn't with the GtkImage.

http://developer.gnome.org/doc/API/2.0/gtk/GtkEventBox.html
http://www.gtk.org/faq/#AEN573

> Additionaly, the goal of catch the mouse events is to get the x and y
> coordinates of the GtkImage for drag it arount the GtkWindow. Is it
> possible? How can i do this?

Forget the event box, put the image to a GtkLayout instead
(filling the whole window) and move the widget in the
layout's mouse event signal handlers.

Yeti


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


Re: correction in gtk-runtime 2.8.17

2006-04-25 Thread David Necas (Yeti)
On Tue, Apr 25, 2006 at 08:20:08AM -0600, Michael Torrie wrote:
> 
> Umm, because this is a list about developing applications using gtk.
> The "gtk runtime" is a collection of all the files needed so that an end
> user can run gtk applications.  GTK applications are of no value to
> anyone without the runtime.  You're confused, no doubt, because the gtk
> runtime ships installed by default on almost all linux distros (along
> with the developer libraries and headers).  But on MS Windows, end users
> have to install the gtk runtime in order to run gtk apps.  Hence people
> like Benoit have put together nice packages to make this slick and easy
> for Windows users.
> 
> This is the appropriate list for this announcement, as it has to do with
> app development, not gtk itself.

I apologize I was not clearer.

I understand prefectly what a Gtk+ runtime is *generally*.
However I cannot see the point of announcing

- every Gtk+ runtime under the Sun here (I do not say it is
  wrong to announce Gtk+ packages here, on the other hand
  try to imagine every existing Gtk+ runtime posting
  notification of every update here)

- and especially, `a Gtk+ runtime' without any reference
  which one is it, where one gets it, with no URL, no hint
  what bloody platform it is packaged for, simply nothing

So, if someone announces something, please, please make the
announcements actually *useful*.

Yeti


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


Re: correction in gtk-runtime 2.8.17

2006-04-25 Thread David Necas (Yeti)
On Tue, Apr 25, 2006 at 05:52:55AM +0200, Benoit Carpentier wrote:
> Hi everybody,
> 
> A new version of gtk runtime 2.8.17 is released.
> There was a trouble with Pango because the name of the folder is not 1.4.0 
> but 1.5.0 now. So the installer is changed and should work now.
> 
> Regards,
> 
> Benoît Carpentier, "GTKool"

Am I the only one who misses the point -- or at least
context -- of these announcements?  What the hell is[*]
`gtk runtime' and why is it announced here?

Yeti


[*] I can google it, of course (not that it is so easy --
Google can find a bazzillion things called gtk runtime).
But does it make such an announcement useful?


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


Re: Set up callbacks for dynamically created buttons

2006-04-22 Thread David Necas (Yeti)
On Sat, Apr 22, 2006 at 09:22:44AM +0200, Daniel Pekelharing wrote:
> 
> gint button_callback(GtkWidget *button, gint i)
> {
>   printf("Button %d was clicked\n", i);
> }
> 
> and connect to it like:
> 
> g_signal_connect(G_OBJECT(buttons[i]), "clicked", 
> G_CALLBACK(button_callback), (gpointer)i)

Please do not do this.  Perhaps it works on your i386 box,
but the macros GINT_TO_POINTER() and GPOINTER_TO_INT() exist
for a good reason.

> Alternatively if you want to pass some other data to the callback you
> could determine which button was pressed by calling
> gtk_button_get_label(GTK_BUTTON(button)
> from withing the callback to determine the label of the button.

Alternatively (and better), you can use g_object_set_data()
to attach arbitrary data to each button.

Yeti


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


Re: can't ercieve data passed to g_signal_connect

2006-04-21 Thread David Necas (Yeti)
On Fri, Apr 21, 2006 at 12:45:35PM +0100, rachit goel wrote:
>  
>  g_signal_connect ((gpointer)eventt[iter],"leave_notify_event", 
> G_CALLBACK (mouse_leave1),data1);
>  g_signal_connect ((gpointer)eventt[iter],"button_press_event", 
> G_CALLBACK (tab_click1), data1);
>  g_signal_connect ((gpointer)eventt[iter],"enter_notify_event", 
> G_CALLBACK (tab_mouse_enter1) , data1); 
>  
>  ...
>  
>  
>  void tab_click1(GtkWidget *widget,gchar* data1)
>  ...

Have a look at the prototypes of "*-event" callbacks.  The
second argument is the event, user_data is always the last
argument.

Yeti


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


Re: Scroll WIndow with GtkTreeView

2006-04-21 Thread David Necas (Yeti)
On Fri, Apr 21, 2006 at 01:00:10PM +0530, Sailaxmi korada  wrote:
> abnormal way. Is there any other way that I can make them move in sync...
> and be scrolled together. Without Viewport, the table is behaving in an
> My application requires Tree Widget and Table to be placed in same container

Since you have to fake the headers above the table anyway,
fake them above the treeview too and disable the real column
headers.

Yeti


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


Re: Scroll WIndow with GtkTreeView

2006-04-21 Thread David Necas (Yeti)
On Fri, Apr 21, 2006 at 10:47:24AM +0530, Sailaxmi korada  wrote:
>   In my application, I'm placing my TreeView widget in a scrolled window.
> When I'm scrolling down the list, my headers are getting scrolled up, so
> they are no more visible. Is there any way to retain the headers in the
> visible area of the window. Thanks in advance

http://www.gtk.org/faq/#AEN747

The answer is the same for treeviews.

Yeti


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


Re: can't ercieve data passed to g_signal_connect

2006-04-20 Thread David Necas (Yeti)
On Thu, Apr 20, 2006 at 08:25:57PM +0100, rachit goel wrote:
> i am having a problem 

You have the problem...

> i just can't recieve the data passed to signal handler using 
> g_signal_connect() .
> it always gets messed up.

...you did not post enough information.  What's your code?

Yeti


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


Re: Copy GtkListStore

2006-04-20 Thread David Necas (Yeti)
On Thu, Apr 20, 2006 at 05:42:51PM +0400, Dubravin Andrey wrote:
> How to create copy of GtkListStore, not object reference? Need to create
> copy of all data in GtkListStory.

Get the number of columns with gtk_tree_model_get_n_columns()
and their types with gtk_tree_model_get_column_type(),
create a new list store with gtk_list_store_newv().
Iterate over rows, in each row iterate over columns, fetch
values with the generic method gtk_tree_model_get_value()
ans store them with gtk_list_store_set_value().

Of course, the copy will be be still shallow.  If you want
a deep copy, you have to know how to deep-copy values like
objects or raw pointers (which is generally impossible) if
they can be present.

Yeti


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


Re: Random Number of Buttons

2006-04-20 Thread David Necas (Yeti)
On Thu, Apr 20, 2006 at 05:02:48AM -0700, 3saul wrote:
> 
> I'm wanting to know the best way to declare a random number of buttons for my
> gtk app. The number will changed depending on the argument passed to my app.

GtkWidget **buttons;

buttons = g_new(GtkWidget*, n);
for (i = 0; i < n; i++) {
   buttons[i] = gtk_button_new...
   gtk_button_whatever(GTK_BUTTON(buttons[i])...
   ...
   gtk_box_pack_start(GTK_BOX(some_box), buttons[i]...
}

Since this is a basic C skill, I suppose this is not the
problem -- so what is the problem?

Yeti


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


Re: problem: gtk_image gives critical error

2006-04-18 Thread David Necas (Yeti)
On Tue, Apr 18, 2006 at 03:42:43AM -0700, Deependra Shekhawat wrote:
> When I print the address of p in the funcl it prints a
> 
> address.
> In the callback function it also prints the same for 
> ptr.
> Then what's the problem.

The address does not change, but the part of stack it points
to is overwritten meanwhile.

> Also I use structures to pass data all the time to
> the callback function then there's no error but with
> this image widget there seems any problem.
> Please clarify if I have any alternatives 

Allocate the structures on heap (for example).

Yeti


--
That's enough.

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


Re: problem: gtk_image gives critical error

2006-04-18 Thread David Necas (Yeti)
On Tue, Apr 18, 2006 at 03:05:51AM -0700, Deependra Shekhawat wrote:
> Hello friends,
> This is my code:
> 
> struct splash
> {
>   GtkWidget *splash_image;
> };
> void func1(void)
> {
>   GtkWidget *img;
>   struct splash p;

This structure is created on stack and exists only until the
function func1 exits.

>   img=gtk_image_new();
>   p.splash_image=img; 
>   
>   g_signal_connect(G_OBJECT(button1),
>"clicked",
>G_CALLBACK(on_butt_clicked),
>(gpointer) &p);

Therefore &p becomes invalid immediately after you pass it
to g_signal_connect().

> }
> 
> void on_butt_clicked(GtkButton *button,gpointer data)
> {
>   struct splash *ptr;
>   ptr=(struct splash *)data;
> 
>   //some code is here
>   
>   //following line gives error at execution time.
> gtk_image_set_from_pixbuf(GTK_IMAGE((GtkWidget*)ptr->splash_image),buffer);
> }
> 
> Error is:
> (splash_screen:3549): Gtk-CRITICAL **: file
> gtkimage.c: line 772 (gtk_image_set_from_pixbuf):
>  assertion `GTK_IS_IMAGE (image)' failed

So, you are accessing some random piece of stack here.

Yeti


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


Re: g_object_set_data()

2006-04-12 Thread David Necas (Yeti)
On Wed, Apr 12, 2006 at 03:29:50PM +0200, jls wrote:
> 
>I try to set a glist to a name

What does it mean "set a glist to a name"?

>with the function
>g_object_set_data as follow :
> g_object_set_data(G_OBJECT(DirList),"dirlist",pWindow);
>   when I try to get this object with the g_object_get_data
>   function

And the code is?

>GLib-GObject-WARNING **: invalid uninstantiatable type
>`' in cast to `GtkCList'
>   Gtk-CRITICAL **: file gtkclist.c: line
>   2673 (gtk_clist_append): assertion `GTK_IS_CLIST (clist)' 
> failed 

You cannot get these errors from g_object_get_data().
So what you really do?

>   Who can I deal with those functions ? 

g_object_set_data(G_OBJECT(object), "key", pointer);
...
/* later */
pointer = g_object_get_data(G_OBJECT(object), "key");

Of course, object must still exist.

Yeti


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


Re: Rendering Problem

2006-04-12 Thread David Necas (Yeti)
On Wed, Apr 12, 2006 at 02:14:05PM +0530, Sailaxmi korada  wrote:
> 
>   I'm facing rendering problem with List store.

GtkListStore store is the model.  It does not render
anything.

GtkTreeView is the view, i.e. the thing that displays
something.  Its columns are completely unrelated to the
model columns -- until you explicitly relate them with cell
data function or column-renderer attributes association.

> I've 3 columns.
> 
>  
> 
> 1.Name
> 2.Value
> 3.Hex representation of the value
> 
>  
> 
> The value shall be displayed as binary buttons, that I'm able to do, but I
> want to suppress the display of integer value. Also the radio buttons should
> appear between Name and Hex Value. Right now, the rendering is like this
> 
>  
> 
> Name Value(in interger) Hex 16binary buttons.

The columns appear in the order you appended them into the
view (and if you use gtk_tree_view_insert_column(), they
appear in the positions you insterted them).  Is there
something that prevents you from packing the columns in the
order you need?

> I Don't want to display the value in integer and buttons should be in the
> middle.

The tree view displays columns you explicitly created and
added there.  Is there something that prevents you from not
creating the columns you do not want to display?

> Also whenever I'm clicking on refresh, the store is getting
> refreshed, but previous set of buttons are not getting erased, new ones are
> appended to this. How can I correct this problem

You probably do not update the rows but append new rows
instead.

Yeti


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


Re: Choosing a parent class

2006-04-11 Thread David Necas (Yeti)
On Tue, Apr 11, 2006 at 07:35:41PM +0200, Andreas Kotowicz wrote:
> I created a composite widget which consists of two frames, one of which
> holds a calendar and a second one which has some buttons. I now ask
> myself what is the right parent class to choose from. Is it GtkFrame?
> Why can't I just choose GtkWidget? are there any rules which classes to
> choose from for composite widgets? (I know, the tutorial says you should
> use the class which is most similar but that's now very precise).

Inherit from the class the widget actually *is*.  If you
inherit from GtkFoo, your widget will inherit the properties
and methods (this is what inheritance is about) --
gtk_foo_blow_up() can be expected to work with your new
widget too.  Well, life is not that simple, so in practice
not everything inherited makes always sense, but you get the
idea.

If it is a composite, then it *is* a GtkHBox, a GtkVBox,
a GtkTable, ... whatever, and all ther rest is just
contained in (members).  If it is a new type of container
(does not seem likely), inherit from GtkContainer.  If it is
something that just ties a group of separate widgets
together (think GtkSizeGroup), do not inherit from any
widget, but from GtkObject and make the widgets members.

Yeti


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


Re: Accessing filenames from file choosers

2006-04-11 Thread David Necas (Yeti)
On Tue, Apr 11, 2006 at 11:48:17AM +0100, Ross Clement wrote:
> I create a few file chooser dialogs. These were set up in glade. I can
> make the dialogs appear, use them, and then make them disappear again.
> What I can't do is fetch the selected filename from the dialog.
> 
> Looking around it seems that I should use the function
> 
> gtk_file_selection_get_filename((GtkFileSelection *)fs);

No, you should not.  GtkFileSelection is the old file
selector, GtkFileChooser is the new one, they are two
completely different classes.  You have to use
GtkFileChooser methods, see

http://developer.gnome.org/doc/API/2.0/gtk/GtkFileChooser.html

There you can easily find gtk_file_chooser_get_filename()
and gtk_file_chooser_get_filenames().

BTW your typecasting is evil.  You can always disable the
type checks GTK_FOO(foo) normally performs by defining
G_DISABLE_CAST_CHECKS, but you can never enable type checks
for raw (GtkFoo*)foo casts.

Yeti


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


Re: 3000 toggle buttons in a table?

2006-04-10 Thread David Necas (Yeti)

You do not set the renderer "active" property anywhere
except in the toggle_cell callback.  Therefore it always
renders *all* the cells in the last state (active or
inactive) some cell was toggled to.  You need either a cell
data func or to use gtk_tree_view_column_new_with_attributes()
to tell the renderer in which state it should render the
cells.  The "active" propery is not set in any automagic
way, *something* must set it before the cell is rendered.

It seems all my previous advices were vain too.  The tree
model should have exactly two columns: G_TYPE_STRING (the
label) and G_TYPE_UINT16 (the value), and you should use
a cell data function to set renderer properties to display
the guint16 value once as toggles, once as hex, in different
columns.

In fact, everything that the code sample I sent needs to add
to do *exactly* what you want is s/64/16/g, a hex-value
column (in the view, *not* in the model) + its cell data
function + its "cell-edited" callback.  Of course, I can
write the missing bits too -- it would be shorter than this
mail -- but that would not teach you fishing.

Please read the Gtk+ Tree View Tutorial to learn the
concepts first.

Yeti


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


Re: 3000 toggle buttons in a table?

2006-04-10 Thread David Necas (Yeti)
On Mon, Apr 10, 2006 at 12:40:12PM +0530, Sailaxmi korada  wrote:
> 
> Address(label)  1-16 radio buttons(represent the binary value) hex value
> 
> Data of 178 rows is filled in the above structure. But now when I'm
> selecting a radio button, all the radio buttons in the same column of 178
> rows are getting selected. Can anyone help me out

Do you really want *radiobuttons* i.e. only one bit being
always set?  Anyway, this can be hardly answered without the
code (moreover your description is pretty unclear -- do you
describe the model, the view, or what?).

You have a complete working code sample which sets bits in
some integers using treeview checkbuttons, I sent it in my
first reply (it only misses the hex value representation
part), so compare it with your code.

Yeti


--
That's enough.
___
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 get data into text view

2006-04-09 Thread David Necas (Yeti)
On Sun, Apr 09, 2006 at 05:23:43AM -0700, Deependra Shekhawat wrote:
> I am developing a application where-in I have to
> display the output of the command "tail -f
> /var/log/messages" into a text view.
> Now the problem is I know system() to execute the
> command but how do I re-direct the output of the
> command into Textbuffer so textview can display it.
> Once I do the above I also want the data displayed to
> be dynamically change when the file data increases
> (note I am using tail -f).

Scrap it, create a GIOChannel instead, plug it into the main
loop waiting on poll-in (i.e. G_IO_IN), and add the new
data to the text buffer in the callback function (more
GIOChannel discussion can be found in the list archives).

Yeti


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


Re: gtk_button_set_label ERROR

2006-04-06 Thread David Necas (Yeti)
On Thu, Apr 06, 2006 at 03:55:33AM -0700, 3saul wrote:
> GtkWidget *button1 = 0;

NULL can be hardly used as a GtkButton.

Yeti


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


Re: gtk_button_set_label ERROR

2006-04-06 Thread David Necas (Yeti)
On Wed, Apr 05, 2006 at 10:25:22PM -0700, 3saul wrote:
> 
> Whenever I call gtk_button_set_label I get the following error and the
> function does not succeed.
> 
> GTK-CRITICAL **: gtk_button_set_label: assertion 'GTK_IS_BUTTON (button)
> failed.
> 
> Is there a common reason for this error?

When you get a message telling you that something expected
to be a button is not a button, check your code if the thing
you pass really is a button, because it is not.  Is the
message so hard do decipher?

Yeti


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


Re: 3000 toggle buttons in a table?

2006-04-06 Thread David Necas (Yeti)
On Thu, Apr 06, 2006 at 12:24:18PM +0530, Sailaxmi korada  wrote:
>   I was trying to fulfill my requirement of 3000 toggle buttons, with list
> store...that was just fantasticBut I'm held up with another
> requirement...it is like this...
> The 16 toggle buttons in a row represent a hex value(they are binary
> representations). So whenever I toggle the checkbox, the corresponding hex
> value shall be displayed in a text entry and vice versa. I mean if I'm
> entering a hex value in text entry then the corresponding toggles shall be
> selected/deselected. Is it possible to achieve this using list storeif
> yes, can you suggest me an efficient way of doing it...

The bit checkbuttons and the hex representation are
visualizations of the same single list store column, namely
the integer holding the value (if they are not, you tree
model is misdesigned and you should fix it), so if you
update the value in the list store both representations are
updated.

Yeti


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


Re: Widget Type Checking

2006-04-05 Thread David Necas (Yeti)
On Wed, Apr 05, 2006 at 02:02:02PM -0700, Leon Ross wrote:
> 
> I have a vbox that contains x number of hboxs. Each hbox contains 2 items, a
> label and either a GTK_COMBO or a GTK_ENTRY.

GtkCombo is deprecated (and superseded by GtkComboBox).
Moreover, your layout seems to call for a GtkTable.

> I need to gather all of these "text fields" (using gtk_entry_get_text(..))
>  in the GTK_COMBO or GTK_ENTRY and just print them to the terminal.
> 
> My question is: is there a way to check whether the second item in the hbox
> is either a GTK_COMBO or GTK_ENTRY? by doing this I would know whether to
> use
> GTK_ENTRY(GTK_COMBO(item->entry)) or just GTK_ENTRY(item) for the parameter
> of gtk_entry_get_text.

You can use GTK_IS_ENTRY(), GTK_IS_COMBO_BOX() to check for
a type (or any subclass) -- or G_TYPE_FROM_INSTANCE() to get
the exact type of an object.

But if you have to scan the hierarchy to access your
widgets it can be a sign of not well designed code.

Yeti


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


Re: Update text label

2006-04-04 Thread David Necas (Yeti)
On Tue, Apr 04, 2006 at 05:01:06AM -0700, 3saul wrote:
> 
> Thanks a lot. However it's for a menu not a button...

I'm sorry (there is nothing like menu button, I chose the
wrong half of the term).

> This line:
> time_date1 = gtk_menu_item_new_with_mnemonic ("MENU");
> I've changed to
> time_date1 = gtk_menu_item_new_with_mnemonic (x);
> 
> this works, the menu button gets the string stored in x..however the string
> stored in x changes (with the current time).

GtkWidget *label;

label = GTK_BIN(menu_item)->child;
gtk_label_set_text_with_mnemonic(GTK_LABEL(label), x);

Yeti


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


Re: 3000 toggle buttons in a table?

2006-04-04 Thread David Necas (Yeti)
On Tue, Apr 04, 2006 at 01:47:10PM +0530, Sailaxmi korada  wrote:
> Why I said Tree view doesn't fit my requirement was, in a row I've to
> display label, 15 toggle buttons, text entry...
> Like this I've to fill the widgets in 178 rows. Displaying label is fine
> with List store...
> But how can I manage with text entry??

What about an editable column?  If it has to look exactly
like a classic text entry, then this is a problem, but if
any editable text field will do, treeview can do that
easily.

Yeti


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


Re: Update text label

2006-04-04 Thread David Necas (Yeti)
On Mon, Apr 03, 2006 at 08:00:57PM -0700, 3saul wrote:
> 
> I'm very very new to GTK programming. I've created a button which get's it's
> label from a variable. The text in the variable will change and I need to
> find out how to 'refresh' the label on the button.

gtk_button_set_label()

Please at least skim the API reference first, this should
be easy to find.

Yeti


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


Re: 3000 toggle buttons in a table?

2006-04-04 Thread David Necas (Yeti)
On Tue, Apr 04, 2006 at 10:55:08AM +0530, Sailaxmi korada  wrote:
> 
> Perhaps, my application requires 16 toggle buttons to be placed in each row,
> that represent a hex value. So I need not write 3000 callbacks for them,
> instead with one call back I can manage to calculate the hex value, based on
> the position of toggle button. Tree view doesn't fit my requirement.

The treeview example I sent does exactly that -- the toggle
buttons represents bits in some integers (64bit in that
case).  So why it does not fit?

Yeti


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


Re: 3000 toggle buttons in a table?

2006-04-03 Thread David Necas (Yeti)
On Mon, Apr 03, 2006 at 11:23:51PM +0200, Gus Koppel wrote:
> 
> On the other hand, filling the visible area of a treeview with 3000
> toggles would still result in suboptimal display performance.

Suboptimal maybe, OTOH if you try the example I attached to
my previous mail, you can see we are now in fractions of
a second -- at this point hacking together a new widget
makes sense only if it has other advantages (visual
presentation or behaviour hard to achieve with GtkTreeView,
perhaps with a more fitting API).

However the primary question is still what is this supposed
to be good for...

Yeti


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


Re: 3000 toggle buttons in a table?

2006-04-03 Thread David Necas (Yeti)
On Mon, Apr 03, 2006 at 01:40:25PM -0400, Tristan Van Berkom wrote:
> 
> Why not use GtkCellRendererToggle w/ GtkTreeView & GtkListStore ?
> 
> Or use a GtkListStore to select your data item and some togglebuttons
> and whatever other control widgets below your treeview (i.e. the single
> toggle button applies only to the selected row) ?
> 
> (Sure; writing treeview code is a pain, but its perfect for these
> "large dataset" situations).

It is not so much pain -- if your code actually does
something, the treeview bureaucracy is not substantial.
What bugs me more is the extra requested space at the right
side of the tree view when one goes mad and simply creates
a large grid of GtkCellRendererToggles.  Is it a bug?  Does
anyone observe it too?

Yeti


--
That's enough.



===
#include 
#include 

/* Someone put this into GLib... */
static guint64
g_rand_int64(GRand *rand)
{
guint64 low, hi;

low = g_rand_int(rand);
hi = g_rand_int(rand);

return low | (hi << 32);
}

static void
render_cell(G_GNUC_UNUSED GtkCellLayout *layout,
GtkCellRenderer *renderer,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
{
guint i = GPOINTER_TO_UINT(user_data);
guint64 x;

gtk_tree_model_get(model, iter, 0, &x, -1);
g_object_set(G_OBJECT(renderer), "active", (gboolean)((x >> i) & 1), NULL);
}

static void
toggle_cell(GtkCellRendererToggle *renderer,
gchar *path,
GtkListStore *store)
{
GtkTreeModel *model;
GtkTreeIter iter;
guint64 x, bit = 1;

g_print("Setting (%u, %u) to %s\n",
GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(renderer), "id")),
atoi(path),
!gtk_cell_renderer_toggle_get_active(renderer) ? "On" : "Off");

model = GTK_TREE_MODEL(store);
gtk_tree_model_iter_nth_child(model, &iter, NULL, atoi(path));

gtk_tree_model_get(model, &iter, 0, &x, -1);
bit = bit << GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(renderer), "id"));
if (gtk_cell_renderer_toggle_get_active(renderer))
x &= ~bit;
else
x |= bit;
gtk_list_store_set(store, &iter, 0, x, -1);
}

int
main(int argc, char *argv[])
{
GtkWidget *window, *treewidget;
GtkTreeView *treeview;
GtkListStore *store;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkCellLayout *layout;
GtkTreeSelection *selection;
GtkTreeIter iter;
GRand *rng;
guint i, nrows = 50;

gtk_init(&argc, &argv);

rng = g_rand_new();
store = gtk_list_store_new(1, G_TYPE_UINT64);
for (i = 0; i < nrows; i++) {
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, g_rand_int64(rng), -1);
}
g_rand_free(rng);

treewidget = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
treeview = GTK_TREE_VIEW(treewidget);
g_object_unref(store);

column = gtk_tree_view_column_new();
layout = GTK_CELL_LAYOUT(column);
for (i = 0; i < 64; i++) {
renderer = gtk_cell_renderer_toggle_new();
g_object_set_data(G_OBJECT(renderer), "id", GUINT_TO_POINTER(i));
gtk_cell_layout_pack_start(layout, renderer, FALSE);
gtk_cell_layout_set_cell_data_func(layout, renderer,
   render_cell, GUINT_TO_POINTER(i),
   NULL);
g_object_set(renderer, "activatable", TRUE, NULL);
g_signal_connect(renderer, "toggled", G_CALLBACK(toggle_cell), store);
}
gtk_tree_view_append_column(treeview, column);
gtk_tree_view_set_headers_visible(treeview, FALSE);

selection = gtk_tree_view_get_selection(treeview);
gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_add(GTK_CONTAINER(window), treewidget);

g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(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


Re: Callbacks and widgets

2006-03-27 Thread David Necas (Yeti)
On Tue, Mar 28, 2006 at 09:38:20AM +0200, Gonzalo Aguilar Delgado wrote:
> 
> Because receiver callback is getting only the receiver widget,

In addition, the callback gets an arbitrary pointer passed
as user_data to g_signal_connect().  A pointer can be used
to pass anything.

This is a very frequently asked question, search the
archives for discussion...

Yeti


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


Re: Issue with gtk+ 2.8.15 for win32

2006-03-25 Thread David Necas (Yeti)
On Sat, Mar 25, 2006 at 07:11:36AM -0500, Elden Armbrust wrote:
> The whole thing is quite confusing.  The code in the tutorial on the gtk 
> site uses destroy_event,

I can see only three signal connections there: to
"delete_event", "destroy", and "clicked" (of the button),
no "destroy_event".

> but uses g_signal_connect.
> Glade, however, appears to be using gtk_signal_connect.

I would not infer anything from glade-generated code as code
generation has been deprecated for a long time.

> This, I assume, 
> is why the tutorial code worked while the glade code didn't.

gtk_signal_connect() is a simple compatibility wrapper
around g_signal_connect() (g_signal_connect_closure_by_id(),
actually).  It should work equivalently.

Yeti


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


Re: stdio and/or network events?

2006-03-25 Thread David Necas (Yeti)
On Fri, Mar 24, 2006 at 10:01:33PM -0500, Dan McMahill wrote:
> 
> Is there a mechanism in gtk to detect the event of the app being fed 
> some input on stdin and/or via a network socket?

See GIOChannels.

Yeti


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


Re: Issue with gtk+ 2.8.15 for win32

2006-03-25 Thread David Necas (Yeti)
On Fri, Mar 24, 2006 at 09:11:26PM -0600, Nickolai Dobrynin wrote:
> 1.  Use "destroy" rather than "destroy_event" as the second argument to your
>  call.  "destroy" is a signal rather than an event.

That was confusing.

"destroy-event" (note the use of underscores was deprecated)
is a signal too.  Some signals are emitted as a consequence
of events, others are emitted on other occasions, but that
does not make the former less signalish.

The reason why callbacks connected to "destroy-event" are
almost always useless is different:
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidget-destroy-event

Yeti


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


Re: Issue with gtk+ 2.8.15 for win32

2006-03-24 Thread David Necas (Yeti)
On Fri, Mar 24, 2006 at 04:04:53PM -0500, Elden Armbrust wrote:
> >When exiting out of a program written in C using GTK+ 2.8.15, the 
> >process does not end (ever) but the window does close.

That is correct.  Gtk+ does not terminate applications just
because some of their windows was closed.  So the program
continues to run normally, it just do not display any
window now.

You need to connect to the "destroy" signal of the window
and do gtk_main_quit() (which makes gtk_main() return) in
the callback.  See the tutorial, section Getting started.

Yeti


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


Re: difference between g_signal

2006-03-24 Thread David Necas (Yeti)
On Fri, Mar 24, 2006 at 05:18:21PM +0100, Jerome Le Saux wrote:
> 
> GtkWidget* DirList, 
> 
> // my button
>  pMenuItem = gtk_menu_item_new_with_label(OPENDK);
>  g_signal_connect_swapped(G_OBJECT(pMenuItem), "activate",
> G_CALLBACK(OnOpenDkFile), DirList);

It isn't clear what value DirList has here, but let's suppose
it's OK.

>  gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem);
> 
> 
> 
> // my frame where I would to display my DirList widget
> scrolled_window=gtk_scrolled_window_new(NULL, NULL);
>   gtk_container_add(GTK_CONTAINER(pVbox), scrolled_window);
> DirList = gtk_clist_new_with_titles (3, DirTitles);

Please do not use GtkCList, use GtkTreeView.  Any tutorial
that taught you to use GtkClist now in 2006 should go to
the stamping mill.

>   g_signal_connect (G_OBJECT (DirList), "select_row", NULL, NULL);

The callback function definitely should not be NULL.

>   gtk_container_add (GTK_CONTAINER (scrolled_window), DirList);
> 
> .
> 
> // and my function OnOpenDkFile
> 
> int OnOpenDkFile( gpointer data)
> {
> char file[64][14];
> ...
> // I open a dialog box to set the file to be selected
> 
> for (i=0;i<64,i++)
> {
>  strcpy(file[i],"totot");
> }
> gtk_clist_append(data,file);
> }
> 
> and no problem during the compilation, but, either I obtain a seg fault when
> I try to add file in the data gpointer, or  GTK return me that it can't
> append into cllist . etc
> 
> How can I add element to the list.

Please convert the code to use GtkTreeView.

> And how the list can be displayed into the scrolled window ?

GtkTreeView supports scrolling natively (don't know about
GtkCList), so gtk_container_add(scrolled_window, treeview);
should suffice.

Yeti


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


Re: Theme not affecting titlebar on windows xp... help needed

2006-03-17 Thread David Necas (Yeti)
On Fri, Mar 17, 2006 at 03:37:11PM -0700, Plummer, Jeff-P56711 wrote:
> An application looks strange if the inside boxes have one theme, and the
> outsides window has a different theme (i.e. default windows titlebar,
> close, minimize, maximize buttons).
> 
> There has to be a way to make a windows application look like something
> other than a boring looking windows app.

Boring is not the word I would use, what about familiar,
consistent, predictable, or integrated?

Anyway, I do not know how or if decorations of individual
windows can be themed on Microsoft Windows, but Gtk+ has
nothing to do with it, you have to talk to the windowing
system.

Yeti


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


Re: more questions on struct, variables and objects

2006-03-16 Thread David Necas (Yeti)
On Fri, Mar 17, 2006 at 12:35:47AM +0100, Andreas Kotowicz wrote:
> so I have
> 
> typedef struct _FooApp
> {
>   gchar *app_name;
> 
>   GtkWidget *main_window;
>   .
>   .
> } FooApp;
> 
> which I use like this:
> 
> FooApp *
> create_app (void)
> {
>   FooApp *app;
> 
>   app = g_new0 (FooApp, 1);
> 
>   app->app_name = g_strdup ("My Foo App");
>   app->main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>   .
> }
> 
> now somewhere in my callbacks I want to create a messagebox:
> 
> void game_over(void *data)
> {
> 
> FooApp *app = (FooApp*)data;
> GtkWidget *msgBox;
> 
> gchar* message;
> message = g_strdup_printf("GAME OVER") ;
> 
> msgBox = gtk_message_dialog_new(GTK_WINDOW(app->main_window),
> GTK_DIALOG_DESTROY_WITH_PARENT,
> GTK_MESSAGE_WARNING,GTK_BUTTONS_CLOSE,message);
> 
> g_signal_connect_swapped(msgBox,"response",G_CALLBACK(destroy_game_over_cb),msgBox);
> 
> gtk_widget_show_all(msgBox);
> g_free (message);
> }
> 
> 
> but calling this messagebox I also want to modify some elements of app.

So why do you pass msgBox as *both* the object to connect to
and user_data to g_signal_connect_swapped() instead of just
passing app as user_data?

> 
> BTW, is there any difference in memory usage if I use
> 
> gchar* message;
> message = g_strdup_printf("GAME OVER") ;
> 
> msgBox = gtk_message_dialog_new(GTK_WINDOW(app->main_window),
> GTK_DIALOG_DESTROY_WITH_PARENT,
> GTK_MESSAGE_WARNING,GTK_BUTTONS_CLOSE,message);
> g_free (message);
> 
> 
> or 
> 
> 
> msgBox = gtk_message_dialog_new(GTK_WINDOW(app->main_window),
> GTK_DIALOG_DESTROY_WITH_PARENT,
> GTK_MESSAGE_WARNING,GTK_BUTTONS_CLOSE,"Game OVER");
> 
> ?

In the first case you allocate a useless copy of "GAME OVER"
just to free it again.

Yeti


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


Re: Handling Unix signals in a GTK+ application

2006-03-16 Thread David Necas (Yeti)
On Thu, Mar 16, 2006 at 03:55:50PM -0500, Tristan Van Berkom wrote:
> Well, it locks a mutex before accessing the GMainContext; so if gtk+ is
> compiled with threads... it should work... unless I'm on crack and mutexes
> are useless from signal handlers... but I dont think so.

Maybe I'm missing something, but how does this help when the
signal is delivered to the thread which is just inside
g_idle_add() (the only thread in a single-threaded program)?

Yeti


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


Re: Handling Unix signals in a GTK+ application

2006-03-16 Thread David Necas (Yeti)
On Thu, Mar 16, 2006 at 03:40:08PM -0500, Tristan Van Berkom wrote:
> >
> Yes sure, but why would you want to use a flag... when you can just call 
> g_idle_add
> *from the signal hanlder*

Is g_idle_add() really reentrant?  It does not look so at
the first sight.

Yeti


--
That's enough.
___
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 validate data entry

2006-03-16 Thread David Necas (Yeti)
On Thu, Mar 16, 2006 at 02:34:26PM +0530, shibu alampatta wrote:
>   i want to validate data enry to the entry widget. means, insome
> cases i want only digits be allowed to enter to the widget, or some
> times only alphabets and digits no other symbol ..  ie entering of
> unwanted characters need to be blocked. any help

If you looked at GtkEditable API documentation, you would
find an example of input conversion (validation is even
easier than that).

Yeti


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


Re: glib hash tables

2006-03-14 Thread David Necas (Yeti)
On Tue, Mar 14, 2006 at 11:48:56AM +0200, Adrian Vasile wrote:
> I'm having trouble understanding the GHashTable and it's member
> functions.

GHashTable just stores some untyped pointers.

Since it has no idea what type the stored data are, it
cannot make a copies of them and does not make copies of
them.  So...

> I've made the following simple code for testing purposes:
> 
> #include 
> #include 
> 
> typedef struct _client
> {
>   guint   id;
>   guint   win;
>   gchar   *name;
>   gchar   *number;
>   gbooleanmute;
> } client ;
> 
> static void print_hash_kv (gpointer key, gpointer value, gpointer
> user_data)
> {
>   gchar   *i = (gchar *) key;
>   client  *d = (client *) value;
>   
>   printf ("<-- %s -> %d , %s, %s in %d.\n", i, d->id, d->name, d->number,
> d->win);
> }
> 
> int main (int argc, char **argv)
> {
>   client  *c, *d;
>   GHashTable  *hash = g_hash_table_new (g_str_hash, g_str_equal); 
> 
>   if ((c = g_new (client, 1)) == NULL)

This cannot happen.  g_new() aborts program when it fails to
allocate the memory.

>   {
>   printf ("unable to alloc c");
>   return 1;
>   }
>   
>   c->id = 2;
>   c->win = 3;
>   c->name = g_strdup ("client1");
>   c->number = g_strdup ("0123456789");
>   c->mute = TRUE;
>   
>   printf ("--> %d , %s, %s in %d.\n", c->id, c->name, c->number, c->win);
>   
>   g_hash_table_insert (hash, g_strdup ("2"), c);

I wonder who is going to free the key.  Perhaps you intended
to use g_hash_table_new_full() and supply a key destroy
function?  Or just get rid of the g_strdup() if keys are
constant strings.

>   g_free (c);

Now the table contains a pointer to freed memory at key "2".
The c you freed here is the same chunk of memory as is
stored in the table.  Remember, no copies, it just stores
some pointer.

>   hash = g_hash_table_ref (hash);

I wonder what is this intended to mean.  You already own
a reference to the hash table -- the initial one.  And
I cannot see any g_hash_table_unref() here, so you will have
two *two* reference to the hash table to the end of program.
Why?

>   if ((d = g_new (client, 1)) == NULL)
>   {
>   printf ("unable to alloc d");
>   return 1;
>   }
> 
>   d->id = 1;
>   d->win = 2;
>   d->name = g_strdup ("client2");
>   d->number = g_strdup ("9876543210");
>   d->mute = FALSE;
>   
>   printf ("--> %d , %s, %s in %d.\n", d->id, d->name, d->number, d->win);
>   
>   g_hash_table_insert (hash, g_strdup ("1"), d);

Again, the key is likely to be leaked.

>   g_free (d);

Again, this makes the item at key "1" invalid (pointer to
freed memory).

>   printf ("done inserting. \n");
> 
>   g_hash_table_foreach (hash, print_hash_kv, NULL);
> 
>   return 0;
> }
> 
> The thing is that the output is quite annoying:
> --> 2 , client1, 0123456789 in 3. 
> --> 1 , client2, 9876543210 in 2.
> done inserting.
> <-- 1 -> 0 , client2, 9876543210 in 2.
> <-- 2 -> 0 , client2, 9876543210 in 2.

The memory block orignially allocated for c (and then freed)
was reused for d.  After d was freed too it was not reused
for anything else yet -- you'd get totally bogus values then.

> My question is how do I manage to get the hash table to actually give me 
> back all the my inserts

Don't destroy them.

Yeti


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


Re: GtktreeView & Model segmentation fault

2006-03-13 Thread David Necas (Yeti)
On Mon, Mar 13, 2006 at 11:16:04AM -0800, Van H Tran wrote:
> I get a "Segmentation fault" in a gtktreeview i'm
> using. Basically, it's a Treeview with expandable
> folders (like a file browser) 
> 
> The problem is: The program crashes very randomly when
> i just try to click to expand/collapse the folders,
> particularly when the tree has depth >= 3. After a
> certain number of clicks (sometimes 10, sometimes
> more), i get a segmentation fault. Inserting debugging
> messages doesn't help either as it also crashes at
> some random instruction...
>  So i'm just clueless and can't track what exactly
> went wrong here. The randomness really buggers me.
> 
> Does anyone have any advice on this? Is there some
> error with my GtkModel or memory allocation, possibly?
> Some common error with GtkTreeView that i am missing?
> Or what tools can i use track this problem down? 
> The code is rather messy so i don't want to post it
> here.

Well, I'd recommend to use valgrind in such case.  If it is
indeed a memory problem chances are you'll get it reported
where it occurs instead where the app finally crashes.

Yeti


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


Re: reinitialize application

2006-03-10 Thread David Necas (Yeti)
On Fri, Mar 10, 2006 at 08:57:09PM +0100, Andreas Kotowicz wrote:
> I tried the destroy and construct way:
> 
> void
> on_button4_clicked (GtkButton   *button,
> gpointer user_data)
> {
> 
>  gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
> 
>  *GtkWidget *window1;
>  window1 = create_window1 ();
>  gtk_widget_show (window1); 
> }
> 
> the widget gets destroyed, but the app closes.

If you have gtk_main_quit() connected to the "destroy"
signal of the window, you should not be surprised that it
does what you told it to do (quits Gtk main loop when the
window it destroyed).

Gtk itself definitely does not terminate your app when some
window is closed, you had to explicitely set it up so.

Yeti


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


Re: reinitialize application

2006-03-10 Thread David Necas (Yeti)
On Fri, Mar 10, 2006 at 07:40:25PM +0100, Andreas Kotowicz wrote:
> 
> so what I'm looking after is a way to clear all those entry fields any
> other variables which might have changed during the running program. 
> so just reinitialize the app :)

If you want to reset state of some widgets to a predefined
state, just iterate through them and set their state.  Or
destroy them and construct anew.

However, if you want to `clear any other variables that
might have changed', that is get your program to the state it
started in, you can actually restart it.  Save the contents
of argv when the program starts, and then execv() self to
restart.  Of course, there are still things like open files
that are not reset this way and other possibilites of subtle
problems.  You can take care of them manually or use other
means to reset them (e.g., fcntl() to set close-on-exec flag
on open files).

Yeti


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


Re: Closing Main window with out Closing the child window

2006-03-10 Thread David Necas (Yeti)
On Fri, Mar 10, 2006 at 09:51:03AM -0500, Prabhakar Muthuswamy wrote:
>  I have a main window (which is a login screen) after I am
> authenticated this main window should go away and other window should
> pop up. As of now I am able to pop the second window but the main window
> is hiding behind the second window. Is there an API which would allow me
> to close the main window with out closing the entire application?

Closing any window does not terminate the application,
unless you set it up so.  And there is no main window (well,
your app perhaps has a main window, but that concept is
introduced by the app, not by Gtk+).

So, do not terminate the app in the "destroy" callback of
the window, or disconnect the callback, or just stop doing
the thing that makes your app quit.  Then you can simply
destroy the first window when you show the second one.

Yeti


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


Re: Left side widget of Evolution mail client

2006-03-09 Thread David Necas (Yeti)
On Thu, Mar 09, 2006 at 01:23:38PM -0500, Carlos Savoretti wrote:
> Hi all
> 
> Can anyone tell me what kind of widget is used in the left
> side of the main window of Evolution mail client ?

The source code of Evolution is freely available, so anyone
can tell by looking there (but no, I did not look there for
you because I believe people learn more by finding out
themselves).

Yeti


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


Re: change picture and text on button click

2006-03-04 Thread David Necas (Yeti)
On Sat, Mar 04, 2006 at 09:09:26PM +0100, rupert wrote:
> ...
> but I only get some error in the bash:
> 
> (spielkram:7144): GLib-GObject-WARNING **: IA__g_object_get_valist: object
> class `GtkButton' has no property named `pixbuf'
>
> ...
> 
> void bild_aktualisieren(GtkImage *bild)
> 
> ...
> 
> int main(int argc, char **argv)
> {
> ...
> knopf = g_object_new(GTK_TYPE_BUTTON, "label", "fester", NULL);
> ...
> g_signal_connect(knopf, "clicked", G_CALLBACK(bild_aktualisieren),
> NULL);

So, bild_aktualisieren() gets `knopf' as its argument, which
is a GtkButton and the error message is right.

You do not even pass the image to change in the
g_signal_connect() userdata argument (it is NULL), so
I wonder how you expected bild_aktualisieren() to get the
image.  But even if you passed bild as the last argument of
g_signal_connect()

 g_signal_connect(knopf, "clicked", G_CALLBACK(bild_aktualisieren), bild);

the callback would get it as the *last* (second, in this
case) argument, or you would have to use
g_signal_connect_swapped() to swap the arguments instead

A few more notes.  Using g_object_set() and g_object_get()
for everything can seem generic and cool, but it gives you
absolutely no compile time type checking -- unlike direct
getters and setters like gtk_image_set_from_pixbuf() (that
are also somewhat faster, but this is not the main point).
The line

g_object_get(bild, "pixbuf", &pixbuf, NULL);

is redundant as you immediately assign something else to the
pixbuf variable on the next line -- what you are trying to
acomplish by that?  Should your programs ever be open-source
and/or internationalized, stop using national symbol names
and/or messages right now, it will save you much grief later.

Yeti


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


Re: box around a GtkLabel

2006-03-03 Thread David Necas (Yeti)
On Fri, Mar 03, 2006 at 01:09:39PM -0500, Zvi Sebrow wrote:
> I'm trying to draw a box around one or more GtkLabels.
> when i use a GtkDrawingArea, the box comes out fine, 
> but the labels are covered by the inside of the box. 
> is there a way to set a GtkDrawingArea to be transparent,
> so it wont cover up any GtkLabels?
> 
> or is there another, simpler way of doing this?

Yes, it is: just draw the text with gdk_draw_layout() on the
drawing area.

Yeti


--
That's enough.
___
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 underline the text of a button [solved]

2006-02-26 Thread David Necas (Yeti)
On Sun, Feb 26, 2006 at 11:03:24PM -0700, Gezim Hoxha wrote:
> 
> Thanks for this. Line two of the code doesn't work though because there
> needs to be an argument when gtk_label_new is called, this worked
> however:
>   GtkWidget *pulse_label  = gtk_label_new ("Temp Text");

You can just pass NULL.

Yeti


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


Re: GSList and g_filename_from_uri free memory problem

2006-02-23 Thread David Necas (Yeti)
On Thu, Feb 23, 2006 at 10:19:36AM +0100, Colossus wrote:
> 
> I don't have to store pointers to freed memory but the filename
> without file:// and escaped sequences that g_filename_from_uri gives 
> me back !

It does not matter whether you free the memory before or
after g_slist_prepend().  The result is exactly the same:
the list contains a pointer to freed memory.

Yeti


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


Re: GSList and g_filename_from_uri free memory problem

2006-02-23 Thread David Necas (Yeti)
On Thu, Feb 23, 2006 at 09:46:14AM +0100, Colossus wrote:
> David Necas (Yeti) wrote:
> 
> >You have to free it yourself before freeing the list or
^^
> >individual elements.
   ^^^

> I did it with g_free (filename) but when I use g_print (gslist->data)
> I get corrupted results.

filename and gslist->data are pointers to *the same* memory.
When you free the memory -- it does not matter whether you
do g_free(filename) or g_free(gslist->data) -- both pointers
will point to the same freed memory.

> >GSList can store some untyped pointers.  It has no idea of
> >what they point to (or if they are real pointers at all),
> >therefore it cannot make copies of the data, cannot free
> >them, etc.  It just stores some untyped pointers.
> 
> So how to solve the problem ?

Since the problem seems to be an incorrect assumption of how
GSList works and I cannot describe how it actually works more
clearly than above, then either by letting someone with
better English skills to explain it or by you trying harder
to understand me.

Yeti


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


Re: GSList and g_filename_from_uri free memory problem

2006-02-23 Thread David Necas (Yeti)
On Thu, Feb 23, 2006 at 09:22:30AM +0100, Colossus wrote:
> 
> gchar **array = NULL;:
> array = gtk_selection_data_get_uris ( data );
> while (array[len])
> {
>filename = g_filename_from_uri ( array[len] , NULL, NULL );
>Files_to_Add = g_slist_prepend ( Files_to_Add , filename );
>g_free (filename);
>len++;
> }
> 
> The problem is that when I free filename the GSList data becames 
> corrupted, but the docs says that g_filename_from_uri returns 
> allocated memory, so what can I do ? Once I put filename in the GSList 
> I don't need it anymore.

I suppose you do need something when you store it to
a GSList.  What is the point of storing pointers to freed
memory to a GSList?

> Is filename freed when I call g_slist_free ?

You have to free it yourself before freeing the list or
individual elements.

GSList can store some untyped pointers.  It has no idea of
what they point to (or if they are real pointers at all),
therefore it cannot make copies of the data, cannot free
them, etc.  It just stores some untyped pointers.

Yeti


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


Re: defective GTK app crashes gnome

2006-02-18 Thread David Necas (Yeti)
On Fri, Feb 17, 2006 at 10:01:54PM -0500, Freddie Unpenstein wrote:
> 
> > Maybe a stupid question, but have you tried Ctrl-Alt-KP_Divide to
> > ungrab or the more brutal Ctrl-Alt-KP_Multiply to kill the naughty
> > client? (if you have these enabled)
> 
> Here's probably an even more stupid question.  They exist?!?  ;)

IIRC in old XFree86 they were even hardcoded to Xserver
(like the other Ctrl-Alt-Foo special Xserver actions).

> So how do you enable them, if they're not already enabled?

They are defined in compat/xfree86 XKB file, so make sure
it's included, but it should be so by default.

Yeti


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


Re: defective GTK app crashes gnome

2006-02-12 Thread David Necas (Yeti)
On Sat, Feb 11, 2006 at 09:43:51AM -0500, Freddie Unpenstein wrote:
> 
> I've managed to trash X while playing with widgets that use grabs...

Maybe a stupid question, but have you tried
Ctrl-Alt-KP_Divide to ungrab or the more brutal
Ctrl-Alt-KP_Multiply to kill the naughty client? (if you
have these enabled)

Yeti


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


Re: Resize Event

2006-02-09 Thread David Necas (Yeti)
On Thu, Feb 09, 2006 at 02:51:02PM +0100, Philippe CHAUVAT wrote:
> I wrote a program (Win32, VC++, Gtk2.8.10rc1, GLADE) which is describe 
> like the following tree:
> - Window
>   - Vbox
> - ScrolledWindow
>   - Viewport
> - DrawingArea with GL support (gtk_widget_set_gl_capability 
> func) => named D.A.
>   - button
>   - and other things
> 
> 
> I need to setup some basic function like zoom, pan and so on.
> For this, I need to detect the "resize" event of the window. When the 
> window grow up, just because the D.A. must grow up too, 
> "size_request_event" is launched and everything is fine.
> 
> *But* when window is down resized, no event seems to be launch. Does 
> anyone know which event with wich Widget to manage this ?

IIUC you are looking for "size-allocate"; "size-request" is
emitted when widget is asked for preferred size, but
"size-allocate" when it's told the actual allocation.

Yeti


--
That's enough.
___
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 GTK+ on Mingw&msys? what i need to begin with GTK+?

2006-02-06 Thread David Necas (Yeti)
On Mon, Feb 06, 2006 at 06:35:41AM +, i VS šĚźÖ¸Ž wrote:
> now i'm starting programming with GTK+ in order to support multi 
> platform(like Unix, Linux, Windows, MacOS) about which run the my 
> appllications.
> but i get to be difficult from first step. 
> that looks a base.
> 
> i would build and install GTK+ API packages(from sources) on Mingw 
> including msys under Windows xp.
> why? because of   i think my GTK+ applications have to be compiled and 
> build, 
> after doing which they  have to be run at anywhere(that is, linux version 
> do on linux, , windows version do on windows..) -

Why do you think you have to compile Gtk+ yourself,
especially that you have to start with that?  Of course, you
have to compile your app.  But the former does not follow
from the latter.

> i can know how to 
> cross-compile for each different platfrom from Mingw wegsite.

IAFAIK this was successfuly tried with cross-compilation for
MS Windows on U*ix.  But cross-compilation for Mac OS X on
MS Windows with MinGW is something that -- if ever tried --
will require much deeper knowledge than what configure and
Makefile.in are for (no offence please).

Since you need the target system for testing anyway, start
with compilation for each system on that system, and once it
works, you can attempt cross-compilation.

> i done as following 
> "http://developer.gnome.org/doc/API/2.0/gtk/gtk-building.html";.
> so i done following on command prompt of msys :
> 1. unzip GTK+ 2.8.9 source package 'gtk+-2.8.9.tar.gz' at /sdk/gtk 
> directory i made
> 2. i move my path to gtk+-2.8.9 source topleve folder '/sdk/gtk/gtk+-2.8.9' 
> which be made by above unzipping.
> 3../configure
> this looks working some of many  processing.

And it ended with some error...

> 4.make
>  this display a message as "*** No targets specified and no makefie found. 
> Stop."

...because no Makefile was created.  Without that error it's
hard to say.

> so i done as 'make -f Makefile.in', this case make display as "*** missing 
> separator. Stop"
> the missing separator of Makefile.in is @SET_MAKE@ at source line 15 

Please read some tutorial on the GNU automake/autoconf/...
toolchain (there are plenty of them).

> i can don't more.
> please tell me what i need to begin with GTK+?

Install it, for example from GladeWin32
(http://gladewin32.sourceforge.net/).

> and how to do for which load GTK+ API architecture on Mingw&msys (not GTK+ 
> for Win32 package, i know it purpose) ?

I'm sorry but this sentence is totally unintelligible.

Yeti


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


Re: Simple GDK app segfaults for unknown reason

2006-01-20 Thread David Necas (Yeti)
On Fri, Jan 20, 2006 at 11:36:38AM +0100, László Monda wrote:
> Hi List,
> 
> I've just written a simple GDK application that basically converts an
> input JPEG image to a BMP using a Pixbuf.
> 
> Unfortunately it segfaults.
> 
> 8<
> 
> #include 
> 
> int main(int argc, char *argv[])
> {
> gdk_init(&argc, &argv);
> 
> GError **error = NULL;
> GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file("input.jpg", error);
> gdk_pixbuf_save(pixbuf, "output.bmp", "bmp", error);
> 
> return 0;
> }
> 
> 8<
> 
> Could someone here explain why does it segfault?

The list of gdk_pixbuf_save() options must be
NULL-terminated, that means if you don't pass any options
you still have to pass the terminating NULL.  The use of
GError is errorneous too, but since you effectively pass
NULL (and thus ignore errors), it does not cause the crash.

Yeti


--
That's enough.
___
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 popup menus and highlighted items in TreeView

2006-01-19 Thread David Necas (Yeti)
On Wed, Jan 18, 2006 at 10:02:30PM -0600, Gabriel Burt wrote:
> I have a TreeView (F-Spot's tag list) that has a popup menu.
> 
> If I have a tag (row) selected and then right-click on a different tag,
> it first pops up the menu, then (the default handler) selects all the
> tags in between the two tags.
> 
> The problem is I need to know how many tags are highlighted to customize
> the popup menu, but because of the ordering of these operations, I get
> the wrong value.  Is the only answer to not use the default handler and
> do the selection logic (shift/ctrl) myself?

g_signal_connect_after() does not help?

Yeti


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


Re: Finding memory leaks

2006-01-18 Thread David Necas (Yeti)
On Wed, Jan 18, 2006 at 04:22:09PM -0300, Juan Pablo wrote:
> I've made some progress on my program and now i would like to check for
> memory leaks.
> 
> Do you recommend any way or program in special for doing this?

Valgrind (http://valgrind.org/).

Yeti


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


Re: Differences beetwen ref and weak ref

2006-01-17 Thread David Necas (Yeti)
On Tue, Jan 17, 2006 at 05:35:33PM +, Uzytkownik wrote:
> I'm so sorry - when should I use weak reference?

Weak reference is a method to get notified that an object
was destroyed.  Maybe it is better to not think about them
as about references at all.

When you take a [real] reference on an object, its refcount
increases and it will not be destroyed even if everything
else releases its references -- because of your reference.
Sometimes you want to keep a pointer to an object while not
preventing it from destruction.  If you simply removed the
g_object_ref(), you'd have a pointer, but you would not know
whether it is still valid.  So you use a weak reference/weak
pointer.

Yeti


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


Re: key press events and gtk_dialog_new_with_buttons()

2006-01-11 Thread David Necas (Yeti)
On Wed, Jan 11, 2006 at 06:54:46PM +1100, Richard Gipps wrote:
> I applied this function to the three entries but it only works on one of 
> them (the first entry I apply it to).  Note that I have tried them all on 
> their own (by commenting out the other two) and they work fine.  Any ideas?

#include 

int
main(int argc, char *argv[])
{
GtkWidget *dialog, *entry;
gint response;

gtk_init(&argc, &argv);
dialog = gtk_dialog_new_with_buttons("Entry Activate", NULL, 0,
 GTK_STOCK_CANCEL,
 GTK_RESPONSE_CANCEL,
 GTK_STOCK_OK,
 GTK_RESPONSE_OK,
 NULL);
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

entry = gtk_entry_new();
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), entry);

entry = gtk_entry_new();
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), entry);

entry = gtk_entry_new();
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), entry);

gtk_widget_show_all(dialog);
response = gtk_dialog_run(GTK_DIALOG(dialog));
g_print("Response: %d\n", response);
gtk_widget_destroy(dialog);

return 0;
}

This works.

Yeti


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


Re: key press events and gtk_dialog_new_with_buttons()

2006-01-10 Thread David Necas (Yeti)
On Tue, Jan 10, 2006 at 08:34:36PM +1100, Richard Gipps wrote:
> Thanks for your response.  I tried your suggestion, but it didn't 
> seem to work.  Note that I have three entry widgets in the dialogue box and 
> the cursor can be inside of any of them when I want the enter key to act 
> like the OK button.  Would that make any difference?

Yes it makes a difference, see gtk_entry_set_activates_default().

> Also note that I am writing this in (for) Windows.

That should not make any difference, at least it works for
me.

Yeti


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


Re: key press events and gtk_dialog_new_with_buttons()

2006-01-10 Thread David Necas (Yeti)
On Tue, Jan 10, 2006 at 12:51:27PM +1100, [EMAIL PROTECTED] wrote:
> I have created a dialogue window using gtk_dialogue_new_with_buttons (see 
> below)
> and attached a callback function to the "response" event.
> 
> gtk_dialog_new_with_buttons("Y-Axis Scales",
> NULL,
> GTK_DIALOG_MODAL,
> GTK_STOCK_CANCEL,
> GTK_RESPONSE_CANCEL,
> GTK_STOCK_OK,
> GTK_RESPONSE_OK,
> NULL);
>
> If the Enter key is pressed I want the dialogue to act as if the OK button has
> been clicked and if the Escape key is pressed to look like the Cancel button 
> has
> been clicked.  What is the best way to go about doing this?

Add

  gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

to make Enter activate OK instead of Cancel.
Escape already works.

Yeti


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


Re: GtkTreeView only displays one column

2006-01-09 Thread David Necas (Yeti)
On Mon, Jan 09, 2006 at 02:23:08PM +, Tony Houghton wrote:
> 
> I've distilled my code down to a standalone program. Hopefully now
> someone else will easily be able to play with it and see what's wrong.

The column becomes visible when you
(a) do not set sizing mode to GTK_TREE_VIEW_COLUMN_FIXED
(b) actually give the first column a fixed width > 0 with
gtk_tree_view_column_set_fixed_width() 
While that makes kind of sense I cannot say I understand
the logic behind... but I hope it helps anyway.

Yeti


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


Re: Changing the tab order in a dialog

2006-01-09 Thread David Necas (Yeti)
On Mon, Jan 09, 2006 at 03:07:14AM -0800, Suresh Stephen wrote:
>  I have created a GUI using GTK and i have created a dialog box which 
> will contain multiple entries. In the following fashion
>  
>  entry 1entry 5
>  entry 2entry 6
>  entry 3entry 7
>  entry 4ebtry 8
>  
>  1,2,3 indicate the order in which i have added the text entries into the 
> widget
>  When i press tab to navigate across the text entries the control moves from 
> entry 1 to entry 5 then to entry 2 and then to entry 6 and so on. I want the 
> tab order to move from entry 1 to entry 2  and then to entry 3 and so on. Any 
> one knows how to do it ,any help would be great.

You are probably looking for gtk_container_set_focus_chain().

Yeti


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


Re: gtk label size

2006-01-02 Thread David Necas (Yeti)
On Mon, Jan 02, 2006 at 06:24:03PM +0100, Fernando Apesteguía wrote:
> Suppose that the window where labels are located is size-fixed. The problem
> comes when I create the label longer enough (Great Mistake!!!) for most
> of languages...
> Normally the text is something like "x" but in some .po files, this is
> translated as "xx xxx  "
> 
> What is the standard way to handle this? Should I  let the string to be
> truncated by the size of the label? If this is the case,  would be a good
> idea to set a complete tool-tip text?

The standard way is to not make windows/labels/whatever
fixed-size.  If this isn't possible, use ellipsization --
see gtk_label_set_ellipsize().  Whether to add or not to add
a tooltip depends on situation, but generally it's a good
idea.

Yeti


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


Re: building modules/plugins (GModule) in a portable way

2005-12-31 Thread David Necas (Yeti)
On Thu, Dec 29, 2005 at 01:15:02PM +0100, Olivier Sessink wrote:
> we have excellent portable GModule functions for module loadingin glib,
> but how do we compile them in a portable way? I thought libtool was the
> solution, but I have little success there.
> 
> My plugin uses symbols that are exported by the application, and the
> plugin exports a single symbol to the application.
> 
> I therefore, compile my application with
> 
> libtool -mode=compile $CC blabla compile flags
> 
> and then I link it with
> 
> libtool -mode=link $CC -export-dynamic blabla link flags
> 
> I compile the plugin with
> 
> libtool -mode=compile $CC blabla compile flags
> 
> and I link the plugin with
> 
> libtool -mode=link $CC -module -export-dynamic blabla link flags
> 
> but linking fails If I add '-shared' to this command, it succeeds on
> Linux, but it fails on OSX...
> 
> So what is the portable way to compile plugins?

What works is to compile most of your app as a shared object
(== library) and make your app executable a more or less
trivial program that links to it.  At least it works on
Linux, *BSD, OS X, and Solaris where I tried that.

On these systems (where libtool's $allow_undefined_flag is
supported) it also isn't necessary to link modules with
anything the program links to, greatly improving linking and
dlopen()ing speed.  Of course, it changes symbol resolution
(to better in my opinion).

Well, this may not be what you want and it may not work
out-of-the-box on Win32 (AFAIK neither does the method you
described).

Yeti


--
That's enough.
___
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 a button to be activated when i press the enter key

2005-12-31 Thread David Necas (Yeti)
On Sat, Dec 31, 2005 at 03:39:59AM -0800, Suresh Stephen wrote:
>   Just wanted to know one thing , for example consider i have a text 
> entry and two buttons ok and cancel . Wat i want to perform is after adding 
> some data to the entry i just want to press enter so that the ok button is 
> pressed, if any one knows a way to solve this i will be very thankful for 
> that.

Most likely you want to use gtk_entry_set_activates_default().


#include 

int
main(int argc, char *argv[])
{
GtkWidget *dialog, *entry;
gint response;

gtk_init(&argc, &argv);
dialog = gtk_dialog_new_with_buttons("Entry Activate", NULL, 0,
 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 GTK_STOCK_OK, GTK_RESPONSE_OK,
 NULL);
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

entry = gtk_entry_new();
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), entry);

gtk_widget_show_all(dialog);
response = gtk_dialog_run(GTK_DIALOG(dialog));
g_print("Response: %d\nText: %s\n",
response, gtk_entry_get_text(GTK_ENTRY(entry)));
gtk_widget_destroy(dialog);

return 0;
}


Otherwise you can connect to "activate" signal of the entry
and perform arbitrary user-confusing action in the callback.

Yeti


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


Re: Beginner with GTK

2005-12-28 Thread David Necas (Yeti)
On Tue, Dec 27, 2005 at 06:03:52PM -0200, Joddy Schäfer wrote:
> Hi, is GTK cross-plataform?

Yes, it is.

> I use windows xp, so if I write a code using GTK will it work on some othre 
> OS?

The mere fact you used Gtk+ for GUI does not make all your
code portable.  But the Gtk+ part will be portable.  In
other words, you _can_ write portable apps with Gtk+.

> If it does, do can I use GTK with MS Visual C++ 6?

Yes, you can.  IIRC GladeWin32 even registers shomehow with
MSVC when it finds it.

Yeti


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


Re: gtk expander

2005-12-23 Thread David Necas (Yeti)
On Fri, Dec 23, 2005 at 03:31:41PM +0100, Fernando Apesteguía wrote:
> I have a problem with gtk expander. I create that object and put it in the
> window, using Glade. But how can I attach controls to the expander so when I
> click on it the controls are showed and when click again they aren't?
> 
> I've visited http://developer.gnome.org/doc/API/gtk/ but there is no
> information about any Gtk Expander Widget.

I can't help with Glade, but regarding docs: GtkExpander is
a 2.4+ thing, so you won't find it in the ancient Gtk+ 1.2
API.  Look here instead:

  http://developer.gnome.org/doc/API/2.0/gtk/

Yeti


--
That's enough.
___
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 glib-mkenums

2005-12-19 Thread David Necas (Yeti)
On Mon, Dec 19, 2005 at 05:54:27PM +0100, Maciej Piechotka wrote:
> 
> % glib-mkenums --template gwyddiontypes.h.template

Where is the list of headers containing enum declarations?

Yeti


--
That's enough.
___
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 glib-mkenums

2005-12-19 Thread David Necas (Yeti)
On Mon, Dec 19, 2005 at 08:59:26AM +0100, Maciej Piechotka wrote:
> 
> Ok. In makefile it's more clear. But what's $(enum_headers)?

Headers that contain the enum declarations you want to
process with glib-mkenums.

Yeti


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


Re: Gtk+ Version compatibilty?

2005-12-18 Thread David Necas (Yeti)
On Sun, Dec 18, 2005 at 03:35:30PM +0200, Daniel Pekelharing wrote:
> I've been working on an Autoconf system for my app,
> When it comes to detecting Gtk+, I don't know how early a version I
> should allow for?
> 
> On my FC4 system I have Gtk+-2.6.7, should I setup the configure script
> to pass only on this or a later version?
> Or is there somewhere I can find a backward version compatibility list?

Unless you depend on a particular bugfix, you should require
2.y.0 as the minimum version (e.g., 2.6.0), as microversions
are quite compatible.

Each class, method, or other symbol has a note in API docs
which version of Gtk+ it appeared in (or it should have such
a note).  Of course, if you wrote the app without caring
about compatibility with older verions, checking the status
of each used symbol now is not very practical.

I'd recommend to simply compile and *test* the app
successively with Gtk+ 2.4, 2.2, 2.0 till it stops to
build/work.  Although all 2.x versions are essentially
backward compatible, there were various subtle behavioural
changes that may prove critical just for your app and
something can behave oddly even if it builds.  No
compatibility list will tell you that.

If you do not care so much, requiring 2.6.0 should be a safe
bet.

Yeti


--
That's enough.
___
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 glib-mkenums

2005-12-18 Thread David Necas (Yeti)
On Sun, Dec 18, 2005 at 12:40:46PM +0100, Maciej Piechotka wrote:
> I'd like to use glib-mkenums.
> I've tried to use it, but I have no idea how to use it.
> Could somebody give me an example of file and what should by in command line.
> If some example is in GNOME CVS please give me in which project(but
> I'll be happy if you give me an information which file) I'll find it.

Gtk+ itself uses it, see gtk/Makefile.am.

However, passing the templates as a bunch of command line
options inside makefile, as Gtk+ does it, is IMO quite ugly.
If you prefer template files, you can have a look at

header file template
http://cvs.sourceforge.net/viewcvs.py/gwyddion/gwyddion/libgwyddion/gwyddiontypes.h.template?view=markup

C file template
http://cvs.sourceforge.net/viewcvs.py/gwyddion/gwyddion/libgwyddion/gwyddiontypes.c.template?view=markup

makefile rules to use them (near the bottom)
http://cvs.sourceforge.net/viewcvs.py/gwyddion/gwyddion/libgwyddion/Makefile.am?view=markup

for inspiration.

Without the timestamp preservation tricks the rules would be
simply

glib-mkenums --template H-TEMPLATE HEADERS-WITH-ENUMS >ENUMS.h
glib-mkenums --template C-TEMPLATE HEADERS-WITH-ENUMS >ENUMS.c

You can try this with my templates on your .h files to see
how it works.

It should be sufficient to change only two things in the
templates to make them fit your project: #included headers
and namespace prefixes.

Yeti


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


Re: cleanup data set with g_object_set_data()

2005-12-17 Thread David Necas (Yeti)
On Sat, Dec 17, 2005 at 11:45:42AM +0100, Olivier Sessink wrote:
> if data is set with g_object_set_data(), is that automatically freed if
> the object is unreffed?

No, but you can use g_object_set_data_full() instead and
pass something like g_free as the last argument.

Of course, the function is called when the object is
destroyed, not when it's just unreferenced.

Yeti


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


Re: gtk_combo_box_entry_new_text in GTK2 < 2.4

2005-12-06 Thread David Necas (Yeti)
On Mon, Dec 05, 2005 at 10:22:00PM -0700, Kevin DeKorte wrote:
> I've written some code that uses gtk_combo_box_entry_new_text, but I
> have some people that are using gtk2 < 2.4 (where
> gtk_combo_box_entry_new_text appears). Any idea how I would implement
> this functionality in gtk2 2.2?

GtkComboBox itself exist only since 2.4.  If you want your
app work with older Gtk+, use GtkOptionMenu.

If you only use the simple text-combo-box interface, it
should be quite easy to write construction, get-active, and
set-active wrapper functions for GtkOptionMenu and
GtkComboBox methods -- so you would use GtkComboBox on
newer Gtk+ and GtkOptionMenu on older without littering the
code with #ifdefs.

Or just use GtkOptionMenu everywhere if you only need the
simple interface.  And if you need the advanced GtkComboBox
interface... tell your users to install Gtk 2.6+ or install
it with your app.

Yeti


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


Re: combo rant

2005-11-26 Thread David Necas (Yeti)
On Fri, Nov 25, 2005 at 11:26:58PM +0200, Paul Pogonyshev wrote:
> 
> It is the trade-off of the policy that "the selected item is under the 
> pointer in
> the just shown popup, period."  I think it is generally good, but this is an 
> example
> of where it shows its drawbacks.  However, for the sake of UI consistency, I 
> believe
> it should _not_ be changed.  I.e. it be "under the pointer, period", not 
> "under the
> pointer, but only if..."

It's funny you say that in a thread where intents to
make an alternative implementation were mentioned just a few
mails ago.  If a policy leads to consequences disliked so
much that people start implementing their own widgets,
you failed twice: first, you these new widgets will be far
more inconsistent, not speaking about follow the policy;
and second, you wasted these people time.

Incidentally, I implemented a few selectors with a button
bringing up a normal-treeviw recently too, exactly because
gtkcombobox was awful to use.

Second, policy `the items always appear in the same
positions (relative to the combo)' would be at least as much
consistent.  If the position was for exmple below combo, one
would be in trouble only if the combo was near bottom screen
edge, not any horizontal edge like now.

How many problems must a policy cause to make people realize
it's wrong?

> Maybe a keyboard
> shortcut for the popup that causes it to instantly be filled with items

[rant]Could this keyboard shortcut be made Ctrl-L, please?
This way one would not have to learn so many different
please-fix-this-widget keyboard shortcut.[/rant]

To the general usability of combo box.  The upper limit of
number of items until it becomes cumbersome is one thing and
has been discussed througly, I'd just say Gtk+ combo has
this limit quite low.  But there is a *lower* limit too.

How long is it since you've last seen a combo box with only
two or three choices that could be replaced with
radiobuttons (or even a yes/no checkbox!) immediately getting:
- visibility of all the choices
- posibility to assign mnemonics to individual choices
- constant positions of the choices
- fix of sceeen edge interaction problems
- fix of obscuring of other widgets
- ease of use (less clicks)
- improved accessibility
Hardly more than a few minutes ago...

Yeti


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


Re: example

2005-11-22 Thread David Necas (Yeti)
On Wed, Nov 23, 2005 at 12:41:12AM +1100, ashley maher wrote:
> 
> So it occurred to me that a properly written c_handler should return the
> data required.  This has proven not so.
>
> ...
>
> static void
> gtree_onSelection (GtkTreeView *treeview, gpointer *data)

A properly written callback should have correct function
signature, please see:

  
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeView.html#GtkTreeView-row-activated

> Just is not getting me anywhere. Hence my question if somebody had a
> working example somewhere

A "row-activated" callback example is even in Gtk+ demo,
please see demo/gtk-demo/main.c.

Yeti


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


Re: valgrind memcheck shows gtk-hello leak memories.

2005-11-22 Thread David Necas (Yeti)
On Mon, Nov 21, 2005 at 11:38:27PM -0500, Allin Cottrell wrote:
> On Tue, 22 Nov 2005, sigsegv11 wrote:
> 
> > I test a very simple gtk program from the gtk-2.0 
> >tutor(http://www.gtk.org/tutorial/x364.html) using valgrind, and 
> >it reports the program leak memories. Is it a gtk's problem(really 
> >have some memory leaks) or a valgrind's BUG?
> 
> Probably neither.  To get good results with glib when using valgrind 
> (I think this is still good info), you should configure your glib 
> build using the flag
> 
> --enable-gc-friendly

If you mean more memory leaks by good results, then I agree.
This option makes GLib to wipe out zombie pointers in
logically unused memory -- like GList items waiting for
recycling -- allowing valgrind to detect the memory they
pointed to is not actually reachable.

But I don't understand how --enable-gc-friendly could make
valgrind report *less* memory leaks.  I use it with
gc-unfriendly GLib and Gtk+ regularly and the leaks it finds
are real.

Instead, I'd suggest to compile GLib with -g and not to strip
it and to use --num-callers=20 or something like that to see
where the problem is (gtype.c, type_node_any_new_W()):

  node = g_malloc0 (node_size);
  if (!pnode) /* offset fundamental 
types */
{
  node = G_STRUCT_MEMBER_P (node, SIZEOF_FUNDAMENTAL_INFO);
  ...

Well, some people might not call that a leak because the
type info for fundamental types is never freed anyway, but
it's clear node is lost and can't be freed any more (except
by some dirty code that calculates the original pointer
again).

Then you can create a suppression and add it to your
favourite Gtk+ suppression list...

Yeti


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


Re: apparent leak in widget creation/destroy

2005-11-18 Thread David Necas (Yeti)
On Fri, Nov 18, 2005 at 09:56:24AM -0600, Boncek, John wrote:
> We have 2 large C++ application programs using GTK 2.2.4 which have had
> persistent problems in running out of memory.  We have narrowed the
> problem down to a small test case, shown below, which consumes all
> available memory until locking up the system.  We run this test case with
> the free command in another terminal window to show free memory on a
> half-second cycle, thus:
>   free -o -m -s 0.5
> The widget-creation call can be either gtk_fixed_new or
> gtk_drawing_area_new.

The widget still has the initial floating reference, and
gtk_object_destroy() does not release any references itself.
The method to get rid of a maybe-floating GtkObject in
situation like yours is some variation on

g_object_ref(object);
gtk_object_sink(object);
gtk_object_destroy(object);
g_object_unref(object);

(you can explicitely test object state instead and branch
the code...)

Yeti


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


Re: C/GTK - Packing GtkImage inside GtkEventBox loses reference

2005-11-18 Thread David Necas (Yeti)
On Fri, Nov 18, 2005 at 03:56:52PM -0200, Marcus Reis wrote:
> 
> g_signal_connect (G_OBJECT (event_box), 
>   "button_press_event",
>   G_CALLBACK (movimento_do_jogador),
>   image);
>
> ...
> 
> static void movimento_do_jogador(GtkWidget *widget, GtkWidget *image)

This is a wrong prototype for a "button-press-event"
callback, see

  
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidget-button-press-event

The callback gets the event as its second argument (which
you try to use it as a widget).

I would also add it's probably not the best idea to load the
image from file every time it changes; simply loading the
images to three pixbufs and using gtk_image_set_from_pixbuf()
would be a considerable improvement.

Yeti


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


Re: Warning with GTK 2.6. 8 " Could not find the icon 'gnome-fs-home' "

2005-11-09 Thread David Necas (Yeti)
On Wed, Nov 09, 2005 at 08:28:15AM -0500, Matthias Clasen wrote:
> 
> It is easy to use hicolor without using GNOME or KDE.

IMHO the question is why it has to print such a warning at
all, not what people can or cannot use hicolor with.

Yeti


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


Re: gtk win32 and env variables

2005-11-05 Thread David Necas (Yeti)
On Sat, Nov 05, 2005 at 03:40:40PM +0100, Goran Rakić wrote:
> 
> Put this first:
> 
> ... (some win32 registry code) ...

Or have a look at g_win32_get_package_installation_directory().
Calling it with NULL arguments is usually sufficient. *Not*
storing the directory in registry has the advantage the app
can be moved around freely without breaking it (of course,
if it's not prevented by other factors).

Yeti


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


Re: g_module...: module calls function of core applicatioin

2005-10-30 Thread David Necas (Yeti)
On Sun, Oct 30, 2005 at 05:43:21PM +0100, Tobias Kipfelsberger wrote:
> I have a plugin which is registered and loaded with the g_module functions.
> So far so good everything works find.
> But how can i let the modul access a function of the coreapplication?
> 
> Example:
> in CoreApplication.h:
> 
> G_MODULE_EXPORT void 
> setCoreMenuAppbarText (const gchar* text)
> {}
> 
> in plugin.c:
> 
> #include "CoreApplication.h"
> void
> xyz ()
> {
>  setCoreMenuAppbarText("test");
> }
> 
> as i execute the programm... i always get a undefined symbol error.

You have to link the program with -export-dynamic (either as
ld option, or libtool link option if you use libtool).

Yeti


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


Re: Mouse over the widget

2005-10-28 Thread David Necas (Yeti)
On Fri, Oct 28, 2005 at 11:55:32AM +0400, Alexander S.Kresin wrote:
>   I can catch the moment when a mouse pointer appears over a widget 

Have a look at "enter-notify-event" and
"leave-notify-event".

Yeti


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


Re: Gtk && Xara

2005-10-18 Thread David Necas (Yeti)
On Tue, Oct 18, 2005 at 02:17:57PM -0400, Matthias Clasen wrote:
> 
> This whole discussion is pointless, since GTK+ is LGPL, not GPL...

How does this prevent anyone from creating a derived work of
Gtk+ and something GPLed and distribute it under GNU GPL?
This discussion might be pointless on gtk-devel, but we are
on gtk-app-devel.

Yeti


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


Re: GtkFileChooserButton issues

2005-10-14 Thread David Necas (Yeti)
On Thu, Oct 13, 2005 at 04:11:30PM +0200, David Necas (Yeti) wrote:
> 
> I'm unable to set the button back to the "(None)" state

This was a problem in my code, as it works on a simple
example.

> When it starts in the "(None)" state, user decides not to
> select anything and presses Cancel, the file dialog is
> closed and the button shows the last selected file (instead
> of "(None)")

I reported this as a bug

http://bugzilla.gnome.org/show_bug.cgi?id=318845

but I'm still interested in a workaround.

Yeti


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


GtkFileChooserButton issues

2005-10-13 Thread David Necas (Yeti)

Hi, I'm trying to use GtkFileSelectionButton, but...

I'm unable to set the button back to the "(None)" state when
nothing is selected.  Of course, I can destroy the button
and create a new one, but that's not very nice.

When it starts in the "(None)" state, user clicks on some
files, but then decides not to select anything and presses
Cancel, the file dialog is closed and the button shows the
last selected file (instead of "(None)"), but no signal
"selection-changed" is emitted.

The latter looks like a bug (I'll report it if it's so), I'm
not sure about the former.

Moreover, it is not possible to get the dialog from
a GtkFileChooserButton, therefore I cannot even connect to
the dialog to detect non-OK closing of the dialog and fix
the button (or, destroy it and create anew).  Is there any
other method to work around it and make Cancel really cancel
the selection?

I'm using Gtk+ 2.6.

Yeti


--
That's enough.
___
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 g_write function?

2005-10-13 Thread David Necas (Yeti)
On Wed, Oct 12, 2005 at 09:07:19PM -0400, Freddie Unpenstein wrote:
> 
> I must say, I wouldn't mind some of the more common functions being wrapped 
> (if it can be done without excessive overhead).

I would call that bloat even if it was done with

  #define g_write write

You'd soon end up with

  #define g_COMPLETE_ISO_C_AND_POSIX_API COMPLETE_ISO_C_AND_POSIX_API

because it's equally `confusing' to mix strchr() with
g_strlcpy(), etc.

> If you have to include the original standard header as well, then you end up 
> with both sets and can (I do from time to time) find yourself accidentally 
> mixing the original functions with their enhanced glib equivelants.

The rule is simple: functions that operate on file names are
wrapped.

Yeti


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


Re: gtk label problem

2005-09-28 Thread David Necas (Yeti)
On Wed, Sep 28, 2005 at 03:03:53PM +0530, Suganya wrote:
> I have a label widget which displays a text (in my case, it is the
> status of the SIP call)
> 
> Depending on the status of the call, the text in the label widget should
> change.
> 
> The problem I am facing is that the text is changing some times and not
> changing other times.

Most likely the cause is the same as in a parallel thread
http://mail.gnome.org/archives/gtk-app-devel-list/2005-September/msg00268.html

Yeti


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


Re: Is now gdk-bixbuf the part of gtk+-2?

2005-09-27 Thread David Necas (Yeti)
On Mon, Sep 26, 2005 at 06:02:58PM -0400, John (J5) Palmieri wrote:
> 
> Actually I believe you do.  On Fedora gdk-pixbuf is a separate package
> so if a developer doesn't have gdk-pixbuf-devel package installed
> configure should detect this and throw an error.

Please don't confuse people.  There is a standalone
gdk-pixbuf rpm on Fedora, but it's the old standalone
gdk-pixbuf, which people probably don't install at all
nowadays.  The Gtk+-2.0 gdk-pixbuf is a part of gtk2
package.

Yeti


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


Re: Internationalization ???

2005-09-18 Thread David Necas (Yeti)
On Sun, Sep 18, 2005 at 07:42:19PM +0200, Rss Reader wrote:
> 
> is there another way to Internationalizate an
> application without using gettext, because i'm not
> using the autotools to build my projet.

You can, but unless you are going to customize Gtk+ to use
your home-grown 18n solution too (and reimplement gettext
along the way), it will be still using libintl for its own
i18n.  Not to mention I consider this idea extremely silly.

>  Or could we i18ne it witout  using autotools, by
> using gettext, is there any links ...???

Have you tried section Overview in gettext manual? It shows
all the essential programs, when they are used and what they
do.

Moreover, the standard gettext Makefile.in.in uses little of
the automake machinery and defines its own rules for
everything essential, so it should not be so hard to write
a non-autotools Makefile based on that.

Yeti


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


Re: gtk_list_store_new(1, G_TYPE_STRING) and retrieving data

2005-09-07 Thread David Necas (Yeti)
On Wed, Sep 07, 2005 at 08:42:42PM +0200, HuamiSoft Hubert Sokolowski wrote:
> 
> static gboolean model_foreach (GtkTreeModel *model,
> GtkTreePath *path,
> GtkTreeIter *iter,
> gpointer data)
> {
>   gtk_tree_model_get (model, iter,
>   COLUMN, &value,
>   -1);
> 
>   return FALSE;
> }

But don't forget to free the retrieved string, see:

http://scentric.net/tutorial/sec-treemodel-data-retrieval.html#sec-treemodel-retrieved-data-disposal

Yeti


--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Yelp compilation problem

2005-09-01 Thread David Necas (Yeti)
On Thu, Sep 01, 2005 at 04:46:26PM +0530, harshavardhanreddy mandeepala wrote:
> I am using FC3
> Now I want to install yelp-2.6.3 in to my linux syatem.
> But when run ./configure command it is giving error message as fallows
> 
> ...
> 
> ... Package libgtkhtml-2.0 was not found in the pkg-config search path.
> Perhaps you should add the directory containing `libgtkhtml-2.0.pc'
> to the PKG_CONFIG_PATH environment variable
> No package 'libgtkhtml-2.0' found

Install gtkhtml2-devel-2.6.2 rpm (or whatever is current
version in FC3) and everything it depends on.

> But after that i installed libgtkhtml-3.0.0 tar successfully but still it is 
> giving same problem.

Always try to install a distro provided package first.

Note libgtkhtml3 and libgtkhtml2 are two different and
independently installable libraries, it's like Gtk+ 1.2 and
2.0.

Yeti


--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


  1   2   >