r295 - trunk/src/target/OM-2007/openmoko-libs/libmokoui
mickey at gta01.hmw-consulting.de
mickey at gta01.hmw-consulting.de
Mon Dec 4 20:40:38 CET 2006
Author: mickey
Date: 2006-12-04 19:40:37 +0000 (Mon, 04 Dec 2006)
New Revision: 295
Modified:
trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c
trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-wheel.c
trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.c
trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.h
Log:
mokoui: add common method moko_finger_window_get_geometry_hint for positioning popup-windows like the MokoFingerWheel, MokoFingerToolBox, etc.
Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c 2006-12-04 16:25:21 UTC (rev 294)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c 2006-12-04 19:40:37 UTC (rev 295)
@@ -217,28 +217,6 @@
static void moko_finger_tool_box_show(GtkWidget* widget)
{
- MokoFingerWheel* wheel = NULL;
- MokoWindow* window = moko_application_get_main_window( moko_application_get_instance() );
- if ( MOKO_IS_FINGER_WINDOW(window) )
- {
- wheel = moko_finger_window_get_wheel( MOKO_FINGER_WINDOW(window) );
- if ( GTK_WIDGET_VISIBLE(wheel) )
- {
- moko_debug( "moko_finger_tool_box: wheel is visible" );
- //FIXME get from theme
- gtk_widget_set_size_request( widget, 350, 104 );
- }
- else
- {
- moko_debug( "moko_finger_tool_box: wheel not visible" );
- //FIXME get from theme
- gtk_widget_set_size_request( widget, 640, 104 );
- }
- }
- else
- {
- g_warning( "moko_finger_tool_box: main window not a finger window" );
- }
//gtk_widget_ensure_style( widget ); //FIXME needed here?
moko_debug( "moko_finger_wheel_show" );
GTK_WIDGET_CLASS(parent_class)->show(widget);
@@ -246,29 +224,23 @@
if ( !priv->popup )
{
priv->popup = gtk_window_new(GTK_WINDOW_POPUP);
- //FIXME Setting it to transparent is probably not necessary since we issue a mask anyway, right?
- //gtk_widget_set_name( GTK_WIDGET(priv->popup), "transparent" );
gtk_container_add( GTK_CONTAINER(priv->popup), widget );
MokoWindow* window = moko_application_get_main_window( moko_application_get_instance() );
- GtkRequisition req;
- gtk_widget_size_request( widget, &req );
- //moko_debug( "My requisition is %d, %d", req.width, req.height );
- int x, y, w, h;
- gdk_window_get_geometry( GTK_WIDGET(window)->window, &x, &y, &w, &h, NULL );
- //moko_debug( "WINDOW geometry is %d, %d * %d, %d", x, y, w, h );
- int absx;
- int absy;
-
+ g_return_if_fail( MOKO_IS_FINGER_WINDOW(window) );
+ GtkAllocation geometry;
+ gboolean valid = moko_finger_window_get_geometry_hint( MOKO_FINGER_WINDOW(window), widget, &geometry );
g_signal_connect_after( G_OBJECT(widget), "size_allocate", G_CALLBACK(cb_size_allocate), widget );
-
- gdk_window_get_origin( GTK_WIDGET(window)->window, &absx, &absy );
- GtkAllocation* alloc = >K_WIDGET(window)->allocation;
- //moko_debug( "WINDOW allocation is %d, %d * %d, %d", alloc->x, alloc->y, alloc->width, alloc->height );
- gtk_window_move( priv->popup, absx + w - req.width, absy + h - req.height );
+ gtk_window_move( priv->popup, geometry.x, geometry.y );
+ gtk_widget_set_size_request( GTK_WIDGET(widget), geometry.width, geometry.height );
+ gtk_window_resize( priv->popup, geometry.width, geometry.height );
}
gtk_widget_show( priv->popup );
- if ( wheel && GTK_WIDGET_VISIBLE(wheel) )
- moko_finger_wheel_raise( wheel );
+ MokoWindow* window = moko_application_get_main_window( moko_application_get_instance() );
+ if ( MOKO_IS_FINGER_WINDOW(window) )
+ {
+ MokoFingerWheel* wheel = moko_finger_window_get_wheel( MOKO_FINGER_WINDOW(window) );
+ if ( wheel && GTK_WIDGET_VISIBLE(wheel) ) moko_finger_wheel_raise( wheel );
+ }
}
static void moko_finger_tool_box_hide(GtkWidget* widget)
Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-wheel.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-wheel.c 2006-12-04 16:25:21 UTC (rev 294)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-wheel.c 2006-12-04 19:40:37 UTC (rev 295)
@@ -187,19 +187,12 @@
//gtk_widget_set_name( GTK_WIDGET(priv->popup), "transparent" );
gtk_container_add( GTK_CONTAINER(priv->popup), widget );
MokoWindow* window = moko_application_get_main_window( moko_application_get_instance() );
- GtkRequisition req;
- gtk_widget_size_request( widget, &req );
- //moko_debug( "My requisition is %d, %d", req.width, req.height );
- int x, y, w, h;
- gdk_window_get_geometry( GTK_WIDGET(window)->window, &x, &y, &w, &h, NULL );
- //moko_debug( "WINDOW geometry is %d, %d * %d, %d", x, y, w, h );
- int absx;
- int absy;
- gdk_window_get_origin( GTK_WIDGET(window)->window, &absx, &absy );
- GtkAllocation* alloc = >K_WIDGET(window)->allocation;
- //moko_debug( "WINDOW allocation is %d, %d * %d, %d", alloc->x, alloc->y, alloc->width, alloc->height );
- gtk_window_move( priv->popup, absx, absy + h - req.height );
+ //FIXME check if it's a finger window
+ GtkAllocation geometry;
+ gboolean valid = moko_finger_window_get_geometry_hint( window, widget, &geometry );
+ gtk_window_move( GTK_WIDGET(priv->popup), geometry.x, geometry.y );
+
//FIXME Isn't there a way to get this as a mask directly from the style without having to reload it?
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(GTK_WIDGET(widget)->style->rc_style->bg_pixmap_name[GTK_STATE_NORMAL], NULL);
GdkPixmap* pixmap;
Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.c 2006-12-04 16:25:21 UTC (rev 294)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.c 2006-12-04 19:40:37 UTC (rev 295)
@@ -25,7 +25,7 @@
#include <gtk/gtklabel.h>
#include <gtk/gtkbutton.h>
-#undef DEBUG_THIS_FILE
+#define DEBUG_THIS_FILE
#ifdef DEBUG_THIS_FILE
#define moko_debug(fmt,...) g_debug(fmt,##__VA_ARGS__)
#else
@@ -107,6 +107,7 @@
if (!priv->wheel) priv->wheel = moko_finger_wheel_new();
return priv->wheel;
}
+
MokoFingerToolBox* moko_finger_window_get_toolbox(MokoFingerWindow* self)
{
moko_debug( "moko_finger_window_get_toolbox" );
@@ -114,3 +115,60 @@
if (!priv->tools) priv->tools = moko_finger_tool_box_new();
return priv->tools;
}
+
+gboolean moko_finger_window_get_geometry_hint(MokoFingerWindow* self, GtkWidget* hintee, GtkAllocation* allocation)
+{
+ //FIXME get geometry hints from theme
+ moko_debug( "moko_finger_window_geometry_hint" );
+
+ GtkRequisition req;
+ gtk_widget_size_request( hintee, &req );
+ int x, y, w, h;
+ gdk_window_get_geometry( GTK_WIDGET(self)->window, &x, &y, &w, &h, NULL );
+ int absx;
+ int absy;
+ gdk_window_get_origin( GTK_WIDGET(self)->window, &absx, &absy );
+
+ moko_debug( "hintee requisition is %d, %d", req.width, req.height );
+ moko_debug( "finger window geometry is %d, %d * %d, %d", x, y, w, h );
+
+ if ( MOKO_IS_FINGER_WHEEL(hintee) )
+ {
+ allocation->x = absx;
+ allocation->y = absy + h - req.height;
+ allocation->width = w;
+ allocation->height = h;
+ return TRUE;
+ }
+ else if ( MOKO_IS_FINGER_TOOL_BOX(hintee) )
+ {
+ MokoFingerWindowPriv* priv = MOKO_FINGER_WINDOW_PRIVATE(self);
+ if ( priv->wheel && GTK_WIDGET_VISIBLE(priv->wheel) )
+ {
+ moko_debug( "-- wheel is visible" );
+ GtkAllocation* wheelalloc = &(GTK_WIDGET(priv->wheel)->allocation);
+ moko_debug( "-- wheel alloc is %d, %d, %d, %d", wheelalloc->x, wheelalloc->y, wheelalloc->width, wheelalloc->height );
+ //FIXME get from theme: 22 is the overlap factor for wheel + toolbox
+#define WHEEL_TOOL_BOX_OVERLAP 22
+#define TOOL_BOX_HEIGHT 104
+ allocation->x = absx + wheelalloc->x + wheelalloc->width - WHEEL_TOOL_BOX_OVERLAP;
+ allocation->y = absy + h - req.height;
+ //allocation->width = w - allocation->x;
+ allocation->width = w - wheelalloc->width + WHEEL_TOOL_BOX_OVERLAP;
+ //FIXME compute
+ allocation->height = TOOL_BOX_HEIGHT;
+ return TRUE;
+ }
+ else
+ {
+ moko_debug( "-- wheel not visible" );
+ allocation->x = absx;
+ allocation->y = absy + h - req.height;
+ allocation->width = w;
+ //FIXME compute
+ allocation->height = TOOL_BOX_HEIGHT;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.h
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.h 2006-12-04 16:25:21 UTC (rev 294)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-window.h 2006-12-04 19:40:37 UTC (rev 295)
@@ -38,11 +38,11 @@
#define MOKO_FINGER_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_FINGER_WINDOW, MokoFingerWindowClass))
typedef struct {
- MokoWindow parent;
+ MokoWindow parent;
} MokoFingerWindow;
typedef struct {
- MokoWindowClass parent_class;
+ MokoWindowClass parent_class;
} MokoFingerWindowClass;
GType moko_finger_window_get_type (void);
@@ -51,6 +51,7 @@
void moko_finger_window_set_contents(MokoFingerWindow* self, GtkWidget* child);
MokoFingerWheel* moko_finger_window_get_wheel(MokoFingerWindow* self);
MokoFingerToolBox* moko_finger_window_get_toolbox(MokoFingerWindow* self);
+gboolean moko_finger_window_get_geometry_hint(MokoFingerWindow* self, GtkWidget* hintee, GtkAllocation* allocation);
G_END_DECLS
More information about the commitlog
mailing list