Comment 19 for bug 349336

Revision history for this message
Cody Russell (bratsche) wrote :

Okay cool, I didn't look at the full code only the patch. I'm at Guadec and the network isn't responding very well, so I never got to respond to your actual question.. so here is my only other thought on the patch.

+ #FIXME: is there a better way to set the title AND have a stock icon?
+ remove.get_children()[0].get_children()[0].get_children()[1].set_label(_("_Remove Packages"))

There's not really a way to change the text in a more direct way without messing up the icon (because conceptually, stocks are really "icon + text" combinations so using button_new_from_stock is really just a convenience function), but if you want to do something a little less cryptic looking (although maybe with a bit more code) you could do something to the effect of:

void set_button_text_and_icon (GtkButton *button, gchar *stock_id, gchar *label)
{
   gint image_spacing;

   gtk_widget_style_get (GTK_WIDGET (button),
                           "image-spacing", &image_spacing,
                           NULL);
   hbox = gtk_hbox_new (FALSE, image_spacing);

   image = gtk_image_new_from_stock (GTK_STOCK_CANCEL);
   gtk_box_pack_start (hbox, image, FALSE, FALSE, 0);

   label = gtk_label_new (_("_Remove Packages"));
   gtk_box_pack_start (hbox, label, FALSE, FALSE, 0);

   gtk_widget_show_all (hbox);
   gtk_container_add (GTK_CONTAINER (button), hbox);
}

Sorry, I'm not familar with pygtk so this is the best I can offer. It's up to you, this is just a suggestion that I think makes the code a little bit more obvious in my opinion.