summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-12-19 01:44:59 +0100
committerGravatar Nikias Bassen2010-12-19 01:44:59 +0100
commitde4d91b9429f6bbaa5970c8194b152c67bb3f289 (patch)
treecab9299b077ba026fbc5b3d609788b13e3e4898d
parent59d520af8bbb6ff7702575036be387a9875b440d (diff)
downloadsbmanager-de4d91b9429f6bbaa5970c8194b152c67bb3f289.tar.gz
sbmanager-de4d91b9429f6bbaa5970c8194b152c67bb3f289.tar.bz2
Better handle jumpy icons
-rw-r--r--src/gui.c36
-rw-r--r--src/sbitem.c1
-rw-r--r--src/sbitem.h1
3 files changed, 35 insertions, 3 deletions
diff --git a/src/gui.c b/src/gui.c
index fcaa34d..b6bd4ba 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -52,6 +52,7 @@
#define MAX_PAGE_ITEMS 16
#define PAGE_X_OFFSET(i) ((gfloat)(i)*(gfloat)(STAGE_WIDTH))
+#define ICON_MOVEMENT_DURATION 250
#define FOLDER_ANIM_DURATION 500
const char CLOCK_FONT[] = "FreeSans Bold 12px";
@@ -161,6 +162,14 @@ static void pages_free()
}
}
+static gboolean item_enable(gpointer item)
+{
+ if (item) {
+ ((SBItem*)item)->enabled = TRUE;
+ }
+ return FALSE;
+}
+
static void clutter_actor_get_abs_center(ClutterActor *actor, gfloat *center_x, gfloat *center_y)
{
*center_x = 0.0;
@@ -407,7 +416,7 @@ static void gui_dock_align_icons(gboolean animated)
if (item != selected_item) {
if (animated) {
- clutter_actor_animate(icon, CLUTTER_EASE_OUT_QUAD, 250, "x", xpos, "y", ypos, NULL);
+ clutter_actor_animate(icon, CLUTTER_EASE_OUT_QUAD, ICON_MOVEMENT_DURATION, "x", xpos, "y", ypos, NULL);
} else {
clutter_actor_set_position(icon, xpos, ypos);
}
@@ -460,7 +469,7 @@ static void gui_page_align_icons(guint page_num, gboolean animated)
if (item != selected_item) {
if (animated) {
- clutter_actor_animate(icon, CLUTTER_EASE_OUT_QUAD, 250, "x", xpos, "y", ypos, NULL);
+ clutter_actor_animate(icon, CLUTTER_EASE_OUT_QUAD, ICON_MOVEMENT_DURATION, "x", xpos, "y", ypos, NULL);
} else {
clutter_actor_set_position(icon, xpos, ypos);
}
@@ -1208,7 +1217,11 @@ static gboolean item_button_press_cb(ClutterActor *actor, ClutterButtonEvent *ev
return FALSE;
}
}
-
+
+ if (!item->enabled) {
+ return FALSE;
+ }
+
char *strval = sbitem_get_display_name(item);
g_mutex_lock(selected_mutex);
@@ -1267,6 +1280,11 @@ static gboolean item_button_release_cb(ClutterActor *actor, ClutterButtonEvent *
}
SBItem *item = (SBItem*)user_data;
+ if (!item->enabled) {
+ return FALSE;
+ }
+ item->enabled = FALSE;
+
char *strval = sbitem_get_display_name(item);
/* remove empty pages and page indicators as needed */
@@ -1312,6 +1330,8 @@ static gboolean item_button_release_cb(ClutterActor *actor, ClutterButtonEvent *
start_x = 0.0;
start_y = 0.0;
+ clutter_threads_add_timeout(ICON_MOVEMENT_DURATION, (GSourceFunc)item_enable, (gpointer)item);
+
g_mutex_unlock(selected_mutex);
return TRUE;
@@ -1354,6 +1374,9 @@ static gboolean subitem_button_press_cb(ClutterActor *actor, ClutterButtonEvent
}
SBItem *item = (SBItem*)user_data;
+ if (!item->enabled) {
+ return FALSE;
+ }
char *strval = sbitem_get_display_name(item);
@@ -1396,6 +1419,11 @@ static gboolean subitem_button_release_cb(ClutterActor *actor, ClutterButtonEven
}
SBItem *item = (SBItem*)user_data;
+ if (!item->enabled) {
+ return FALSE;
+ }
+ item->enabled = FALSE;
+
char *strval = sbitem_get_display_name(item);
g_mutex_lock(selected_mutex);
@@ -1419,6 +1447,8 @@ static gboolean subitem_button_release_cb(ClutterActor *actor, ClutterButtonEven
start_x = 0.0;
start_y = 0.0;
+ clutter_threads_add_timeout(ICON_MOVEMENT_DURATION, (GSourceFunc)item_enable, (gpointer)item);
+
g_mutex_unlock(selected_mutex);
if (selected_folder)
diff --git a/src/sbitem.c b/src/sbitem.c
index 9b49186..b780050 100644
--- a/src/sbitem.c
+++ b/src/sbitem.c
@@ -66,6 +66,7 @@ SBItem *sbitem_new(plist_t icon_info)
item->drawn = FALSE;
item->is_dock_item = FALSE;
item->is_folder = FALSE;
+ item->enabled = TRUE;
item->subitems = NULL;
return item;
diff --git a/src/sbitem.h b/src/sbitem.h
index c4e660e..d38769a 100644
--- a/src/sbitem.h
+++ b/src/sbitem.h
@@ -37,6 +37,7 @@ typedef struct {
gboolean drawn;
gboolean is_dock_item;
gboolean is_folder;
+ gboolean enabled;
GList *subitems;
} SBItem;