2007-06-19 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-stage.c:
        * clutter/clutter-stage.h:
        * clutter/glx/clutter-stage-glx.c:
        * clutter/sdl/clutter-stage-sdl.c:
        Add window title setting/getting functionality.

        * clutter/clutter-event.c: (clutter_key_event_unicode):
        Remove uneeded convert case call.

        * clutter/cogl/gl/cogl.c: (cogl_rectangle)
        Use parameters correctly for underlying GL rect call.

        * tests/test-entry.c:
        Add a window title.
This commit is contained in:
Matthew Allum 2007-06-19 09:10:37 +00:00
parent 1494a017c3
commit 38e6cab1d8
8 changed files with 143 additions and 8 deletions

View File

@ -1,3 +1,20 @@
2007-06-19 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-stage.c:
* clutter/clutter-stage.h:
* clutter/glx/clutter-stage-glx.c:
* clutter/sdl/clutter-stage-sdl.c:
Add window title setting/getting functionality.
* clutter/clutter-event.c: (clutter_key_event_unicode):
Remove uneeded convert case call.
* clutter/cogl/gl/cogl.c: (cogl_rectangle)
Use parameters correctly for underlying GL rect call.
* tests/test-entry.c:
Add a window title.
2007-06-18 Matthew Allum <mallum@openedhand.com>
* clutter/sdl/clutter-event-sdl.c:

View File

@ -248,11 +248,7 @@ clutter_key_event_unicode (ClutterKeyEvent *keyev)
{
g_return_val_if_fail (keyev != NULL, 0);
if ((keyev->modifier_state & CLUTTER_SHIFT_MASK) ||
(keyev->modifier_state & CLUTTER_LOCK_MASK))
return g_unichar_toupper (clutter_keysym_to_unicode (keyev->keyval));
else
return clutter_keysym_to_unicode (keyev->keyval);
return clutter_keysym_to_unicode (keyev->keyval);
}
/**

View File

@ -61,6 +61,8 @@ struct _ClutterStagePrivate
guint is_fullscreen : 1;
guint is_offscreen : 1;
guint is_cursor_visible : 1;
gchar *title;
};
enum
@ -72,6 +74,7 @@ enum
PROP_OFFSCREEN,
PROP_CURSOR_VISIBLE,
PROP_PERSPECTIVE,
PROP_TITLE,
};
enum
@ -147,6 +150,9 @@ clutter_stage_set_property (GObject *object,
case PROP_PERSPECTIVE:
clutter_stage_set_perspectivex (stage, g_value_get_boxed (value));
break;
case PROP_TITLE:
clutter_stage_set_title (stage, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -186,6 +192,9 @@ clutter_stage_get_property (GObject *object,
clutter_stage_get_perspectivex (stage, &perspective);
g_value_set_boxed (value, &perspective);
break;
case PROP_TITLE:
g_value_set_string (value, priv->title);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -240,6 +249,22 @@ clutter_stage_class_init (ClutterStageClass *klass)
"The color of the main stage",
CLUTTER_TYPE_COLOR,
CLUTTER_PARAM_READWRITE));
/**
* ClutterStage:title:
*
* The stages title - usually displayed in stage windows title decorations.
*
* Since: 0.4
*/
g_object_class_install_property
(gobject_class, PROP_TITLE,
g_param_spec_string ("title",
"Title",
"Stage Title",
NULL,
CLUTTER_PARAM_READWRITE));
/**
* ClutterStage::event:
* @stage: the actor which received the event
@ -855,6 +880,54 @@ clutter_stage_event (ClutterStage *stage,
return res;
}
/**
* clutter_stage_set_title
* @stage: A #ClutterStage
* @title: A utf8 string for the stage windows title.
*
* Sets the stage title.
*
* Since 0.4
**/
void
clutter_stage_set_title (ClutterStage *stage,
const gchar *title)
{
ClutterStagePrivate *priv;
g_return_if_fail (CLUTTER_IS_STAGE (stage));
priv = stage->priv;
g_free (priv->title);
priv->title = g_strdup (title);
if (CLUTTER_STAGE_GET_CLASS (stage)->set_title)
CLUTTER_STAGE_GET_CLASS (stage)->set_title (stage, priv->title);
g_object_notify (G_OBJECT (stage), "title");
}
/**
* clutter_stage_get_title
* @stage: A #ClutterStage
*
* Gets the stage title.
*
* Return value: pointer to the title string for the stage. The
* returned string is owned by the actor and should not
* be modified or freed.
*
* Since: 0.4
**/
G_CONST_RETURN gchar *
clutter_stage_get_title (ClutterStage *stage)
{
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
return stage->priv->title;
}
/*** Perspective boxed type ******/
/**

View File

@ -90,6 +90,8 @@ struct _ClutterStageClass
gint y,
gint width,
gint height);
void (* set_title) (ClutterStage *stage,
const gchar *title);
/* signals */
void (* event) (ClutterStage *stage,
@ -169,6 +171,10 @@ GdkPixbuf * clutter_stage_snapshot (ClutterStage *stage,
gboolean clutter_stage_event (ClutterStage *stage,
ClutterEvent *event);
void clutter_stage_set_title (ClutterStage *stage,
const gchar *title);
G_CONST_RETURN gchar *clutter_stage_get_title (ClutterStage *stage);
G_END_DECLS
#endif /* __CLUTTER_STAGE_H__ */

View File

@ -415,7 +415,7 @@ cogl_texture_sub_image_2d (COGLenum target,
void
cogl_rectangle (gint x, gint y, guint width, guint height)
{
GE( glRecti (x,y ,width, height) );
GE( glRecti (x, y, x + width, y + height) );
}
/* FIXME: Should use ClutterReal or Fixed */

View File

@ -441,11 +441,44 @@ clutter_stage_glx_set_cursor_visible (ClutterStage *stage,
}
}
static void
clutter_stage_glx_set_title (ClutterStage *stage,
const gchar *title)
{
ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (stage);
Atom atom_NET_WM_NAME, atom_UTF8_STRING;
if (stage_glx->xwin == None)
return;
/* FIXME: pre create these to avoid too many round trips */
atom_NET_WM_NAME = XInternAtom (stage_glx->xdpy, "_NET_WM_NAME", False);
atom_UTF8_STRING = XInternAtom (stage_glx->xdpy, "UTF8_STRING", False);
if (title == NULL)
{
XDeleteProperty (stage_glx->xdpy,
stage_glx->xwin,
atom_NET_WM_NAME);
}
else
{
XChangeProperty (stage_glx->xdpy,
stage_glx->xwin,
atom_NET_WM_NAME,
atom_UTF8_STRING,
8,
PropModeReplace,
(unsigned char*)title,
(int)strlen(title));
}
}
static void
clutter_stage_glx_set_offscreen (ClutterStage *stage,
gboolean offscreen)
{
/* Do nothing ? */
}
static void
@ -548,6 +581,7 @@ clutter_stage_glx_class_init (ClutterStageGLXClass *klass)
stage_class->set_cursor_visible = clutter_stage_glx_set_cursor_visible;
stage_class->set_offscreen = clutter_stage_glx_set_offscreen;
stage_class->draw_to_pixbuf = clutter_stage_glx_draw_to_pixbuf;
stage_class->set_title = clutter_stage_glx_set_title;
}
static void

View File

@ -171,6 +171,13 @@ clutter_stage_sdl_draw_to_pixbuf (ClutterStage *stage,
G_OBJECT_TYPE_NAME (stage));
}
static void
clutter_stage_sdl_set_title (ClutterStage *stage,
const gchar *title)
{
SDL_WM_SetCaption (title, NULL);
}
static void
clutter_stage_sdl_dispose (GObject *gobject)
{
@ -201,6 +208,7 @@ clutter_stage_sdl_class_init (ClutterStageSDLClass *klass)
stage_class->set_cursor_visible = clutter_stage_sdl_set_cursor_visible;
stage_class->set_offscreen = clutter_stage_sdl_set_offscreen;
stage_class->draw_to_pixbuf = clutter_stage_sdl_draw_to_pixbuf;
stage_class->set_title = clutter_stage_sdl_set_title;
}
static void

View File

@ -40,7 +40,8 @@ main (int argc, char *argv[])
clutter_actor_set_size (stage, 800, 600);
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
clutter_stage_set_title (stage, "ClutterEntry Test");
entry = clutter_entry_new_with_text ("Sans 14",
"Type something, be sure to use the "
"left/right arrow keys to move the "