Re: Label on a button - bit more complicated than I thought.




 This is a bit more complicated than I thought.

 I looked into the gtktoolbar.c source code. ( Gtk 1.2.10)

 I noticed that the toolbar_append func. calls the toolbar_insert func. It then
creates a GtkToolbarChild widget. Then it sets the widget's child to the type
it was passed in.

 Here is the pseudo code:

===========
  Child = new GtkToolbarChild.
  if type is GTK_TOGGLE_BUTTON, then  set 
  child -> widget = new Toggle button.
  if label text != null, child->label = new Label(label text)  <===== And here
is the problem. The label is set on this GtkToolbarChild object, and not on the
togglebutton itself.
  and then they  return the child->widget -- wich is the toogle button. But the
label "stays" behind.

===== End pseudo code.

  How the heck  I am going to get a reference to the object that holds the
label is beyond me, since this child GtkToolbarChild is "private".

   this is going to be fun !!!!

Any takers on the search for the solution ??

Thanks again.


--- Harring Figueiredo <harringf yahoo com> wrote:


 Luciano, 

  Thanks for the hint, but I think that this is not possible. There is no way
to "name" the label -- I am using Glade 6.4 --. Here is the code that Glade
generates.

==========code================
 tmp_toolbar_icon = create_pixmap (window1, "_cdrom.xpm");
  toolbar_start_button = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
                                GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
                                NULL,
                                "Start",
                                "Start Processing Incoming Jobs", NULL,
                                tmp_toolbar_icon, NULL, NULL);
  gtk_widget_set_name (toolbar_start_button, "toolbar_start_button");
 
================================

 the GTK docs says that "Start" will be used to create the label, but it does
not name the label widget itself.

  I tried calling gtk_object_get_data(toolbar_start_button, "Start"); 
  to see if GTK had "named" the widget under the hood, but it fails.

 Any other approach?

 
--- Luciano Chavez <lnx1138 us ibm com> wrote:
On Thu, 2002-07-25 at 13:11, Harring Figueiredo wrote:

 Folks,

 I have a toolbar toogle button, and would like to set the text based on
its
state.

 I poked unto the code gtkbutton.c and there is a commnent saying that we
now
use have to use:
 GTK_BIN(button)->child.

 I am using the aboce code and casting back to a GTK_LABEL.

 When trying to set the text label (gtk_label_set_text) I get a assertion
saying the it is not a label.

 The button does have a Icon (pixmap) and a label. ( I am using glade to
build
it). I printed the GtkType, but I found no way to get what type of widget
I
get
when calling GTK_BIN(b)->child.


The fact that you have a pixmap and label tells me the child is another
container type and thus why it's not working. If you have naming enabled
in Glade, you may be able to get to the label widget directly from the
main window.

label = gtk_object_get_data (GTK_OBJECT (top_window), "your_label");

-- 
regards,

Luciano Chavez

lnx1138 us ibm com          
http://evms.sourceforge.net

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


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]