diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | components/help/hyperbola-nav-tree.c | 200 | ||||
-rw-r--r-- | icons/Makefile.am | 6 | ||||
-rw-r--r-- | icons/hyperbola-book-closed.png | bin | 0 -> 285 bytes | |||
-rw-r--r-- | icons/hyperbola-book-open.png | bin | 0 -> 278 bytes | |||
-rw-r--r-- | icons/hyperbola-folder-closed.png | bin | 0 -> 262 bytes | |||
-rw-r--r-- | icons/hyperbola-folder-open.png | bin | 0 -> 262 bytes | |||
-rw-r--r-- | icons/hyperbola-section-closed.png | bin | 0 -> 236 bytes | |||
-rw-r--r-- | icons/hyperbola-section-open.png | bin | 0 -> 236 bytes |
9 files changed, 156 insertions, 71 deletions
@@ -1,3 +1,24 @@ +Tue Mar 27 02:25:31 2001 George Lebl <jirka@5z.com> + + * components/help/hyperbola-nav-tree.c (ensure_italic_style) + (set_node_style) (reset_style_for_node) (reset_styles) + (ensure_pixmap_and_mask) (ensure_icons) (get_node_icons) + (ctree_populate_subnode) (ctree_populate) + (hyperbola_navigation_tree_new) (pixmap_unref_and_null) + (bitmap_unref_and_null) (hyperbola_navigation_tree_destroy): + Remove the italic stuff and replace with icons. There's a + different icon for folders, different for books and different for + sections. The one for sections is the one used for man and info + pages, but we could also have a separate one for those. I suppose + that's up to Arlo. This should fix #6911, though I suppose I'll + leave it open to get further feedback. + + * icons/Makefile.am, hyperbola-book-closed.png, + hyperbola-book-open.png, hyperbola-folder-closed.png, + hyperbola-folder-open.png, hyperbola-section-closed.png, + hyperbola-section-open.png: Add some testing icons, stolen + from the GTK+ testing program. + Tue Mar 27 00:45:02 2001 George Lebl <jirka@5z.com> * components/help/hyperbola-filefmt.c diff --git a/components/help/hyperbola-nav-tree.c b/components/help/hyperbola-nav-tree.c index 7970c66eb..ad5dbf01d 100644 --- a/components/help/hyperbola-nav-tree.c +++ b/components/help/hyperbola-nav-tree.c @@ -5,6 +5,7 @@ #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <libnautilus-extensions/nautilus-ctree.h> +#include <libnautilus-extensions/nautilus-theme.h> #include <libnautilus-extensions/nautilus-gdk-font-extensions.h> #include "hyperbola-nav.h" @@ -27,7 +28,20 @@ typedef struct { gint notify_count; - GtkStyle *italic_style; + GdkPixmap *folder_open_pixmap; + GdkBitmap *folder_open_mask; + GdkPixmap *folder_closed_pixmap; + GdkBitmap *folder_closed_mask; + + GdkPixmap *book_open_pixmap; + GdkBitmap *book_open_mask; + GdkPixmap *book_closed_pixmap; + GdkBitmap *book_closed_mask; + + GdkPixmap *section_open_pixmap; + GdkBitmap *section_open_mask; + GdkPixmap *section_closed_pixmap; + GdkBitmap *section_closed_mask; } HyperbolaNavigationTree; static void hyperbola_navigation_tree_destroy (GtkCTree * ctree, @@ -51,42 +65,84 @@ typedef struct { } PopulateInfo; static void -ensure_italic_style (HyperbolaNavigationTree *view) +ensure_pixmap_and_mask (GdkPixmap **pixmap, GdkBitmap **mask, const char *name) { - if (view->italic_style == NULL) { - /* Set italic style for page names */ - GdkFont *font; - GtkStyle *style = gtk_style_copy - (gtk_widget_get_style (view->ctree)); + char *fullname; + GdkPixbuf *pixbuf; - font = style->font; - style->font = nautilus_gdk_font_get_italic (font); - gdk_font_unref (font); + if (*pixmap != NULL) { + return; + } - view->italic_style = style; + fullname = nautilus_theme_get_image_path (name); + if (fullname == NULL) { + return; } -} -static void -set_node_style (HyperbolaNavigationTree *view, - GtkCTree *ctree, GtkCTreeNode *node) -{ - HyperbolaTreeNode *tnode; + pixbuf = gdk_pixbuf_new_from_file (fullname); + if (pixbuf == NULL) { + return; + } - g_assert (GTK_IS_CTREE (ctree)); + gdk_pixbuf_render_pixmap_and_mask (pixbuf, + pixmap, + mask, + 127 /* alpha_threshold */); - tnode = gtk_ctree_node_get_row_data (ctree, node); + g_free (fullname); +} - if (tnode != NULL - && (tnode->type == HYP_TREE_NODE_PAGE - || tnode->type == HYP_TREE_NODE_SECTION - || tnode->type == HYP_TREE_NODE_BOOK)) { - ensure_italic_style (view); +static void +ensure_icons (HyperbolaNavigationTree *view) +{ + ensure_pixmap_and_mask (&view->folder_open_pixmap, + &view->folder_open_mask, + "hyperbola-folder-open.png"); + ensure_pixmap_and_mask (&view->folder_closed_pixmap, + &view->folder_closed_mask, + "hyperbola-folder-closed.png"); + + ensure_pixmap_and_mask (&view->book_open_pixmap, + &view->book_open_mask, + "hyperbola-book-open.png"); + ensure_pixmap_and_mask (&view->book_closed_pixmap, + &view->book_closed_mask, + "hyperbola-book-closed.png"); + + ensure_pixmap_and_mask (&view->section_open_pixmap, + &view->section_open_mask, + "hyperbola-section-open.png"); + ensure_pixmap_and_mask (&view->section_closed_pixmap, + &view->section_closed_mask, + "hyperbola-section-closed.png"); +} - gtk_ctree_node_set_row_style (ctree, node, view->italic_style); - } else { - /* no special style */ - gtk_ctree_node_set_row_style (ctree, node, NULL); +static void +get_node_icons (HyperbolaNavigationTree *view, + HyperbolaTreeNode *node, + GdkPixmap **pixmap_closed, + GdkBitmap **mask_closed, + GdkPixmap **pixmap_opened, + GdkBitmap **mask_opened) +{ + ensure_icons (view); + + if (node->type == HYP_TREE_NODE_FOLDER) { + *pixmap_opened = view->folder_open_pixmap; + *mask_opened = view->folder_open_mask; + *pixmap_closed = view->folder_closed_pixmap; + *mask_closed = view->folder_closed_mask; + } else if (node->type == HYP_TREE_NODE_BOOK) { + *pixmap_opened = view->book_open_pixmap; + *mask_opened = view->book_open_mask; + *pixmap_closed = view->book_closed_pixmap; + *mask_closed = view->book_closed_mask; + } else if (node->type == HYP_TREE_NODE_SECTION + || node->type == HYP_TREE_NODE_PAGE) { + *pixmap_opened = view->section_open_pixmap; + *mask_opened = view->section_open_mask; + *pixmap_closed = view->section_closed_pixmap; + *mask_closed = view->section_closed_mask; } } @@ -97,6 +153,10 @@ ctree_populate_subnode (gpointer key, gpointer value, gpointer user_data) PopulateInfo *pi = (PopulateInfo *) user_data, subpi; gboolean term; char *title; + GdkPixmap *pixmap_closed = NULL; + GdkBitmap *mask_closed = NULL; + GdkPixmap *pixmap_opened = NULL; + GdkBitmap *mask_opened = NULL; #ifdef ENABLE_SCROLLKEEPER_SUPPORT /* Get rid of leading numbers used to make sure TOCs are displayed properly */ @@ -115,16 +175,19 @@ ctree_populate_subnode (gpointer key, gpointer value, gpointer user_data) #endif title = node->title; + get_node_icons (pi->view, node, + &pixmap_closed, &mask_closed, + &pixmap_opened, &mask_opened); + term = (node->type == HYP_TREE_NODE_PAGE) || !node->children; pi->sibling = gtk_ctree_insert_node (GTK_CTREE (pi->ctree), - pi->parent, NULL, &title, 5, NULL, - NULL, NULL, NULL, term, FALSE); + pi->parent, NULL, &title, 5, + pixmap_closed, mask_closed, + pixmap_opened, mask_opened, + term, FALSE); node->user_data = pi->sibling; - set_node_style (pi->view, GTK_CTREE (pi->ctree), pi->sibling); - - #ifdef ENABLE_SCROLLKEEPER_SUPPORT if (title != node->title) g_free (title); /* We used the copy from the split */ @@ -134,6 +197,7 @@ ctree_populate_subnode (gpointer key, gpointer value, gpointer user_data) node); if (node->children) { + subpi.view = pi->view; subpi.ctree = pi->ctree; subpi.sibling = NULL; subpi.parent = pi->sibling; @@ -168,34 +232,6 @@ ctree_populate (HyperbolaNavigationTree * view) G_IN_ORDER, &subpi); } -static void -reset_style_for_node (GtkCTree *ctree, GtkCTreeNode *node, gpointer data) -{ - HyperbolaNavigationTree *view = data; - - set_node_style (view, ctree, node); -} - -static void -reset_styles (GtkWidget *widget, GtkStyle *old_style, gpointer data) -{ - HyperbolaNavigationTree *view = data; - - g_assert (GTK_IS_CTREE (widget)); - - if (view->italic_style != NULL) { - gtk_style_unref (view->italic_style); - view->italic_style = NULL; - } - - gtk_clist_freeze (GTK_CLIST (widget)); - gtk_ctree_post_recursive (GTK_CTREE (widget), - NULL, - reset_style_for_node, - view); - gtk_clist_thaw (GTK_CLIST (widget)); -} - BonoboObject * hyperbola_navigation_tree_new (void) { @@ -223,8 +259,6 @@ hyperbola_navigation_tree_new (void) hyperbola_navigation_tree_select_row, view); gtk_signal_connect (GTK_OBJECT (view->top_ctree), "destroy", hyperbola_navigation_tree_destroy, view); - gtk_signal_connect (GTK_OBJECT (view->top_ctree), "style_set", - reset_styles, view); #endif view->ctree = gtk_ctree_new (1, 0); @@ -240,11 +274,7 @@ hyperbola_navigation_tree_new (void) hyperbola_navigation_tree_select_row, view); gtk_signal_connect (GTK_OBJECT (view->ctree), "destroy", hyperbola_navigation_tree_destroy, view); - gtk_signal_connect (GTK_OBJECT (view->ctree), "style_set", - reset_styles, view); - view->italic_style = NULL; - #ifdef ENABLE_SCROLLKEEPER_SUPPORT view->selected_ctree = NULL; view->selected_node = NULL; @@ -460,13 +490,41 @@ hyperbola_navigation_tree_select_row (GtkCTree * ctree, GtkCTreeNode * node, } static void +pixmap_unref_and_null (GdkPixmap **pixmap) +{ + if (*pixmap != NULL) { + gdk_pixmap_unref (*pixmap); + *pixmap = NULL; + } +} + +static void +bitmap_unref_and_null (GdkPixmap **bitmap) +{ + if (*bitmap != NULL) { + gdk_bitmap_unref (*bitmap); + *bitmap = NULL; + } +} + +static void hyperbola_navigation_tree_destroy (GtkCTree * ctree, HyperbolaNavigationTree * view) { set_pending_location (view, NULL); - if (view->italic_style != NULL) { - gtk_style_unref (view->italic_style); - view->italic_style = NULL; - } + pixmap_unref_and_null (&view->folder_open_pixmap); + bitmap_unref_and_null (&view->folder_open_mask); + pixmap_unref_and_null (&view->folder_closed_pixmap); + bitmap_unref_and_null (&view->folder_closed_mask); + + pixmap_unref_and_null (&view->book_open_pixmap); + bitmap_unref_and_null (&view->book_open_mask); + pixmap_unref_and_null (&view->book_closed_pixmap); + bitmap_unref_and_null (&view->book_closed_mask); + + pixmap_unref_and_null (&view->section_open_pixmap); + bitmap_unref_and_null (&view->section_open_mask); + pixmap_unref_and_null (&view->section_closed_pixmap); + bitmap_unref_and_null (&view->section_closed_mask); } diff --git a/icons/Makefile.am b/icons/Makefile.am index 9b8518b73..34002d4fa 100644 --- a/icons/Makefile.am +++ b/icons/Makefile.am @@ -134,6 +134,12 @@ icon_DATA =\ hand-72.png \ hand-96.png \ home.png \ + hyperbola-book-closed.png \ + hyperbola-book-open.png \ + hyperbola-folder-closed.png \ + hyperbola-folder-open.png \ + hyperbola-section-closed.png \ + hyperbola-section-open.png \ i-blockdev.png \ i-bookmark-20.png \ i-bookmark-missing-20.png \ diff --git a/icons/hyperbola-book-closed.png b/icons/hyperbola-book-closed.png Binary files differnew file mode 100644 index 000000000..f8990f208 --- /dev/null +++ b/icons/hyperbola-book-closed.png diff --git a/icons/hyperbola-book-open.png b/icons/hyperbola-book-open.png Binary files differnew file mode 100644 index 000000000..464e0648c --- /dev/null +++ b/icons/hyperbola-book-open.png diff --git a/icons/hyperbola-folder-closed.png b/icons/hyperbola-folder-closed.png Binary files differnew file mode 100644 index 000000000..b1d899014 --- /dev/null +++ b/icons/hyperbola-folder-closed.png diff --git a/icons/hyperbola-folder-open.png b/icons/hyperbola-folder-open.png Binary files differnew file mode 100644 index 000000000..2f90260f8 --- /dev/null +++ b/icons/hyperbola-folder-open.png diff --git a/icons/hyperbola-section-closed.png b/icons/hyperbola-section-closed.png Binary files differnew file mode 100644 index 000000000..3260e6031 --- /dev/null +++ b/icons/hyperbola-section-closed.png diff --git a/icons/hyperbola-section-open.png b/icons/hyperbola-section-open.png Binary files differnew file mode 100644 index 000000000..906c92c30 --- /dev/null +++ b/icons/hyperbola-section-open.png |