2311
2306
GtkWidget * grouping_launcher = GTK_WIDGET(task_icon_get_launcher (grouping_icon));
2313
2308
g_assert (grouping_launcher);
2309
for (i=task_icon_get_items(grouping_icon);i; i=i->next)
2311
TaskItem * item = i->data;
2312
if (TASK_IS_LAUNCHER(item))
2316
if (g_list_find (priv->grouping_list,item))
2320
priv->grouping_list = g_list_prepend (priv->grouping_list,item);
2314
2322
for (i=priv->icons; i; i=i->next)
2316
2324
GtkWidget * launcher;
2333
2341
if ( g_strcmp0 (task_launcher_get_desktop_path(TASK_LAUNCHER(grouping_launcher)),
2334
2342
task_launcher_get_desktop_path(TASK_LAUNCHER(launcher)) )==0)
2336
for (j=task_icon_get_items(icon);j;j=j->next)
2344
for (j=task_icon_get_items(icon);j; j?j=j->next:j)
2338
2347
TaskItem * item = j->data;
2339
2348
if (TASK_IS_LAUNCHER(item))
2352
if (g_list_find (priv->grouping_list,item))
2343
2356
task_icon_moving_item (grouping_icon,icon,item);
2357
priv->grouping_list = g_list_prepend (priv->grouping_list,item);
2344
2358
j = task_icon_get_items(icon);
2365
task_manager_regroup_nonlauncher_icon (TaskManager * manager,TaskIcon * grouping_icon)
2367
g_assert (TASK_IS_ICON(grouping_icon));
2368
g_assert (TASK_IS_MANAGER(manager));
2374
TaskManagerPrivate * priv = manager->priv;
2375
for (i=task_icon_get_items(grouping_icon);i; i=i->next)
2377
TaskItem * item = i->data;
2378
if (g_list_find (priv->grouping_list,item))
2382
priv->grouping_list = g_list_prepend (priv->grouping_list,item);
2385
for (i=priv->icons; i; i=i->next)
2389
if (icon == grouping_icon)
2393
if (task_icon_contains_launcher (icon) )
2397
for (j=task_icon_get_items(icon);j;j?j=j->next:j)
2399
gint match_score = 0;
2400
gint max_match_score = 0;
2401
TaskIcon * match = NULL;
2402
TaskItem * item = j->data;
2403
if (g_list_find (priv->grouping_list,item))
2407
for (w = priv->icons; w; w = w->next)
2409
TaskIcon *taskicon = w->data;
2410
/*optimization.... if the icon we're checking against has a launcher
2411
then the item would have been grouped with it on open if it could have
2413
if ( task_icon_contains_launcher (taskicon))
2417
match_score = task_icon_match_item (taskicon, item);
2418
if (match_score > max_match_score)
2420
max_match_score = match_score;
2425
match && (match==grouping_icon)
2427
(priv->grouping || ( (task_icon_count_items(match)==1) && (task_icon_contains_launcher (match)) ) )
2429
( max_match_score > 99-priv->match_strength))
2431
/*we have one match in this icon. dump all the other items in also and
2432
get the hell out of the inner loop. 3 nested loops nasty... short
2433
circuiting as much as possible*/
2434
task_icon_moving_item (grouping_icon,icon,item);
2435
priv->grouping_list = g_list_prepend (priv->grouping_list,item);
2436
for (k=task_icon_get_items (icon);k;k=k->next)
2438
if (g_list_find (priv->grouping_list,k->data))
2442
task_icon_moving_item (grouping_icon,icon,k->data);
2443
priv->grouping_list = g_list_prepend (priv->grouping_list,k->data);
2351
2452
task_manager_regroup (TaskManager * manager)
2355
2456
TaskManagerPrivate * priv = manager->priv;
2358
2458
find the permanent Launchers and regroup them*/
2359
2459
for (i=priv->icons; i; i=i->next)
2380
2480
task_manager_regroup_launcher_icon (manager,icon);
2483
/* Find the icons that do not have a launcher. */
2484
for (i=priv->icons; i; i=i->next)
2488
if ( !task_icon_contains_launcher (icon) )
2490
GSList *items = task_icon_get_items(icon);
2493
task_manager_regroup_nonlauncher_icon (manager,icon);
2497
g_list_free (priv->grouping_list);
2498
priv->grouping_list = NULL;