Re: Linking the buttons to gtk app

2010-08-27 Thread dhk
On 08/27/2010 01:27 AM, Guruprasad Bhat wrote:
> Hello, I have developed a GUI application for ARM based product. It has 10
> buttons, so I want to link button press to GTK. How can I start to do this?
> In which level/layer I have work to get it done?
> 
> *Regards,*
> *  Guruprasad Bhat.*
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

This is a little off the subject, but how do you get you application on
the ARM device especially when it's got an OS like Windows CE or
something like that?

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


Re: Widget name is 0x0 after GtkWidget key-press-event

2010-08-14 Thread dhk
On 08/13/2010 04:50 PM, John Stebbins wrote:
> On 08/13/2010 06:22 AM, Tadej Borovšak wrote:
>> Hi.
>>
>> Your problems are caused by the fact that GtkBuilder since GTK+-2.20
>> doesn't set widget's "name" property to "id" field anymore. API
>> docs[1] warn about this change (see the first "Note" section in
>> description).
>>
>> Tadej
>>
>> [1] 
>> http://library.gnome.org/devel/gtk/stable/GtkBuilder.html#GtkBuilder.description
>>
>>   
> use gtk_buildable_get_name(GTK_BUILDABLE(widget)) instead.
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Thanks all, that looks exactly like what happened.  It really messed
things up especially after being away from it for a while.

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

Re: Widget name is 0x0 after GtkWidget key-press-event

2010-08-13 Thread dhk
On 08/13/2010 07:56 AM, dhk wrote:
> The GtkWidget key-press-event signal doesn't seem to be filling in the
> name of the widget.  When I print the name in the debugger it's 0x0.
> 
> I haven't run the program in a couple of months, but the last time I did
> everything worked.  Since then I've been keeping up on the upgrades
> (using Gentoo Linux with an amd64 processor).
> 
> The program uses GtkBuilder.  There is an xml file with a treeview which
> has a key-press-event signal.  When the event occurs the callback is
> called and the parameters look right, but the name of the widget is 0x0.
>  Is this a bug from a recent release?  See below.
> 
> Breakpoint 2, rxTvKeyPressEventCb (treeview=0x8f6120, event=0x945ca0,
> user_data=0x0) at possubs.c:1886
> 1886gboolean add_row=FALSE;
> (gdb) p *treeview
> $27 = {object = {parent_instance = {g_type_instance = {g_class =
> 0x6d1520}, ref_count = 9, qdata = 0x988b20}, flags = 2166720},
>   private_flags = 1536, state = 0 '\000', saved_state = 0 '\000', name =
> 0x0, style = 0x930070, requisition = {width = 707, height = 191},
> allocation = {x = 7, y = 81, width = 768, height = 258}, window =
> 0x8c5a30, parent = 0x8c4350}
> (gdb) p *event
> $28 = {type = GDK_KEY_PRESS, window = 0x696c10, send_event = 0 '\000',
>   time = 4862537, state = 16, keyval = 65289, length = 0,
>   string = 0x9960b0 "", hardware_keycode = 23, group = 0 '\000',
>   is_modifier = 0}
> (gdb)
> 
> Thanks,
> 
> dhk
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

One more thing.

I get my widgets as follows and all the name's are 0x0.

if(!gtk_builder_add_from_file(builder, filename, &error)) {
g_warning("Couldn't load builder file: %s", error->message);
g_error_free(error);
}

gtk_builder_connect_signals(builder, NULL);

w=GTK_WIDGET(gtk_builder_get_object(builder, "rxNb"));

All w->name's are 0x0.  This never use to be the case.  So this seems to
be the root of the problem.  Is this a bug in Gtk Builder?

Thanks,

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


Widget name is 0x0 after GtkWidget key-press-event

2010-08-13 Thread dhk
The GtkWidget key-press-event signal doesn't seem to be filling in the
name of the widget.  When I print the name in the debugger it's 0x0.

I haven't run the program in a couple of months, but the last time I did
everything worked.  Since then I've been keeping up on the upgrades
(using Gentoo Linux with an amd64 processor).

The program uses GtkBuilder.  There is an xml file with a treeview which
has a key-press-event signal.  When the event occurs the callback is
called and the parameters look right, but the name of the widget is 0x0.
 Is this a bug from a recent release?  See below.

Breakpoint 2, rxTvKeyPressEventCb (treeview=0x8f6120, event=0x945ca0,
user_data=0x0) at possubs.c:1886
1886  gboolean add_row=FALSE;
(gdb) p *treeview
$27 = {object = {parent_instance = {g_type_instance = {g_class =
0x6d1520}, ref_count = 9, qdata = 0x988b20}, flags = 2166720},
  private_flags = 1536, state = 0 '\000', saved_state = 0 '\000', name =
0x0, style = 0x930070, requisition = {width = 707, height = 191},
allocation = {x = 7, y = 81, width = 768, height = 258}, window =
0x8c5a30, parent = 0x8c4350}
(gdb) p *event
$28 = {type = GDK_KEY_PRESS, window = 0x696c10, send_event = 0 '\000',
  time = 4862537, state = 16, keyval = 65289, length = 0,
  string = 0x9960b0 "", hardware_keycode = 23, group = 0 '\000',
  is_modifier = 0}
(gdb)

Thanks,

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


Broken Links in GTK Documentation

2010-06-29 Thread dhk
There are a lot of broken links in the GTK documentation.

For example when clicking on GDK_FOCUS_CHANGE_MASK and other hyperlinks
in
http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget-focus-out-event
the result is "Not Found".

It looks like the links in the stable documentation point to the
"unstable" documentation.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Setting a Tree View Cell to insensitive and uneditable

2010-04-22 Thread dhk
On 04/22/2010 02:55 AM, Freddie Unpenstein wrote:
> From: "dhk", Date: 20/04/2010 09:46:
> 
>> On 04/19/2010 01:34 PM, Nicolas Soubeiran wrote:
>>> When creating your model set a specific column with a boolean property.
>>> gtk_list_store_new(N_COLUMN, G_TYPE_STRING, G_TYPE_BOOLEAN);
>>>
>>> Then in the treeview create a column using
>>> gtk_tree_view_column_new_with_attributes("title", text_cell,"string",
>>> STRING_COLUMN, "editable", EDITABLE_COLUMN, NULL);
>>
>> Both replies seem to be saying the same thing, but I still don't
>> understand why the attribute values need to be stored in other columns.
>> Also I don't see how storing the attributes in other columns affect an
>> individual cell.
> 
> They are.  That is the typical way of doing it.  ANY table column (as long as 
> it's the right type) can be linked to ANY attributes of ANY cells in that row 
> (note the plurals - the mapping is essentially restricted only by value 
> type).  Notice also that for a column showing a text string, the text shown 
> in that column is just another attribute of the cell, as is its colour, font, 
> editability, whatever.  A value in a table can also be linked to any 
> compatible attriute of any one of the cells in the table, or even several 
> attributes of the same cell.  So you could have a cells editability 
> controlled by a table column, and in the very next cell be showing true/false 
> whether the previous cell is editable, from the same table value, or two 
> boolean attributes of a single cell controlled from the same table value, etc.
> 
> 
>> So this is the way to control the editability and sensitivity of a
>> single cell without changing the cells above and below the cell in the
>> same column. Does this apply for all attributes?
> 
> There is also another method of controlling cell attributes.  For every row, 
> an optional function will be called (I forget the name off-hand).  But this 
> function is called once per row, and can extract information from the table, 
> and set the attributes of however many of the cells as it wishes.  I've used 
> that a couple times particularly where I woul have to have several values in 
> the table to accomplish one task, such as a colour, boolean and integer 
> field, all to reflect one property.  Instead I've set the row function to 
> read the single boolean field, and set the relevant cell attributes 
> accordingly.
> 
> But for something simple like editability, using a table columns is certainly 
> simpler, and probably more understandable also.
> 
> 
> As I understand it, Gtk essentially iterates over the list of attribute/value 
> linkages, which are nothing more than "for row number n, place the value of 
> table column x, into attribute y of tree view cell z", blindly and faithfully 
> performing each value copy in turn, per row of your tree view.  Any attribute 
> you don't set, will remain as it was at the time that cell renderer was 
> established.  Likewise there's nothing at all stopping you from setting one 
> cell attribute more than once (pretty useless), or setting several attributes 
> to one value (often quite useful).  The row function is simply another way of 
> doing this same job, except that you do the value copying yourself, ie. fetch 
> the table value (or any other value), and you set the relevant cell 
> attributes from it as you see fit.
> 
> 
> Fredderic
> 

Thanks, for explaining.  I think I know what to do, I just have to get
comfortable with the idea.  After all these years, I never looked at
trees this way.

Thanks again,

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


Re: Setting a Tree View Cell to insensitive and uneditable

2010-04-19 Thread dhk
On 04/19/2010 01:34 PM, Nicolas Soubeiran wrote:
> When creating your model set a specific column with a boolean property.
> e.g :
> enum
> {
> STRING_COLUMN =0,
> EDITABLE_COLUMN,
> N_COLUMN
> }
> ...
>  gtk_list_store_new(N_COLUMN, G_TYPE_STRING, G_TYPE_BOOLEAN);
> 
> Then in the treeview create a column using
> gtk_tree_view_column_new_with_attributes("title", text_cell,"string",
> STRING_COLUMN, "editable", EDITABLE_COLUMN, NULL);
> 
> and when fillling your model precise which row is editable.
> Hope this help,
> regards
> 

Both replies seem to be saying the same thing, but I still don't
understand why the attribute values need to be stored in other columns.
 Also I don't see how storing the attributes in other columns affect an
individual cell.

So this is the way to control the editability and sensitivity of a
single cell without changing the cells above and below the cell in the
same column.  Does this apply for all attributes?

Thanks,

dhk

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


Setting a Tree View Cell to insensitive and uneditable

2010-04-18 Thread dhk
I'm using the following call in my callback where cell is a pointer to a
GtkCellRenderer.

g_object_set(cell, "sensitive", FALSE, "editable", FALSE, NULL);

The problem is this sets the attributes on the whole column and not just
the cell and when a new row is prepended to the treeview the cell in the
new row can not be edited.

Is it possible to set a cell in a specific column and row to insensitive
and uneditable and not affect the rest of the cells in the same column?

Thanks,

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


News Ticker

2010-04-07 Thread dhk
I would like to have text scroll horizontally across a text view an
found it's a lot more difficult that scrolling text vertically.

Is there anything that would help make development on a GTK News Ticker
easier?

Thanks,

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


Re: Getting a Widget Choice

2010-02-20 Thread dhk
Tristan Van Berkom wrote:
> You should always prefer using either gtk_builder_get_object(), or
> also using trustable API's like gtk_button_get_image_widget() for instance.
> (not sure if thats an existing api, but you get the idea).
> 
> I.e. the composition of opaque composite widgets from GTK+ can
> change, possibly breaking unwary code which walks through the
> hierarchy checking widget types.
> 
> Also, the composition of your GtkBuilder file may change, if you always
> access the elements by the keys you provide (i.e. the name field right now)
> then you wont run into trouble when changing your interface in the future.
> 
> Cheers,
>  -Tristan
> 
> On Sat, Feb 20, 2010 at 9:04 AM, dhk  wrote:
>> When a widget can be gotten by using GTK builder functions or GTK Widget
>> functions, does it make a difference, or is one way better than the
>> other, for finding the widget.
>>
>> For example when I can get the same widget using either of the following
>> two calls, which one should I use and why?
>>
>>
>> GtkWidget *nb=NULL; /* A notebook widget */
>>
>> /* Call 1 */
>> nb=GTK_WIDGET(gtk_builder_get_object(gtk_builder, "notebook_name"));
>>
>> /* Call 2 */
>> nb=gtk_widget_get_ancestor(widget, GTK_TYPE_NOTEBOOK);
>>
>>
>> Thanks,
>>
>> dhk
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>
> 

Good point, I didn't think about the API's and the interface changing.

Thanks,

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


Getting a Widget Choice

2010-02-20 Thread dhk
When a widget can be gotten by using GTK builder functions or GTK Widget
functions, does it make a difference, or is one way better than the
other, for finding the widget.

For example when I can get the same widget using either of the following
two calls, which one should I use and why?


GtkWidget *nb=NULL; /* A notebook widget */

/* Call 1 */
nb=GTK_WIDGET(gtk_builder_get_object(gtk_builder, "notebook_name"));

/* Call 2 */
nb=gtk_widget_get_ancestor(widget, GTK_TYPE_NOTEBOOK);


Thanks,

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


GtkActionEntry

2010-02-03 Thread dhk
Is there a way to use the TAB key with GtkActionEntry?

I have the menu working fine with GtkActionEntry, the function keys
work, single character keys work, keys in combination with control, alt,
and shift work, but I can't get it to work with a TAB key.  Is there
special syntax?  How can I get the , , ,
. . . to work like the others?

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


Reuse of a gtk_tree_model_get() Pointer

2010-01-23 Thread dhk
How can I reuse a pointer that was used in a call to gtk_tree_model_get()?

For example a call like gtk_tree_model_get(tmdl, &iter, INDEX, &rxi.idx,
QUANTITY, &rxi.qty, DESCRIPTION, &rxi.sdesc, -1);

If I wanted to add or change the description, depending upon whether
rxi.sdesc is NULL or not, should I free rxi.sdesc and allocate space for
the new string and then do a string copy?

Thanks,

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


Re: GtkNotebook "switch-page" Signal

2010-01-09 Thread dhk
dhk wrote:
> David Nečas wrote:
>> On Fri, Jan 08, 2010 at 05:59:27PM -0500, dhk wrote:
>>> When changing from one tab to another in a GtkNotebook I often need to
>>> know the tab that was selected.  It seems the "switch-page" signal just
>>> tells the current page and there are functions that tell the current
>>> page and will navigate through the page, but I don't see anything that
>>> will tell tell the destination page or the tab that received the signal.
>>>
>>> Does anyone know how to determine this?
>> "switch-page" gives you the new page (i.e. the page the notebook is
>> switching to).  What is `destination' page if not this?
>>
>> Yeti
>>
>>
> 
> It looks like it gives the page I switched from, but I want the page I
> switched to.
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Never mind.  I was getting the page number from the notebook not the
page number parameter of the "switch-page" callback.  The documentation
doesn't specify which page the index is for, it just says "page_num :
the index of the page".

Thanks,

dhk



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

Re: GtkNotebook "switch-page" Signal

2010-01-09 Thread dhk
David Nečas wrote:
> On Fri, Jan 08, 2010 at 05:59:27PM -0500, dhk wrote:
>> When changing from one tab to another in a GtkNotebook I often need to
>> know the tab that was selected.  It seems the "switch-page" signal just
>> tells the current page and there are functions that tell the current
>> page and will navigate through the page, but I don't see anything that
>> will tell tell the destination page or the tab that received the signal.
>>
>> Does anyone know how to determine this?
> 
> "switch-page" gives you the new page (i.e. the page the notebook is
> switching to).  What is `destination' page if not this?
> 
> Yeti
> 
> 

It looks like it gives the page I switched from, but I want the page I
switched to.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

GtkNotebook "switch-page" Signal

2010-01-08 Thread dhk
When changing from one tab to another in a GtkNotebook I often need to
know the tab that was selected.  It seems the "switch-page" signal just
tells the current page and there are functions that tell the current
page and will navigate through the page, but I don't see anything that
will tell tell the destination page or the tab that received the signal.

Does anyone know how to determine this?

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


Re: GTK Action Handler

2010-01-02 Thread dhk
Tadej Borovšak wrote:
> Hello.
> 
>> When the button or expander is clicked with the mouse the callbacks work
>> fine.  The problem is from the menu the "activate" signal has GtkAction
>> as the first parameter of the callback and I don't think that can be
>> cast to a GtkButton or GtkExpander.  I want to call the button and
>> expander callbacks as if they were clicked with the mouse.
> 
> You can get hold of the proxy widget of the action by calling
> gtk_action_get_proxies(). After you obtain the needed widget, you cna
> call callback function like it would be called by GTK+ itself.
> 
> Tadej
> 

I tried gtk_action_get_proxies() which works, but it looks like it
returns the menu item.  I'm still not sure how everything ties together.
 For example why is the function called gtk_action_get_proxies() it
seems to just return the menu item.  Anyway the way I got it to work,
which doesn't seem unreasonable, was to traverse the GtkWindow down
until I found the GtkExpander in that I was looking for and then I
emitted a signal.  I think this is what you were getting at.  So now my
callback for the action handler is a wrapper around
g_signal_emit_by_name(G_OBJECT(xpndr), "activate").  It finds the
expander and emits the signal.

Any idea how I can connect an accelerator to the Tab key?  In the
gtk_accelerator_name() function in the gtkaccelgroup.c file there isn't
a "" in the list of accelerator name; however, I think there's a
way to add one, possibly with gtk_accel_group_connect(), but I'm not sure.


Thanks,
dhk


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

Re: GTK Action Handler

2009-12-31 Thread dhk
Michael Cronenworth wrote:
> dhk wrote:
>> How can I reuse these callbacks?
> 
> Use user_function( GtkWidget *widget, gpointer data ) instead of
> explicitly setting a class. Then cast widget as whatever you need, eg.:
> GTK_BUTTON( widget ) inside of your callback.
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

When the button or expander is clicked with the mouse the callbacks work
fine.  The problem is from the menu the "activate" signal has GtkAction
as the first parameter of the callback and I don't think that can be
cast to a GtkButton or GtkExpander.  I want to call the button and
expander callbacks as if they were clicked with the mouse.

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


Re: GTK Action Handler

2009-12-31 Thread dhk
Tadej Borovšak wrote:
> Hello.
> 
> Callback prototype for "activate" signal is: void callback( GtkAction
> *action, gpointer data );
> 
> When widget that proxies specific action is activated, it calls
> gtk_action_activate() function which emits "activate" signal.
> 
> Tadej
> 

I think I have one more question.  How do you execute callbacks for
other events from the "activate" signal?  For example an expander
"activate" signal has a "void user_function(GtkExpander *expander,
gpointer user_data)" callback signature or a button "clicked" signal has
a "void user_function(GtkButton *button, gpointer user_data)" callback
signature.  The first parameter is a GtkWidget derivation and not a
GtkAction.  How can I reuse these callbacks?

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

GTK Action Handler

2009-12-31 Thread dhk
What is the callback signature suppose to look like for a GTK Action
handler?

I have a menu made from a GtkBuilder UI definition.  The GtkActionEntry
array sets the callbacks for the menu item; however, what is the
callback suppose to look like?  Some menu items I want to call a button
clicked callback which seems to work and another I want to call an
expander activated callback which doesn't seem to work.  In addition, it
looks like the first parameter of the callback should be a GtkAction
value, so I'm not sure why the button callback works when the expander
callback doesn't.

Thanks,

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


Window Managers Key Combinations and Accelerators

2009-12-09 Thread dhk
How can I prevent all or some window manager key combinations in my gtk
application?


To prevent the default F10 behavior I already use the following.
  GtkSettings *gtk_settings;
  gtk_settings=gtk_settings_get_for_screen(gdk_screen_get_default());
  g_object_set(gtk_settings, "gtk-menu-bar-accel", NULL, NULL);

The "gtk-menu-bar-accel" string was something given from other
questions.  Is there a list of other strings I can use in this place?

Two things I would like to do is override the default Tab key press
behavior and the Ctrl-Alt-Del behavior.

I'm using the GtkUIManager to set accelerator keys, but some keys like
the Tab key don't seem to work.  I figured in my GtkActionEntry array I
could use "", but that doesn't have any affect.  I'm guessing it's
the Window Manager overriding it.  Is this correct or is it something
else?  Also, is there a place I can find the mapping of the keys to
their string value?

Thanks,

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


Re: Invalid GtkTreeIter

2009-11-04 Thread dhk
Claudio Saavedra wrote:
> El mar, 03-11-2009 a las 16:53 -0500, dhk escribió:
>> I have a program that declares a number of GtkTreeIter's.  Recently the
>> prepending to the parent iter broke.  I found out that, in some cases,
>> the stamp to the iter's are negative just after the iter is declared.
>> This means the iter is invalid.  The following test program does the
>> same thing.
>>
>> Why aren't all the stamps to the four iter's (a, b, c, and d) valid and
>> positive?
> 
> Because your iters are not initialized at all... you are going the wrong
> way on the search for a solution to your initial problem. What do you
> mean by "prepending to the parent iter broke"?
> 
> Claudio
> 

In the gtk-demo program has a block as follows in the Tree View/Tree
Store example.  This doesn't initialize the the child iter before using
it in the gtk_tree_store_append(), but the stamp is valid.

/* add children */
  while (holiday->label)
{
  GtkTreeIter child_iter;

  gtk_tree_store_append (model, &child_iter, &iter);
  gtk_tree_store_set (model, &child_iter,
  HOLIDAY_NAME_COLUMN, holiday->label,
  ALEX_COLUMN, holiday->alex,
  HAVOC_COLUMN, holiday->havoc,
  TIM_COLUMN, holiday->tim,
  OWEN_COLUMN, holiday->owen,
  DAVE_COLUMN, holiday->dave,
  VISIBLE_COLUMN, TRUE,
  WORLD_COLUMN, holiday->world_holiday,
  -1);

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

Invalid GtkTreeIter

2009-11-03 Thread dhk
I have a program that declares a number of GtkTreeIter's.  Recently the
prepending to the parent iter broke.  I found out that, in some cases,
the stamp to the iter's are negative just after the iter is declared.
This means the iter is invalid.  The following test program does the
same thing.

Why aren't all the stamps to the four iter's (a, b, c, and d) valid and
positive?


/* Test Program:  tstIters.c
 * Build Command:
 * gcc -Wall -g2 `pkg-config --cflags gtk+-2.0` `pkg-config --libs
gtk+-2.0` tstIters.c -o tstIters
 */
#include 
#include 
#include 

int main(int argc, char **argv) {
  GtkTreeIter a;
  GtkTreeIter b;
  GtkTreeIter c;
  GtkTreeIter d;

  g_printf("a.stamp={%d}\n", a.stamp);
  g_printf("b.stamp={%d}\n", b.stamp);
  g_printf("c.stamp={%d}\n", c.stamp);
  g_printf("d.stamp={%d}\n", d.stamp);

  return 0;
}


Output

$ ./tstIters
a.stamp={4196240}
b.stamp={496461664}
c.stamp={-565527112}
d.stamp={-565527128}
$ ./tstIters
a.stamp={4196240}
b.stamp={-873273504}
c.stamp={716436552}
d.stamp={716436536}
$ ./tstIters
a.stamp={4196240}
b.stamp={938256224}
c.stamp={-1622865320}
d.stamp={-1622865336}
$ ./tstIters
a.stamp={4196240}
b.stamp={1835186016}
c.stamp={-524655784}
d.stamp={-524655800}
$

Thanks,

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


Re: Program Crashes when Removing a Page

2009-11-01 Thread dhk
David Nečas wrote:
> On Fri, Oct 30, 2009 at 06:09:16AM -0400, dhk wrote:
>> I have a notebook that crashes the program when
>> gtk_notebook_remove_page(GTK_NOTEBOOK(nb), page_num) is called.  Each
>> page of the notebook has a lot of stuff on it and the crash always
>> happens on the same page.  The source of gtk_notebook_remove_page()
>> looks like it recursively traverses the page and removes everything.  My
>> suspicion is that there is something on my page that causes the crash,
>> but I don't see what it could be.  The following error message is what I
>> get when gtk_notebook_remove_page() is called.
>> 1285   if(page_num>0) {
>> (gdb)
>> 1286 gtk_notebook_remove_page(GTK_NOTEBOOK(nb), page_num);
>> (gdb)
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x7fffd8340790 in ?? ()
>>
>> How can I find out what's causing the crash?
> 
> Run it under valgrind with G_SLICE=always-malloc
> http://library.gnome.org/devel/glib/stable/glib-running.html
> It will probably tell you that nb points to already-freed memory and
> where it was freed.  If it's so you need to figure out who does not own
> a reference while he should, see also
> http://library.gnome.org/devel/gobject/stable/tools-refdb.html
> that may help.  Or valgrind will tell you that nb is complete rubbish
> and why...
> 
> Yeti
> 
> 

Valgrind, found the problem.  It was in a block of code the was not
finished and forgotten about a few weeks ago.  I commented it out and it
works as before.

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

Program Crashes when Removing a Page

2009-10-30 Thread dhk
I have a notebook that crashes the program when
gtk_notebook_remove_page(GTK_NOTEBOOK(nb), page_num) is called.  Each
page of the notebook has a lot of stuff on it and the crash always
happens on the same page.  The source of gtk_notebook_remove_page()
looks like it recursively traverses the page and removes everything.  My
suspicion is that there is something on my page that causes the crash,
but I don't see what it could be.  The following error message is what I
get when gtk_notebook_remove_page() is called.
1285  if(page_num>0) {
(gdb)
1286gtk_notebook_remove_page(GTK_NOTEBOOK(nb), page_num);
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x7fffd8340790 in ?? ()

How can I find out what's causing the crash?

Thanks,

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


Re: Treeview Row Count

2009-09-24 Thread dhk
Kristian Rietveld wrote:
> Also note that for *lists* (so no parent nodes, no children) a call
> like gtk_tree_model_iter_n_children (model, NULL) will suffice.
> 
> 
> -kris.
> 
> On Thu, Sep 24, 2009 at 1:32 PM, Tadej Borovšak  wrote:
>> Hello.
>>
>>> Is there a function to give the number of rows in a treeview?
>> You probably want to know how many lines are in the GtkTreeModel that
>> serves as data source for GtkTreeView. There is no simple function
>> that would serve you this number, so you'll have to take one of the
>> two available paths:
>> 1) maintain number of rows externally by increasing/decreasing it on
>> additions/removals
>> 2) traverse the whole model and count the lines
>>
>> If you go with second option, gtk_tree_model_foreach function may be
>> of help. Sample counter would look like this:
>>
>>  CODE 
>> ...
>>
>> gint no_rows = 0;
>>
>> gtk_tree_model_foreach( model, (GtkTreeModelForeachFunc)count, &no_rows );
>>
>> ...
>>
>>
>> static gboolean
>> count( GtkTreeModel *model,
>>   GtkTreePath  *path,
>>   GtkTreeIter  *iter,
>>   gint *no_rows )
>> {
>>*no_rows+;
>>return( FALSE );
>> }
>>  CODE 
>>
>> Tadej
>>
>> --
>> Tadej Borovšak
>> tadeboro.blogspot.com
>> tadeb...@gmail.com
>> tadej.borov...@gmail.com
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

That's what I thought, but I was hoping a function existed for
performance sake.  I'll just have to count the rows.  Thanks all.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Treeview Row Count

2009-09-24 Thread dhk
Is there a function to give the number of rows in a treeview?

Thanks,

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


Setting data in a Treeview cell

2009-09-18 Thread dhk
How can I set the data in a treeview cell when going from data entry to
clicking a button?  When I click off the cell being edited, but the
click is somewhere inside the treeview I can set the data.  However,
when the mouse clicks an object outside the treeview the data in the
cell is lost.  So basically two clicks need to be made when I am done
editing a cell one inside the treeview and then the button or menu item
I really want.  This isn't user friendly since the users will not
remember to do this.  How can I get the data set in one shot?

Thanks,

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


What is Gtk builder?

2009-06-22 Thread dhk
I hate to ask what everyone seems to know, but what is gtk builder?  Is 
it part of Glade 3.4.5?  I don't see any gtk builder packages or 
libraries in the Gentoo portage tree.  Also does this mean all my Glade 
programs are obsolete?


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


Re: Accelerator

2009-06-07 Thread dhk

Stefan Kost wrote:

dhk schrieb:

Are accelerators only for menu items?  I've seen a lot of examples with
accelerators and the all seem to connect to a menu item.  I've been
having a difficult time getting accelerators to work even with the
examples.  I think I'm missing something.

One thing I would like is to just have an accelerator execute a function
or a callback.  Maybe if I could just print "Hello World" to the
terminal when pressing Alt-F4 would help prove the concept.


I am struggling with the same issue and resorted to a terrible hack. I've
defined a popupmenu which I never show. It contains menu items with the
accelerators. Voila, global accelerators for the app :)

Stefan


Can someone help?

Thanks,

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





The following is from the Glade mailing list yesterday, the same day as 
your email.  It sounds like there could be a bug, but I'm not sure.  I 
am still having a difficulty getting an accelerator to work:  don'tknow 
what's wrong.


On Sat, Jun 6, 2009 at 4:52 PM, Jonathan Lane wrote:
> > I've asked this on the list before, but it's hard to imagine that no
> > one else has noticed this, so I must be doing something wrong.
> >
> > I'm trying to add accelerators (such as CTRL-O, etc) to my MenuItems.
> > On the Common tab for the GtkImageMenuItem, I hook the accelerator I
> > want to the activate signal.
> >
> > Is this not the way I should be doing it?  Some of them work, but most
> > don't, and I can't figure why.
> >
> > I'm using glade 3.6.3 and saving my projects in Builder format.

Gah, This is my mistake.

This needs to be fixed in GTK+, GtkMenuItem doesnt use an accel-group
property to connect to the window's accel-group, right now the "accel-group"
is only handled by GtkImageMenuItem but it should be handled by
menu items in general.

Im sure there is a bug open for this but I cant seem to find it
right now.

Sorry for this inconvenience.

Cheers,
   -Tristan
___
Glade-users maillist  -  glade-us...@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users

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


Accelerator

2009-05-25 Thread dhk
Are accelerators only for menu items?  I've seen a lot of examples with 
accelerators and the all seem to connect to a menu item.  I've been 
having a difficult time getting accelerators to work even with the 
examples.  I think I'm missing something.


One thing I would like is to just have an accelerator execute a function 
or a callback.  Maybe if I could just print "Hello World" to the 
terminal when pressing Alt-F4 would help prove the concept.


Can someone help?

Thanks,

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


Re: Treeview CRITICAL Error

2009-04-30 Thread dhk

Carlos Pereira wrote:

dhk wrote:
only seems to compile when the -O (Optimization) option is present.  
However the options is set as -O0 (that's Dash-Oh-Zero) which should 
turn optimization off. I'd like to be able to compile the program 
without optimization, but so far this has just been an annoyance.
In my opinion every application should try to compile without warnings 
AND run fine with -O0, -O2, -O3. If your app does not compile AND run 
fine with -O0 to -O3 then you should stop and try to understand why. 
Think about it as an opportunity to know better your application!


Sometime ago, my app was behaving in a strange way when compiling with 
-O3, although it worked fine with -O2. I tracked down the problem to 
just 2, 3 lines of complex, cheesy code, separated by commas. Replacing 
these 2, 3 lines by 4, 5 lines of simple, robust code, solved the issue.
Third - the problem.  The application window has a notebook with a 
handful of tabs, each with different tree views on them.  The program 
seems to run fine.  However, when the second tab is selected, no 
matter what the previous tab was, the following three error lines get 
printed about three times.
I use a lot of notebooks and treeviews myself and they work fine. 
Probably this is a problem of compatibility between your TreeViews and 
TreeStores.


Are you sure the number of columns and their type is right? the 
treeviews are visible? the tree stores are visible? there is no 
confusion between them when you change from one Treeview to another? do 
you understand well the Treeview/TreeStore model?
Now the strange part.  The functions that call 
gtk_tree_store_prepend() and gtk_tree_view_set_cursor() get a tree 
view pasted in as a gpointer and then it's cast to a GtkWidget.  In 
the debugger when the tree view is printed it says "out>" and when printed with a star '*' preceding the tree view it 
displays 0x0:  NULL.
You can print the memory address of your treeviews, when you create 
them, and then in a few selected places, for example:


printf ("treeview in callback: %d\n", my_tree_view); /* ignore the 
warning */

fflush (stdout);

to assert if you get always the memory address you expect. Otherwise 
something is wrong.


If you get NULL when you expected your treeview address, this is usually 
an error easy to track down.


Carlos



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



Finally, I found the error.  I've gone through the treeviews and tree 
stores many times already.  I had it isolated to a specific function, 
but still couldn't find.  After revisiting the the treeview many times 
the problem was the column with the check box.  The enum being used in 
gtk_tree_view_insert_column_with_attributes() was CHECK_BOX when it 
should have been TIP_CHECK_BOX both are valid but have different values. 
 I stared at this many times and didn't notice the error.


This was a change made a few weeks ago before I put the program down to 
do taxes.  It cost a lot of time.


Thanks,

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


Treeview CRITICAL Error

2009-04-25 Thread dhk
I have a program that I'm trying to clean up.  There is a lot going on 
so please bear with me and I try to keep it brief.


First - the build environment uses autoconf.  The only reason I mention 
this is because in the Makefile.am when the -g options is added to the 
CFLAGS is only seems to compile when the -O (Optimization) option is 
present.  However the options is set as -O0 (that's Dash-Oh-Zero) which 
should turn optimization off.


Second - when stepping through the program with the debugger the usual 
strange looping occurs due to optimization; I can't explain why it 
happens, but it does.  This leads to a problem where many variables are 
optimized out.  In the debugger variables are set as "out>".  Does anyone know if this is normal/ok or does it indicate sloppy 
programming?  I'd like to be able to compile the program without 
optimization, but so far this has just been an annoyance.


Third - the problem.  The application window has a notebook with a 
handful of tabs, each with different tree views on them.  The program 
seems to run fine.  However, when the second tab is selected, no matter 
what the previous tab was, the following three error lines get printed 
about three times.


(prog:16939): Gtk-CRITICAL **: gtk_tree_store_get_value: assertion 
`column < tree_store->n_columns' failed


(prog:16939): GLib-GObject-CRITICAL **: g_object_set_property: assertion 
`G_IS_VALUE (value)' failed


(prog:16939): GLib-GObject-CRITICAL **: g_value_unset: assertion 
`G_IS_VALUE (value)' failed


Now from the debugger these lines appear to get printed on calls to 
gtk_tree_store_prepend() and gtk_tree_view_set_cursor(); however, 
nothing fails, only the Gtk-CRITICAL messages get printed.


Now the strange part.  The functions that call gtk_tree_store_prepend() 
and gtk_tree_view_set_cursor() get a tree view pasted in as a gpointer 
and then it's cast to a GtkWidget.  In the debugger when the tree view 
is printed it says "" and when printed with a star 
'*' preceding the tree view it displays 0x0:  NULL.  An assert of the 
NULL tree view doesn't fail.  Then the tree model is gotten from the 
tree view and that says the same thing as the tree view "optimized out>" and 0x0.  An assert on the tree model doesn't fail 
either.  Then the CRITICAL messages are printed on the calls to the two 
gtk_tree_...() function above.


Anyone, what is going on? and what am I dealing with?

Thanks a heap in advance,

dave



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


gdb error

2009-03-29 Thread dhk
When using gdb I get the following error as soon as I hit gtk_init() in 
may main.


(gdb)
60gtk_set_locale ();
(gdb)
61gtk_init(&argc, &argv);
(gdb)
[Thread debugging using libthread_db enabled]
Error while reading shared library symbols:
Cannot find new threads: generic error
Cannot find new threads: generic error
(gdb) q

Thanks,

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


Treeview Signals

2009-03-16 Thread dhk
All,

I have a treeview with Text and Combo Renderers.  The key-press event is
connected to the treeview.  Why does the key-press callback only get
called when the focus cell is a text renderer?  I would like it to be
called when the focus cell is a combo render also.

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


Re: 2. Re: General tips about GTK+ programming

2009-03-05 Thread dhk
Ali Abdallah wrote:
> 
>>
>>
>> --
>>
>> Message: 1
>> Date: Tue, 3 Mar 2009 09:39:51 -0300
>> From: Tomaz Canabrava 
>> Subject: Re: General tips about GTK+ programming
>> To: Vlad Volodin 
>> Cc: gtk-app-devel-list@gnome.org
>> Message-ID:
>> <7ebbb4b50903030439k5e4bc73asff21305eefd84...@mail.gmail.com>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>> from what I'v been into, it's better to write object oriented software
>> using object oriented programming languages. I know some in this list
>> dislikes c++ , but it's more sane than use pointers and simulations of
>> classes.
>> you will not learn how to program better by converting your gtkmm code
>> to gtk, your code will be larger and will do the same thing.
>>   
> I think what he was saying about "learning more when converting his
> program to GTK" is valid,
> since in C you deal with lower level programming than C++ , also you
> know Gtk+ is written in C,
> so when he gets used of C/Gtk/GObject programming he could easily
> understand the way Gtk+ is done.
> 
> My 2 cents.
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

Is there a way to start adding C++ code to an existing C GTK program?
How would you start to convert a GTK program written in C to a GTK
program in C++?

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


Scrolling multiple treeviews

2009-02-28 Thread dhk
Is it possible to have a single vertical scrollbar scroll multiple
treeviews?

To avoid using a horizontal scroll on a large set of data I broke the
data up into multiple treeviews.  However, I would like to have one
scroll control all the views at the same time instead of each treeview
having it's own scrollbar.

All ideas and examples are welcome.

Thanks in advance.

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


Re: Inherited Function Key Behavior

2009-02-07 Thread dhk
Larry Reaves wrote:
> Googling for "gtk f10" turns up this:
> http://markmail.org/message/aff2za6nil5ftzso
> 
> Basically, this should do the trick:
> 
> GtkSettings *gtk_settings;
> gtk_settings = gtk_settings_get_for_screen(gdk_screen_get_default());
> g_object_set(gtk_settings, "gtk-menu-bar-accel", NULL, NULL);
> 
> What that does is set the gtk-menu-bar-accel property (the keybinding
> for the menubar) to NULL, which keeps it from triggering.
> 
> Alternatively, you should be able to set it to F9 for example via
> g_object_set(gtk_settings, "gtk-menu-bar-accel", "F9", NULL);
> 
> -Larry
> 
> 
> On Sat, 2009-02-07 at 16:05 -0500, dhk wrote:
>> My GTK program seems to have inherited some function keys from
>> somewhere.  When I press F10 the menu in the menu bar opens and when I
>> press F10 again it goes away.  The same behavior happens in the
>> gnome-terminal.  When I press F10 my key press event isn't even called,
>> but F9 and others work.  Does anyone know what causes this and how to
>> override it?
>>
>> Thanks,
>>
>> dave
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
> 
That worked, Thanks.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Inherited Function Key Behavior

2009-02-07 Thread dhk
My GTK program seems to have inherited some function keys from
somewhere.  When I press F10 the menu in the menu bar opens and when I
press F10 again it goes away.  The same behavior happens in the
gnome-terminal.  When I press F10 my key press event isn't even called,
but F9 and others work.  Does anyone know what causes this and how to
override it?

Thanks,

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


Re: MenuItem activate signal

2009-02-06 Thread dhk
Carlos Pereira wrote:
> I am fairly experienced with sensitive/insensitive states in Menuitems
> in old Option Menus and new Combo Boxes, but I am not sure in which
> context your Menuitem appears...
> 
> Could you explain what is the parent of your MenuItems? perhaps with a
> very small bit of code showing how they are created?
> 
> Regards,
> Carlos
>> I have a callback that is called when a MenuItem is selected, but in the
>> callback the paramenter is which is suppose to be the MenuItem is NULL.
>>  The callback signature is "void user_function (GtkMenuItem *menuitem,
>> gpointer user_data)".
>>
>> What I want to do is set menuitem to be insensitive when sellected and
>> then sensitive when the task it calls is done.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Dave
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>
>>   
> 
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
The menu is built from a Glade interface.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


MenuItem activate signal

2009-02-06 Thread dhk
I have a callback that is called when a MenuItem is selected, but in the
callback the paramenter is which is suppose to be the MenuItem is NULL.
 The callback signature is "void user_function (GtkMenuItem *menuitem,
gpointer user_data)".

What I want to do is set menuitem to be insensitive when sellected and
then sensitive when the task it calls is done.

Any ideas?

Thanks,

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


Keyed Data Lists

2009-02-03 Thread dhk
Does anyone have an example of how to use "Keyed Data Lists"?

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


Making a Preference Window

2009-01-31 Thread dhk
Does anyone know how to save a modification to GTK program as a Glade
Project?  The reason I want to do this is so the next time the program
is run it starts in a certain state.

For example, one of the things I'd like to do is add a preference window
to my GTK program.  I can design the preference window in Glade and call
it with glade_xml_new() and then glade_parser_parse_file().  After all
options are selected I'd like to save them as a .glade file and use that
one the next time or revert to the original.

I think I need to use the GladeProject and GladeWidget libraries, but
not sure if this is what I want or how to use them.

Is this the correct approach or are there better ways?

Thanks in advance.

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


Printing vs Logging

2009-01-16 Thread dhk
Can someone explain the difference between when to use 1) Message
Logging, 2) the Message Output and Debugging Functions, and 3) the
printing in the String Utility Functions?  It seems that for logging
purposes either of the three can be used.  Is there any advantage of one
over the other?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


How to hide a GtkTreeSelection

2009-01-11 Thread dhk
How do you hide a GtkTreeSelection once you have the row selected?
Instead of deleting the row I would like to make it invisible.

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


Re: Glade signal connect data and full

2008-11-11 Thread dhk
Mike Massonnet wrote:
> Hi, and really quickly,
> 
> Le Mon, 10 Nov 2008 08:38:53 -0500,
> dhk <[EMAIL PROTECTED]> a écrit :
> 
>> All,
>>
>> Could some explain how to use glade_xml_signal_connect_data() and
>> glade_xml_signal_connect_full()?  Some good examples would be helpful
>> also.
> 
> http://www.google.com/codesearch?q=lang%3Ac+glade_xml_signal_connect_full
> 
>> Thanks,
>>
>> dave
> 
> HTH
> Mike
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Thanks, but this is a lot like the glade source.  It doesn't explain the
variables.  I need to know what the parameters are and where they come
from.  I think the handler_name the one in the glade xml file and the
GladeXMLConnectFunc some made up function to execute.  Is this correct?

I'm not sure if these are the functions I need to do what I want, but
they seem correct.  What I want to do is pass a value for user_data into
a handler when a button is clicked.  The glade_xml_signal_autoconnect()
function doesn't let me do that.

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

Glade signal connect data and full

2008-11-10 Thread dhk
All,

Could some explain how to use glade_xml_signal_connect_data() and
glade_xml_signal_connect_full()?  Some good examples would be helpful also.

I don't think I know the difference between the signal handler name and
the signal handler function that is used as parameters.

In my GTK program I want to pass different values for user_data for a
button click depending upon notebook tab that has focus.

Also is there a way to disconnect a signal made with
glade_xml_signal_connect_data() from an object?

Thanks,

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


Passing an iter

2008-10-20 Thread dhk
Is it safe to pass an iter as a parameter to a function?

Thanks,

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


Re: gtkmm and autoconf

2008-10-03 Thread dhk
Ruben Safir wrote:
> Hello
> 
> I'm really a novice at autoconf and automake and trying to learn some
> gtkmm but I'm running into a problem that I just don't have the
> familiarity to solve and I'd like to request some help
> 
> I've done a google search for a solution and came up blank so I hope
> someone can help me here.
Try these links . . .
http://sources.redhat.com/automake/automake.html
http://sourceware.org/autobook/autobook/autobook_283.html

> 
> I'm working from documentation here
> http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-headers-and-linking.html
> http://www.openismus.com/documents/linux/automake/automake.shtml#ExampleFiles
> http://www.elitecoders.de/mags/cscene/CS2/CS2-10.html
> http://www.openismus.com/documents/linux/automake/automake.shtml
> and of course the GNU manual and http://sources.redhat.com/autobook/
> 
> I need to include the include and library flags into autoconf and
> automake and it seems to fail to pickup the gtkmm and gtk library
> 
> I'm using this autogen.sh script
> -
> #! /bin/sh
> 
> # $Id: autogen.sh,v 1.4 2002/12/02 01:39:49 murrayc Exp $
> #
> # Copyright (c) 2002  Daniel Elstner  <[EMAIL PROTECTED]>
> #
> # This program is free software; you can redistribute it and/or modify
> dir=`echo "$0" | sed 's,[^/]*$,,'`
> echo $dir
> test "x${dir}" = "x" && dir='.'
> 
> if test "x`cd "${dir}" 2>/dev/null && pwd`" != "x`pwd`"
> then
> echo "This script must be executed directly from the source
> directory."
> exit 1
> fi
> 
> rm -f config.cache acconfig.h
> 
> echo "- libtoolize."&& \
> libtoolize --force  && \
> echo "- aclocal."   && \
> aclocal && \
> echo "- autoconf."  && \
> autoconf&& \
> echo "- autoheader."&& \
> autoheader  && \
> echo "- automake."  && \
> automake --add-missing --gnu&& \
> echo&& \
> ./configure "$@"&& exit 0
> 
> exit 1
> 
> 
> 
> 
> This is my top level configure.ac
> 
> AC_INIT(src/one_window.cc)
> 
> AM_INIT_AUTOMAKE(one_window,0.1)
> AM_CONFIG_HEADER(config.h)
> 
> AC_PROG_CC
> AC_PROG_CXX
> 
> AC_PROG_INSTALL
> AC_PROG_LIBTOOL
> 
> PKG_CHECK_MODULES([MYAPP], [gtkmm-2.4 >= 2.4.0])
> AC_OUTPUT(Makefile src/Makefile)
> --
In my configure.ac I have the following and it work fine.  Yours looks
the same except for the brackets "[]" around MYAPP.
pkg_modules="gtk+-2.0 >= 2.0.0 libglade-2.0 >= 2.0.0 libxml-2.0 >= 2.0.0"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])

> 
> 
> 
> 
> This is my toplevel Makefile.am
> 
> 
> SUBDIRS = src
> EXTRA_DIST=autogen.sh
> 
> 
> 
> 
> 
> This is my src directory Makefile.am
> ___
> 
> bin_PROGRAMS = onewindow
> onewindow_SOURCES = one_window.cc 
> 
> __
> 
> 
> and the C++ code is very simple
> one_window.cc
> _
> #include 
> 
> int main(int argc, char *argv[])
> {
> Gtk::Main kit(argc, argv);
> 
> Gtk::Window window;
> 
> Gtk::Main::run(window);
> 
> return 0;
> }
> _
> 
> 
> 
> Everything seems to work except for the make command
> 
> [EMAIL PROTECTED]:~/cplus/pharm/gmm> make
> make  all-recursive
> make[1]: Entering directory `/home/ruben/cplus/pharm/gmm'
> Making all in src
> make[2]: Entering directory `/home/ruben/cplus/pharm/gmm/src'
>  cd .. && /bin/sh /home/ruben/cplus/pharm/gmm/missing --run automake-1.9
> --gnu  
> src/Makefile
>  cd .. && /bin/sh ./config.status src/Makefile depfiles
> config.status: creating src/Makefile
> config.status: executing depfiles commands
> make[2]: Leaving directory `/home/ruben/cplus/pharm/gmm/src'
> make[2]: Entering directory `/home/ruben/cplus/pharm/gmm/src'
> if g++ -DHAVE_CONFIG_H -I. -I. -I.. -g -O2 -MT one_window.o -MD -MP
> -MF ".de
> ps/one_window.Tpo" -c -o one_window.o one_window.cc; \
> then mv -f ".deps/one_window.Tpo" ".deps/one_window.Po"; else rm -f
> ".deps/one_w
> indow.Tpo"; exit 1; fi
> one_window.cc:1:19: gtkmm.h: No such file or directory
> one_window.cc: In function `int main(int, char**)':
> one_window.cc:5: error: `Gtk' undeclared (first use this function)
> one_window.cc:5: error: (Each undeclared identifier is reported only
> once for 
>each function it appears in.)
> one_window.cc:5: error: syntax error before `::' token
> make[2]: *** [one_window.o] Error 1
> make[2]: Leaving directory `/home/ruben/cplus/pharm/gmm/src'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/home/ruben/cplus/pharm/gmm'
> make: *** [all] Error 2
> 
> 
> The resulting Makefile.in h

Re: Need to get the tree view from the model

2008-09-17 Thread dhk

Emmanuele Bassi wrote:

On Wed, 2008-09-17 at 13:48 +, dhk wrote:
What is the most direct way to get the tree view from the tree model?  I 
don't see a function for doing this.


it wouldn't make any sense.

a model can be used as the data source for many TreeView widgets.

Also, when I went to the source, GtkTreeModel is defined a follows: 
typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */


Why is it called a "Dummy typedef" and why can't I find the structure 
for it?


there is no data structure: GtkTreeModel is an interface. the dummy
typedef is there just for type casting purposes.

ciao,
 Emmanuele.

I have different treeviews that use the same model, each on a notebook 
tabs.  Whenever a row is added I call gtk_tree_model_foreach(), which 
passes in the model, to get the highest line number (user_data is used 
to pass back the number).  My GtkTreeModelForeachFunc function uses a 
static variable to keep track of the highest number.  The problem is if 
the user switches tabs I need to reset the static variable since the 
treview changed.


What I think I'll do is after the gtk_tree_model_foreach() call when I 
get my line number I'll call my GtkTreeModelForeachFunc with NULLs which 
 will reset my static variable.  That should be acceptable.


Thanks all,
Dave




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


Need to get the tree view from the model

2008-09-17 Thread dhk
What is the most direct way to get the tree view from the tree model?  I 
don't see a function for doing this.


Also, when I went to the source, GtkTreeModel is defined a follows: 
typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */


Why is it called a "Dummy typedef" and why can't I find the structure 
for it?


Thanks,

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


Getting GtkCellRenderer's

2008-09-09 Thread dhk

How do you get a GtkCellRenderer from a treeview or a GtkTreeViewColumn?

Thanks,

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


Re: g_signal_emit()

2008-09-01 Thread dhk

dhk wrote:

Kristian Rietveld wrote:

On Sun, Aug 31, 2008 at 2:08 PM, dhk <[EMAIL PROTECTED]> wrote:

I have two callback functions.  The first for when a cell in a treeview
gets edited and the second for when the tab key is pressed.  The 
first works
fine.  In the second, I want to emit the "edited" signal so it acts 
as if

the first event happened.  However, the g_signal_emit() in the
"key-press-event" callback does not seem to work.

I am doing the following and the renderer and sig_id are valid.

sig_id=g_signal_lookup("edited", G_OBJECT_TYPE(renderer));
g_signal_emit(renderer, sig_id, 0);


It looks like you are trying to emit the edited signal here without
specifying the correct arguments.


In short what I'm trying to do is emit the "edited" event when the
"key-press-event" occurs.  That way when the use tabs off the cell in 
the

treeview the callback for the "edited" event is called.  It doesn't make
sense the if there are two way to leave a cell (tabbing off it or 
clicking

outside of it) that you can't call the same event.


Maybe you can try using gtk_cell_editable_editing_done() here?  The
editing-done signal handler of the respective cell editable will take
care of emitting the edited signal.  You can get hold of the correct
cell editable by listening for the editing-started signal on the cell
renderer.


regards,

-kris.

That sounds like it could work.  I'll see if I can get the 
GtkCellEditable from gtk_cell_renderer_start_editing().  That seems to 
take a lot of parameter that I don't have.  I'll let you know what happens.


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

Kris, that was a great idea.  The tricky part was getting the 
GtkCellEditable pointer without doing a lot of work.  Doing a lot of 
work usually means I'm doing something wrong.  After looking at the gtk 
source, I was able to come up with the following four lines.  It will 
emit the "edited" signal from a "key-press-event" callback.


gtk_tree_view_get_cursor(GTK_TREE_VIEW(treeview), &tp, &focus_column);
if(focus_column!=NULL) {
  gtk_cell_editable_editing_done(focus_column->editable_widget);
}

Thanks,

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


Re: g_signal_emit()

2008-08-31 Thread dhk

Kristian Rietveld wrote:

On Sun, Aug 31, 2008 at 2:08 PM, dhk <[EMAIL PROTECTED]> wrote:

I have two callback functions.  The first for when a cell in a treeview
gets edited and the second for when the tab key is pressed.  The first works
fine.  In the second, I want to emit the "edited" signal so it acts as if
the first event happened.  However, the g_signal_emit() in the
"key-press-event" callback does not seem to work.

I am doing the following and the renderer and sig_id are valid.

sig_id=g_signal_lookup("edited", G_OBJECT_TYPE(renderer));
g_signal_emit(renderer, sig_id, 0);


It looks like you are trying to emit the edited signal here without
specifying the correct arguments.


In short what I'm trying to do is emit the "edited" event when the
"key-press-event" occurs.  That way when the use tabs off the cell in the
treeview the callback for the "edited" event is called.  It doesn't make
sense the if there are two way to leave a cell (tabbing off it or clicking
outside of it) that you can't call the same event.


Maybe you can try using gtk_cell_editable_editing_done() here?  The
editing-done signal handler of the respective cell editable will take
care of emitting the edited signal.  You can get hold of the correct
cell editable by listening for the editing-started signal on the cell
renderer.


regards,

-kris.

That sounds like it could work.  I'll see if I can get the 
GtkCellEditable from gtk_cell_renderer_start_editing().  That seems to 
take a lot of parameter that I don't have.  I'll let you know what happens.


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


Re: g_signal_emit()

2008-08-31 Thread dhk

dhk wrote:
I have two callback functions.  The first for when a cell in a treeview 
gets edited and the second for when the tab key is pressed.  The first 
works fine.  In the second, I want to emit the "edited" signal so it 
acts as if the first event happened.  However, the g_signal_emit() in 
the "key-press-event" callback does not seem to work.


I am doing the following and the renderer and sig_id are valid.

sig_id=g_signal_lookup("edited", G_OBJECT_TYPE(renderer));
g_signal_emit(renderer, sig_id, 0);

When I get to the g_signal_emit() call I get the following error.
g_signal_emit(renderer, sig_id, 0);
Program received signal SIGSEGV, Segmentation fault.
0x7f712d797ad0 in strlen () from /lib/libc.so.6

The backtrace from gdb is:
#0  0x7f712d797ad0 in strlen () from /lib/libc.so.6
#1  0x7f712ddfbd03 in g_strdup () from /usr/lib/libglib-2.0.so.0
#2  0x7f712e4b7dc8 in ?? () from /usr/lib/libgobject-2.0.so.0
#3  0x7f712e4a4897 in g_signal_emit_valist ()
   from /usr/lib/libgobject-2.0.so.0
#4  0x7f712e4a4db3 in g_signal_emit () from 
/usr/lib/libgobject-2.0.so.0




If I use g_signal_emit_by_name() I get the following error in gdb.

g_signal_emit_by_name(G_OBJECT(renderer), "edited::cellEditedCb");
  or
g_signal_emit_by_name(G_OBJECT(renderer), "edited::0");

WARNING gsignal.c:2140: signal id `193' does not support detail (1256)

All I'm trying to do is have the "key-press-event" act like the "edited" 
event when the tab key is pressed.


How can this be done?

Thanks,

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



In short what I'm trying to do is emit the "edited" event when the 
"key-press-event" occurs.  That way when the use tabs off the cell in 
the treeview the callback for the "edited" event is called.  It doesn't 
make sense the if there are two way to leave a cell (tabbing off it or 
clicking outside of it) that you can't call the same event.


Any ideas?

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


g_signal_emit()

2008-08-30 Thread dhk
I have two callback functions.  The first for when a cell in a treeview 
gets edited and the second for when the tab key is pressed.  The first 
works fine.  In the second, I want to emit the "edited" signal so it 
acts as if the first event happened.  However, the g_signal_emit() in 
the "key-press-event" callback does not seem to work.


I am doing the following and the renderer and sig_id are valid.

sig_id=g_signal_lookup("edited", G_OBJECT_TYPE(renderer));
g_signal_emit(renderer, sig_id, 0);

When I get to the g_signal_emit() call I get the following error.
g_signal_emit(renderer, sig_id, 0);
Program received signal SIGSEGV, Segmentation fault.
0x7f712d797ad0 in strlen () from /lib/libc.so.6

The backtrace from gdb is:
#0  0x7f712d797ad0 in strlen () from /lib/libc.so.6
#1  0x7f712ddfbd03 in g_strdup () from /usr/lib/libglib-2.0.so.0
#2  0x7f712e4b7dc8 in ?? () from /usr/lib/libgobject-2.0.so.0
#3  0x7f712e4a4897 in g_signal_emit_valist ()
   from /usr/lib/libgobject-2.0.so.0
#4  0x7f712e4a4db3 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0



If I use g_signal_emit_by_name() I get the following error in gdb.

g_signal_emit_by_name(G_OBJECT(renderer), "edited::cellEditedCb");
  or
g_signal_emit_by_name(G_OBJECT(renderer), "edited::0");

WARNING gsignal.c:2140: signal id `193' does not support detail (1256)

All I'm trying to do is have the "key-press-event" act like the "edited" 
event when the tab key is pressed.


How can this be done?

Thanks,

dave
___
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-event event clears cell in treeview

2008-08-28 Thread dhk

dhk wrote:
I have a key-press-event connected to my treeview so a Tab can be used 
to navigate through the cells.  It work well except that when the Tab is 
pressed it clear all the data in the cell.  If I use the mouse to move 
to another cell the data remains.


My callback doesn't touch the data.  All it does is get tree paths, 
columns, and then grabs focus and sets the cursor on a cell.  None of 
that should clear the data in a cell . . . should it?


Does Anyone know of any reason for this?

Thanks,

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

I've narrowed down the problem to a callback not getting called when the 
 key-press-event event occurs.  If I click off the field first the 
callback set the data with the "edited" event.  Then I can go back to 
the field and tab off and the data remains.


What I think I need to do is call g_signal_emit_by_name() in the 
key-press-event event callback, but I haven't gotten it working yet. 
The prototype from the gtk documentation is: 
g_signal_emit_by_name(gpointer instance, const gchar *detailed_signal, 
...);.  Can some explain the parameter to this?  I don't think I'm 
getting them right.  I think the instance is my treeview or renderer. 
The detailed-signal is in the form of "signal-name::detail"  which I 
know the signal is "edited" but what is the detail suppose to be?


Thanks,

dave


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


Re: Clone a notebook tab?

2008-08-28 Thread dhk

Roland Roberts wrote:
Is there a way to clone a notebook tab?  I'm writing an application 
where I've laid out the tab using glade.  The tab is for controlling a 
camera, and I may have multiple cameras.  Each time I connect one, I'd 
like to clone a generic tab then reassign data associated with the tab 
just like I do when the first camera attaches.  Is there any shortcut 
other than writing the layout completely in code?


roland

I get the object out of the .glade file whenever I need to duplicate a 
widget and then add it to the container.  In your case, a notebook tab, 
the object would be probably be a vbox in the .glade file and your 
container would be the notebook you want to add it to.


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


key-press-event event clears cell in treeview

2008-08-26 Thread dhk
I have a key-press-event connected to my treeview so a Tab can be used 
to navigate through the cells.  It work well except that when the Tab is 
pressed it clear all the data in the cell.  If I use the mouse to move 
to another cell the data remains.


My callback doesn't touch the data.  All it does is get tree paths, 
columns, and then grabs focus and sets the cursor on a cell.  None of 
that should clear the data in a cell . . . should it?


Does Anyone know of any reason for this?

Thanks,

dave
___
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 create unique widget when reusing widget id's from a GladeXML object.

2008-08-12 Thread dhk

Tristan Van Berkom wrote:

oops this missed the list...

On Tue, Aug 12, 2008 at 6:58 AM, Olivier Guilyardi <[EMAIL PROTECTED]> wrote:
[...]

About performance, from the liblglade manual : "the XML parse tree is cached
to speed up creating another GladeXML object for the same file".


Yes, and for the same reasons outlined above its a good idea to unref
your GladeXML objects as soon as your UI is built, so you dont have
access to the hash map provided by the glade xml.

dhk:
  Your theory about keeping track by pages is indeed sane,
you can use a simple recursive algorythm to find a widget
by name inside a page, I'll leave some pseudo code for you here,
but IMO, using a structure in a list to hold pointers to the desired
widgets and other page specific datas is cleaner and better
programming practice - mostly because it maintains a cleaner
split between business logic and user interface.

Consider that when your UI and business logic become more
complex; with your model you might end up using g_object_get/set_data()
alot and working directly with widgets (which you may decide to rename,
change in the UI) - and with structs in a list, you will be adding struct
members instead - and possibly tweaking the code portion that
loads the structs and builds the UI whenever the UI might change.

Cheers,
  -Tristan


Find widget in container by name recursively:

container_foreach (container, widget) {
 if (!strcmp (gtk_widget_get_name (widget) , data.search))
 data.widget = widget;

  if (is_container (widget))
 gtk_container_foreach (widget, container_foreach, data);

}


GtkWidget *find_widget_in_container (container, name)
{
  struct {
   gchar *search = name;
   GtkWidget *widget = NULL;
  } data;

  gtk_container_foreach (container, container_foreach, &data);
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Good point, but right now I don't want to store the info.  I'll look it 
up when necessary.  I'll keep it in mind though.


Thanks,
dave
___
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 create unique widget when reusing widget id's from a GladeXML object.

2008-08-12 Thread dhk

Olivier Guilyardi wrote:

Hi,

dhk wrote:
How can a unique widget be created by using the same widget from a 
GladeXML object multiple times?


You can use different GladeXML objects, constructed out of the same 
glade file. Example:


GladeXML *xml = glade_xml_new("test.glade", NULL, NULL);
GtkWidget *widget1 = glade_xml_get_widget(xml, "mywidget");

GladeXML *xml2 = glade_xml_new("test.glade", NULL, NULL);
GtkWidget *widget2 = glade_xml_get_widget(xml2, "mywidget");

Here widget1 and widget2 (and their children) are different "instances" 
of mywidget.


About performance, from the liblglade manual : "the XML parse tree is 
cached to speed up creating another GladeXML object for the same file".


Regards,

This is exactly the way I expected it to work, and it does.  Thanks for 
the confirmation on the functionality.  It help me find the real problem 
that was somewhere else.  At least now I know for sure that this 
procedure is acceptable.


Thanks,
dave
___
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 create unique widget when reusing widget id's from a GladeXML object.

2008-08-12 Thread dhk

Tristan Van Berkom wrote:

If you are using one glade file for the tab contents and parsing it again
for each tab, then you get widgets in your runtime interface that have
the same name, thats not an issue for gtk+ - but, as you named them
yourself, its up to you to identify them some other way.

Im not sure I understood properly what you wrote, but if I did, I would
expect you to be using a list of structs or objects representing the
data and widgets in that tab.

Cheers,
   -Tristan

On Mon, Aug 11, 2008 at 7:15 PM, dhk <[EMAIL PROTECTED]> wrote:

dhk wrote:

I'm adding tabs to a notebook by getting the tab (a vbox) out of a
GladeXML object.  The tab widget returned from glade_xml_build_widget() can
be added to the notebook and everything works fine.

The problem is when more tabs are added.  It doesn't seem like the widget
id's on each tab are exclusive to that tab.  The last tab added behaves the
best, but if a previous tab is clicked data entered and events on that tab
appear on the last tab.  This appears to be because the widget id's are the
same in each tab because each tab was build from the same widget in the
GladeXML file.  What happens is when there are two tabs, the data placed in
a field on tab one shows up in the field on both tabs.  I thought the scope
of the widget added to one tab would be out of scope for all other tabs.

How can a unique widget be created by using the same widget from a
GladeXML object multiple times?

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


Does this have to do with referencing?  It looks like the same resources are
being used by the new widgets.  Any ideas?

Thanks,
dave


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



Are you saying that I have to get each object out of the widget and 
store their reference and data somewhere?  That sounds like it could get 
messy.  I thought just by adding a widget to a container, in this case a 
notebook container, would keep track of that widget as long a I could 
keep track of the page it's on.


What's happening is I add the same widget from the Glade xml, it's a 
vbox which is a tab page to a notebook, multiple times.  Now I have a 
notebook of n pages.  Each page is a form.  The data and events on one 
page affect other pages which it shouldn't.  Each page has a unique name 
so when I search that vbox widget for the page with focus I would expect 
to get the widgets of the form on that page, but I don't.  So in a way I 
am keeping track of the widget by the unique name of the tab.  Is this ok?


Thanks,
dave
___
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 create unique widget when reusing widget id's from a GladeXML object.

2008-08-11 Thread dhk

dhk wrote:
I'm adding tabs to a notebook by getting the tab (a vbox) out of a 
GladeXML object.  The tab widget returned from glade_xml_build_widget() 
can be added to the notebook and everything works fine.


The problem is when more tabs are added.  It doesn't seem like the 
widget id's on each tab are exclusive to that tab.  The last tab added 
behaves the best, but if a previous tab is clicked data entered and 
events on that tab appear on the last tab.  This appears to be because 
the widget id's are the same in each tab because each tab was build from 
the same widget in the GladeXML file.  What happens is when there are 
two tabs, the data placed in a field on tab one shows up in the field on 
both tabs.  I thought the scope of the widget added to one tab would be 
out of scope for all other tabs.


How can a unique widget be created by using the same widget from a 
GladeXML object multiple times?


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

Does this have to do with referencing?  It looks like the same resources 
are being used by the new widgets.  Any ideas?


Thanks,
dave


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


How to create unique widget when reusing widget id's from a GladeXML object.

2008-08-10 Thread dhk
I'm adding tabs to a notebook by getting the tab (a vbox) out of a 
GladeXML object.  The tab widget returned from glade_xml_build_widget() 
can be added to the notebook and everything works fine.


The problem is when more tabs are added.  It doesn't seem like the 
widget id's on each tab are exclusive to that tab.  The last tab added 
behaves the best, but if a previous tab is clicked data entered and 
events on that tab appear on the last tab.  This appears to be because 
the widget id's are the same in each tab because each tab was build from 
the same widget in the GladeXML file.  What happens is when there are 
two tabs, the data placed in a field on tab one shows up in the field on 
both tabs.  I thought the scope of the widget added to one tab would be 
out of scope for all other tabs.


How can a unique widget be created by using the same widget from a 
GladeXML object multiple times?


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


Re: Finding a widget in a Glade interface

2008-08-10 Thread dhk

Chris Vine wrote:

On Sat, 09 Aug 2008 18:18:40 +
dhk <[EMAIL PROTECTED]> wrote:

Referencing the widgets is what I'm trying to do.  So, are you
saying, the function is ok without any freeing?  Also, am I
decrementing the reference count? I don't see it.


You will need to free the list: your mistake was in trying to free its
contents. As I said, I do not think that you need to decrement any
reference counts on the widgets, but if you are in doubt you should
look at the source code (by which I meant, look at the GTK+ source
code).

To understand GTK+ memory management more generally, try this:
http://library.gnome.org/devel/gtk/stable/GtkObject.html
and as further background, this:
http://library.gnome.org/devel/gobject/stable/gobject-The-Base-Object-Type.html

You should generally never call g_free() on any object derived from
GObject/GInitiallyUnowned/GtkObject (which includes anything derived
from GtkWidget), as memory and lifetime management is done by reference
counting.

Chris



Great, that should do it.

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


Re: Finding a widget in a Glade interface

2008-08-09 Thread dhk

Chris Vine wrote:

On Sat, 09 Aug 2008 10:06:57 +
dhk <[EMAIL PROTECTED]> wrote:
[snip]

Does anyone have any ideas on how to free the memory correctly?


g_list_foreach() operates on the data held by the list element, not on
the element itself, so your freeGList() function is wrong, even if
freeing the data is correct.

However, if the list elements reference widgets, as I assume, then you
shouldn't be freeing them anyway.  I strongly suspect you should not
even be decrementing the reference count, as I doubt that
gtk_container_get_children() passes over ownership, but inspecting the
source code will reveal that.

Chris

Referencing the widgets is what I'm trying to do.  So, are you saying, 
the function is ok without any freeing?  Also, am I decrementing the 
reference count? I don't see it.


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


Re: Finding a widget in a Glade interface

2008-08-09 Thread dhk

dhk wrote:

Nicola Fontana wrote:

On Sun, 03 Aug 2008 19:10:37 +
dhk <[EMAIL PROTECTED]> wrote:
Is gtk_container_get_children() suppose to return a list of all 
children including children of children down to the last leaf or just 
the immediate children?  I only seem to get the immediate children.  
Will gtk_container_foreach() or gtk_container_forall() go down all 
levels to the last leaf or just the next level?


Both work on immediate children. You must call them recursively,
something like that:

void
action(GtkWidget *widget)
{
  /* Do something */
}

void
callback(GtkWidget *widget)
{
  action(widget);
  if (GTK_IS_CONTAINER(widget))
  gtk_container_foreach(GTK_CONTAINER(widget),
callback, NULL);

}

gtk_container_foreach() is the way: the forall() version
traverses also internal stuff I think you don't care about.

Ciao


Almost there.  I wrote a function, findWidget() below, to find a widget
by name.  This was needed because I'm adding objects to the interface
after Glade has built the interface. It works, but I'm sure it's laeking
memory like a sieve.  Whenever I try to free the memory I have problems.
 How and where should the memory get freed?  Can I get a code review?

/* Recursivly find a widget by name and return it's reference. */
GtkWidget * findWidget(GtkWidget *p, const char *str) {
  GList *children=NULL;
  GList *child=NULL;
  GtkWidget *w=NULL;

  children=gtk_container_get_children(GTK_CONTAINER(p));
  child=children;

  while(child) {

w=GTK_WIDGET(child->data);
if(w!=NULL && w->name!=NULL) {
  g_debug("Name is {%s}\n", w->name);
}

if(w!=NULL && GTK_IS_CONTAINER(w) && w->name!=NULL && strcmp((char
*)w->name, str)!=0) {
  w=findWidget(w, str);
  if(w!=NULL && w->name!=NULL && strcmp((char *)w->name, str)==0) {
break;
  } else {
child=g_list_next(child);
  }
} else {
  break;
}

  } /* end of while() */
  child=g_list_next(child);

  // PROBLEMS freeing memory
  //g_list_foreach(children, (GFunc)freeGList, NULL); // ERROR: double
free or corruption
  //g_list_foreach(children, (GFunc)g_free, children->data); // ERROR
  //g_list_free(children); // ERROR

  return w;
}

/* Callback for freeing memory in a GList. */
void freeGList(gpointer *data, gpointer *user_data) {
  GList *gl=(GList *)data;

  g_free(gl->data);
  gl->data=NULL;
}

Thanks,

Dave



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



Does anyone have any ideas on how to free the memory correctly?

Thanks,
dave

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


Re: Finding a widget in a Glade interface

2008-08-07 Thread dhk

Nicola Fontana wrote:

On Sun, 03 Aug 2008 19:10:37 +
dhk <[EMAIL PROTECTED]> wrote:
Is gtk_container_get_children() suppose to return a list of all children 
including children of children down to the last leaf or just the 
immediate children?  I only seem to get the immediate children.  Will 
gtk_container_foreach() or gtk_container_forall() go down all levels to 
the last leaf or just the next level?


Both work on immediate children. You must call them recursively,
something like that:

void
action(GtkWidget *widget)
{
  /* Do something */
}

void
callback(GtkWidget *widget)
{
  action(widget);
  if (GTK_IS_CONTAINER(widget))
  gtk_container_foreach(GTK_CONTAINER(widget),
callback, NULL);

}

gtk_container_foreach() is the way: the forall() version
traverses also internal stuff I think you don't care about.

Ciao


Almost there.  I wrote a function, findWidget() below, to find a widget
by name.  This was needed because I'm adding objects to the interface
after Glade has built the interface. It works, but I'm sure it's laeking
memory like a sieve.  Whenever I try to free the memory I have problems.
 How and where should the memory get freed?  Can I get a code review?

/* Recursivly find a widget by name and return it's reference. */
GtkWidget * findWidget(GtkWidget *p, const char *str) {
  GList *children=NULL;
  GList *child=NULL;
  GtkWidget *w=NULL;

  children=gtk_container_get_children(GTK_CONTAINER(p));
  child=children;

  while(child) {

w=GTK_WIDGET(child->data);
if(w!=NULL && w->name!=NULL) {
  g_debug("Name is {%s}\n", w->name);
}

if(w!=NULL && GTK_IS_CONTAINER(w) && w->name!=NULL && strcmp((char
*)w->name, str)!=0) {
  w=findWidget(w, str);
  if(w!=NULL && w->name!=NULL && strcmp((char *)w->name, str)==0) {
break;
  } else {
child=g_list_next(child);
  }
} else {
  break;
}

  } /* end of while() */
  child=g_list_next(child);

  // PROBLEMS freeing memory
  //g_list_foreach(children, (GFunc)freeGList, NULL); // ERROR: double
free or corruption
  //g_list_foreach(children, (GFunc)g_free, children->data); // ERROR
  //g_list_free(children); // ERROR

  return w;
}

/* Callback for freeing memory in a GList. */
void freeGList(gpointer *data, gpointer *user_data) {
  GList *gl=(GList *)data;

  g_free(gl->data);
  gl->data=NULL;
}

Thanks,

Dave



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


Re: Finding a widget in a Glade interface

2008-08-03 Thread dhk

Nicola Fontana wrote:

On Thu, 31 Jul 2008 11:07:34 +
dhk <[EMAIL PROTECTED]> wrote:


Jim George wrote:
I wasn't a fan of keeping the GladeXml object around due to the 
resources it used.  Even though it's not as efficient as storing 
pointer, I wish I could just traverse up and down the the object tree 
for my pointer.  I guess I'll be storing the pointers that I need.  That 
would mean that after calling glade_xml_new() I need to call 
glade_xml_get_widget() on each object I will need and then save that 
pointer . . . right?


You don't need special API to traverse Gtk widgets, and GladeXml
is less than needed: just use GTK_IS_CONTAINER() and
gtk_container_get_children() or gtk_container_forall().

If you want to go from the leafs to the root, use
gtk_widget_get_parent().

Is gtk_container_get_children() suppose to return a list of all children 
including children of children down to the last leaf or just the 
immediate children?  I only seem to get the immediate children.  Will 
gtk_container_foreach() or gtk_container_forall() go down all levels to 
the last leaf or just the next level?


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


Re: Finding a widget in a Glade interface

2008-07-31 Thread dhk

Jim George wrote:

I should have mentioned that by time I want to call

glade_xml_get_widget() the GladeXML *xml created by xml =
glade_xml_new("filename.glade", NULL, NULL); is out of scope.  If I call
 open the file again to get the widget it has no affect on the running
window.  I need to get the widget from the running window from some
callback.  Any ideas?

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

tom



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

In addition to the examples posted earlier, you can also download the
source to any standard gtk program for additional examples. I used the
devhelp source for this.
-Jim

I wasn't a fan of keeping the GladeXml object around due to the 
resources it used.  Even though it's not as efficient as storing 
pointer, I wish I could just traverse up and down the the object tree 
for my pointer.  I guess I'll be storing the pointers that I need.  That 
would mean that after calling glade_xml_new() I need to call 
glade_xml_get_widget() on each object I will need and then save that 
pointer . . . right?


Thanks,

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


Re: Finding a widget in a Glade interface

2008-07-30 Thread dhk

Tristan Van Berkom wrote:

On Wed, Jul 30, 2008 at 3:40 PM, Tristan Van Berkom <[EMAIL PROTECTED]> wrote:

for future reference, this could easily have been pulled out
of the docs/header files: glade_xml_get_widget()

type libglade and "feel lucky" its right there.


oops, I obviously meant in google here...


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

Thanks,

Dave




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


Finding a widget in a Glade interface

2008-07-30 Thread dhk
How do you look up a widget when the interface is created with 
glade_xml_new()?


There use to be a lookup_widget() function that worked if you called one 
of the two glade macros:  GLADE_HOOKUP_OBJECT() or 
GLADE_HOOKUP_OBJECT_NO_REF().  Now unless you build the interface 
yourself and hook up each object it doesn't work.


Is there another function embedded somewhere that will find an object 
after calling glade_xml_new()?


Thanks,

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


Re: Callback Parameters are Switched

2008-07-21 Thread dhk

Tomas Carnecky wrote:

dhk wrote:
I'm using glade for a front end which has a button that when clicked 
passes a notebook as the user_data to the callback.


I'm using the gdb debugger to look at the two parameters in the 
callback and they are switched.  The first parameter, the button, is 
the notebook object and the second parameter, the user_data, is the 
button object. If I don't use user_data in Glade the parameter are 
correct, the first is the button and the second is NULL.


Why is this happening?


http://library.gnome.org/devel/gobject/stable/gobject-Signals.html#g-signal-connect-swapped 



tom

Ok, I think that explains it, but how was I suppose to know that was 
happening?  . . . and what is the purpose in swapping the parameters? 
Why do that?


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


Callback Parameters are Switched

2008-07-21 Thread dhk
I'm using glade for a front end which has a button that when clicked 
passes a notebook as the user_data to the callback.


I'm using the gdb debugger to look at the two parameters in the callback 
and they are switched.  The first parameter, the button, is the notebook 
object and the second parameter, the user_data, is the button object. 
If I don't use user_data in Glade the parameter are correct, the first 
is the button and the second is NULL.


Why is this happening?

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


Re: tabbing through a treeview

2008-07-18 Thread dhk

Rui Tiago Cação Matos wrote:

The attached example changes the selected line with just Tab.

Rui


One more question about this.

What is the purpose of checking the event->state?  My event->state is 
always 16, not zero, which is one of the unused values.


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


Getting a Column Number

2008-07-15 Thread dhk

Anyone?

The following will get me the Column from a treeview, but from 
focus_column I don't know if I'm in the first, second, third . . . or 
last column.


GtkTreePath *tp=NULL;
GtkTreeViewColumn *focus_column=NULL;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(treeview), &tp, &focus_column);

How do you get the column number from a GtkTreeViewColumn pointer?  Is 
there a way to get the previous and/or next Column or column number?


Thanks,

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


Getting a Column Number

2008-07-15 Thread dhk
The following will get me the Column from a treeview, but from 
focus_column I don't know if I'm in the first, second, third . . . or 
last column.


GtkTreePath *tp=NULL;
GtkTreeViewColumn *focus_column=NULL;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(treeview), &tp, &focus_column);

How do you get the column number from a GtkTreeViewColumn pointer?  Is 
there a way to get the previous and/or next Column or column number?


Thanks,

Dave

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


Re: tabbing through a treeview

2008-07-14 Thread dhk

Rui Tiago Cação Matos wrote:

The attached example changes the selected line with just Tab.

Rui


It works great.  I just added a few g_print()'s to see what's happening.

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


Re: tabbing through a treeview

2008-07-13 Thread dhk

Rui Tiago Cação Matos wrote:

On 10/07/2008, dhk <[EMAIL PROTECTED]> wrote:

Does anyone know how to move/loop through the fields in a treeview by just
pressing the Tab key?  I would like to make the mouse optional and not a
requirement.


I believe you can connect to the treeview's key-press-event and do
your logic from the handler. Though I'm not sure you can capture the
Tab key before gtk+ captures it and does it's internal widget
navigation.

Good luck,
Rui

I can't seem to get the key-press-event to work for any key pressed.  So 
that's the first problem, after that works then I'll see if the Tab key 
works.


The key-press-event event is connected to a cell renderer but it never 
seems to get called when I type in the cell.  In Glade for my main 
window I have the "Key Press | Structure" set in Events, this set the 
GDK_KEY_PRESS_MASK which the GtkWidget documentation says needs to be set.


So I have my callback, I connect the signal to the callback, and have 
the event mask set on the main window, is there something else that 
needs to be set for the key-press-event?


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

tabbing through a treeview

2008-07-10 Thread dhk
Does anyone know how to move/loop through the fields in a treeview by 
just pressing the Tab key?  I would like to make the mouse optional and 
not a requirement.


Thanks in advance,

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


tabbing through a treeview

2008-07-09 Thread dhk
Does anyone know how to move/loop through the fields in a treeview by 
just pressing the Tab key?  I would like to make the mouse optional and 
not a requirement.


Thanks in advance,

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


Re: Windows over Windows

2008-06-15 Thread dhk

Gregory Hosler wrote:

dhk wrote:
| How can a modal window or dialog from a secondary event always and
| completely cover the main window?  The main window should look like it
| was replaced until the second window or dialog is closed.

Depending upon the sizes of the two windows... The modal window can 
parent itself, and
center itself over the child window. Of course the user can still drag 
the modal window,
uncovering the child window. An alternative would be to have the modal 
window "hide" the
parent window (if that's what you really want), and then unhide it when 
it is being destroyed.


-G

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


I like the hide idea, but when I try to hide the main window nothing 
happens.  The basic logic I'm using to try to hide the main window when 
a new window pops up after selecting from the menu in the main window is:

GtkWidget *tlwin=gtk_widget_get_toplevel(GTK_WIDGET(menuitem));
gtk_widget_hide(tlwin);

Any ideas why the main window is still there?

Thanks,
Dave


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


Windows over Windows

2008-06-15 Thread dhk
How can a modal window or dialog from a secondary event always and 
completely cover the main window?  The main window should look like it 
was replaced until the second window or dialog is closed.


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


Windows verses Dialogs

2008-06-15 Thread dhk
When should a dialog be used instead of a window?  Can't a window always 
be used?  Do you give anything up when using a dialog?  What's the 
difference?


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


glade_xml_signal_autoconnect and user_data

2008-06-06 Thread dhk
Is glade_xml_signal_autoconnect()only used for callbacks that don't take 
user_data?  If not, how can user_data be passed to a callback when using 
glade_xml_signal_autoconnect()?

Thanks,

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


calendar in a treeview

2008-06-05 Thread dhk
How can I update a treeview cell with a date selected from a calendar? 
The cell is a GtkCellRendererText and pops up a calendar with the 
"editing-started" signal when it gets focus.

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


Returning a Calendar date string to a treeview cell

2008-06-04 Thread dhk
I have a treeview with a text render for a date.  I wanted to be able to
pop-up a calendar and select a date and have it get set in the cell of
the treeview.  I'm using the "editing-started" signal from GtkCellRenderer.

My callback function is below.

A couple of things are not clear.  First, on entry into the cell the
calendar pops up and when a date is selected it prints to the terminal
just fine.  The problem is I don't know how to get the date back to the
calling function below in order to set it in the cell.  Second, the data
I set in the cell with g_object_set() and gtk_entry_set_text() is only
there while the cell has focus.  When I move off the cell the data
disappears.

So How can I get the date string back to ipmsDateCellEditingStartedCb()
to set it in the cell and have it remain there?

This is the callback function.

void ipmsDateCellEditingStartedCb(GtkCellRendererText *cell,
GtkCellEditable *editable, gchar *path_string, gpointer user_data) {
   GladeXML *gxml=NULL;
   GtkWidget *tv=GTK_WIDGET(user_data);
   GtkTreeModel* tmdl=gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
   GtkEntry *entry=NULL;

   g_print("ipmsDateCellEditingStartedCb\n");
   gxml=glade_xml_new(FILE_GLADE_XML0, "calendar_dialog", NULL);
   glade_xml_signal_autoconnect(gxml);
   //g_object_set(G_OBJECT(editable), "text", "Stock", NULL);
   if(GTK_IS_ENTRY(editable)) {
 entry=GTK_ENTRY(editable);
 gtk_entry_set_text(entry, "adasdadas");
   }
}

Thanks,
Dave


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


Returning a Calendar date string to a treeview cell

2008-06-03 Thread dhk
I have a treeview with a text render for a date.  I wanted to be able to 
pop-up a calendar and select a date and have it get set in the cell of 
the treeview.  I'm using the "editing-started" signal from GtkCellRenderer.

My callback function is below.

A couple of things are not clear.  First, on entry into the cell the 
calendar pops up and when a date is selected it prints to the terminal 
just fine.  The problem is I don't know how to get the date back to the 
calling function below in order to set it in the cell.  Second, the data 
I set in the cell with g_object_set() and gtk_entry_set_text() is only 
there while the cell has focus.  When I move off the cell the data 
disappears.

So How can I get the date string back to ipmsDateCellEditingStartedCb() 
to set it in the cell and have it remain there?

This is the callback function.

void ipmsDateCellEditingStartedCb(GtkCellRendererText *cell, 
GtkCellEditable *editable, gchar *path_string, gpointer user_data) {
   GladeXML *gxml=NULL;
   GtkWidget *tv=GTK_WIDGET(user_data);
   GtkTreeModel* tmdl=gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
   GtkEntry *entry=NULL;

   g_print("ipmsDateCellEditingStartedCb\n");
   gxml=glade_xml_new(FILE_GLADE_XML0, "calendar_dialog", NULL);
   glade_xml_signal_autoconnect(gxml);
   //g_object_set(G_OBJECT(editable), "text", "Stock", NULL);
   if(GTK_IS_ENTRY(editable)) {
 entry=GTK_ENTRY(editable);
 gtk_entry_set_text(entry, "adasdadas");
   }
}

Thanks,
Dave

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


Representing XML in Tree Stores

2008-05-04 Thread dhk
What is the best way to represent complex xml in a tree store?

It seems like it should be easy, but when looping the models with 
gtk_tree_model_foreach() some problems arise:  especially when there are 
multiple views on different notebook tabs.

The approach I am using is one Tree Store for each complex xml node. 
Then for each item in the first tree I have to loop all other trees to 
find the nodes that belong to it.  I do this by use gtk_tree_model_get() 
on each row to see if the sequence numbers match and if they do it gets 
processed.  The problem I have is I'm looping each store multiple times 
to find what I want, which seems inefficient, instead of looping each 
store once.

Any ideas?

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


treeview combo box - multi select

2007-11-13 Thread dhk
When using a combo box in a treeview, how can it be configured so the
user can select one or more items in the glist?

Thanks,
--dhk

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


multiple selects in a treeview combo

2007-11-07 Thread dhk
I'm sending this again since I haven't gotten any response.

I have a combo render in a treeview and I can't get the callback to set
the value once it's selected.  I want the combo to default to "Stock"
but be able to be changed to any of the other values in the itemtype
array.  Below is the way the item type combo is being created and added
to the tree view followed by the callback.  Does any one see the error?

Thanks,
--dhk

  /* --- ItemType Treeview Column --- */
  renderer = gtk_cell_renderer_combo_new();

  /* Create the combo box */
  ls_combo=gtk_list_store_new(1, G_TYPE_STRING);
  for(ii=0; ii<9; ii++) {
gtk_list_store_append (ls_combo, &iter);
gtk_list_store_set (ls_combo, &iter, 0, itemtype[ii], -1);
  }

  g_object_set(G_OBJECT(renderer), "model", ls_combo,
   "text-column", 0,
   "text", "Stock",
   "has-entry", FALSE,
   "editable", TRUE,
   NULL);

  g_signal_connect(renderer, "edited",
G_CALLBACK(itemTypeComboEditedCb), ls_combo);

  /* Create a Column */
  column=gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column, "ItemType");
  gtk_tree_view_column_pack_start(column, renderer, FALSE);
  ips=IPS_ItemType;
  // gtk_tree_view_column_set_attributes(column, renderer, "text", ips,
NULL);
  col_num=gtk_tree_view_insert_column(GTK_TREE_VIEW(tv), column, -1);

  g_object_unref(ls_combo);

  /* FIELD is the column number not the index:  always one more than
index. */
  g_object_set_data(G_OBJECT(renderer), "FIELD",
GUINT_TO_POINTER(col_num));
  /* -- */



/* The callback */
void itemTypeComboEditedCb(GtkCellRendererText *cell, const gchar *path,
const gchar *value, GtkListStore *list) {
  gboolean rc=FALSE;
  GtkTreeIter iter;
  GtkTreePath *tp=NULL;
  GtkTreeModel *tm=NULL; /* a tree model */
  gint col_num=0;

  tp=gtk_tree_path_new_from_string(path);
  col_num=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "FIELD"));

  gtk_tree_model_get_iter (GTK_TREE_MODEL(list), &iter, tp);
  gtk_list_store_set(list, &iter, 0, value, -1);  
   
  /* The following sets the whole column to the same value, not just the
row it was select in. */
  //g_object_set(G_OBJECT(cell), "text", value, NULL);
}


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


multicolumn combo with multiple options selectable

2007-11-06 Thread dhk
I want to put a combo box in a treeview with two columns so the first
column is a label and the second is a check box.  Also I would like to
be able to check off more than one option in the combo box.  So if the
treeview had a textile row the color column combo would list available
colors and one or more colors can be selected or checked off.  The part
of my code I'm trying to do this in is below.  First the only column
that shows in the combo is the list of colors and the check boxes seem
to get lost.  Second, I not sure how to connect the itemToggled signal
to the check boxes.  

Thank you in advance,
--dhk

function_to_build_the_multicolumn_combo() {
.
.
.
  enum {COL_COLOR, COL_USE, COL_CNT};
  typedef struct Color {gchar *color; gboolean use;} Color;
  static Color colors[]={
{"Red", FALSE},
{"Blue", TRUE},
{"Green", TRUE},
{"Brown", FALSE},
{"Black", FALSE},
{"White", FALSE}
  };
.
.
.
  /*  */
  //renderer=gtk_cell_renderer_toggle_new();
  //g_object_set(G_OBJECT(renderer), "activatable", TRUE, NULL);
  //g_signal_connect(renderer, "toggled", G_CALLBACK(itemToggled), tv);

  /* Create the combo box */
  ls_combo=gtk_list_store_new(COL_CNT, G_TYPE_STRING, G_TYPE_BOOLEAN);
  for(ii=0; iihttp://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Can a button go in a treeview?

2007-10-22 Thread dhk
Is there a way to put a button in a treeview or atleast put a label next
to a toggle in a treeview?  I want to be able to change the label on the
button or toggle depending on the status of the row and then have it
operate accordingly.

Thanks,

--dhk

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


GtkNotebookPage

2007-09-30 Thread dhk

I have a notebook with a treeview on each page.  I'm trying to reference
a treeview on a notebook tab when it is clicked and compare it to
another treeview on another tab; I'm using the "switch-page" signal.
The treeviews are in vbox's in the tabs and I can't seem to get to the
one on the tab that was clicked.  The callback is like this . . .

void
on_ipm_notebook1_switch_page  (GtkNotebook *notebook,
GtkNotebookPage *page,
guintpage_num,
gpointer user_data)
{
  GtkWidget *tv=(GtkWidget *)user_data;
  /* the treeview is in c_page */
  GtkWidget *c_page=gtk_notebook_get_nth_page(notebook, page_num);

}

How would I get the treeview that's on the c_page?  Is there a way to
send more than one object in with user_data?  user_data doesn't seem to
like pointer-to-pointer (GtkWidget **tv) data.

Also, what can you do with the GtkNotebookPage object?  I don't see why
this is passed in since there doesn't seem to be a way to use it.

Thanks in advance,

--dhk

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


Cell Renderer Combo in a Treeview

2007-09-13 Thread dhk
The attached and inline program below illustrates the problem I'm having
with rendering a combo box in a treeview.  The two big things are 1) I
can't get the combo to default to a value without setting it globally,
and 2) the values don't get displayed when set and it seems to be
setting the value in the combo list not the tree.

Does any one see the error?

Thanks in advance,
--dhk


/* Compile Command:
 * gcc -Wall -g3 `pkg-config --cflags --libs gtk+-2.0` -o comboTst
comboTst.c
 */
#include 
#include 
#include 

#include 
#include 

enum {COL_DESC, COL_TYPE, COL_DISABLE, COL_NUM};

void treeStore0(GtkWidget *tv);
void treeView0(GtkWidget *tv);
void itemToggled(GtkCellRendererToggle *cell, gchar *path, gpointer
data);
void destroyCb(GtkWidget *widget, gpointer data);
void itemTypeComboEditedCb(GtkCellRendererText *cell, const gchar *path,
const gchar *value, GtkListStore *list);

int main(int argc, char **argv) {
#define TST 0
  GtkWidget *window=NULL;
  GtkWidget *scrolledwindow=NULL;
#if TST
  GtkWidget *tv=NULL;
#else
  GtkWidget *tv[3]={NULL, NULL, NULL};
#endif
  GtkTreeModel *tm=NULL;
  GtkTreeIter iter;

  gtk_init (&argc, &argv);

  window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "Tree View Test");
  gtk_window_set_default_size(GTK_WINDOW(window), 300, 165);
  g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(destroyCb), NULL);

  scrolledwindow=gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_show(scrolledwindow);
  gtk_container_add(GTK_CONTAINER(window), scrolledwindow);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
GTK_SHADOW_IN);
  gtk_widget_show(window);

#if TST
  tv=gtk_tree_view_new();
  gtk_widget_show(tv);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), tv);

  treeStore0(tv); /* Make the tree store */
  treeView0(tv); /* Make the tree view */

  tm=gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
#else
  tv[0]=gtk_tree_view_new();
  tv[1]=gtk_tree_view_new();
  tv[2]=gtk_tree_view_new();
  gtk_widget_show(tv[0]);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), tv[0]);

  treeStore0(tv[0]); /* Make the tree store */
  treeView0(tv[0]); /* Make the tree view */

  tm=gtk_tree_view_get_model(GTK_TREE_VIEW(tv[0]));
#endif
#undef TST

  gtk_tree_store_append(GTK_TREE_STORE(tm), &iter, NULL);
  gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, COL_DESC, "Click the
Type for the combo box", -1);
  gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, COL_DISABLE, TRUE, -1);
  gtk_tree_store_append(GTK_TREE_STORE(tm), &iter, NULL);
  gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, COL_DESC, "First I'd
like it to default to one of the values.", -1);
  gtk_tree_store_append(GTK_TREE_STORE(tm), &iter, NULL);
  gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, COL_DESC, "Then I'd like
the box to behave like a combo box should.", -1);
  gtk_tree_store_append(GTK_TREE_STORE(tm), &iter, NULL);
  gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, COL_DESC, "The values
selected don't get displayed.", -1);
  gtk_tree_store_append(GTK_TREE_STORE(tm), &iter, NULL);
  gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, COL_DESC, ". . . and the
list inside changes acorrding to the selection.", -1);

  gtk_main();

  return 0;
}
void treeStore0(GtkWidget *tv) {
  GtkTreeStore *ts=NULL;

  ts=gtk_tree_store_new(COL_NUM, /* Total number of columns */
G_TYPE_STRING,  /* */
G_TYPE_STRING,  /**/
G_TYPE_BOOLEAN  /* Check Box - Disable item */
  );

  gtk_tree_view_set_model(GTK_TREE_VIEW(tv), GTK_TREE_MODEL(ts));
}


void treeView0(GtkWidget *tv) {
  gint ii;
  GtkCellRenderer *renderer=NULL;
  GtkTreeViewColumn *column=NULL;
  gint col_num=0;

   /* Variable for the Combo Box */
  GtkListStore *ls_combo=NULL;
  GtkTreeIter iter;
  gchar *type[5]={"Thoroughbred", "Standardbred", "Shortbread", "Stock",
"Nag"};
  /* --- Description --- */
  renderer = gtk_cell_renderer_text_new();
  g_object_set(renderer, "editable", TRUE, NULL);
  g_object_set(G_OBJECT(renderer), "width-chars", 100, NULL);

  /* Create a Column */
  column=gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column, "Description");
  gtk_tree_view_column_pack_start(column, renderer, FALSE);
  gtk_tree_view_column_set_attributes(column, renderer, "text",
COL_DESC, NULL);
  col_num=gtk_tree_view_insert_column(GTK_TREE_VIEW(tv), column, -1);

  /* FIELD is the column number not the index:  always one more than
index. */
  g_object_set_data(G_OBJECT(renderer), "FIELD",
GUINT_TO_POINTER(col_num));

  /* PROBLEM v v v v v v PROBLEM */
  /* --- Type --- */
  renderer = gtk_ce

Re: Cell Renderer Combo Callback

2007-09-12 Thread dhk
O'm going to have to try another approach. I know this isn't wrong, but
the combo doesn't work correctly.  I'm going to stuff this in a smaller
program and try to narrow down what's going on.

Thanks,

--dhk

On Wed, 2007-09-12 at 15:51 +0200, Damien Caliste wrote:
> Hello,
> 
> Le 12/09/2007, dhk <[EMAIL PROTECTED]> a écrit :
> > Thanks, but it still doesn't work.  I think the problem is in getting
> > the iter for the list store which is used in the combo render or it
> > might be working and just not getting rendered to be visible.  I'm
> > fairly sure the problem is in the callback.
> Ok, I test your code in some of mine to see what happen. The two points
> I spoke about are relevant and should be applied. Because, with the
> first ("text, "Stock") "Stock" is always drawn instead of the choice.
> With the second, nothing is printed in the cell.
> 
> But, in the callback, going through a GtkTreePath (think to free it
> after use) doesn't work (don't know why exactly). In my experience, I
> use instead directly:
> valid = gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(list),
> &iter, path);
> to get the iter from the string 'path'.
> 
> With these three points, it should work.
> 
> Damien.
> 
> 
> PS: if you want a default value for your combo, like "Stock", just add
> "Stock" in your model.
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

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


Re: Cell Renderer Combo Callback

2007-09-12 Thread dhk
Thanks, but it still doesn't work.  I think the problem is in getting
the iter for the list store which is used in the combo render or it
might be working and just not getting rendered to be visible.  I'm
fairly sure the problem is in the callback.

On Wed, 2007-09-12 at 13:47 +0200, Damien Caliste wrote:
> Hello,
> 
> Le 12/09/2007, dhk <[EMAIL PROTECTED]> a écrit :
> > I have a combo render in a treeview and I can't get the callback to
> > set the value once it's selected.
> I didn't test the code you gave, so can't be sure, but I suggest to
> remove the « "text", "Stock", » property from the combo rendrer.
> >   g_object_set(G_OBJECT(renderer), "model", ls_combo,
> >"text-column", 0,
> >"text", "Stock",
> >"has-entry", FALSE,
> >"editable", TRUE,
> >NULL);
> In my own code, I also create my column with the "text" attribute
> pointing to the right column id of my model:
> > col = gtk_tree_view_column_new_with_attributes("ItemType", renderer,
> >  "text", 0, NULL);
> That's the only differences I can figure out.
> 
> Damien.
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

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


Cell Renderer Combo Callback

2007-09-12 Thread dhk
I have a combo render in a treeview and I can't get the callback to set
the value once it's selected.  I want the combo to default to "Stock"
but be able to be changed to any of the other values in the itemtype
array.  Below is the way the item type combo is being created and added
to the tree view followed by the callback.  Does any one see the error?

Thanks,
--dhk

GtkListStore *ls_combo=NULL;
.
.
.

  /* --- ItemType Treeview Column --- */
  renderer = gtk_cell_renderer_combo_new();

  /* Create the combo box */
  ls_combo=gtk_list_store_new(1, G_TYPE_STRING);
  for(ii=0; ii<9; ii++) {
gtk_list_store_append (ls_combo, &iter);
gtk_list_store_set (ls_combo, &iter, 0, itemtype[ii], -1);
  }

  g_object_set(G_OBJECT(renderer), "model", ls_combo,
   "text-column", 0,
   "text", "Stock",
   "has-entry", FALSE,
   "editable", TRUE,
   NULL);

  g_signal_connect(renderer, "edited",
G_CALLBACK(itemTypeComboEditedCb), ls_combo);

  /* Create a Column */
  column=gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column, "ItemType");
  gtk_tree_view_column_pack_start(column, renderer, FALSE);
  ips=IPS_ItemType;
  // gtk_tree_view_column_set_attributes(column, renderer, "text", ips,
NULL);
  col_num=gtk_tree_view_insert_column(GTK_TREE_VIEW(tv), column, -1);

  g_object_unref(ls_combo);

  /* FIELD is the column number not the index:  always one more than
index. */
  g_object_set_data(G_OBJECT(renderer), "FIELD",
GUINT_TO_POINTER(col_num));
  /* -- */



/* The callback */
void itemTypeComboEditedCb(GtkCellRendererText *cell, const gchar *path,
const gchar *value, GtkListStore *list) {
  gboolean rc=FALSE;
  GtkTreeIter iter;
  GtkTreePath *tp=NULL;
  GtkTreeModel *tm=NULL; /* a tree model */
  gint col_num=0;

  tp=gtk_tree_path_new_from_string(path);
  col_num=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "FIELD"));

  gtk_tree_model_get_iter (GTK_TREE_MODEL(list), &iter, tp);
  gtk_list_store_set(list, &iter, 0, value, -1);  
   
  /* The following sets the whole column to the same value, not just the
row it was select in. */
  //g_object_set(G_OBJECT(cell), "text", value, NULL);
}


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


Cell Renderer Combo Callback

2007-09-11 Thread dhk
I have a combo render in a treeview and I can't get the callback to set
the value once it's selected.  I want the combo to default to "Stock"
but be able to be changed to any of the other values in the itemtype
array.  Below is the way the item type combo is being created and added
to the tree view followed by the callback.  Does any one see the error?

Thanks,
--dhk

  /* --- ItemType Treeview Column --- */
  renderer = gtk_cell_renderer_combo_new();

  /* Create the combo box */
  ls_combo=gtk_list_store_new(1, G_TYPE_STRING);
  for(ii=0; ii<9; ii++) {
gtk_list_store_append (ls_combo, &iter);
gtk_list_store_set (ls_combo, &iter, 0, itemtype[ii], -1);
  }

  g_object_set(G_OBJECT(renderer), "model", ls_combo,
   "text-column", 0,
   "text", "Stock",
   "has-entry", FALSE,
   "editable", TRUE,
   NULL);

  g_signal_connect(renderer, "edited",
G_CALLBACK(itemTypeComboEditedCb), ls_combo);

  /* Create a Column */
  column=gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column, "ItemType");
  gtk_tree_view_column_pack_start(column, renderer, FALSE);
  ips=IPS_ItemType;
  // gtk_tree_view_column_set_attributes(column, renderer, "text", ips,
NULL);
  col_num=gtk_tree_view_insert_column(GTK_TREE_VIEW(tv), column, -1);

  g_object_unref(ls_combo);

  /* FIELD is the column number not the index:  always one more than
index. */
  g_object_set_data(G_OBJECT(renderer), "FIELD",
GUINT_TO_POINTER(col_num));
  /* -- */



/* The callback */
void itemTypeComboEditedCb(GtkCellRendererText *cell, const gchar *path,
const gchar *value, GtkListStore *list) {
  gboolean rc=FALSE;
  GtkTreeIter iter;
  GtkTreePath *tp=NULL;
  GtkTreeModel *tm=NULL; /* a tree model */
  gint col_num=0;

  tp=gtk_tree_path_new_from_string(path);
  col_num=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "FIELD"));

  gtk_tree_model_get_iter (GTK_TREE_MODEL(list), &iter, tp);
  gtk_list_store_set(list, &iter, 0, value, -1);  
   
  /* The following sets the whole column to the same value, not just the
row it was select in. */
  //g_object_set(G_OBJECT(cell), "text", value, NULL);
}

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


Toggle and the Inconsistent Property

2007-09-02 Thread dhk
What is the inconsistent property to a toggle?  

I want to be able to flag rows in a treeview for possible deletion so
they can be reviewed before flagging them for deletion.  So the check
box needs to have three states, kind of like the minesweeper game,
checked, unchecked, and an inbetween state.  Does anyone know how to do
this?

Thanks in advance,

--dhk

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


  1   2   >