aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/shortcut-bar/test-shortcut-bar.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2000-03-31 23:45:24 +0800
committerDamon Chaplin <damon@src.gnome.org>2000-03-31 23:45:24 +0800
commitfb80c3b9a1b00c2eb17d29293cbd9877e456f7ba (patch)
treef155a7080ac0f6bef160919649be17d5792c7630 /widgets/shortcut-bar/test-shortcut-bar.c
parent711197b6b76d7200708567005c3f864d7aa7dded (diff)
downloadgsoc2013-evolution-fb80c3b9a1b00c2eb17d29293cbd9877e456f7ba.tar
gsoc2013-evolution-fb80c3b9a1b00c2eb17d29293cbd9877e456f7ba.tar.gz
gsoc2013-evolution-fb80c3b9a1b00c2eb17d29293cbd9877e456f7ba.tar.bz2
gsoc2013-evolution-fb80c3b9a1b00c2eb17d29293cbd9877e456f7ba.tar.lz
gsoc2013-evolution-fb80c3b9a1b00c2eb17d29293cbd9877e456f7ba.tar.xz
gsoc2013-evolution-fb80c3b9a1b00c2eb17d29293cbd9877e456f7ba.tar.zst
gsoc2013-evolution-fb80c3b9a1b00c2eb17d29293cbd9877e456f7ba.zip
added support for a callback function to set the icons.
2000-03-31 Damon Chaplin <damon@helixcode.com> * widgets/shortcut-bar/e-shortcut-bar.[hc]: added support for a callback function to set the icons. * widgets/shortcut-bar/test-shortcut-bar.c: updated to use the callback function. svn path=/trunk/; revision=2268
Diffstat (limited to 'widgets/shortcut-bar/test-shortcut-bar.c')
-rw-r--r--widgets/shortcut-bar/test-shortcut-bar.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/widgets/shortcut-bar/test-shortcut-bar.c b/widgets/shortcut-bar/test-shortcut-bar.c
index 2018d614d1..250704d227 100644
--- a/widgets/shortcut-bar/test-shortcut-bar.c
+++ b/widgets/shortcut-bar/test-shortcut-bar.c
@@ -31,12 +31,19 @@
#include "e-shortcut-bar.h"
#define NUM_SHORTCUT_TYPES 5
-gchar *shortcut_types[] = {
+gchar *shortcut_types[NUM_SHORTCUT_TYPES] = {
"folder:", "file:", "calendar:", "todo:", "contacts:"
};
+gchar *icon_filenames[NUM_SHORTCUT_TYPES] = {
+ "gnome-balsa2.png", "gnome-folder.png", "gnome-calendar.png",
+ "gnome-cromagnon.png", "gnome-ccthemes.png"
+};
+GdkPixbuf *icon_pixbufs[NUM_SHORTCUT_TYPES];
GtkWidget *main_label;
+static GdkPixbuf* icon_callback (EShortcutBar *shortcut_bar,
+ gchar *url);
static void on_main_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
gpointer data);
@@ -74,6 +81,8 @@ int
main (int argc, char *argv[])
{
GtkWidget *window, *hpaned, *shortcut_bar;
+ gchar *pathname;
+ gint i;
gnome_init ("test-shortcut-bar", "0.1", argc, argv);
@@ -94,6 +103,8 @@ main (int argc, char *argv[])
shortcut_bar = e_shortcut_bar_new ();
gtk_paned_pack1 (GTK_PANED (hpaned), shortcut_bar, FALSE, TRUE);
gtk_widget_show (shortcut_bar);
+ e_shortcut_bar_set_icon_callback (E_SHORTCUT_BAR (shortcut_bar),
+ icon_callback);
#if 0
gtk_container_set_border_width (GTK_CONTAINER (shortcut_bar), 4);
@@ -113,6 +124,15 @@ main (int argc, char *argv[])
gtk_widget_pop_visual ();
gtk_widget_pop_colormap ();
+ /* Load our default icons. */
+ for (i = 0; i < NUM_SHORTCUT_TYPES; i++) {
+ pathname = gnome_pixmap_file (icon_filenames[i]);
+ if (pathname)
+ icon_pixbufs[i] = gdk_pixbuf_new_from_file (pathname);
+ else
+ icon_pixbufs[i] = NULL;
+ }
+
add_test_groups (E_SHORTCUT_BAR (shortcut_bar));
gtk_signal_connect (GTK_OBJECT (shortcut_bar), "item_selected",
@@ -125,6 +145,22 @@ main (int argc, char *argv[])
}
+static GdkPixbuf*
+icon_callback (EShortcutBar *shortcut_bar,
+ gchar *url)
+{
+ gint i;
+
+ for (i = 0; i < NUM_SHORTCUT_TYPES; i++) {
+ if (!strncmp (url, shortcut_types[i],
+ strlen (shortcut_types[i]))) {
+ return icon_pixbufs[i];
+ }
+ }
+
+ return NULL;
+}
+
static void
on_main_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,