Re: Gtk+ Equivalent of Gnome Code



On Thu, 07 Sep 2000 18:55:15 -0400, Eric Lemings <eric b lemings lmco com> wrote:
Hi all,

I used Glade to generate some Gtk+ code.  I thought.   I had Gnome
support turned off but it stilled generated the following code:

  tmp_toolbar_icon = gnome_stock_pixmap_widget (window1,
GNOME_STOCK_PIXMAP_NEW);
  button4 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar3),
                                GTK_TOOLBAR_CHILD_BUTTON,
                                NULL,
                                _("New"),
                                NULL, NULL,
                                tmp_toolbar_icon, NULL, NULL);

How do I do this strictly using Gtk+?

Thanks,
Eric.

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


Here's one way to do it.  First find stock_new.png which corresponds to
GNOME_STOCK_PIXMAP_NEW and convert it to an xpm file.
ex:
bash$ locate stock_new.png
/usr/lib/libgnomeui/pixmaps/stock_new.png

bash$ convert /usr/lib/libgnomeui/pixmaps/stock_new.png stock_new.xpm

then create a GtkPixmap from this and use it in place of
tmp_toolbar_icon.

#include <gtk/gtk.h>

int main (int argc, char *argv[])
{
        GtkWidget *win, *toolbar, *tmp_toolbar_icon;
        GtkWidget *button4;
        GdkPixmap *gdkpixmap;
        GdkBitmap *mask;

        gtk_init (&argc, &argv);

        win = gtk_window_new (GTK_WINDOW_TOPLEVEL);

        toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, 
                                   GTK_TOOLBAR_BOTH);
        gtk_container_add (GTK_CONTAINER (win), toolbar);
        gtk_widget_realize (toolbar);

        gdkpixmap = gdk_pixmap_create_from_xpm (toolbar->window, &mask, NULL,
                                                "stock_new.xpm");
        tmp_toolbar_icon = gtk_pixmap_new (gdkpixmap, mask);

        button4 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), 
                                GTK_TOOLBAR_CHILD_BUTTON, 
                                NULL, 
                                "New", 
                                NULL, NULL, 
                                tmp_toolbar_icon, NULL, NULL);
        
        gtk_widget_show_all (win);
        gtk_main ();
        return 0;
}





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