2
* Copyright (C) 2008 Canonical Ltd
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU 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
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU 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
* Authored by Neil Jagdish Patel <neil.patel@canonical.com>
23
#include "launcher-catbar.h"
24
#include "launcher-defines.h"
26
#include "tidy-texture-frame.h"
28
G_DEFINE_TYPE (LauncherCatbar, launcher_catbar, CLUTTER_TYPE_GROUP);
30
#define LAUNCHER_CATBAR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
31
LAUNCHER_TYPE_CATBAR, \
32
LauncherCatbarPrivate))
34
struct _LauncherCatbarPrivate
36
ClutterActor *bg_texture;
39
ClutterActor *hilight_texture;
40
ClutterActor *hilight;
49
static guint _catbar_signals[LAST_SIGNAL] = { 0 };
54
launcher_catbar_class_init (LauncherCatbarClass *klass)
56
GObjectClass *obj_class = G_OBJECT_CLASS (klass);
58
_catbar_signals[CAT_SELECTED] =
59
g_signal_new ("categroy-selected",
60
G_OBJECT_CLASS_TYPE (obj_class),
62
G_STRUCT_OFFSET (LauncherCatbarClass, category_selected),
64
g_cclosure_marshal_VOID__POINTER,
67
g_type_class_add_private (obj_class, sizeof (LauncherCatbarPrivate));
71
_append_category (LauncherCatbar *bar,
72
LauncherMenuCategory *category,
77
ClutterActor *texture;
79
ClutterColor color = { 0xff, 0xff, 0xff, 0xff };
81
icon = launcher_menu_category_get_icon (category);
82
texture = clutter_texture_new_from_pixbuf (icon);
83
clutter_actor_set_size (texture, size -(4*CAT_PADDING), size-(4*CAT_PADDING));
84
clutter_actor_set_anchor_point_from_gravity (texture, CLUTTER_GRAVITY_NORTH);
85
clutter_actor_set_position (texture,
87
offset + CAT_PADDING);
88
clutter_container_add_actor (CLUTTER_CONTAINER (bar), texture);
89
clutter_actor_show (texture);
91
label = clutter_label_new_full (CAT_FONT,
92
launcher_menu_category_get_name (category),
94
clutter_container_add_actor (CLUTTER_CONTAINER (bar), label);
95
clutter_actor_set_anchor_point_from_gravity (label, CLUTTER_GRAVITY_NORTH);
96
clutter_actor_set_position (label,
98
clutter_actor_get_y (texture) + CAH(texture)
100
clutter_actor_show (label);
104
launcher_catbar_init (LauncherCatbar *catbar)
106
LauncherCatbarPrivate *priv;
107
LauncherMenu *menu = launcher_menu_get_default ();
109
gint bar_width = CAT_SIZE();
110
gint bar_height = CAT_SIZE() * N_CATS;
114
priv = catbar->priv = LAUNCHER_CATBAR_GET_PRIVATE (catbar);
116
temp = gdk_pixbuf_new_from_file (PKGDATADIR"/sidebar.png", NULL);
117
priv->bg_texture = clutter_texture_new_from_pixbuf (temp);
118
clutter_actor_realize (priv->bg_texture);
119
g_object_unref (temp);
121
priv->bg = tidy_texture_frame_new (CLUTTER_TEXTURE (priv->bg_texture),
123
clutter_container_add_actor (CLUTTER_CONTAINER (catbar), priv->bg);
124
clutter_actor_set_size (priv->bg, bar_width, bar_height);
125
clutter_actor_set_position (priv->bg, 0,
126
((CSH()/2)-(bar_height/2))+PANEL_HEIGHT);
127
clutter_actor_show (priv->bg);
129
for (l = launcher_menu_get_categories (menu); l; l = l->next)
131
LauncherMenuCategory *cat = l->data;
133
_append_category (catbar, cat, bar_width,
134
(bar_width * i)+ clutter_actor_get_y (priv->bg));
140
launcher_catbar_get_default (void)
143
static ClutterActor *catbar = NULL;
146
catbar = g_object_new (LAUNCHER_TYPE_CATBAR,