2 * Copyright (C) 2007 OpenedHand Limited
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Author: Neil Jagdish Patel <njp@o-hand.com>
23 #include "astro-example.h"
25 #include <libastro-desktop/astro-defines.h>
26 #include <libastro-desktop/astro-application.h>
27 #include <libastro-desktop/astro-window.h>
29 G_DEFINE_TYPE (AstroExample2, astro_example2, ASTRO_TYPE_APPLICATION);
31 #define ASTRO_EXAMPLE2_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
32 ASTRO_TYPE_EXAMPLE2, AstroExample2Private))
34 struct _AstroExample2Private
41 /* Public Functions */
43 /* Private functions */
45 get_title (AstroApplication *app)
47 g_return_val_if_fail (ASTRO_IS_EXAMPLE2 (app), NULL);
49 return ASTRO_EXAMPLE2 (app)->priv->title;
53 set_title (AstroApplication *app, const gchar *title)
55 g_return_if_fail (ASTRO_IS_EXAMPLE2 (app));
56 g_return_if_fail (title);
58 ASTRO_EXAMPLE2 (app)->priv->title = g_strdup (title);
62 get_icon (AstroApplication *app)
64 g_return_val_if_fail (ASTRO_IS_EXAMPLE2 (app), NULL);
66 return ASTRO_EXAMPLE2 (app)->priv->icon;
70 set_icon (AstroApplication *app, GdkPixbuf *icon)
72 g_return_if_fail (ASTRO_IS_EXAMPLE2 (app));
73 g_return_if_fail (GDK_IS_PIXBUF (icon));
75 ASTRO_EXAMPLE2 (app)->priv->icon = icon;
79 get_window (AstroApplication *app)
81 AstroExample2Private *priv;
82 ClutterColor color = { 0xff, 0xff, 0x22, 0x22 };
83 ClutterActor *window = NULL, *rect;
85 g_return_val_if_fail (ASTRO_IS_EXAMPLE2 (app), NULL);
86 priv = ASTRO_EXAMPLE2 (app)->priv;
88 if (CLUTTER_IS_ACTOR (priv->window))
89 window = priv->window;
92 window = astro_window_new ();
94 rect = clutter_rectangle_new_with_color (&color);
95 clutter_container_add_actor (CLUTTER_CONTAINER (window), rect);
96 clutter_actor_set_size (rect, CSW (), CSH()-ASTRO_PANEL_HEIGHT());
97 clutter_actor_show (rect);
100 ASTRO_EXAMPLE2 (app)->priv->window = window;
102 return ASTRO_WINDOW (window);
106 close (AstroApplication *app)
108 AstroExample2Private *priv;
110 g_return_if_fail (ASTRO_IS_EXAMPLE2 (app));
111 priv = ASTRO_EXAMPLE2 (app)->priv;
113 if (CLUTTER_IS_ACTOR (priv->window))
114 clutter_actor_destroy (priv->window);
119 astro_example2_class_init (AstroExample2Class *klass)
121 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
122 AstroApplicationClass *app_class = ASTRO_APPLICATION_CLASS (klass);
124 app_class->get_title = get_title;
125 app_class->set_title = set_title;
126 app_class->get_icon = get_icon;
127 app_class->set_icon = set_icon;
128 app_class->get_window = get_window;
129 app_class->close = close;
131 g_type_class_add_private (gobject_class, sizeof (AstroExample2Private));
135 astro_example2_init (AstroExample2 *example2)
137 AstroExample2Private *priv;
138 priv = example2->priv = ASTRO_EXAMPLE2_GET_PRIVATE (example2);
146 astro_example2_new (const gchar *title, GdkPixbuf *icon)
148 AstroApplication *example2 = g_object_new (ASTRO_TYPE_EXAMPLE2,
151 astro_application_set_title (example2, title);
152 astro_application_set_icon (example2, icon);