r129 - in trunk/src/target/OM-2007: artwork/themes/openmoko-standard/gtk-2.0 examples/openmoko-finger-demo libraries/mokoui
mickey at gta01.hmw-consulting.de
mickey at gta01.hmw-consulting.de
Thu Oct 26 01:43:53 CEST 2006
Author: mickey
Date: 2006-10-25 23:43:52 +0000 (Wed, 25 Oct 2006)
New Revision: 129
Added:
trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.c
trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.h
Modified:
trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/gtkrc
trunk/src/target/OM-2007/examples/openmoko-finger-demo/demo-main.c
trunk/src/target/OM-2007/libraries/mokoui/mokoui.pro
Log:
mokoui: add MokoPixmapContainer, Mickey's breakthrough for theming
Modified: trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/gtkrc
===================================================================
--- trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/gtkrc 2006-10-25 19:01:53 UTC (rev 128)
+++ trunk/src/target/OM-2007/artwork/themes/openmoko-standard/gtk-2.0/gtkrc 2006-10-25 23:43:52 UTC (rev 129)
@@ -1,5 +1,7 @@
gtk-font-name = "Vera Sans 16"
+include "gtknotebook"
+
# pixmap_path "/local/pkg/openmoko/OM-2007/artwork/themes/openmoko-standard/gtk-2.0"
#----------------------------------------------------------------------------
Modified: trunk/src/target/OM-2007/examples/openmoko-finger-demo/demo-main.c
===================================================================
--- trunk/src/target/OM-2007/examples/openmoko-finger-demo/demo-main.c 2006-10-25 19:01:53 UTC (rev 128)
+++ trunk/src/target/OM-2007/examples/openmoko-finger-demo/demo-main.c 2006-10-25 23:43:52 UTC (rev 129)
@@ -19,17 +19,21 @@
#include <mokoui/moko-application.h>
#include <mokoui/moko-finger-window.h>
+#include <mokoui/moko-pixmap-container.h>
#include <gtk/gtkactiongroup.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkcheckmenuitem.h>
+#include <gtk/gtkfixed.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenutoolbutton.h>
#include <gtk/gtkstock.h>
#include <gtk/gtktoolbutton.h>
#include <gtk/gtkuimanager.h>
+#include <gtk/gtknotebook.h>
#include <gtk/gtkvbox.h>
+#include <gtk/gtkentry.h>
#include <stdlib.h>
@@ -44,7 +48,8 @@
g_set_application_name( "OpenMoko-Finger-Demo" );
/* main window */
- MokoFingerWindow* window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+ //MokoFingerWindow* window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+ GtkWindow* window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
/* application menu */
GtkMenu* appmenu = GTK_MENU(gtk_menu_new());
@@ -53,13 +58,37 @@
gtk_menu_shell_append( appmenu, closeitem );
//moko_finger_window_set_application_menu( window, appmenu );
+ GtkVBox* vbox = gtk_vbox_new( TRUE, 10 );
+
+ gtk_container_add( GTK_CONTAINER(window), vbox );
/* connect close event */
g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK( gtk_main_quit ), NULL );
+#if 0
+
+ g_print( "gdkwindow for vbox = %p", GTK_WIDGET(vbox)->window );
+ gtk_widget_set_name( GTK_WIDGET(vbox), "mywidget" );
+
+
/* navigation area */
- GtkButton* contents = gtk_button_new_with_label( "Hello Finger Area!" );
- //moko_finger_window_set_contents( window, GTK_WIDGET(contents) );
+ GtkNotebook* nb = gtk_notebook_new();
+ gtk_notebook_append_page( nb, button1, NULL );
+ gtk_notebook_append_page( nb, button2, NULL );
+
+ gtk_box_pack_start( vbox, GTK_WIDGET(nb), TRUE, TRUE, 20 );
+#endif
+
+ GtkEntry* entry = gtk_entry_new();
+ gtk_entry_set_text( entry, "This is a line of text" );
+
+ MokoPixmapContainer* fixed = moko_pixmap_container_new();
+ moko_pixmap_container_set_cargo( fixed, GTK_WIDGET(entry) );
+
+ gtk_box_pack_start( vbox, GTK_WIDGET(fixed), TRUE, TRUE, 10 );
+
+ //moko_finger_window_set_contents( window, GTK_WIDGET(nb) );
+
/* show everything and run main loop */
gtk_widget_show_all( GTK_WIDGET(window) );
g_debug( "openmoko-finger-demo entering main loop" );
Added: trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.c
===================================================================
--- trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.c 2006-10-25 19:01:53 UTC (rev 128)
+++ trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.c 2006-10-25 23:43:52 UTC (rev 129)
@@ -0,0 +1,157 @@
+
+/* moko_pixmap_container.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-pixmap-container.h"
+
+G_DEFINE_TYPE (MokoPixmapContainer, moko_pixmap_container, GTK_TYPE_FIXED);
+
+#define PIXMAP_CONTAINER_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_PIXMAP_CONTAINER, MokoPixmapContainerPrivate))
+
+typedef struct _MokoPixmapContainerPrivate MokoPixmapContainerPrivate;
+
+struct _MokoPixmapContainerPrivate
+{
+};
+
+static GtkFixedClass *parent_class = NULL;
+
+/* virtual methods */
+
+static void
+moko_pixmap_container_size_request(GtkWidget *widget, GtkRequisition *requisition);
+
+static void
+moko_pixmap_container_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (moko_pixmap_container_parent_class)->dispose)
+ G_OBJECT_CLASS (moko_pixmap_container_parent_class)->dispose (object);
+}
+
+static void
+moko_pixmap_container_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (moko_pixmap_container_parent_class)->finalize (object);
+}
+
+static void
+moko_pixmap_container_class_init (MokoPixmapContainerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+ /* get pointer to parent */
+ parent_class = g_type_class_peek_parent(klass);
+
+ /* add private data */
+ g_type_class_add_private (klass, sizeof (MokoPixmapContainerPrivate));
+
+ /* hook virtual methods */
+ widget_class->size_request = moko_pixmap_container_size_request;
+
+ /* install properties */
+ gtk_widget_class_install_style_property( widget_class, g_param_spec_boxed(
+ "size-request",
+ "Size Request",
+ "Sets the widget size request to a fixed value",
+ GTK_TYPE_BORDER, G_PARAM_READABLE) );
+
+ gtk_widget_class_install_style_property( widget_class, g_param_spec_boxed(
+ "cargo-border",
+ "Cargo Border",
+ "Position and Size of the cargo element",
+ GTK_TYPE_BORDER, G_PARAM_READABLE) );
+}
+
+static void
+moko_pixmap_container_init (MokoPixmapContainer *self)
+{
+ g_debug( "moko_pixmap_container_init" );
+ gtk_fixed_set_has_window( self, TRUE );
+}
+
+MokoPixmapContainer*
+moko_pixmap_container_new (void)
+{
+ return g_object_new (MOKO_TYPE_PIXMAP_CONTAINER, NULL);
+}
+
+static void
+moko_pixmap_container_size_request(GtkWidget *widget, GtkRequisition *requisition)
+{
+ g_debug( "moko_pixmap_container_size_request" );
+
+ GtkBorder* size_request;
+ GtkBorder* cargo_border;
+ gtk_widget_style_get(widget, "size-request", &size_request,
+ "cargo-border", &cargo_border, NULL );
+
+
+ GtkFixed *fixed;
+ GtkFixedChild *child;
+ GList *children;
+ GtkRequisition child_requisition;
+
+ fixed = GTK_FIXED (widget);
+ requisition->width = 0;
+ requisition->height = 0;
+
+ children = fixed->children;
+ while (children)
+ {
+ child = children->data;
+ children = children->next;
+
+ if ( cargo_border && cargo_border->left + cargo_border->right + cargo_border->top + cargo_border->bottom
+ && !child->x && !child->y )
+ {
+ g_warning( "moko_pixmap_container_set_cargo: style requested cargo = '%d, %d x %d, %d'", size_request->left, size_request->top, size_request->right, size_request->bottom );
+ gtk_widget_set_size_request( child->widget, cargo_border->right - cargo_border->left, cargo_border->bottom - cargo_border->top );
+ child->x = cargo_border->left;
+ child->y = cargo_border->top;
+ }
+
+ if (GTK_WIDGET_VISIBLE(child->widget))
+ {
+ gtk_widget_size_request(child->widget, &child_requisition);
+
+ requisition->height = MAX (requisition->height,
+ child->y +
+ child_requisition.height);
+ requisition->width = MAX (requisition->width,
+ child->x +
+ child_requisition.width);
+ }
+ }
+
+ requisition->height += GTK_CONTAINER(fixed)->border_width * 2;
+ requisition->width += GTK_CONTAINER(fixed)->border_width * 2;
+
+ if ( size_request->left + size_request->right + size_request->top + size_request->bottom )
+ {
+ g_warning( "moko_pixmap_container_size_request: style requested size = '%d x %d'", size_request->right, size_request->bottom );
+ requisition->height = MAX( requisition->height, size_request->bottom );
+ requisition->width = MAX( requisition->height, size_request->right );
+ }
+}
+
+void
+moko_pixmap_container_set_cargo(MokoPixmapContainer* self, GtkWidget* child)
+{
+ gtk_fixed_put( GTK_FIXED(self), child, 0, 0 );
+}
Property changes on: trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.h
===================================================================
--- trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.h 2006-10-25 19:01:53 UTC (rev 128)
+++ trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.h 2006-10-25 23:43:52 UTC (rev 129)
@@ -0,0 +1,57 @@
+
+/* moko_pixmap_container.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_PIXMAP_CONTAINER_H_
+#define _MOKO_PIXMAP_CONTAINER_H_
+
+#include <gtk/gtkfixed.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MOKO_TYPE_PIXMAP_CONTAINER moko_pixmap_container_get_type()
+
+#define MOKO_PIXMAP_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_PIXMAP_CONTAINER, MokoPixmapContainer))
+
+#define MOKO_PIXMAP_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOKO_TYPE_PIXMAP_CONTAINER, MokoPixmapContainerClass))
+
+#define MOKO_IS_PIXMAP_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_PIXMAP_CONTAINER))
+
+#define MOKO_IS_PIXMAP_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_PIXMAP_CONTAINER))
+
+#define MOKO_PIXMAP_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_PIXMAP_CONTAINER, MokoPixmapContainerClass))
+
+typedef struct {
+ GtkFixed parent;
+} MokoPixmapContainer;
+
+typedef struct {
+ GtkFixedClass parent_class;
+} MokoPixmapContainerClass;
+
+GType moko_pixmap_container_get_type (void);
+
+MokoPixmapContainer* moko_pixmap_container_new (void);
+
+void moko_pixmap_container_set_cargo(MokoPixmapContainer* self, GtkWidget* child);
+
+G_END_DECLS
+
+#endif // _MOKO_PIXMAP_CONTAINER_H_
+
Property changes on: trunk/src/target/OM-2007/libraries/mokoui/moko-pixmap-container.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/src/target/OM-2007/libraries/mokoui/mokoui.pro
===================================================================
--- trunk/src/target/OM-2007/libraries/mokoui/mokoui.pro 2006-10-25 19:01:53 UTC (rev 128)
+++ trunk/src/target/OM-2007/libraries/mokoui/mokoui.pro 2006-10-25 23:43:52 UTC (rev 129)
@@ -2,6 +2,7 @@
VERSION = 0.0.1
HEADERS = \
+ moko-pixmap-container.h \
moko-application.h \
moko-window.h \
moko-finger-window.h \
@@ -10,6 +11,7 @@
moko-toolbox.h \
moko-search-bar.h
SOURCES = \
+ moko-pixmap-container.c \
moko-application.c \
moko-window.c \
moko-finger-window.c \
More information about the commitlog
mailing list