emacs-devel
[Top][All Lists]
Advanced

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

Re: svn icons in the toolbar


From: Jan Djärv
Subject: Re: svn icons in the toolbar
Date: Thu, 20 Sep 2007 08:24:46 +0200
User-agent: Thunderbird 2.0.0.6 (X11/20070728)



Stephen Berman skrev:

I forgot that I am using the gtk-qt engine, which "allows GTK
applications to use Qt widget styles", including tool bar icons.  The
icons I see are actually KDE icons from
/opt/kde3/share/icons/crystalsvg/32x32/actions.  I assume gtk-qt maps
the Gnome stock icons to corresponding KDE icons of the selected
theme.  I couldn't find an icon in the crystal theme corresponding to
system-file-manager, but it may just be that gtk-qt does not handle
named Gnome icons.


Try the attached program.  Compile like this:

% gcc -o icon-view icon-view.c `pkg-config  gtk+-2.0 --cflags --libs`

If run without arguments, it lists the named icons Gtk+ knows about. The list may be long, I have 2309 names.

If you give it names as arguments, it displays a tool bar with those icons.

If it just list stock-* names, then the gtk-qt engine only deals with stock 
icons.

        Jan D.
#include <stdio.h>

#include <libintl.h>
#include <string.h>
#include <gtk/gtk.h>

static gboolean
destroy(GtkWidget *widget,
        GdkEvent *event,
        gpointer data)
{
    gtk_main_quit();
    return TRUE;
}

static gint
comp_func(gconstpointer a,
          gconstpointer b,
          gpointer user_data)
{
    return strcmp((const char *)a, (const char *)b);
}

int
main(int argc, char *argv[])
{
    gtk_set_locale();
    gtk_init(&argc, &argv);

    GtkWidget *wmain = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(wmain), "icon-view");

    g_signal_connect(G_OBJECT(wmain), "delete-event",
                     G_CALLBACK(destroy), 0);

    GtkWidget *tb = gtk_toolbar_new();
    GtkTooltips *wtooltip = gtk_tooltips_new();
    gtk_toolbar_set_show_arrow(GTK_TOOLBAR(tb), FALSE);
    gtk_toolbar_set_style(GTK_TOOLBAR(tb), GTK_TOOLBAR_ICONS);

    size_t i;

    if (argc == 1) {
        GdkDisplay *gdpy = gdk_display_get_default();
        GdkScreen *gscreen = gdk_display_get_default_screen(gdpy);
        GtkIconTheme *icontheme = gtk_icon_theme_get_for_screen(gscreen);
        GList *list = gtk_icon_theme_list_icons(icontheme, NULL);

        list = g_list_sort_with_data(list, comp_func, NULL);
        GList *it;
        for (it = list; it != NULL; it = g_list_next(it)) {
            printf("%s\n", (char *)it->data);
        }
        return 0;
    }

    for (i = 1; i < argc; ++i) {
        int is_stock = 0;
        const char *name = argv[i];
        if (strncmp("s:", name, 2) == 0) {
            is_stock = 1;
            name += 2;
        }

        GtkToolItem*  ti;
        if (is_stock) {
            ti = gtk_tool_button_new_from_stock(name);
        } else {
            ti = gtk_tool_button_new(NULL, NULL);
            gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(ti), name);
        }
        gtk_tool_item_set_expand(ti, TRUE);
        gtk_tool_item_set_tooltip(ti, wtooltip, name, NULL);
        gtk_toolbar_insert(GTK_TOOLBAR(tb), GTK_TOOL_ITEM(ti), -1);
    }

    gtk_container_add(GTK_CONTAINER(wmain), tb);
    gtk_widget_show_all(wmain);
    gtk_main();

    return 0;
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]