* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
GtkTreeStore *store;
gint i;
GType *t;
- volatile GType dummy; /* G_GNUC_CONST makes the optimizer remove
- * get_type calls if you don't do something
- * like this
- */
/* Make the tree more interesting */
- dummy = gtk_scrolled_window_get_type ();
- dummy = gtk_label_get_type ();
- dummy = gtk_hscrollbar_get_type ();
- dummy = gtk_vscrollbar_get_type ();
- dummy = pango_layout_get_type ();
+ /* - we need this magic here so we are sure the type ends up being
+ * registered and gcc doesn't optimize away the code */
+ g_type_class_unref (g_type_class_ref (gtk_scrolled_window_get_type ()));
+ g_type_class_unref (g_type_class_ref (gtk_label_get_type ()));
+ g_type_class_unref (g_type_class_ref (gtk_scrollbar_get_type ()));
+ g_type_class_unref (g_type_class_ref (pango_layout_get_type ()));
t = get_model_types ();
}
}
+void
+on_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ g_print ("Row activated\n");
+}
enum
{
GtkWidget *window;
GtkWidget *sw;
GtkWidget *tv;
- GtkWidget *table;
+ GtkWidget *box;
GtkWidget *combo_box;
GtkTreeModel *model;
gint i;
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_default_size (GTK_WINDOW (window), 430, 400);
- table = gtk_table_new (3, 1, FALSE);
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (window), table);
+ gtk_container_add (GTK_CONTAINER (window), box);
tv = gtk_tree_view_new_with_model (models[0]);
-
+ g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL);
+
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
GDK_BUTTON1_MASK,
row_targets,
/* Model menu */
combo_box = gtk_combo_box_text_new ();
+ gtk_widget_set_halign (combo_box, GTK_ALIGN_CENTER);
for (i = 0; i < MODEL_LAST; i++)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), model_names[i]);
- gtk_table_attach (GTK_TABLE (table), combo_box,
- 0, 1, 0, 1,
- 0, 0,
- 0, 0);
-
+ gtk_container_add (GTK_CONTAINER (box), combo_box);
g_signal_connect (combo_box,
"changed",
G_CALLBACK (model_selected),
/* Columns menu */
combo_box = gtk_combo_box_text_new ();
+ gtk_widget_set_halign (combo_box, GTK_ALIGN_CENTER);
for (i = 0; i < COLUMNS_LAST; i++)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), column_type_names[i]);
- gtk_table_attach (GTK_TABLE (table), combo_box,
- 0, 1, 1, 2,
- 0, 0,
- 0, 0);
+ gtk_container_add (GTK_CONTAINER (box), combo_box);
set_columns_type (GTK_TREE_VIEW (tv), COLUMNS_LOTS);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), COLUMNS_LOTS);
tv);
sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_hexpand (sw, TRUE);
+ gtk_widget_set_vexpand (sw, TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- gtk_table_attach (GTK_TABLE (table), sw,
- 0, 1, 2, 3,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
+ gtk_container_add (GTK_CONTAINER (box), sw);
gtk_container_add (GTK_CONTAINER (sw), tv);
+ create_prop_editor (G_OBJECT (tv), GTK_TYPE_TREE_VIEW);
+ create_prop_editor (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tv))), GTK_TYPE_TREE_SELECTION);
+
gtk_widget_show_all (window);
gtk_main ();