summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-21 13:38:26 +0100
committerGravatar Martin Szulecki2010-01-21 13:38:26 +0100
commit194663e06c6b538638c527678e29b3d84383b547 (patch)
treea0f1c9ef883cec75219530e510fa5897c53b707b /src
parentd9051870303cce2e2620aa6e9cc339a4dc7b8f96 (diff)
downloadsbmanager-194663e06c6b538638c527678e29b3d84383b547.tar.gz
sbmanager-194663e06c6b538638c527678e29b3d84383b547.tar.bz2
Rip most sbitem code into seperate file for refactoring
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am7
-rw-r--r--src/sbitem.c108
-rw-r--r--src/sbitem.h49
-rw-r--r--src/sbmanager.c80
4 files changed, 164 insertions, 80 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 4ed61bb..b350a40 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,8 +22,11 @@ AM_LDFLAGS = \
bin_PROGRAMS = sbmanager
-sbmanager_SOURCES = device.c device.h \
- sbmanager.c
+sbmanager_SOURCES = device.c \
+ device.h \
+ sbitem.c \
+ sbitem.h \
+ sbmanager.c
sbmanager_CFLAGS = $(AM_CFLAGS)
sbmanager_LDFLAGS = $(AM_LDFLAGS)
diff --git a/src/sbitem.c b/src/sbitem.c
new file mode 100644
index 0000000..a53949e
--- /dev/null
+++ b/src/sbitem.c
@@ -0,0 +1,108 @@
+/**
+ * sbitem.c
+ * SpringBoard Item representation
+ *
+ * Copyright (C) 2009-2010 Nikias Bassen <nikias@gmx.li>
+ * Copyright (C) 2009-2010 Martin Szulecki <opensuse@sukimashita.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more profile.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "sbitem.h"
+
+char *sbitem_get_display_name(SBItem *item)
+{
+ char *strval = NULL;
+ plist_t node = plist_dict_get_item(item->node, "displayName");
+ if (node && plist_get_node_type(node) == PLIST_STRING) {
+ plist_get_string_val(node, &strval);
+ }
+ return strval;
+}
+
+
+char *sbitem_get_display_identifier(SBItem *item)
+{
+ char *strval = NULL;
+ plist_t node = plist_dict_get_item(item->node, "displayIdentifier");
+ if (node && plist_get_node_type(node) == PLIST_STRING) {
+ plist_get_string_val(node, &strval);
+ }
+ return strval;
+}
+
+SBItem *sbitem_new(plist_t icon_info)
+{
+ SBItem *item = NULL;
+
+ if (plist_get_node_type(icon_info) != PLIST_DICT) {
+ return item;
+ }
+
+ item = g_new0(SBItem, 1);
+ item->node = plist_copy(icon_info);
+ item->texture = NULL;
+ item->is_dock_item = FALSE;
+
+ return item;
+}
+
+void sbitem_free(SBItem *item)
+{
+ if (item) {
+ if (item->node) {
+ plist_free(item->node);
+ }
+ if (item->texture && CLUTTER_IS_ACTOR(item->texture)) {
+ ClutterActor *parent = clutter_actor_get_parent(item->texture);
+ if (parent) {
+ clutter_actor_destroy(parent);
+ item->texture = NULL;
+ item->label = NULL;
+ } else {
+ clutter_actor_destroy(item->texture);
+ item->texture = NULL;
+ }
+ }
+ if (item->label && CLUTTER_IS_ACTOR(item->label)) {
+ clutter_actor_destroy(item->label);
+ item->label = NULL;
+ }
+ free(item);
+ }
+}
+
+void g_func_sbitem_free(SBItem *item, gpointer data)
+{
+ sbitem_free(item);
+}
+
+char *sbitem_get_icon_filename(SBItem *item)
+{
+ char *value = sbitem_get_display_identifier(item);
+ if (!value)
+ return NULL;
+
+ return g_strdup_printf("/tmp/%s.png", value);
+}
diff --git a/src/sbitem.h b/src/sbitem.h
new file mode 100644
index 0000000..2c6bd66
--- /dev/null
+++ b/src/sbitem.h
@@ -0,0 +1,49 @@
+/**
+ * sbitem.h
+ * SpringBoard Item representation
+ *
+ * Copyright (C) 2009-2010 Nikias Bassen <nikias@gmx.li>
+ * Copyright (C) 2009-2010 Martin Szulecki <opensuse@sukimashita.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more profile.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef SBITEM_H
+#define SBITEM_H
+
+#include <glib.h>
+#include <clutter/clutter.h>
+#include <plist/plist.h>
+
+typedef struct {
+ plist_t node;
+ ClutterActor *texture;
+ ClutterActor *label;
+ gboolean is_dock_item;
+} SBItem;
+
+char *sbitem_get_display_name(SBItem *item);
+char *sbitem_get_display_identifier(SBItem *item);
+char *sbitem_get_icon_filename(SBItem *item);
+
+SBItem *sbitem_new(plist_t icon_info);
+void sbitem_free(SBItem *item);
+
+void g_func_sbitem_free(SBItem *item, gpointer data);
+
+#endif
diff --git a/src/sbmanager.c b/src/sbmanager.c
index 75029da..426791b 100644
--- a/src/sbmanager.c
+++ b/src/sbmanager.c
@@ -42,6 +42,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "device.h"
+#include "sbitem.h"
#define STAGE_WIDTH 320
#define STAGE_HEIGHT 480
@@ -68,13 +69,6 @@ typedef struct {
device_info_t device_info;
} SBManagerApp;
-typedef struct {
- plist_t node;
- ClutterActor *texture;
- ClutterActor *label;
- gboolean is_dock_item;
-} SBItem;
-
const ClutterActorBox dock_area = { 0.0, STAGE_HEIGHT - DOCK_HEIGHT, STAGE_WIDTH, STAGE_HEIGHT };
const ClutterActorBox sb_area = { 0.0, 16.0, STAGE_WIDTH, STAGE_HEIGHT - DOCK_HEIGHT - 16.0 };
@@ -158,56 +152,10 @@ static gboolean elapsed_ms(struct timeval *tv, guint ms)
}
}
-static char *sbitem_get_display_name(SBItem *item)
-{
- char *strval = NULL;
- plist_t node = plist_dict_get_item(item->node, "displayName");
- if (node && plist_get_node_type(node) == PLIST_STRING) {
- plist_get_string_val(node, &strval);
- }
- return strval;
-}
-
-
-static char *sbitem_get_display_identifier(SBItem *item)
-{
- char *strval = NULL;
- plist_t node = plist_dict_get_item(item->node, "displayIdentifier");
- if (node && plist_get_node_type(node) == PLIST_STRING) {
- plist_get_string_val(node, &strval);
- }
- return strval;
-}
-
-static void sbitem_free(SBItem *a, gpointer data)
-{
- if (a) {
- if (a->node) {
- plist_free(a->node);
- }
- if (a->texture && CLUTTER_IS_ACTOR(a->texture)) {
- ClutterActor *parent = clutter_actor_get_parent(a->texture);
- if (parent) {
- clutter_actor_destroy(parent);
- a->texture = NULL;
- a->label = NULL;
- } else {
- clutter_actor_destroy(a->texture);
- a->texture = NULL;
- }
- }
- if (a->label && CLUTTER_IS_ACTOR(a->label)) {
- clutter_actor_destroy(a->label);
- a->label = NULL;
- }
- free(a);
- }
-}
-
static void sbpage_free(GList *sbitems, gpointer data)
{
if (sbitems) {
- g_list_foreach(sbitems, (GFunc) (sbitem_free), NULL);
+ g_list_foreach(sbitems, (GFunc) (g_func_sbitem_free), NULL);
g_list_free(sbitems);
clutter_group_remove_all(CLUTTER_GROUP(page_indicator_group));
}
@@ -1054,15 +1002,6 @@ static void gui_show_icons()
clutter_stage_ensure_redraw(CLUTTER_STAGE(stage));
}
-static char *sbitem_get_icon_filename(SBItem *item)
-{
- char *value = sbitem_get_display_identifier(item);
- if (!value)
- return NULL;
-
- return g_strdup_printf("/tmp/%s.png", value);
-}
-
static gboolean sbitem_texture_new(gpointer data)
{
SBItem *item = (SBItem *)data;
@@ -1117,21 +1056,6 @@ static gpointer sbitem_thread_load_texture(gpointer data)
return NULL;
}
-static SBItem *sbitem_new(plist_t icon_info)
-{
- SBItem *di = NULL;
-
- if (plist_get_node_type(icon_info) != PLIST_DICT) {
- return di;
- }
-
- di = g_new0(SBItem, 1);
- di->node = plist_copy(icon_info);
- di->texture = NULL;
-
- return di;
-}
-
static guint gui_load_icon_row(plist_t items, GList **row)
{
int i;