r197 - in trunk/src/target/OM-2007: applications/openmoko-chordmaster libraries/mokoui
mickey at gta01.hmw-consulting.de
mickey at gta01.hmw-consulting.de
Sun Nov 12 12:31:48 CET 2006
Author: mickey
Date: 2006-11-12 11:31:47 +0000 (Sun, 12 Nov 2006)
New Revision: 197
Added:
trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.c
trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.h
Modified:
trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c
trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.h
Log:
mokoui: factor out MokoTreeView and adjust theming and examples accordingly
Modified: trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c 2006-11-12 11:29:10 UTC (rev 196)
+++ trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c 2006-11-12 11:31:47 UTC (rev 197)
@@ -25,6 +25,7 @@
#include <mokoui/moko-application.h>
#include <mokoui/moko-paned-window.h>
#include <mokoui/moko-tool-box.h>
+#include <mokoui/moko-tree-view.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtklabel.h>
@@ -33,7 +34,6 @@
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktreeview.h>
int main( int argc, char** argv )
{
@@ -135,66 +135,20 @@
void populate_navigation_area( ChordMasterData* d )
{
d->liststore = gtk_list_store_new( NUM_COLS, G_TYPE_STRING, G_TYPE_STRING );
+ d->view = moko_tree_view_new_with_model( d->liststore );
- //FIXME get color from style
- GdkColor color;
- color.red = 0x7f << 8;
- color.green = 0x7f << 8;
- color.blue = 0x7f << 8;
-
- GValue v = { 0, };
- g_value_init (&v, GDK_TYPE_COLOR);
- g_value_set_boxed( &v, &color);
-
- d->view = gtk_tree_view_new_with_model( d->liststore );
- gtk_tree_view_set_rules_hint( d->view, TRUE );
- GtkTreeViewColumn* col = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title( col, "Chordname" );
- gtk_tree_view_column_set_alignment( col, 0.5 );
- gtk_tree_view_column_set_spacing( col, 4 );
- gtk_tree_view_append_column( d->view, col );
+ GtkTreeViewColumn* col = moko_tree_view_append_column_new_with_name( d->view, "Chordname" );
GtkCellRenderer* ren = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start( col, ren, TRUE );
gtk_tree_view_column_add_attribute( col, ren, "text", COLUMN_NAME );
- g_object_set_property( G_OBJECT(ren), "foreground-gdk", &v );
- g_object_set( G_OBJECT(col),
- "resizable", TRUE,
- "reorderable", TRUE,
- "sort-indicator", TRUE,
- NULL );
-
- col = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title( col, "Fretboard" );
- gtk_tree_view_column_set_alignment( col, 0.5 );
- gtk_tree_view_column_set_spacing( col, 4 );
- gtk_tree_view_append_column( d->view, col );
+ col = moko_tree_view_append_column_new_with_name( d->view, "Fretboard" );
ren = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start( col, ren, TRUE );
gtk_tree_view_column_add_attribute( col, ren, "text", COLUMN_FRETS );
- g_object_set_property( G_OBJECT(ren), "foreground-gdk", &v );
- g_object_set( G_OBJECT(col),
- "resizable", TRUE,
- "reorderable", TRUE,
- "sort-indicator", TRUE,
- NULL );
+ moko_paned_window_set_upper_pane( d->window, GTK_WIDGET(moko_tree_view_put_into_scrolled_window(d->view)) );
- //gtk_tree_view_set_headers_clickable( view, TRUE );
- gtk_tree_view_set_headers_visible( d->view, TRUE );
- //gtk_tree_view_set_search_column( view, COLUMN_NAME );
-
- GtkScrolledWindow* scrollwin = gtk_scrolled_window_new( NULL, NULL );
- //FIXME get from style or (even better) set as initial size hint in MokoPanedWindow (also via style sheet of course)
- gtk_widget_set_size_request( GTK_WIDGET(scrollwin), 0, 170 );
- gtk_scrolled_window_set_policy( scrollwin, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
-
- //g_object_set( G_OBJECT(d->view), "can-focus", FALSE, NULL );
-
- //gtk_scrolled_window_add_with_viewport( scrollwin, GTK_WIDGET(d->view) );
- gtk_container_add( scrollwin, GTK_WIDGET(d->view) );
- moko_paned_window_set_upper_pane( d->window, GTK_WIDGET(scrollwin) );
-
GtkTreeSelection* selection = gtk_tree_view_get_selection( d->view );
g_signal_connect( G_OBJECT(selection), "changed", G_CALLBACK(cb_cursor_changed), d );
Modified: trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.h 2006-11-12 11:29:10 UTC (rev 196)
+++ trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.h 2006-11-12 11:31:47 UTC (rev 197)
@@ -26,9 +26,8 @@
#include <mokoui/moko-application.h>
#include <mokoui/moko-paned-window.h>
#include <mokoui/moko-tool-box.h>
-
+#include <mokoui/moko-tree-view.h>
#include <gtk/gtkliststore.h>
-#include <gtk/gtktreeview.h>
typedef struct _ChordMasterData {
MokoApplication* app;
@@ -38,7 +37,7 @@
ChordsDB* chordsdb;
FretboardWidget* fretboard;
GtkListStore* liststore;
- GtkTreeView* view;
+ MokoTreeView* view;
} ChordMasterData;
enum {
Added: trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.c
===================================================================
--- trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.c 2006-11-12 11:29:10 UTC (rev 196)
+++ trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.c 2006-11-12 11:31:47 UTC (rev 197)
@@ -0,0 +1,106 @@
+/* moko-tree-view.c
+ *
+ * Authored By Michael 'Mickey' Lauer <mlauer at vanille-media.de>
+ *
+ * Copyright (C) 2006 Vanille-Media
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Public License as published by
+ * the Free Software Foundation; version 2.1 of the license.
+ *
+ * This program 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 Public License for more details.
+ *
+ * Current Version: $Rev$ ($Date: 2006/10/05 17:38:14 $) [$Author: mickey $]
+ */
+
+#include "moko-tree-view.h"
+
+G_DEFINE_TYPE (MokoTreeView, moko_tree_view, GTK_TYPE_TREE_VIEW);
+
+#define TREE_VIEW_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_TREE_VIEW, MokoTreeViewPrivate))
+
+typedef struct _MokoTreeViewPrivate
+{
+} MokoTreeViewPrivate;
+
+/* forward declarations */
+/* ... */
+
+static void
+moko_tree_view_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (moko_tree_view_parent_class)->dispose)
+ G_OBJECT_CLASS (moko_tree_view_parent_class)->dispose (object);
+}
+
+static void
+moko_tree_view_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (moko_tree_view_parent_class)->finalize (object);
+}
+
+static void
+moko_tree_view_class_init (MokoTreeViewClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ /* register private data */
+ g_type_class_add_private (klass, sizeof (MokoTreeViewPrivate));
+
+ /* hook virtual methods */
+ /* ... */
+
+ /* install properties */
+ /* ... */
+
+ object_class->dispose = moko_tree_view_dispose;
+ object_class->finalize = moko_tree_view_finalize;
+}
+
+static void
+moko_tree_view_init (MokoTreeView *self)
+{
+ gtk_tree_view_set_rules_hint( GTK_TREE_VIEW(self), TRUE );
+ gtk_tree_view_set_headers_visible( GTK_TREE_VIEW(self), TRUE );
+}
+
+MokoTreeView*
+moko_tree_view_new (void)
+{
+ return g_object_new (MOKO_TYPE_TREE_VIEW, NULL);
+}
+
+MokoTreeView*
+moko_tree_view_new_with_model (GtkTreeModel *model)
+{
+ return g_object_new (MOKO_TYPE_TREE_VIEW, "model", model, NULL);
+}
+
+GtkTreeViewColumn* moko_tree_view_append_column_new_with_name(MokoTreeView* self, gchar* name)
+{
+ GtkTreeViewColumn* column = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title( column, name );
+ gtk_tree_view_column_set_alignment( column, 0.5 );
+ gtk_tree_view_column_set_spacing( column, 4 );
+ gtk_tree_view_append_column( GTK_TREE_VIEW(self), column );
+
+ g_object_set( G_OBJECT(column),
+ "resizable", TRUE,
+ "reorderable", TRUE,
+ "sort-indicator", TRUE,
+ NULL );
+ return column;
+}
+
+GtkScrolledWindow* moko_tree_view_put_into_scrolled_window(MokoTreeView* self)
+{
+ GtkScrolledWindow* scrolledwindow = gtk_scrolled_window_new( NULL, NULL );
+ //FIXME get from style or (even better) set as initial size hint in MokoPanedWindow (also via style sheet of course)
+ gtk_widget_set_size_request( GTK_WIDGET(scrolledwindow), 0, 170 );
+ gtk_scrolled_window_set_policy( scrolledwindow, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
+ gtk_container_add( scrolledwindow, GTK_WIDGET(self) );
+ return scrolledwindow;
+}
Property changes on: trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.h
===================================================================
--- trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.h 2006-11-12 11:29:10 UTC (rev 196)
+++ trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.h 2006-11-12 11:31:47 UTC (rev 197)
@@ -0,0 +1,53 @@
+/* moko-tree-view.h
+ *
+ * Authored By Michael 'Mickey' Lauer <mlauer at vanille-media.de>
+ *
+ * Copyright (C) 2006 Vanille-Media
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Public License as published by
+ * the Free Software Foundation; version 2.1 of the license.
+ *
+ * This program 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 Public License for more details.
+ *
+ * Current Version: $Rev$ ($Date: 2006/10/05 17:38:14 $) [$Author: mickey $]
+ */
+
+#ifndef _MOKO_TREE_VIEW_H_
+#define _MOKO_TREE_VIEW_H_
+
+#include <gtk/gtktreeview.h>
+#include <gtk/gtkscrolledwindow.h>
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MOKO_TYPE_TREE_VIEW moko_tree_view_get_type()
+#define MOKO_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_TREE_VIEW, MokoTreeView))
+#define MOKO_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOKO_TYPE_TREE_VIEW, MokoTreeViewClass))
+#define MOKO_IS_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_TREE_VIEW))
+#define MOKO_IS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_TREE_VIEW))
+#define MOKO_TREE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_TREE_VIEW, MokoTreeViewClass))
+
+typedef struct {
+ GtkTreeView parent;
+} MokoTreeView;
+
+typedef struct {
+ GtkTreeViewClass parent_class;
+} MokoTreeViewClass;
+
+GType moko_tree_view_get_type (void);
+MokoTreeView* moko_tree_view_new (void);
+
+GtkTreeViewColumn* moko_tree_view_append_column_new_with_name(MokoTreeView* self, gchar* name);
+GtkScrolledWindow* moko_tree_view_put_into_scrolled_window(MokoTreeView* self);
+
+G_END_DECLS
+
+#endif // _MOKO_TREE_VIEW_H_
+
Property changes on: trunk/src/target/OM-2007/libraries/mokoui/moko-tree-view.h
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the commitlog
mailing list