| cxp (1.5.6) | 2003-11-14 19:45 |
| cxpdd (0.1) | 2004-02-29 20:57 |
| cxplorer-devel (2.1.0) | 2005-10-23 20:53 |
| cxplorer-stable (2.0.0) | 2005-10-17 15:39 |
| libcxp (0.5.6) | 2005-10-23 20:05 |
| OriginalLastRelease (1.5.5) | 2003-09-25 00:03 |
| PukiWiki2SFJPWiki (0.1) | 2009-05-09 01:14 |
Gtk+-1.2にあったGtkCListやGtkTree、GtkCTreeに代わるもの。GtkTreeViewでは、見た目やデータを分離したModel/View/Controllerという設計が取られている。
ツリー型のViewを実現するWidget。後述のGtkTreeViewColumnのコンテナとなっている。なお、GtkTreeModelなどと接続されるまで実際の描画は行われない模様。(Modelの中身は空でも良い。)
他のWidgetと同じでGtkWidget型へのポインタを返すことに注意。
GtkTreeViewに列を表現するためのWidget。後述のGtkCellRendererのコンテナとなっている。
こいつはまんまGtkTreeViewColumn型へのポインタを返す。
などがある。ともに何番目の列となったかが戻り値となる。
セルを表現するためのWidget。文字列や画像、真偽のいずれを扱うかによってGtkCellRendererText、GtkCellRendererPixbuf、GtkCellRendererToggleに分類される。真偽は、トグルボタンとして表現される。その特性上、一つのGtkTreeColumnに対して複数のGtkCellRendererをパッキングすることが可能。
順にGtkCellRendererText、GtkCellRendererPixbuf、GtkCellRendererToggleを生成するが、全てGtkCellRenderer型へのポインタを返す。
gtk_tree_view_column_add_attributeなどで設定できるプロパティの種類
| "attributes" | PangoAttrList | Read / Write | |
| "background" | gchararray | Write | |
| "background-gdk" | GdkColor | Read / Write | |
| "background-set" | gboolean | Read / Write | |
| "editable" | gboolean | Read / Write | |
| "editable-set" | gboolean | Read / Write | |
| "family" | gchararray | Read / Write | |
| "family-set" | gboolean | Read / Write | |
| "font" | gchararray | Read / Write | |
| "font-desc" | PangoFontDescription | Read / Write | |
| "foreground" | gchararray | Write | |
| "foreground-gdk" | GdkColor | Read / Write | |
| "foreground-set" | gboolean | Read / Write | |
| "language" | gchararray | Read / Write | |
| "language-set" | gboolean | Read / Write | |
| "markup" | gchararray | Write | |
| "rise" | gint | Read / Write | |
| "rise-set" | gboolean | Read / Write | |
| "scale" | gdouble | Read / Write | |
| "scale-set" | gboolean | Read / Write | |
| "single-paragraph-mode" | gboolean | Read / Write | |
| "size" | gint | Read / Write | |
| "size-points" | gdouble | Read / Write | |
| "size-set" | gboolean | Read / Write | |
| "stretch" | PangoStretch | Read / Write | |
| "stretch-set" | gboolean | Read / Write | |
| "strikethrough" | gboolean | Read / Write | 打ち消し線 |
| "strikethrough-set" | gboolean | Read / Write | |
| "style" | PangoStyle | Read / Write | |
| "style-set" | gboolean | Read / Write | |
| "text" | gchararray | Read / Write | |
| "underline" | PangoUnderline | Read / Write | |
| "underline-set" | gboolean | Read / Write | |
| "variant" | PangoVariant | Read / Write | |
| "variant-set" | gboolean | Read / Write | |
| "weight" | gint | Read / Write | |
| "weight-set" | gboolean | Read / Write |
| "pixbuf" | GdkPixbuf | Read / Write |
| "pixbuf-expander-closed" | GdkPixbuf | Read / Write |
| "pixbuf-expander-open" | GdkPixbuf | Read / Write |
| "stock-detail" | gchararray | Read / Write |
| "stock-id" | gchararray | Read / Write |
| "stock-size" | guint | Read / Write |
| "activatable" | gboolean | Read / Write |
| "active" | gboolean | Read / Write |
| "inconsistent" | gboolean | Read / Write |
| "radio" | gboolean | Read / Write |
G_TYPE_POINTERを除いてメモリの解放を心配する必要はない。GtkTreeViewが破棄されると同時に解放される。つまり、G_TYPE_POINTER型のフィールドについては、プログラマでメモリの解放の面倒を見る必要がある。
受け取るgchar型のポインタについては、初期化の必要はないが、&を用いてポインタへのポインタを渡すこと。
でないとPangoがレンダリングできない。
などを利用。非表示の項目についてはそのままでも可。
ダミーノードを削除するのは、必要なchildを作成してから。でないと削除した時点で展開が解かれてしまう。
http://scentric.net/tutorial/sec-treemodel-data-manipulation.html
You do not need to worry about allocating and freeing memory for the data to store. The model (or more precisely: the GLib/GObject GType and GValue system) will take care of that for you. If you store a string, for example, the model will make a copy of the string and store that. If you then set the field to a new string later on, the model will automatically free the old string and again make a copy of the new string and store the copy. This applies to almost all types, be it G_TYPE_STRING or GDK_TYPE_PIXBUF.
http://scentric.net/tutorial/sec-treemodel-data-retrieval.html より
- gchar *first_name, *last_name, *tree_path_str;
- guint year_of_birth;
- /* Note: here we use 'iter' and not '&iter', because we did not allocate
- * the iter on the stack and are already getting the pointer to a tree iter */
- gtk_tree_model_get (model, iter,
- COL_FIRST_NAME, &first_name,
- COL_LAST_NAME, &last_name,
- COL_YEAR_BORN, &year_of_birth,
- -1);
- tree_path_str = gtk_tree_path_to_string(path);
- g_print ("Row %s: %s %s, born %u\n", tree_path_str,
- first_name, last_name, year_of_birth);
- g_free(tree_path_str);
- g_free(first_name); /* gtk_tree_model_get made copies of */
- g_free(last_name); /* the strings for us when retrieving them */
Gtk+で標準で用意されているストックアイコンを使用するには、GdkCellRendererPixbufの"stock-id"プロパティを設定する。その場合、関係する列は、G_TYPE_STRINGである必要があり、ストックアイコンのストックIDを格納する。
ストックIDについては、以下を参照。
http://developer.gnome.org/doc/API/2.0/gtk/gtk-Stock-Items.html
GtkTreeModelを取得して、GTK_LIST_STOREでキャストすると大丈夫。
gtk_tree_store_set()において画像がない場合には、明示的にNULLをセットすること。でないとセグフォが起こる。