コード例 #1
0
static gboolean _on_active_window_changed (G_GNUC_UNUSED gpointer data, GldiWindowActor *actor)
{
	// on gere son animation et son indicateur.
	Icon *icon = _get_appli_icon (actor);
	CairoDock *pParentDock = NULL;
	if (CAIRO_DOCK_IS_APPLI (icon))
	{
		if (icon->bIsDemandingAttention)  // force the stop demanding attention, as it can happen (for some reason) that the attention state doesn't change when the appli takes the focus.
			gldi_appli_icon_stop_demanding_attention (icon);
		
		pParentDock = CAIRO_DOCK(cairo_dock_get_icon_container (icon));
		if (pParentDock == NULL)  // inhibited or not shown
		{
			///cairo_dock_update_activity_on_inhibitors (icon->cClass, actor);
			gldi_window_inhibitors_set_active_state (actor, TRUE);
		}
		else
		{
			gldi_appli_icon_animate_on_active (icon, pParentDock);
		}
	}
	
	// on enleve l'indicateur sur la precedente appli active.
	Icon *pLastActiveIcon = _get_appli_icon (s_pCurrentActiveWindow);
	if (CAIRO_DOCK_IS_APPLI (pLastActiveIcon))
	{
		CairoDock *pLastActiveParentDock = CAIRO_DOCK(cairo_dock_get_icon_container (pLastActiveIcon));
		if (pLastActiveParentDock == NULL)  // inhibited or not shown
		{
			///cairo_dock_update_inactivity_on_inhibitors (pLastActiveIcon->cClass, s_pCurrentActiveWindow);
			gldi_window_inhibitors_set_active_state (s_pCurrentActiveWindow, FALSE);
		}
		else
		{
			cairo_dock_redraw_icon (pLastActiveIcon);
			if (pLastActiveParentDock->iRefCount != 0)  // l'icone est dans un sous-dock, comme l'indicateur est aussi dessine sur l'icone pointant sur ce sous-dock, il faut la redessiner sans l'indicateur.
			{
				CairoDock *pMainDock = NULL;
				Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (pLastActiveParentDock, &pMainDock);
				if (pPointingIcon && pMainDock)
				{
					cairo_dock_redraw_icon (pPointingIcon);
				}
			}
		}
	}
	s_pCurrentActiveWindow = actor;
	
	return GLDI_NOTIFICATION_LET_PASS;
}
コード例 #2
0
void cairo_dock_deactivate_module_and_unload (gchar *cModuleName)
{
	if (g_pMainDock == NULL)
		return ;
	CairoDockModule *pModule = cairo_dock_find_module_from_name (cModuleName);
	Icon *pIcon = cairo_dock_find_icon_from_module (pModule, pModule->pContainer);
	
	if (CAIRO_DOCK_IS_DOCK (pModule->pContainer))
	{
		CairoDock *pDock = CAIRO_DOCK (pModule->pContainer);
		if (pIcon != NULL)
		{
			cairo_dock_remove_icon_from_dock (pDock, pIcon);  // desactive le module.
			cairo_dock_update_dock_size (pDock);
		}
		else
		{
			cairo_dock_deactivate_module (pModule);
		}
		gtk_widget_queue_draw (pDock->pWidget);
	}
	else
	{
		cairo_dock_deactivate_module (pModule);
	}
	
	cairo_dock_update_conf_file_with_active_modules2 (NULL, g_cConfFile);
	cairo_dock_free_icon (pIcon);
}
コード例 #3
0
static gboolean _on_window_destroyed (G_GNUC_UNUSED gpointer data, GldiWindowActor *actor)
{
	cd_debug ("window %s (%p) is destroyed", actor->cName, actor);
	Icon *icon = _get_appli_icon (actor);
	if (icon != NULL)
	{
		if (actor->bDemandsAttention)  // force the stop demanding attention, in case the icon was in a sub-dock (the main icon is also animating).
			gldi_appli_icon_stop_demanding_attention (icon);
		
		CairoDock *pParentDock = CAIRO_DOCK(cairo_dock_get_icon_container (icon));
		if (pParentDock != NULL)
		{
			cd_message ("  va etre supprimee");
			cairo_dock_unregister_appli (icon);  // unregister the icon immediately, since it doesn't represent anything any more; it unsets pAppli, so that when the animation is over, the icon will be destroyed.
			
			cairo_dock_trigger_icon_removal_from_dock (icon);
		}
		else  // inhibited or not shown -> destroy it immediately
		{
			cd_message ("  pas dans un container, on la detruit donc immediatement");
			///cairo_dock_update_name_on_inhibitors (icon->cClass, actor, NULL);
			gldi_window_inhibitors_set_name (actor, NULL);
			gldi_object_unref (GLDI_OBJECT (icon));  // will call cairo_dock_unregister_appli and update the inhibitors.
		}
	}
	
	if (s_pCurrentActiveWindow == actor)
		s_pCurrentActiveWindow = NULL;
	
	return GLDI_NOTIFICATION_LET_PASS;
}
コード例 #4
0
void cairo_dock_compute_icon_area (Icon *icon, CairoContainer *pContainer, GdkRectangle *pArea)
{
	double fReflectSize = 0;
	if (CAIRO_DOCK_IS_DOCK (pContainer) && CAIRO_DOCK (pContainer)->bUseReflect)
	{
		fReflectSize = myIcons.fReflectSize * icon->fScale * fabs (icon->fHeightFactor) + icon->fDeltaYReflection;
	}
	fReflectSize = MAX (fReflectSize, myIndicators.iIndicatorDeltaY);
	
	double fX = icon->fDrawX;
	fX += icon->fWidth * icon->fScale * (1 - fabs (icon->fWidthFactor))/2;
	
	double fY = icon->fDrawY;
	fY += (pContainer->bDirectionUp ? icon->fHeight * icon->fScale * (1 - icon->fHeightFactor)/2 : - fReflectSize);
	if (fY < 0)
		fY = 0;
	
	if (pContainer->bIsHorizontal)
	{
		pArea->x = (int) floor (fX);
		pArea->y = (int) floor (fY);
		pArea->width = (int) ceil (icon->fWidth * icon->fScale * fabs (icon->fWidthFactor)) + 1;
		pArea->height = (int) ceil (icon->fHeight * icon->fScale * fabs (icon->fHeightFactor) + fReflectSize);
	}
	else
	{
		pArea->x = (int) floor (fY);
		pArea->y = (int) floor (fX);
		pArea->width = ((int) ceil (icon->fHeight * icon->fScale * fabs (icon->fHeightFactor) + fReflectSize)) + 1;
		pArea->height = (int) ceil (icon->fWidth * icon->fScale * fabs (icon->fWidthFactor));
	}
	//g_print ("redraw : %d;%d %dx%d\n", pArea->x, pArea->y, pArea->width,pArea->height);
}
コード例 #5
0
static void _find_icon_in_dock_with_command (Icon *pIcon, gpointer *data)
{
	CairoDock *pDock = CAIRO_DOCK (cairo_dock_get_icon_container(pIcon));
	gchar *cCommandPrefix = data[0];
	int length = GPOINTER_TO_INT (data[1]);
	Icon *pAfterIcon = data[2];
	Icon **pFoundIcon = data[3];
	CairoDock **pFoundDock = data[4];
	Icon **pFirstIcon = data[5];
	CairoDock **pFirstParentDock = data[6];
	if (pDock == myData.pCurrentDock || *pFoundIcon != NULL) // on a deja cherche dans le main dock, ou deja trouve ce qu'on cherchait.
		return ;
	
	gboolean bFound = _cd_do_icon_match (pIcon, cCommandPrefix, length);
	if (bFound)
	{
		if (pAfterIcon == NULL)
		{
			*pFoundIcon = pIcon;
			*pFoundDock = pDock;
		}
		else
		{
			if (*pFirstIcon == NULL)  // on garde une trace de la 1ere icone pour boucler dans la liste.
			{
				*pFirstIcon = pIcon;
				*pFirstParentDock = pDock;
			}
			if (pIcon == pAfterIcon)
			{
				data[2] = NULL;
			}
		}
	}
}
コード例 #6
0
void cairo_dock_activate_modules_from_list (gchar **cActiveModuleList, CairoDock *pDock, double fTime)
{
	if (cActiveModuleList == NULL)
		return ;

	GError *erreur = NULL;
	gchar *cModuleName;
	CairoDockModule *pModule;
	int i = 0, iOrder = 0;
	while (cActiveModuleList[i] != NULL)
	{
		cModuleName = cActiveModuleList[i];
		//g_print (" + %s\n", cModuleName);
		pModule = g_hash_table_lookup (s_hModuleTable, cModuleName);
		if (pModule != NULL)
		{
			pModule->fLastLoadingTime = fTime;
			if (! pModule->bActive)
			{
				Icon *pIcon = cairo_dock_activate_module (pModule, pDock, &erreur);
				if (erreur != NULL)
				{
					cd_warning ("Attention : %s", erreur->message);
					g_error_free (erreur);
					erreur = NULL;
				}
				if (pIcon != NULL)
				{
					if (pIcon->fOrder == CAIRO_DOCK_LAST_ORDER)
						pIcon->fOrder = g_list_length (pDock->icons);  // pas optimise, mais oblige de leur donner un numero distinct pour chacun, y compris quand on en active seulement 1.
					iOrder ++;
					if (CAIRO_DOCK_IS_DOCK (pModule->pContainer))
						cairo_dock_insert_icon_in_dock (pIcon, CAIRO_DOCK (pModule->pContainer), ! CAIRO_DOCK_UPDATE_DOCK_SIZE, ! CAIRO_DOCK_ANIMATE_ICON, CAIRO_DOCK_APPLY_RATIO, g_bUseSeparator);
				}
			}
			else
			{
				/*CairoDock *pMyDock = NULL;
				Icon *pIcon = NULL;
				if (CAIRO_DOCK_IS_DOCK (pModule->pContainer))
				{
					pIcon = cairo_dock_find_icon_from_module (pModule, pModule->pContainer);
					pMyDock = CAIRO_DOCK (pModule->pContainer);
					pIcon->fWidth /= pMyDock->fRatio;
					pIcon->fHeight /= pMyDock->fRatio;
				}*/
				cairo_dock_reload_module (pModule, FALSE);
				/*if (pMyDock != NULL && pIcon != NULL)
				{
					pIcon->fWidth *= pMyDock->fRatio;
					pIcon->fHeight *= pMyDock->fRatio;
				}*/
			}
		}
		i ++;
	}
}
コード例 #7
0
static Window cairo_dock_detach_appli_of_class (const gchar *cClass, gboolean bDetachAll)
{
	g_return_val_if_fail (cClass != NULL, 0);
	
	const GList *pList = cairo_dock_list_existing_appli_with_class (cClass);
	Icon *pIcon;
	const GList *pElement;
	gboolean bNeedsRedraw = FALSE, bDetached;
	CairoDock *pParentDock;
	Window XFirstFoundId = 0;
	for (pElement = pList; pElement != NULL; pElement = pElement->next)
	{
		pIcon = pElement->data;
		cd_debug ("detachement de l'icone %s (%d;%d)", pIcon->acName, bDetachAll, XFirstFoundId);
		CairoContainer *pContainer = cairo_dock_search_container_from_icon (pIcon);
		if (CAIRO_DOCK_IS_DOCK (pContainer))
		{
			pParentDock = CAIRO_DOCK (pContainer);
			bDetached = FALSE;
			if (bDetachAll || XFirstFoundId == 0)
			{
				gchar *cParentDockName = pIcon->cParentDockName;
				pIcon->cParentDockName = NULL;  // astuce.
				bDetached = cairo_dock_detach_icon_from_dock (pIcon, pParentDock, g_bUseSeparator);  // on la garde, elle pourra servir car elle contient l'Xid.
				if (! pParentDock->bIsMainDock)
				{
					if (pParentDock->icons == NULL)
						cairo_dock_destroy_dock (pParentDock, cParentDockName, NULL, NULL);
					else
						cairo_dock_update_dock_size (pParentDock);
				}
				else
					bNeedsRedraw |= (bDetached);
				g_free (cParentDockName);
			}
			if (bDetached && XFirstFoundId == 0)
				XFirstFoundId = pIcon->Xid;
			else
			{
				/**cairo_t *pCairoContext = cairo_dock_create_context_from_window (CAIRO_CONTAINER (pContainer));
				cd_messge ("  on recharge l'icone de l'appli detachee %s", pIcon->acName);
				cairo_dock_fill_one_icon_buffer (pIcon, pCairoContext, 1 + g_fAmplitude, pParentDock->bHorizontalDock, TRUE, pParentDock->bDirectionUp);
				cairo_destroy (pCairoContext);*/
				bNeedsRedraw |= pParentDock->bIsMainDock;
			}
		}
	}
	if (! cairo_dock_is_loading () && bNeedsRedraw)
	{
		cairo_dock_update_dock_size (g_pMainDock);
		gtk_widget_queue_draw (g_pMainDock->pWidget);  /// pDock->calculate_icons (pDock); ?...
	}
	return XFirstFoundId;
}
コード例 #8
0
static gboolean _window_is_overlapping_dock (GldiWindowActor *actor, gpointer data)
{
	CairoDock *pDock = CAIRO_DOCK (data);
	if (gldi_window_is_on_current_desktop (actor) && ! actor->bIsHidden)
	{
		if (gldi_dock_overlaps_window (pDock, actor))
		{
			return TRUE;
		}
	}
	return FALSE;
}
コード例 #9
0
void gldi_icon_request_animation (Icon *pIcon, const gchar *cAnimation, int iNbRounds)
{
	CairoDock *pDock = CAIRO_DOCK (cairo_dock_get_icon_container(pIcon));
	g_return_if_fail (CAIRO_DOCK_IS_DOCK (pDock));  // currently only animate icons that are inside a dock
	
	if (pIcon->iAnimationState != CAIRO_DOCK_STATE_REST)  // on le fait avant de changer d'animation, pour le cas ou l'icone ne serait plus placee au meme endroit (rebond).
		cairo_dock_redraw_container (CAIRO_CONTAINER (pDock));
	gldi_icon_stop_animation (pIcon);
	
	if (cAnimation == NULL || iNbRounds == 0 || pIcon->iAnimationState != CAIRO_DOCK_STATE_REST)
		return ;
	gldi_object_notify (pIcon, NOTIFICATION_REQUEST_ICON_ANIMATION, pIcon, pDock, cAnimation, iNbRounds);
	gldi_icon_start_animation (pIcon);
}
コード例 #10
0
void gldi_icon_start_animation (Icon *pIcon)
{
	g_return_if_fail (pIcon != NULL);
	CairoDock *pDock = CAIRO_DOCK (cairo_dock_get_icon_container(pIcon));
	g_return_if_fail (CAIRO_DOCK_IS_DOCK (pDock));  // currently only animate icons that are inside a dock
	cd_message ("%s (%s, %d)", __func__, pIcon->cName, pIcon->iAnimationState);
	
	if (pIcon->iAnimationState != CAIRO_DOCK_STATE_REST &&
		(cairo_dock_icon_is_being_inserted_or_removed (pIcon) || pIcon->bIsDemandingAttention || pIcon->bAlwaysVisible || cairo_dock_animation_will_be_visible (pDock)))
	{
		//g_print ("  c'est parti\n");
		cairo_dock_launch_animation (CAIRO_CONTAINER (pDock));
	}
}
コード例 #11
0
void cairo_dock_trigger_icon_removal_from_dock (Icon *pIcon)
{
	CairoDock *pDock = CAIRO_DOCK (cairo_dock_get_icon_container(pIcon));
	if (pDock != NULL)
	{
		gldi_icon_stop_animation (pIcon);
		if (cairo_dock_animation_will_be_visible (pDock))  // sinon inutile de se taper toute l'animation.
			pIcon->fInsertRemoveFactor = 1.0;
		else
			pIcon->fInsertRemoveFactor = 0.05;
		gldi_object_notify (pDock, NOTIFICATION_REMOVE_ICON, pIcon, pDock);
		gldi_icon_start_animation (pIcon);
	}
}
コード例 #12
0
void cairo_dock_activate_module_and_load (gchar *cModuleName)
{
	if (g_pMainDock == NULL)
		return ;
	gchar *list[2] = {cModuleName, NULL};
	cairo_dock_activate_modules_from_list (list, g_pMainDock, 0);
	
	CairoDockModule *pModule = cairo_dock_find_module_from_name (cModuleName);
	if (pModule != NULL && CAIRO_DOCK_IS_DOCK (pModule->pContainer))
	{
		CairoDock *pDock = CAIRO_DOCK (pModule->pContainer);
		cairo_dock_update_dock_size (pDock);
		gtk_widget_queue_draw (pDock->pWidget);
	}
	
	cairo_dock_update_conf_file_with_active_modules2 (NULL, g_cConfFile);
}
コード例 #13
0
void gldi_icon_request_attention (Icon *pIcon, const gchar *cAnimation, int iNbRounds)
{
	CairoDock *pDock = CAIRO_DOCK (cairo_dock_get_icon_container(pIcon));
	g_return_if_fail (CAIRO_DOCK_IS_DOCK (pDock));  // currently only animate icons that are inside a dock
	
	// stop any current animation
	gldi_icon_stop_animation (pIcon);
	if (pIcon->iAnimationState != CAIRO_DOCK_STATE_REST)
		return ;
	
	// set the 'attention animation' flag
	pIcon->bIsDemandingAttention = TRUE;
	
	// start the animation
	if (iNbRounds <= 0)  // <= 0 means infinite
		iNbRounds = 1e6;
	if (cAnimation == NULL || *cAnimation == '\0' || strcmp (cAnimation, "default") == 0)
	{
		if (myTaskbarParam.cAnimationOnDemandsAttention != NULL)
			cAnimation = myTaskbarParam.cAnimationOnDemandsAttention;
		else
			cAnimation = "rotate";
	}
	
	gldi_icon_request_animation (pIcon, cAnimation, iNbRounds);
	cairo_dock_mark_icon_as_clicked (pIcon);  // pour eviter qu'un simple survol ne stoppe l'animation.
	
	// if the icon is in a sub-dock, also animate the main icon.
	if (pDock->iRefCount > 0)
	{
		CairoDock *pParentDock = NULL;
		Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (pDock, &pParentDock);
		if (pPointingIcon != NULL)
		{
			gldi_icon_request_attention (pPointingIcon, cAnimation, iNbRounds);
		}
	}
	else if (pDock->iVisibility == CAIRO_DOCK_VISI_KEEP_BELOW && pDock->bIsBelow)
		cairo_dock_pop_up (pDock);
}
コード例 #14
0
static gboolean _remove_one_appli (G_GNUC_UNUSED GldiWindowActor *pAppli, Icon *pIcon, G_GNUC_UNUSED gpointer data)
{
	if (pIcon == NULL)
		return TRUE;
	if (pIcon->pAppli == NULL)
	{
		g_free (pIcon);
		return TRUE;
	}
	
	cd_debug (" remove %s...", pIcon->cName);
	CairoDock *pDock = CAIRO_DOCK(cairo_dock_get_icon_container (pIcon));
	if (GLDI_OBJECT_IS_DOCK(pDock))
	{
		gldi_icon_detach (pIcon);
		if (pDock->iRefCount != 0)  // this appli-icon is in a sub-dock (above a launcher or a class-icon)
		{
			if (pDock->icons == NULL)  // the sub-dock gets empty -> free it
			{
				CairoDock *pFakeClassParentDock = NULL;
				Icon *pFakeClassIcon = cairo_dock_search_icon_pointing_on_dock (pDock, &pFakeClassParentDock);
				if (CAIRO_DOCK_ICON_TYPE_IS_CLASS_CONTAINER (pFakeClassIcon))  // also remove the fake launcher that was pointing on it
				{
					cd_debug ("on degage le fake qui pointe sur %s", pDock->cDockName);
					pFakeClassIcon->pSubDock = NULL;  // don't free the sub-dock, since we do it below
					gldi_icon_detach (pFakeClassIcon);
					gldi_object_unref (GLDI_OBJECT (pFakeClassIcon));
				}
				gldi_object_unref (GLDI_OBJECT(pDock));
			}
		}
	}
	
	gldi_icon_unset_appli (pIcon);  // on ne veut pas passer dans le 'unregister'
	g_free (pIcon->cClass);  // ni la gestion de la classe.
	pIcon->cClass = NULL;
	gldi_object_unref (GLDI_OBJECT (pIcon));
	return TRUE;
}
コード例 #15
0
void gldi_icon_stop_attention (Icon *pIcon)
{
	if (! pIcon->bIsDemandingAttention)
		return;
	cd_debug ("%s (%s)", __func__, pIcon->cName);
	gldi_icon_stop_animation (pIcon);
	pIcon->bIsDemandingAttention = FALSE;
	
	CairoDock *pDock = CAIRO_DOCK (cairo_dock_get_icon_container(pIcon));
	g_return_if_fail (pDock != NULL);
	gtk_widget_queue_draw (pDock->container.pWidget);  // redraw all the dock, since the animation of the icon can be larger than the icon itself.
	
	// on stoppe la demande d'attention recursivement vers le bas.
	if (pDock->iRefCount > 0)
	{
		GList *ic;
		for (ic = pDock->icons; ic != NULL; ic = ic->next)
		{
			pIcon = ic->data;
			if (pIcon->bIsDemandingAttention)
				break;
		}
		if (ic == NULL)  // plus aucune animation dans ce dock.
		{
			CairoDock *pParentDock = NULL;
			Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (pDock, &pParentDock);
			if (pPointingIcon != NULL)
			{
				gldi_icon_stop_attention (pPointingIcon);
			}
		}
	}
	else if (pDock->iVisibility == CAIRO_DOCK_VISI_KEEP_BELOW && ! pDock->bIsBelow && ! pDock->container.bInside)
	{
		cairo_dock_pop_down (pDock);
	}
}
コード例 #16
0
gboolean cd_do_update_container (gpointer pUserData, GldiContainer *pContainer, gboolean *bContinueAnimation)
{
	g_return_val_if_fail (!cd_do_session_is_off (), GLDI_NOTIFICATION_LET_PASS);
	
	if (myData.iMotionCount != 0)
	{
		myData.iMotionCount --;
		double f = (double) myData.iMotionCount / 10;
		cairo_dock_emit_motion_signal (CAIRO_DOCK (pContainer),
			f * myData.iPrevMouseX + (1-f) * myData.iMouseX,
			f * myData.iPrevMouseY + (1-f) * myData.iMouseY);
		*bContinueAnimation = TRUE;
	}
	
	int iDeltaT = cairo_dock_get_animation_delta_t (pContainer);
	if (cd_do_session_is_closing ())
	{
		//\___________________ animation de fermeture de la session (disparition des lettres ou du prompt).
		myData.iCloseTime -= iDeltaT;
		if (myData.iCloseTime <= 0)
			cd_do_exit_session ();
		else
			*bContinueAnimation = TRUE;
		cairo_dock_redraw_container (pContainer);
	}
	else if (cd_do_session_is_running ())
	{
		//\___________________ animation du prompt.
		myData.iPromptAnimationCount ++;
		*bContinueAnimation = TRUE;
		
		cairo_dock_redraw_container (pContainer);
	}
	
	return GLDI_NOTIFICATION_LET_PASS;
}
コード例 #17
0
static gboolean _on_window_icon_changed (G_GNUC_UNUSED gpointer data, GldiWindowActor *actor)
{
	Icon *icon = _get_appli_icon (actor);
	if (icon == NULL)
		return GLDI_NOTIFICATION_LET_PASS;
	
	if (cairo_dock_class_is_using_xicon (icon->cClass) || ! myTaskbarParam.bOverWriteXIcons)
	{
		GldiContainer *pContainer = cairo_dock_get_icon_container (icon);
		if (pContainer != NULL)  // if the icon is not in a container (for instance inhibited), it's no use trying to load its image. It's not even useful to mark it as 'damaged', since anyway it will be loaded when inserted inside a container.
		{
			cairo_dock_load_icon_image (icon, pContainer);
			if (CAIRO_DOCK_IS_DOCK (pContainer))
			{
				CairoDock *pDock = CAIRO_DOCK (pContainer);
				if (pDock->iRefCount != 0)
					cairo_dock_trigger_redraw_subdock_content (pDock);
			}
			cairo_dock_redraw_icon (icon);
		}
	}
	
	return GLDI_NOTIFICATION_LET_PASS;
}
コード例 #18
0
Icon *cairo_dock_find_icon_from_module (CairoDockModule *module, CairoContainer *pContainer)
{
	if (! module->bActive || pContainer == NULL)
		return NULL;

	if (CAIRO_DOCK_IS_DOCK (pContainer))
	{
		CairoDock *pDock = CAIRO_DOCK (pContainer);
		Icon *icon;
		GList *ic;
		for (ic = pDock->icons; ic != NULL; ic = ic->next)
		{
			icon = ic->data;
			if (icon->pModule == module)
				return icon;
		}
	}
	else if (CAIRO_DOCK_IS_DESKLET (pContainer))
	{
		CairoDesklet *pDesklet = CAIRO_DESKLET (pContainer);
		return pDesklet->pIcon;
	}
	return NULL;
}
コード例 #19
0
static gboolean _on_window_state_changed (G_GNUC_UNUSED gpointer data, GldiWindowActor *actor, gboolean bHiddenChanged, G_GNUC_UNUSED gboolean bMaximizedChanged, G_GNUC_UNUSED gboolean bFullScreenChanged)
{
	Icon *icon = _get_appli_icon (actor);
	if (icon == NULL)
		return GLDI_NOTIFICATION_LET_PASS;
	
	// on gere le cachage/apparition de l'icone (transparence ou miniature, applis minimisees seulement).
	CairoDock *pParentDock = CAIRO_DOCK(cairo_dock_get_icon_container (icon));
	if (bHiddenChanged)
	{
		cd_message ("  changement de visibilite -> %d", actor->bIsHidden);
		
		// drawing of hidden appli-icons.
		if (g_bUseOpenGL && myTaskbarParam.iMinimizedWindowRenderType == 2)
		{
			if (pParentDock != NULL)
			{
				cairo_dock_draw_hidden_appli_icon (icon, CAIRO_CONTAINER (pParentDock), TRUE);
			}
		}
		else if (myTaskbarParam.iMinimizedWindowRenderType == 0)
		{
			// transparence sur les inhibiteurs.
			///cairo_dock_update_visibility_on_inhibitors (icon->cClass, actor, actor->bIsHidden);
			gldi_window_inhibitors_set_hidden_state (actor, actor->bIsHidden);
		}
		
		// showing hidden appli-icons only
		if (myTaskbarParam.bHideVisibleApplis && myTaskbarParam.bShowAppli)  // on insere/detache l'icone selon la visibilite de la fenetre, avec une animation.
		{
			if (actor->bIsHidden)  // se cache => on insere son icone.
			{
				cd_message (" => se cache");
				pParentDock = gldi_appli_icon_insert_in_dock (icon, g_pMainDock, CAIRO_DOCK_ANIMATE_ICON);
				if (pParentDock != NULL)
				{
					if (g_bUseOpenGL && myTaskbarParam.iMinimizedWindowRenderType == 2)  // quand on est passe dans ce cas tout a l'heure l'icone n'etait pas encore dans son dock.
						cairo_dock_draw_hidden_appli_icon (icon, CAIRO_CONTAINER (pParentDock), TRUE);
					gtk_widget_queue_draw (pParentDock->container.pWidget);
				}
			}
			else  // se montre => on detache l'icone.
			{
				cd_message (" => re-apparait");
				cairo_dock_trigger_icon_removal_from_dock (icon);
			}
		}
		else if (myTaskbarParam.fVisibleAppliAlpha != 0)  // transparence
		{
			icon->fAlpha = 1;  // on triche un peu.
			if (pParentDock != NULL)
				cairo_dock_redraw_icon (icon);
		}
		
		// miniature (on le fait apres l'avoir inseree/detachee, car comme ca dans le cas ou on l'enleve du dock apres l'avoir deminimisee, l'icone est marquee comme en cours de suppression, et donc on ne recharge pas son icone. Sinon l'image change pendant la transition, ce qui est pas top. Comme ca ne change pas la taille de l'icone dans le dock, on peut faire ca apres l'avoir inseree.
		if (myTaskbarParam.iMinimizedWindowRenderType == 1 && (pParentDock != NULL || myTaskbarParam.bHideVisibleApplis))
		{
			// on redessine avec ou sans la miniature, suivant le nouvel etat.
			cairo_dock_load_icon_image (icon, CAIRO_CONTAINER (pParentDock));
			if (pParentDock)
			{
				cairo_dock_redraw_icon (icon);
				if (pParentDock->iRefCount != 0)  // on prevoit le redessin de l'icone pointant sur le sous-dock.
				{
					cairo_dock_trigger_redraw_subdock_content (pParentDock);
				}
			}
		}
	}
	
	return GLDI_NOTIFICATION_LET_PASS;
}
コード例 #20
0
Icon * cairo_dock_activate_module (CairoDockModule *module, CairoDock *pDock, GError **erreur)
{
	cd_message ("%s (%s)", __func__, module->pVisitCard->cModuleName);
	if (module == NULL)
	{
		g_set_error (erreur, 1, 1, "%s () : empty module !", __func__);
		return NULL;
	}

	if (module->bActive)
	{
		g_set_error (erreur, 1, 1, "%s () : module %s is already active !", __func__, module->pVisitCard->cModuleName);
		return NULL;
	}

	GError *tmp_erreur = NULL;
	if (module->pModule == NULL)  // normalement impossible.
	{
		cairo_dock_open_module (module, &tmp_erreur);
		if (tmp_erreur != NULL)
		{
			g_propagate_error (erreur, tmp_erreur);
			return NULL;
		}
	}
	
	if (pDock == NULL)
	{
		module->bActive = TRUE;
		return NULL;
	}
	
	//\____________________ On cree le container de l'applet, ainsi que son icone.
	CairoContainer *pContainer = NULL;
	Icon *pIcon = NULL;
	GKeyFile *pKeyFile = NULL;
	CairoDockMinimalAppletConfig *pMinimalConfig = NULL;
	g_free (module->cConfFilePath);
	module->cConfFilePath = cairo_dock_check_conf_file_exists (module->pVisitCard->cUserDataDir, module->pVisitCard->cShareDataDir, module->pVisitCard->cConfFileName);
	if (module->cConfFilePath != NULL)
	{
		pMinimalConfig = g_new0 (CairoDockMinimalAppletConfig, 1);
		pKeyFile = cairo_dock_pre_read_module_config (module, pMinimalConfig);
		
		if (pMinimalConfig->iDesiredIconWidth > 0)  // le module a une icone, c'est donc une applet.
		{
			module->bCanDetach = pMinimalConfig->iDeskletWidth > 0;
			gchar *cDockName = (pMinimalConfig->cDockName != NULL ? pMinimalConfig->cDockName : CAIRO_DOCK_MAIN_DOCK_NAME);
			
			if (module->bCanDetach && pMinimalConfig->bIsDetached)
			{
				CairoDesklet *pDesklet = cairo_dock_create_desklet (NULL, NULL, pMinimalConfig->bOnWidgetLayer);
				pContainer = CAIRO_CONTAINER (pDesklet);
				cairo_dock_place_desklet (pDesklet, pMinimalConfig);
				while (gtk_events_pending ())
					gtk_main_iteration ();
			}
			else
			{
				CairoDock *pDock = cairo_dock_search_dock_from_name (cDockName);
				if (pDock == NULL)
				{
					pDock = cairo_dock_create_new_dock (g_iWmHint, cDockName, NULL);
					cairo_dock_place_root_dock (pDock);
				}
				pContainer = CAIRO_CONTAINER (pDock);
			}
			module->pContainer = pContainer;
			
			int iIconWidth, iIconHeight;
			if (CAIRO_DOCK_IS_DOCK (pContainer))
			{
				iIconWidth = pMinimalConfig->iDesiredIconWidth;
				iIconHeight = pMinimalConfig->iDesiredIconHeight;
			}
			else  // l'applet creera la surface elle-meme, car on ne sait ni la taille qu'elle voudra lui donner, ni meme si elle l'utilisera !
			{
				iIconWidth = -1;
				iIconHeight = -1;
			}
			pIcon = cairo_dock_create_icon_for_applet (pContainer,
				iIconWidth,
				iIconHeight,
				pMinimalConfig->cLabel,
				pMinimalConfig->cIconFileName,
				module);
			pIcon->fOrder = pMinimalConfig->fOrder;
			pIcon->cParentDockName = g_strdup (cDockName);
			if (CAIRO_DOCK_IS_DESKLET (pContainer))
			{
				CairoDesklet *pDesklet = CAIRO_DESKLET (pContainer);
				pDesklet->pIcon = pIcon;
				///gtk_widget_queue_draw (pContainer->pWidget);
			}
			cairo_dock_free_minimal_config (pMinimalConfig);
		}
	}

	//\____________________ On initialise le module.
	if (CAIRO_DOCK_IS_DOCK (pContainer))
	{
		pIcon->fWidth *= CAIRO_DOCK (pContainer)->fRatio;
		pIcon->fHeight *= CAIRO_DOCK (pContainer)->fRatio;
	}
	module->initModule (pKeyFile, pIcon, pContainer, module->cConfFilePath, &tmp_erreur);
	if (CAIRO_DOCK_IS_DOCK (pContainer))
	{
		pIcon->fWidth /= CAIRO_DOCK (pContainer)->fRatio;
		pIcon->fHeight /= CAIRO_DOCK (pContainer)->fRatio;
	}
	if (pKeyFile != NULL)
		g_key_file_free (pKeyFile);
	if (tmp_erreur != NULL)
	{
		g_propagate_error (erreur, tmp_erreur);
		return NULL;
	}

	module->bActive = TRUE;
	return pIcon;
}
コード例 #21
0
static cairo_surface_t *cairo_dock_duplicate_inhibator_surface_for_appli (cairo_t *pSourceContext, Icon *pInhibatorIcon, double fMaxScale, double *fWidth, double *fHeight)
{
	double fIconWidthSaturationFactor, fIconHeightSaturationFactor;
	cairo_dock_calculate_size_fill (fWidth,
		fHeight,
		g_tIconAuthorizedWidth[CAIRO_DOCK_APPLI],
		g_tIconAuthorizedHeight[CAIRO_DOCK_APPLI],
		FALSE,
		&fIconWidthSaturationFactor,
		&fIconHeightSaturationFactor);
	
	CairoContainer *pInhibhatorContainer= cairo_dock_search_container_from_icon (pInhibatorIcon);
	double fInhibatorMaxScale = (CAIRO_DOCK_IS_DOCK (pInhibhatorContainer) ? (1 + g_fAmplitude) / CAIRO_DOCK (pInhibhatorContainer)->fRatio : 1);
	
	cairo_surface_t *pSurface = cairo_dock_duplicate_surface (pInhibatorIcon->pIconBuffer,
		pSourceContext,
		pInhibatorIcon->fWidth * fInhibatorMaxScale,
		pInhibatorIcon->fHeight * fInhibatorMaxScale,
		*fWidth * fMaxScale,
		*fHeight * fMaxScale);
	return pSurface;
}
コード例 #22
0
void cairo_dock_reload_module (CairoDockModule *module, gboolean bReloadAppletConf)
{
	GError *erreur = NULL;
	g_return_if_fail (module != NULL);
	CairoContainer *pActualContainer = module->pContainer;
	gboolean bContainerTypeChanged = FALSE;
	module->pContainer = NULL;
	cd_message ("%s (%s, %d)", __func__, module->pVisitCard->cModuleName, bReloadAppletConf);

	//\______________ On tente de recharger le module.
	gboolean bModuleReloaded = FALSE;
	if (module->bActive && module->reloadModule != NULL)
	{
		Icon *pIcon = cairo_dock_find_icon_from_module (module, pActualContainer);

		GKeyFile *pKeyFile = NULL;
		CairoDockMinimalAppletConfig *pMinimalConfig = NULL;
		gboolean bToBeInserted = FALSE;
		gboolean bNeedFreeDesklet = FALSE;
		CairoContainer *pNewContainer = NULL;
		if (bReloadAppletConf && module->cConfFilePath != NULL)
		{
			pMinimalConfig = g_new0 (CairoDockMinimalAppletConfig, 1);
			pKeyFile = cairo_dock_pre_read_module_config (module, pMinimalConfig);

			if (pMinimalConfig->iDesiredIconWidth > -1)  // c'est une applet.
			{
				if (pIcon != NULL)
				{
					g_free (pIcon->acName);
					pIcon->acName = pMinimalConfig->cLabel;
					pMinimalConfig->cLabel = NULL;  // astuce.
					g_free (pIcon->acFileName);
					pIcon->acFileName = pMinimalConfig->cIconFileName;
					pMinimalConfig->cIconFileName = NULL;
				}

				if (pMinimalConfig->bIsDetached)  // l'applet est maintenant dans un desklet.
				{
					CairoDesklet *pDesklet;
					if (CAIRO_DOCK_IS_DOCK (pActualContainer))  // elle etait dans un dock.
					{
						cd_message ("le container a change (%s -> desklet)", pIcon->cParentDockName);
						gchar *cOldDockName = g_strdup (pIcon->cParentDockName);
						cairo_dock_detach_icon_from_dock (pIcon, CAIRO_DOCK (pActualContainer), g_bUseSeparator);
						if (CAIRO_DOCK (pActualContainer)->icons == NULL)
							cairo_dock_destroy_dock (CAIRO_DOCK (pActualContainer), cOldDockName, NULL, NULL);
						else
							cairo_dock_update_dock_size (CAIRO_DOCK (pActualContainer));
						g_free (cOldDockName);
						pDesklet = cairo_dock_create_desklet (pIcon, NULL, pMinimalConfig->bOnWidgetLayer);
						bContainerTypeChanged = TRUE;
					}
					else
					{
						pDesklet = CAIRO_DESKLET (pActualContainer);
					}
					pNewContainer = CAIRO_CONTAINER (pDesklet);
					cairo_dock_place_desklet (pDesklet, pMinimalConfig);
				}
				else  // l'applet est maintenant dans un dock.
				{
					gchar *cDockName = (pMinimalConfig->cDockName != NULL ? pMinimalConfig->cDockName : CAIRO_DOCK_MAIN_DOCK_NAME);
					CairoDock *pDock = cairo_dock_search_dock_from_name (cDockName);
					if (pDock == NULL)  // c'est un nouveau dock.
					{
						pDock = cairo_dock_create_new_dock (g_iWmHint, cDockName, NULL);
						cairo_dock_place_root_dock (pDock);
					}
					
					if (CAIRO_DOCK_IS_DESKLET (pActualContainer))  // elle etait dans un desklet.
					{
						bNeedFreeDesklet = TRUE;  // le desklet sera detruit apres le reload.
						cairo_dock_steal_interactive_widget_from_desklet (CAIRO_DESKLET (pActualContainer));
						///cairo_dock_free_desklet (CAIRO_DESKLET (pActualContainer));
						///pActualContainer = NULL;
						bToBeInserted = TRUE;  // l'icone sera inseree dans le dock avant le reload.
						bContainerTypeChanged = TRUE;
					}
					else  // elle etait deja dans un dock.
					{
						if (pActualContainer != CAIRO_CONTAINER (pDock))  // le dock a change.
						{
							cd_message ("le dock a change (%s -> %s)", pIcon->cParentDockName, cDockName);
							gchar *cOldDockName = g_strdup (pIcon->cParentDockName);
							cairo_dock_detach_icon_from_dock (pIcon, CAIRO_DOCK (pActualContainer), g_bUseSeparator);
							if (CAIRO_DOCK (pActualContainer)->icons == NULL)
								cairo_dock_destroy_dock (CAIRO_DOCK (pActualContainer), cOldDockName, NULL, NULL);
							else
								cairo_dock_update_dock_size (CAIRO_DOCK (pActualContainer));
							g_free (cOldDockName);
							bToBeInserted = TRUE;  // l'icone sera inseree dans le dock avant le reload.
						}
					}
					pNewContainer = CAIRO_CONTAINER (pDock);
				}
			}
		}
		else
			pNewContainer = pActualContainer;

		module->pContainer = pNewContainer;
		if (CAIRO_DOCK_IS_DOCK (pNewContainer) && pIcon != NULL)
		{
			if (pMinimalConfig != NULL)
			{
				pIcon->fWidth = pMinimalConfig->iDesiredIconWidth;
				pIcon->fHeight = pMinimalConfig->iDesiredIconHeight;
			}
			cairo_dock_load_one_icon_from_scratch (pIcon, pNewContainer);

			if (bToBeInserted)
			{
				CairoDock *pDock = CAIRO_DOCK (pNewContainer);
				cairo_dock_insert_icon_in_dock (pIcon, pDock, CAIRO_DOCK_UPDATE_DOCK_SIZE, CAIRO_DOCK_ANIMATE_ICON, CAIRO_DOCK_APPLY_RATIO, g_bUseSeparator);
				pIcon->cParentDockName = g_strdup (pMinimalConfig->cDockName);
				cairo_dock_start_animation (pIcon, pDock);
			}
			else
			{
				pIcon->fWidth *= CAIRO_DOCK (pActualContainer)->fRatio;
				pIcon->fHeight *= CAIRO_DOCK (pActualContainer)->fRatio;
				
				if (bReloadAppletConf)
					cairo_dock_update_dock_size (CAIRO_DOCK (pNewContainer));
			}
		}
		
		bModuleReloaded = module->reloadModule (pKeyFile, module->cConfFilePath, pNewContainer);
		
		if (pNewContainer != pActualContainer && CAIRO_DOCK_IS_DOCK (pNewContainer) && CAIRO_DOCK_IS_DOCK (pActualContainer) && pIcon != NULL)
		{
			cairo_dock_synchronize_one_sub_dock_position (pIcon, CAIRO_DOCK (pNewContainer), TRUE);
		}
		
		cairo_dock_free_minimal_config (pMinimalConfig);
		if (pKeyFile != NULL)
			g_key_file_free (pKeyFile);
		
		if (bNeedFreeDesklet)
			cairo_dock_free_desklet (CAIRO_DESKLET (pActualContainer));
	}
}