GnuCash 2.4.99
gnc-tree-view.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * gnc-tree-view.h -- new GtkTreeView with extra features used by   *
00003  *                    all the tree views in gnucash                 *
00004  * Copyright (C) 2003 David Hampton <hampton@employees.org>         *
00005  *                                                                  *
00006  * This program is free software; you can redistribute it and/or    *
00007  * modify it under the terms of the GNU General Public License as   *
00008  * published by the Free Software Foundation; either version 2 of   *
00009  * the License, or (at your option) any later version.              *
00010  *                                                                  *
00011  * This program is distributed in the hope that it will be useful,  *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00014  * GNU General Public License for more details.                     *
00015  *                                                                  *
00016  * You should have received a copy of the GNU General Public License*
00017  * along with this program; if not, contact:                        *
00018  *                                                                  *
00019  * Free Software Foundation           Voice:  +1-617-542-5942       *
00020  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00021  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00022  *                                                                  *
00023 \********************************************************************/
00024 
00032 #ifndef __GNC_TREE_VIEW_H
00033 #define __GNC_TREE_VIEW_H
00034 
00035 #include <gtk/gtk.h>
00036 
00037 G_BEGIN_DECLS
00038 
00039 /* type macros */
00040 #define GNC_TYPE_TREE_VIEW            (gnc_tree_view_get_type ())
00041 #define GNC_TREE_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW, GncTreeView))
00042 #define GNC_TREE_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW, GncTreeViewClass))
00043 #define GNC_IS_TREE_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW))
00044 #define GNC_IS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW))
00045 #define GNC_TREE_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW, GncTreeViewClass))
00046 #define GNC_TREE_VIEW_NAME            "GncTreeView"
00047 
00048 
00049 /* typedefs & structures */
00050 typedef struct
00051 {
00052     GtkTreeView gtk_tree_view;
00053 } GncTreeView;
00054 
00055 typedef struct
00056 {
00057     GtkTreeViewClass gtk_tree_view;
00058 } GncTreeViewClass;
00059 
00060 /* Standard g_object type */
00061 GType gnc_tree_view_get_type (void);
00062 
00063 
00064 /* The columns managed by gnc-tree-view can use the following column
00065    attributes.  Set them with:
00066 
00067    g_object_set_data(col, ATTRIBUTE_NAME, value);
00068 */
00069 
00070 /* A column with this attribute set cannot be hidden from view. Valid
00071    values: GINT_TO_POINTER(0) and GINT_TO_POINTER(1) */
00072 #define ALWAYS_VISIBLE  "always-visible"
00073 
00074 /* This attribute controls visibility of a non-gconf column or a gconf
00075    column before a visibility preference has been recorded. Valid values:
00076    GINT_TO_POINTER(0) and GINT_TO_POINTER(1)  */
00077 #define DEFAULT_VISIBLE  "default-visible"
00078 
00079 #define GNC_TREE_VIEW_COLUMN_DATA_NONE -1
00080 #define GNC_TREE_VIEW_COLUMN_COLOR_NONE -1
00081 #define GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS -1
00082 
00083 
00084 typedef void (* renderer_toggled) (GtkCellRendererToggle *cell_renderer_toggle,
00085                                    const gchar           *path,
00086                                    gpointer               user_data);
00087 
00088 
00133 GtkTreeViewColumn *
00134 gnc_tree_view_add_toggle_column (GncTreeView *view,
00135                                  const gchar *column_title,
00136                                  const gchar *column_short_title,
00137                                  const gchar *pref_name,
00138                                  gint model_data_column,
00139                                  gint model_visibility_column,
00140                                  GtkTreeIterCompareFunc column_sort_fn,
00141                                  renderer_toggled toggle_edited_cb);
00142 
00183 GtkTreeViewColumn *
00184 gnc_tree_view_add_text_column (GncTreeView *view,
00185                                const gchar *column_title,
00186                                const gchar *pref_name,
00187                                const gchar *stock_icon_name,
00188                                const gchar *sizing_text,
00189                                gint model_data_column,
00190                                gint model_visibility_column,
00191                                GtkTreeIterCompareFunc column_sort_fn);
00192 
00200 GtkTreeViewColumn *
00201 gnc_tree_view_add_combo_column (GncTreeView *view,
00202                                 const gchar *column_title,
00203                                 const gchar *pref_name,
00204                                 const gchar *sizing_text,
00205                                 gint model_data_column,
00206                                 gint model_visibility_column,
00207                                 GtkTreeModel *combo_tree_model,
00208                                 gint combo_model_text_column,
00209                                 GtkTreeIterCompareFunc column_sort_fn);
00210 
00253 GtkTreeViewColumn *
00254 gnc_tree_view_add_numeric_column (GncTreeView *view,
00255                                   const gchar *column_title,
00256                                   const gchar *pref_name,
00257                                   const gchar *sizing_text,
00258                                   gint model_data_column,
00259                                   gint model_color_column,
00260                                   gint model_visibility_column,
00261                                   GtkTreeIterCompareFunc column_sort_fn);
00262 
00275 gint gnc_tree_view_append_column (GncTreeView *view,
00276                                   GtkTreeViewColumn *column);
00277 
00295 void gnc_tree_view_set_model(GncTreeView *view, GtkTreeModel *model);
00296 
00303 void gnc_tree_view_configure_columns (GncTreeView *view);
00304 
00315 GtkTreeViewColumn *
00316 gnc_tree_view_find_column_by_name (GncTreeView *view,
00317                                    const gchar *wanted);
00318 
00338 void gnc_tree_view_set_gconf_section (GncTreeView *view,
00339                                       const gchar *section);
00340 
00351 const gchar *gnc_tree_view_get_gconf_section (GncTreeView *view);
00352 
00353 void gnc_tree_view_expand_columns (GncTreeView *view,
00354                                    gchar *first_column_name,
00355                                    ...);
00356 
00365 void
00366 gnc_tree_view_set_show_column_menu (GncTreeView *view,
00367                                     gboolean visible);
00368 
00377 gboolean
00378 gnc_tree_view_get_show_column_menu (GncTreeView *view);
00379 
00387 GtkCellRenderer *
00388 gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column);
00389 
00390 
00391 /* Takes a GdkEventKey and the current path and column for the
00392  * treeview.  Interprets the event as something that might move the
00393  * cursor.  Returns the new column and the possibly changed (if
00394  * navigation wrapped a row) path. */
00395 void
00396 gnc_tree_view_keynav(GncTreeView *view, GtkTreeViewColumn **col,
00397                      GtkTreePath *path, GdkEventKey *event);
00398 
00399 /* Returns TRUE if path is a vaid path for the treeview */
00400 gboolean
00401 gnc_tree_view_path_is_valid(GncTreeView *view, GtkTreePath *path);
00402 
00407 G_END_DECLS
00408 
00409 #endif /* __GNC_TREE_VIEW_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines