-#include "timeval.h"
-
-/* Choose track ------------------------------------------------------------ */
-
-#if TDEBUG
-/* Timing */
-static struct {
- struct timeval total;
- struct timeval gtkbits;
- struct timeval menuupdate;
- struct timeval new_widgets;
- struct timeval undisplay;
- struct timeval colors;
- struct timeval markers;
- struct timeval location;
- struct timeval selection;
-} times;
-
-#define BEGIN(WHAT) do { \
- struct timeval started##WHAT, finished##WHAT; \
- xgettimeofday(&started##WHAT, 0)
-
-#define END(WHAT) \
- xgettimeofday(&finished##WHAT, 0); \
- times.WHAT = tvadd(times.WHAT, tvsub(finished##WHAT, started##WHAT)); \
-} while(0)
-
-#define INIT() memset(×, 0, sizeof times)
-
-#define REPORT() do { \
- fprintf(stderr, "total=%g\n" \
- "gtkbits=%g\n" \
- "menuupdate=%g\n" \
- "new_widgets=%g\n" \
- "undisplay=%g\n" \
- "colors=%g\n" \
- "markers=%g\n" \
- "location=%g\n" \
- "selection=%g\n" \
- "accumulation=%g\n" \
- "\n", \
- tvdouble(times.total), \
- tvdouble(times.gtkbits), \
- tvdouble(times.menuupdate), \
- tvdouble(times.new_widgets), \
- tvdouble(times.undisplay), \
- tvdouble(times.colors), \
- tvdouble(times.markers), \
- tvdouble(times.location), \
- tvdouble(times.selection), \
- (tvdouble(times.gtkbits) \
- + tvdouble(times.menuupdate) \
- + tvdouble(times.new_widgets) \
- + tvdouble(times.undisplay) \
- + tvdouble(times.colors) \
- + tvdouble(times.markers) \
- + tvdouble(times.location) \
- + tvdouble(times.selection))); \
-} while(0)
-#else
-#define BEGIN(WHAT) do {
-#define END(WHAT) } while(0)
-#define INIT() ((void)0)
-#define REPORT() ((void)0)
-#endif
-
-WT(label);
-WT(event_box);
-WT(menu);
-WT(menu_item);
-WT(layout);
-WT(vbox);
-WT(arrow);
-WT(hbox);
-WT(button);
-WT(image);
-WT(entry);
-
-/* Types */
-
-struct choosenode;
-
-/** @brief Accumulated information about the tree widget */
-struct displaydata {
- /** @brief Maximum width required */
- guint width;
- /** @brief Maximum height required */
- guint height;
-};
-
-/* instantiate the node vector type */
-
-VECTOR_TYPE(nodevector, struct choosenode *, xrealloc);
-
-/** @brief Signature of function called when a choosenode is filled */
-typedef void (when_filled_callback)(struct choosenode *cn,
- void *wfu);
-
-/** @brief One node in the virtual filesystem */
-struct choosenode {
- struct choosenode *parent; /**< @brief parent node */
- const char *path; /**< @brief full path or 0 */
- const char *sort; /**< @brief sort key */
- const char *display; /**< @brief display name */
- int pending; /**< @brief pending resolve queries */
- unsigned flags;
-#define CN_EXPANDABLE 0x0001 /**< @brief node is expandable */
-#define CN_EXPANDED 0x0002 /**< @brief node is expanded
- *
- * Expandable items are directories;
- * non-expandable ones are files. */
-#define CN_DISPLAYED 0x0004 /**< @brief widget is displayed in layout */
-#define CN_SELECTED 0x0008 /**< @brief node is selected */
-#define CN_GETTING_FILES 0x0010 /**< @brief files inbound */
-#define CN_RESOLVING_FILES 0x0020 /**< @brief resolved files inbound */
-#define CN_GETTING_DIRS 0x0040 /**< @brief directories inbound */
-#define CN_GETTING_ANY 0x0070 /**< @brief getting something */
-#define CN_CONTINGENT 0x0080 /**< @brief expansion contingent on search */
- struct nodevector children; /**< @brief vector of children */
- void (*fill)(struct choosenode *); /**< @brief request child fill or 0 for leaf */
- GtkWidget *container; /**< @brief the container for this row */
- GtkWidget *hbox; /**< @brief the hbox for this row */
- GtkWidget *arrow; /**< @brief arrow widget or 0 */
- GtkWidget *label; /**< @brief text label for this node */
- GtkWidget *marker; /**< @brief queued marker */
-
- when_filled_callback *whenfilled; /**< @brief called when filled or 0 */
- void *wfu; /**< @brief passed to @c whenfilled */
- int ymin; /**< @brief least Y value */
- int ymax; /**< @brief greatest Y value */
-};
-
-/** @brief One item in the popup menu */
-struct choose_menuitem {
- /* Parameters */
- const char *name; /**< @brief name */
-
- /* Callbacks */
- void (*activate)(GtkMenuItem *menuitem, gpointer user_data);
- /**< @brief Called to activate the menu item.
- *
- * @p user_data is the choosenode the mouse pointer is over. */
-
- gboolean (*sensitive)(struct choosenode *cn);
- /* @brief Called to determine whether the menu item should be sensitive.
- *
- * TODO? */
-
- /* State */
- gulong handlerid; /**< @brief signal handler ID */
- GtkWidget *w; /**< @brief menu item widget */