aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table/e-tree-example-2.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-09-18 11:43:20 +0800
committerChris Lahey <clahey@src.gnome.org>2000-09-18 11:43:20 +0800
commit37d47c916dd0d8d53f277862a297aa23feb8ff13 (patch)
tree8a0f1b3dc651ad004eea1b8de793f2fbada90d85 /widgets/e-table/e-tree-example-2.c
parent645f6e47ea513495f428f9299c5e4ec89dac9891 (diff)
downloadgsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar
gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.gz
gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.bz2
gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.lz
gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.xz
gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.zst
gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.zip
Added check for gnome-app-lib. Removed directories that have been moved to
2000-09-18 Christopher James Lahey <clahey@helixcode.com> * configure.in: Added check for gnome-app-lib. Removed directories that have been moved to gal. From addressbook/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * backend/ebook/Makefile.am, contact-editor/Makefile.am, ename/Makefile.am, gui/component/Makefile.am, gui/widgets/Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * backend/ebook/e-card.c, backend/pas/pas-backend-file.c, contact-editor/e-contact-editor-address.c, contact-editor/e-contact-editor-categories.c, contact-editor/e-contact-editor-categories.h, contact-editor/e-contact-editor-fullname.c, contact-editor/e-contact-editor.c, contact-editor/e-contact-save-as.c, ename/e-address-western.c, ename/test-ename-western-gtk.c, gui/component/addressbook-factory.c, gui/component/addressbook.c, gui/component/e-cardlist-model.h, gui/component/e-ldap-storage.c, gui/component/select-names/e-select-names-bonobo.c, gui/component/select-names/e-select-names-manager.c, gui/component/select-names/e-select-names-model.c, gui/component/select-names/e-select-names-table-model.c, gui/component/select-names/e-select-names-table-model.h, gui/component/select-names/e-select-names-text-model.h, gui/component/select-names/e-select-names.c, gui/component/select-names/e-select-names.h, gui/search/e-addressbook-search-dialog.c, gui/widgets/e-addressbook-model.h, gui/widgets/e-addressbook-view.c, gui/widgets/e-minicard-label.c, gui/widgets/e-minicard-view-widget.c, gui/widgets/e-minicard-view-widget.h, gui/widgets/e-minicard-view.c, gui/widgets/e-minicard-view.h, gui/widgets/e-minicard-widget.h, gui/widgets/e-minicard.c, gui/widgets/test-minicard-label.c, gui/widgets/test-reflow.c, printing/e-contact-print.c: Fixed the #include lines to deal properly with gal. From calendar/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * gui/Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * gui/calendar-model.h, gui/e-calendar-table.c, gui/e-day-view.c, gui/e-week-view-event-item.c, gui/e-week-view.c, gui/event-editor.c, gui/gncal-todo.c, gui/gnome-cal.c, gui/main.c, gui/print.c, gui/dialogs/task-editor.c: Fixed the #include lines to deal properly with gal. * gui/check-filled.xpm: New file since we can't include it from e-table anymore. From camel/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * camel-folder-search.c, camel-folder-search.h, camel-remote-store.c, providers/imap/camel-imap-folder.c, providers/imap/camel-imap-store.c: Fixed the #include lines to deal properly with gal. From composer/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * e-msg-composer-address-dialog.c, e-msg-composer-address-entry.c, e-msg-composer-attachment.c, e-msg-composer-hdrs.c, e-msg-composer.c: Fixed the #include lines to deal properly with gal. From e-util/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Removed all the files moved to gal. * e-dialog-widgets.c: Fixed the #include lines to deal properly with gal. * e-gui-utils.c, e-gui-utils.h: Removed all of the functionality that was moved to gal. * e-canvas-utils.c, e-canvas-utils.h, e-canvas-vbox.c, e-canvas-vbox.h, e-canvas.c, e-canvas.h, e-cursors.c, e-cursors.h, e-font.c, e-font.h, e-popup-menu.c, e-popup-menu.h, e-printable.c, e-printable.h, e-unicode.c, e-unicode.h, e-util.c, e-util.h, e-xml-utils.c, e-xml-utils.h: Moved to gal. From filter/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * filter-editor.c, filter-filter.c, filter-folder.c, filter-input.c, filter-message-search.c, filter-option.c, filter-rule.c, score-editor.c, vfolder-editor.c, vfolder-rule.c: Fixed the #include lines to deal properly with gal. From mail/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * component-factory.c, folder-browser-factory.c, folder-browser.c, mail-callbacks.c, mail-config-gui.c, mail-display.c, mail-display.h, main.c, message-list.c, message-list.h: Fixed the #include lines to deal properly with gal. From po/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * POTFILES.in: Removed files that have been moved to gal. From shell/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * e-component-registry.c, e-corba-storage-registry.c, e-corba-storage.c, e-folder-type-registry.c, e-folder.c, e-local-folder.c, e-local-storage.c, e-shell-folder-creation-dialog.c, e-shell-folder-selection-dialog.c, e-shell-folder-title-bar.c, e-shell-view.c, e-shell.c, e-shortcuts-view.c, e-shortcuts.c, e-storage-set-view.c, e-storage-set-view.h, e-storage-set.c, e-storage.c, evolution-local-storage.c, evolution-session.c, evolution-shell-client.c, evolution-shell-component-client.c, evolution-shell-component.c, evolution-shell-view.c, evolution-storage-listener.c, evolution-storage.c, main.c: Fixed the #include lines to deal properly with gal. From widgets/meeting-time-sel/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * e-meeting-time-sel-list-item.c, e-meeting-time-sel.c, e-meeting-time-sel.h: Fixed the #include lines to deal properly with gal. If you've read this far, you deserve a prize. The first email in my mailbox with the subject "What a commit message!" (and your physical mailing address somewhere in the message) will receive a free Helix Code T-shirt mailed to anywhere within the continental United States. I cannot be held responsible for problems with email systems anywhere. This is supposed to be for fun, so please don't make a fuss if something goes wrong and your mail doesn't reach me. Find my email elsewhere in this message, and if it's been more than a few days, you're probably too late. From widgets/misc/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * e-calendar-item.c, e-calendar.c, e-calendar.h, e-title-bar.c: Fixed the #include lines to deal properly with gal. * e-scroll-frame.c, e-scroll-frame.h: Moved to gal. From widgets/shortcut-bar/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and $(EXTRA_GNOME_LIBS). Removed unneeded libraries. * e-icon-bar.c, e-icon-bar.h, e-shortcut-bar.c, e-shortcut-model.c, test-shortcut-bar.c: Fixed the #include lines to deal properly with gal. From widgets/ChangeLog: 2000-09-18 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Removed directories that have been moved to gal. * e-paned/.cvsignore, e-paned/Makefile.am, e-paned/e-hpaned.c, e-paned/e-hpaned.h, e-paned/e-paned.c, e-paned/e-paned.h, e-paned/e-vpaned.c, e-paned/e-vpaned.h: Moved to gal. * e-reflow/.cvsignore, e-reflow/Makefile.am, e-reflow/e-reflow-sorted.c, e-reflow/e-reflow-sorted.h, e-reflow/e-reflow.c, e-reflow/e-reflow.h: Moved to gal. * e-table/.cvsignore, e-table/ChangeLog, e-table/LICENSE, e-table/Makefile.am, e-table/ROADMAP.e-table, e-table/TODO, e-table/add-col.xpm, e-table/arrow-down.xpm, e-table/arrow-up.xpm, e-table/check-empty.xpm, e-table/check-filled.xpm, e-table/clip.png, e-table/e-cell-checkbox.c, e-table/e-cell-checkbox.h, e-table/e-cell-string.c, e-table/e-cell-text.c, e-table/e-cell-text.h, e-table/e-cell-toggle.c, e-table/e-cell-toggle.h, e-table/e-cell-tree.c, e-table/e-cell-tree.h, e-table/e-cell.c, e-table/e-cell.h, e-table/e-table-click-to-add.c, e-table/e-table-click-to-add.h, e-table/e-table-col-dnd.h, e-table/e-table-col.c, e-table/e-table-col.h, e-table/e-table-column-model.h, e-table/e-table-column.c, e-table/e-table-config.c, e-table/e-table-config.glade, e-table/e-table-config.glade.h, e-table/e-table-config.h, e-table/e-table-defines.h, e-table/e-table-example-1.c, e-table/e-table-example-2.c, e-table/e-table-field-chooser-dialog.c, e-table/e-table-field-chooser-dialog.h, e-table/e-table-field-chooser-item.c, e-table/e-table-field-chooser-item.h, e-table/e-table-field-chooser.c, e-table/e-table-field-chooser.glade, e-table/e-table-field-chooser.glade.h, e-table/e-table-field-chooser.h, e-table/e-table-group-container.c, e-table/e-table-group-container.h, e-table/e-table-group-leaf.c, e-table/e-table-group-leaf.h, e-table/e-table-group.c, e-table/e-table-group.glade, e-table/e-table-group.glade.h, e-table/e-table-group.h, e-table/e-table-header-item.c, e-table/e-table-header-item.h, e-table/e-table-header.c, e-table/e-table-header.h, e-table/e-table-item.c, e-table/e-table-item.h, e-table/e-table-model.c, e-table/e-table-model.h, e-table/e-table-one.c, e-table/e-table-one.h, e-table/e-table-scrolled.c, e-table/e-table-scrolled.h, e-table/e-table-selection-model.c, e-table/e-table-selection-model.h, e-table/e-table-simple.c, e-table/e-table-simple.h, e-table/e-table-size-test.c, e-table/e-table-sort-info.c, e-table/e-table-sort-info.h, e-table/e-table-sorted-variable.c, e-table/e-table-sorted-variable.h, e-table/e-table-sorted.c, e-table/e-table-sorted.h, e-table/e-table-sorter.c, e-table/e-table-sorter.h, e-table/e-table-subset-variable.c, e-table/e-table-subset-variable.h, e-table/e-table-subset.c, e-table/e-table-subset.h, e-table/e-table-text-model.c, e-table/e-table-text-model.h, e-table/e-table-tooltip.h, e-table/e-table-tree.h, e-table/e-table.c, e-table/e-table.h, e-table/e-tree-example-1.c, e-table/e-tree-example-2.c, e-table/e-tree-model.c, e-table/e-tree-model.h, e-table/e-tree-simple.c, e-table/e-tree-simple.h, e-table/image1.png, e-table/image2.png, e-table/image3.png, e-table/remove-col.xpm, e-table/sample.table, e-table/table-test.c, e-table/table-test.h, e-table/test-check.c, e-table/test-cols.c, e-table/test-table.c: Moved to gal. * e-text/.cvsignore, e-text/Makefile.am, e-text/e-entry-test.c, e-text/e-entry.c, e-text/e-entry.h, e-text/e-text-event-processor-emacs-like.c, e-text/e-text-event-processor-emacs-like.h, e-text/e-text-event-processor-types.h, e-text/e-text-event-processor.c, e-text/e-text-event-processor.h, e-text/e-text-model.c, e-text/e-text-model.h, e-text/e-text-test.c, e-text/e-text.c, e-text/e-text.h: Moved to gal. i.e., ... changed evolution to work with gal. svn path=/trunk/; revision=5490
Diffstat (limited to 'widgets/e-table/e-tree-example-2.c')
-rw-r--r--widgets/e-table/e-tree-example-2.c727
1 files changed, 0 insertions, 727 deletions
diff --git a/widgets/e-table/e-tree-example-2.c b/widgets/e-table/e-tree-example-2.c
deleted file mode 100644
index 6324333c19..0000000000
--- a/widgets/e-table/e-tree-example-2.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-tree-example-2.c - Test program for directory reading in the GNOME
- Virtual File System.
-
- Copyright (C) 1999 Free Software Foundation
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Ettore Perazzoli <ettore@comm2000.it> */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include "e-hpaned.h"
-#include "e-util/e-cursors.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-item.h"
-#include "e-cell-text.h"
-#include "e-cell-tree.h"
-#include "e-cell-checkbox.h"
-#include "e-table-scrolled.h"
-#include "e-tree-simple.h"
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#include "art/tree-expanded.xpm"
-#include "art/tree-unexpanded.xpm"
-
-GdkPixbuf *tree_expanded_pixbuf;
-GdkPixbuf *tree_unexpanded_pixbuf;
-
-#define MINI_ICON_SIZE 16
-
-#define RIGHT_COLS 4
-#define LEFT_COLS 4
-
-#define RIGHT_E_TABLE_SPEC \
-"<ETableSpecification> \
- <columns-shown> \
- <column> 0 </column> \
- <column> 1 </column> \
- <column> 2 </column> \
- <column> 3 </column> \
- </columns-shown> \
- <grouping></grouping> \
-</ETableSpecification>"
-
-#define LEFT_E_TABLE_SPEC \
-"<ETableSpecification no-header=\"1\"> \
- <columns-shown> \
- <column> 0 </column> \
- </columns-shown> \
- <grouping></grouping> \
-</ETableSpecification>"
-
-char *left_headers [LEFT_COLS] = {
- "Folder"
-};
-
-char *right_headers [RIGHT_COLS] = {
- "Name",
- "Size",
- "Type",
- "Mime Type"
-};
-
-
-
-GnomeVFSDirectoryFilter *left_filter;
-GnomeVFSDirectoryFilter *right_filter;
-GHashTable *mime_type_to_pixbuf;
-GnomeVFSDirectoryList *right_list = NULL;
-ETreePath *right_root;
-ETreeModel *right_model = NULL;
-ETreeModel *left_model = NULL;
-
-typedef struct {
- char *node_uri;
- GnomeVFSFileInfo *info;
-
- /* next two used only if the node is a directory */
- /* used if the node is expanded */
- GnomeVFSDirectoryList *list;
- /* used if the node is collapsed */
- ETreePath *placeholder;
-} VFSInfo;
-
-/*
- * ETreeSimple callbacks
- * These are the callbacks that define the behavior of our custom model.
- */
-
-static gchar *
-type_to_string (GnomeVFSFileType type)
-{
- switch (type) {
- case GNOME_VFS_FILE_TYPE_UNKNOWN:
- return "Unknown";
- case GNOME_VFS_FILE_TYPE_REGULAR:
- return "Regular";
- case GNOME_VFS_FILE_TYPE_DIRECTORY:
- return "Directory";
- case GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK:
- return "Symbolic Link";
- case GNOME_VFS_FILE_TYPE_FIFO:
- return "FIFO";
- case GNOME_VFS_FILE_TYPE_SOCKET:
- return "Socket";
- case GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE:
- return "Character device";
- case GNOME_VFS_FILE_TYPE_BLOCK_DEVICE:
- return "Block device";
- default:
- return "???";
- }
-}
-
-/* This function returns the value at a particular point in our ETreeModel. */
-static void *
-tree_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
-{
- VFSInfo *vfs_info = e_tree_model_node_get_data (etm, path);
-
- switch (col) {
- case 0: /* filename */
- if (vfs_info->info)
- return vfs_info->info->name;
- else
- return vfs_info->node_uri;
- case 1: /* size */ {
- static char buf[15];
- if (vfs_info->info) {
- if (vfs_info->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
- return "";
- else {
- g_snprintf (buf, sizeof(buf), "%ld", (glong) vfs_info->info->size);
- return buf;
- }
- }
- else
- return "";
- }
- case 2: /* file type */
- if (vfs_info->info)
- return type_to_string (vfs_info->info->type);
- else
- return "";
- case 3: /* mime type */
- if (vfs_info->info) {
- const char *mime_type = gnome_vfs_file_info_get_mime_type (vfs_info->info);
- if (mime_type == NULL)
- mime_type = "(Unknown)";
- return (void*)mime_type;
- }
- else {
- return "";
- }
- default: return "";
- }
-}
-
-/* This function returns the number of columns in our ETableModel. */
-static int
-tree_col_count (ETableModel *etc, void *data)
-{
- return RIGHT_COLS;
-}
-
-/* This function duplicates the value passed to it. */
-static void *
-tree_duplicate_value (ETableModel *etc, int col, const void *value, void *data)
-{
- return g_strdup (value);
-}
-
-/* This function frees the value passed to it. */
-static void
-tree_free_value (ETableModel *etc, int col, void *value, void *data)
-{
- g_free (value);
-}
-
-/* This function creates an empty value. */
-static void *
-tree_initialize_value (ETableModel *etc, int col, void *data)
-{
- return g_strdup ("");
-}
-
-/* This function reports if a value is empty. */
-static gboolean
-tree_value_is_empty (ETableModel *etc, int col, const void *value, void *data)
-{
- return !(value && *(char *)value);
-}
-
-/* This function reports if a value is empty. */
-static char *
-tree_value_to_string (ETableModel *etc, int col, const void *value, void *data)
-{
- return g_strdup(value);
-}
-
-static GdkPixbuf *
-tree_icon_at (ETreeModel *etm, ETreePath *path, void *model_data)
-{
- VFSInfo *vfs_info = e_tree_model_node_get_data (etm, path);
- const char *mime_type;
- GdkPixbuf *scaled_pixbuf = NULL;
-
- if (vfs_info->info == NULL)
- return NULL;
-
- mime_type = gnome_vfs_file_info_get_mime_type (vfs_info->info);
- if (mime_type == NULL)
- mime_type = "(Unknown)";
-
- scaled_pixbuf = g_hash_table_lookup (mime_type_to_pixbuf, mime_type);
- if (!scaled_pixbuf) {
- const char *icon_filename = gnome_vfs_mime_get_icon (mime_type);
- if (icon_filename) {
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (icon_filename);
-
- if (pixbuf) {
- scaled_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf),
- gdk_pixbuf_get_has_alpha (pixbuf),
- gdk_pixbuf_get_bits_per_sample (pixbuf),
- MINI_ICON_SIZE, MINI_ICON_SIZE);
-
- gdk_pixbuf_scale (pixbuf, scaled_pixbuf,
- 0, 0, MINI_ICON_SIZE, MINI_ICON_SIZE,
- 0.0, 0.0,
- (double) MINI_ICON_SIZE / gdk_pixbuf_get_width (pixbuf),
- (double) MINI_ICON_SIZE / gdk_pixbuf_get_height (pixbuf),
- GDK_INTERP_HYPER);
-
- g_hash_table_insert (mime_type_to_pixbuf, (char*)mime_type, scaled_pixbuf);
-
- gdk_pixbuf_unref (pixbuf);
- }
- }
- }
-
- return scaled_pixbuf;
-}
-
-/* This function sets the value at a particular point in our ETreeModel. */
-static void
-tree_set_value_at (ETreeModel *etm, ETreePath *path, int col, const void *val, void *model_data)
-{
-}
-
-/* This function returns whether a particular cell is editable. */
-static gboolean
-tree_is_editable (ETreeModel *etm, ETreePath *path, int col, void *model_data)
-{
- return FALSE;
-}
-
-static void
-sort_list (GnomeVFSDirectoryList *list)
-{
- GnomeVFSDirectorySortRule rules[] = {
- GNOME_VFS_DIRECTORY_SORT_DIRECTORYFIRST,
- GNOME_VFS_DIRECTORY_SORT_BYNAME,
- GNOME_VFS_DIRECTORY_SORT_NONE
- };
-
-
- gnome_vfs_directory_list_sort (list, FALSE, rules);
-}
-
-
-
-static void
-node_collapsed (ETreeModel *etm, ETreePath *path, void *data)
-{
- VFSInfo *vfs_info = e_tree_model_node_get_data (etm, path);
- char *name;
- ETreePath **paths;
- int num_children, i;
-
- if (vfs_info->info)
- name = vfs_info->info->name;
- else
- name = vfs_info->node_uri;
-
- gnome_vfs_directory_list_destroy (vfs_info->list);
-
- /* remove the children of this node, and replace the placeholder */
- num_children = e_tree_model_node_get_children (etm, path, &paths);
- for (i = 0; i < num_children; i ++)
- e_tree_model_node_remove (etm, paths[i]);
- vfs_info->placeholder = e_tree_model_node_insert (etm, path, 0, NULL);
-}
-
-static void
-node_expanded (ETreeModel *etm, ETreePath *path, gboolean *allow_expand, void *data)
-{
- VFSInfo *vfs_info = e_tree_model_node_get_data (etm, path);
- GnomeVFSFileInfo *info;
- GnomeVFSResult result;
- char *name;
-
- if (vfs_info->info)
- name = vfs_info->info->name;
- else
- name = vfs_info->node_uri;
-
- /* Load with no filters and without requesting any metadata. */
- result = gnome_vfs_directory_list_load
- (&vfs_info->list, vfs_info->node_uri,
- (GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS),
- left_filter);
-
- *allow_expand = (result == GNOME_VFS_OK);
-
- if (!*allow_expand) {
- char *buf = g_strdup_printf ("Cannot open directory %s : %s\n",
- vfs_info->info->name, gnome_vfs_result_to_string (result));
- gnome_error_dialog (buf);
- g_free (buf);
- return;
- }
-
- sort_list (vfs_info->list);
-
- /* remove the placeholder and insert all the children of this node */
- e_tree_model_node_remove (etm, vfs_info->placeholder);
-
- info = gnome_vfs_directory_list_first (vfs_info->list);
-
- if (info == NULL) {
- /* no files */
- return;
- }
-
- while (info != NULL) {
- if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
- ETreePath *new_node;
- VFSInfo *new_vfs_info = g_new0(VFSInfo, 1);
- new_vfs_info->info = info;
-
- new_node = e_tree_model_node_insert (etm, path, -1, new_vfs_info);
- new_vfs_info->placeholder = e_tree_model_node_insert (etm, new_node, -1, NULL);
- new_vfs_info->node_uri = g_strdup_printf("%s%s/", vfs_info->node_uri, info->name);
- }
-
- info = gnome_vfs_directory_list_next (vfs_info->list);
- }
-}
-
-static void
-on_cursor_change (ETable *table,
- int row,
- gpointer user_data)
-{
- int num_children, i;
- GnomeVFSFileInfo *info;
- GnomeVFSResult result;
- ETreePath **paths;
- ETreePath *left_path = e_tree_model_node_at_row (left_model, row);
- VFSInfo *vfs_info = e_tree_model_node_get_data (left_model, left_path);
-
- if (right_list) {
- gnome_vfs_directory_list_destroy (right_list);
- right_list = NULL;
- }
-
- /* remove the children of this node, and replace the placeholder */
- num_children = e_tree_model_node_get_children (right_model, right_root, &paths);
- for (i = 0; i < num_children; i ++)
- e_tree_model_node_remove (right_model, paths[i]);
-
- /* Load with no filters and without requesting any metadata. */
- result = gnome_vfs_directory_list_load
- (&right_list, vfs_info->node_uri,
- (GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS),
- right_filter);
-
- if (result != GNOME_VFS_OK)
- return;
-
- info = gnome_vfs_directory_list_first (right_list);
- if (!info)
- return;
-
- while (info != NULL) {
- ETreePath *new_node;
- VFSInfo *new_vfs_info = g_new0(VFSInfo, 1);
- new_vfs_info->info = info;
-
- new_node = e_tree_model_node_insert (right_model, right_root, -1, new_vfs_info);
-
- new_vfs_info->node_uri = g_strdup_printf("%s%s", vfs_info->node_uri, info->name);
-
- info = gnome_vfs_directory_list_next (right_list);
- }
-
-}
-
-static void
-on_double_click (ETable *etable,
- int row,
- void *data)
-{
- GnomeVFSMimeApplication *app;
- ETreePath *path = e_tree_model_node_at_row (right_model, row);
- VFSInfo *vfs_info = e_tree_model_node_get_data (right_model, path);
- const char *mime_type = gnome_vfs_file_info_get_mime_type (vfs_info->info);
- if (mime_type == NULL)
- mime_type = "(Unknown)";
-
- app = gnome_vfs_mime_get_default_application (mime_type);
-
- if (app)
- printf ("exec %s\n", app->command);
- else
- printf ("no command for mime type %s\n", mime_type);
-}
-
-/* create the table on the right */
-static GtkWidget*
-create_right_tree(GtkWidget *paned)
-{
- GtkWidget *e_table;
- GtkWidget *frame;
- ECell *cell_left_just;
- ECell *cell_tree;
- ETableHeader *e_table_header;
- int i;
-
- right_filter = gnome_vfs_directory_filter_new (GNOME_VFS_DIRECTORY_FILTER_NONE,
- GNOME_VFS_DIRECTORY_FILTER_NODIRS,
- NULL);
-
- /* here we create our model. This uses the functions we defined
- earlier. */
- right_model = e_tree_simple_new (tree_col_count,
- tree_duplicate_value,
- tree_free_value,
- tree_initialize_value,
- tree_value_is_empty,
- tree_value_to_string,
- tree_icon_at,
- tree_value_at,
- tree_set_value_at,
- tree_is_editable,
- NULL);
-
- /* create the unexpanded root node and it's placeholder child. */
- right_root = e_tree_model_node_insert (right_model, NULL,
- 0, NULL);
- e_tree_model_root_node_set_visible (right_model, FALSE);
-
- /*
- * Next we create a header. The ETableHeader is used in two
- * different way. The first is the full_header. This is the
- * list of possible columns in the view. The second use is
- * completely internal. Many of the ETableHeader functions are
- * for that purpose. The only functions we really need are
- * e_table_header_new and e_table_header_add_col.
- *
- * First we create the header.
- */
- e_table_header = e_table_header_new ();
-
- /*
- * Next we have to build renderers for all of the columns.
- * Since all our columns are text columns, we can simply use
- * the same renderer over and over again. If we had different
- * types of columns, we could use a different renderer for
- * each column.
- */
- cell_left_just = e_cell_text_new (E_TABLE_MODEL(right_model), NULL, GTK_JUSTIFY_LEFT);
-
- /*
- * This renderer is used for the tree column (the leftmost one), and
- * has as its subcell renderer the text renderer. this means that
- * text is displayed to the right of the tree pipes.
- */
- cell_tree = e_cell_tree_new (E_TABLE_MODEL(right_model),
- tree_expanded_pixbuf, tree_unexpanded_pixbuf,
- TRUE, cell_left_just);
-
- /*
- * Next we create a column object for each view column and add
- * them to the header. We don't create a column object for
- * the importance column since it will not be shown.
- */
- for (i = 0; i < RIGHT_COLS; i++) {
- /* Create the column. */
- ETableCol *ecol = e_table_col_new (
- i, right_headers [i],
- 80, 20,
- i == 0 ? cell_tree
- : cell_left_just,
- g_str_compare, TRUE);
- /* Add it to the header. */
- e_table_header_add_column (e_table_header, ecol, i);
- }
-
- /* This frame is simply to get a bevel around our table. */
- frame = gtk_frame_new (NULL);
-
- /*
- * Here we create the table. We give it the three pieces of
- * the table we've created, the header, the model, and the
- * initial layout. It does the rest.
- */
- e_table = e_table_scrolled_new (e_table_header, E_TABLE_MODEL(right_model), RIGHT_E_TABLE_SPEC);
-
- gtk_signal_connect (GTK_OBJECT (e_table), "double_click", GTK_SIGNAL_FUNC (on_double_click), NULL);
-
- /* Build the gtk widget hierarchy. */
- gtk_container_add (GTK_CONTAINER (frame), e_table);
- gtk_container_add (GTK_CONTAINER (paned), frame);
-
- return e_table;
-}
-
-/* We create a window containing our new tree. */
-static GtkWidget *
-create_left_tree (GtkWidget *paned, char *root_uri)
-{
- GtkWidget *scrolled;
- GtkWidget *e_table;
- GtkWidget *frame;
- ECell *cell_left_just;
- ECell *cell_tree;
- ETableHeader *e_table_header;
- ETreePath *root_node;
- VFSInfo *root_vfs_info;
- ETableCol *ecol;
-
- left_filter = gnome_vfs_directory_filter_new (GNOME_VFS_DIRECTORY_FILTER_NONE,
- /* putting DIRSONLY doesn't work here, so we filter
- files out in node_expanded. */
- (GNOME_VFS_DIRECTORY_FILTER_NOSELFDIR
- | GNOME_VFS_DIRECTORY_FILTER_NOPARENTDIR),
- NULL);
-
-
- /* here we create our model. This uses the functions we defined
- earlier. */
- left_model = e_tree_simple_new (tree_col_count,
- tree_duplicate_value,
- tree_free_value,
- tree_initialize_value,
- tree_value_is_empty,
- tree_value_to_string,
- tree_icon_at,
- tree_value_at,
- tree_set_value_at,
- tree_is_editable,
- NULL);
-
- /* catch collapsed/expanded signals */
- gtk_signal_connect (GTK_OBJECT (left_model), "node_expanded",
- GTK_SIGNAL_FUNC (node_expanded), NULL);
-
- gtk_signal_connect (GTK_OBJECT (left_model), "node_collapsed",
- GTK_SIGNAL_FUNC (node_collapsed), NULL);
-
- /* create the unexpanded root node and it's placeholder child. */
- root_vfs_info = g_new0 (VFSInfo, 1);
- root_vfs_info->node_uri = g_strdup (root_uri);
- root_vfs_info->info = gnome_vfs_file_info_new();
-
- gnome_vfs_get_file_info (root_uri, root_vfs_info->info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
-
- root_node = e_tree_model_node_insert (left_model, NULL,
- 0,
- root_vfs_info);
- e_tree_model_node_set_expanded (left_model, root_node, FALSE);
-
- root_vfs_info->placeholder = e_tree_model_node_insert (left_model, root_node, 0, NULL);
-
- e_tree_model_root_node_set_visible (left_model, TRUE);
-
- /*
- * Next we create a header. The ETableHeader is used in two
- * different way. The first is the full_header. This is the
- * list of possible columns in the view. The second use is
- * completely internal. Many of the ETableHeader functions are
- * for that purpose. The only functions we really need are
- * e_table_header_new and e_table_header_add_col.
- *
- * First we create the header.
- */
- e_table_header = e_table_header_new ();
-
- /*
- * Next we have to build renderers for all of the columns.
- * Since all our columns are text columns, we can simply use
- * the same renderer over and over again. If we had different
- * types of columns, we could use a different renderer for
- * each column.
- */
- cell_left_just = e_cell_text_new (E_TABLE_MODEL(left_model), NULL, GTK_JUSTIFY_LEFT);
-
- /*
- * This renderer is used for the tree column (the leftmost one), and
- * has as its subcell renderer the text renderer. this means that
- * text is displayed to the right of the tree pipes.
- */
- cell_tree = e_cell_tree_new (E_TABLE_MODEL(left_model),
- tree_expanded_pixbuf, tree_unexpanded_pixbuf,
- TRUE, cell_left_just);
-
- /* Create the column. */
- ecol = e_table_col_new (0, left_headers [0],
- 80, 20,
- cell_tree,
- g_str_compare, TRUE);
-
- e_table_header_add_column (e_table_header, ecol, 0);
-
- /* This frame is simply to get a bevel around our table. */
- frame = gtk_frame_new (NULL);
-
- /*
- * Here we create the table. We give it the three pieces of
- * the table we've created, the header, the model, and the
- * initial layout. It does the rest.
- */
- e_table = e_table_new (e_table_header, E_TABLE_MODEL(left_model), LEFT_E_TABLE_SPEC);
-
- gtk_object_set (GTK_OBJECT (e_table),
- "cursor_mode", E_TABLE_CURSOR_LINE,
- NULL);
-
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- /* Build the gtk widget hierarchy. */
- gtk_container_add (GTK_CONTAINER (scrolled), e_table);
- gtk_container_add (GTK_CONTAINER (frame), scrolled);
- gtk_container_add (GTK_CONTAINER (paned), frame);
-
- return e_table;
-}
-
-static void
-create_window(char *root_uri)
-{
- GtkWidget *paned;
- GtkWidget *window, *left_tree, *right_tree;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- paned = e_hpaned_new ();
-
- gtk_container_add (GTK_CONTAINER (window), paned);
-
- left_tree = create_left_tree (paned, root_uri);
- right_tree = create_right_tree (paned);
-
- /* Show it all. */
- gtk_widget_show_all (window);
-
- gtk_signal_connect (GTK_OBJECT (left_tree), "cursor_change", GTK_SIGNAL_FUNC (on_cursor_change), NULL);
- gtk_signal_connect (GTK_OBJECT (window), "delete-event", gtk_main_quit, NULL);
-
- /* kick things off by selecting the root node */
- e_table_set_cursor_row (E_TABLE (left_tree), 0);
- on_cursor_change (E_TABLE(left_tree), 0, NULL);
-}
-
-
-int
-main (int argc, char **argv)
-{
- gchar *root_uri;
-
- if (argv[1] == NULL)
- root_uri = "file:///";
- else
- root_uri = argv[1];
-
- gnome_init ("TableExample", "TableExample", argc, argv);
- e_cursors_init ();
- gnome_vfs_init ();
-
- mime_type_to_pixbuf = g_hash_table_new (g_str_hash, g_str_equal);
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- /*
- * Create our pixbuf for expanding/unexpanding
- */
- tree_expanded_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)tree_expanded_xpm);
- tree_unexpanded_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)tree_unexpanded_xpm);
-
- create_window (root_uri);
-
- gtk_main ();
-
- e_cursors_shutdown ();
- return 0;
-}