void cd_do_select_last_first_entry_in_listing (gboolean bLast)
{
	myData.pListing->fPreviousOffset = myData.pListing->fCurrentOffset;
	GList *e = myData.pListing->pCurrentEntry;
	int i;
	if (bLast)
	{
		e = g_list_last (myData.pListing->pEntries);
		i = myData.pListing->iNbEntries - 1;
		while (e->prev != NULL && ((CDEntry *)(e->data))->bHidden)
		{
			e = e->prev;
			i --;
		}
	}
	else
	{
		e = myData.pListing->pEntries;
		i = 0;
		while (e->next != NULL && ((CDEntry *)(e->data))->bHidden)
		{
			e = e->next;
			i ++;
		}
	}
	myData.pListing->pCurrentEntry = e;
	myData.pListing->fAimedOffset = i * (myDialogs.dialogTextDescription.iSize + 2);
	
	myData.pListing->iCurrentEntryAnimationCount = NB_STEPS_FOR_CURRENT_ENTRY;
	myData.pListing->iScrollAnimationCount = NB_STEPS_FOR_SCROLL;
	myData.pListing->iTitleOffset = 0;
	myData.pListing->sens = 1;
	cairo_dock_launch_animation (CAIRO_CONTAINER (myData.pListing));
	cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing));
}
static gboolean on_leave_desklet (GtkWidget* pWidget,
	GdkEventCrossing* pEvent,
	CairoDesklet *pDesklet)
{
	//g_print ("%s (%d, %p, %d;%d)\n", __func__, pDesklet->container.bInside, pEvent, iMouseX, iMouseY);
	int iMouseX, iMouseY;
	if (pEvent != NULL)
	{
		iMouseX = pEvent->x;
		iMouseY = pEvent->y;
	}
	else
	{
		gldi_container_update_mouse_position (CAIRO_CONTAINER (pDesklet));
		iMouseX = pDesklet->container.iMouseX;
		iMouseY = pDesklet->container.iMouseY;
	}
	if (gtk_bin_get_child (GTK_BIN (pDesklet->container.pWidget)) != NULL && iMouseX > 0 && iMouseX < pDesklet->container.iWidth && iMouseY > 0 && iMouseY < pDesklet->container.iHeight)  // en fait on est dans un widget fils, donc on ne fait rien.
	{
		return FALSE;
	}
	
	pDesklet->container.bInside = FALSE;
	Icon *pPointedIcon = cairo_dock_get_pointed_icon (pDesklet->icons);
	if (pPointedIcon != NULL)
		pPointedIcon->bPointed = FALSE;
	gtk_widget_queue_draw (pWidget);  // redessin des boutons.
	
	gboolean bStartAnimation = FALSE;
	gldi_object_notify (pDesklet, NOTIFICATION_LEAVE_DESKLET, pDesklet, &bStartAnimation);
	if (bStartAnimation)
		cairo_dock_launch_animation (CAIRO_CONTAINER (pDesklet));
	
	return FALSE;
}
void cd_do_select_prev_next_entry_in_listing (gboolean bNext)
{
	CDEntry *pEntry;
	myData.pListing->fPreviousOffset = myData.pListing->fCurrentOffset;
	GList *e = myData.pListing->pCurrentEntry;
	if (bNext)
	{
		do
		{
			e = cairo_dock_get_next_element (e, myData.pListing->pEntries);
			pEntry = e->data;
		} while (e != myData.pListing->pCurrentEntry && pEntry->bHidden);
		
	}
	else
	{
		do
		{
			e = cairo_dock_get_previous_element (e, myData.pListing->pEntries);
			pEntry = e->data;
		} while (e != myData.pListing->pCurrentEntry && pEntry->bHidden);
	}
	myData.pListing->pCurrentEntry = e;
	myData.pListing->fAimedOffset += (bNext ? 1:-1) * (myDialogs.dialogTextDescription.iSize + 2);
	
	myData.pListing->iCurrentEntryAnimationCount = NB_STEPS_FOR_CURRENT_ENTRY;
	myData.pListing->iScrollAnimationCount = NB_STEPS_FOR_SCROLL;
	myData.pListing->iTitleOffset = 0;
	myData.pListing->sens = 1;
	cairo_dock_launch_animation (CAIRO_CONTAINER (myData.pListing));
	cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing));
}
gboolean cd_drop_indicator_update_dock (gpointer pUserData, CairoDock *pDock, gboolean *bContinueAnimation)
{
	CDDropIndicatorData *pData = CD_APPLET_GET_MY_DOCK_DATA (pDock);
	if (pData == NULL)
		return GLDI_NOTIFICATION_LET_PASS;
	
	pData->iDropIndicatorOffset += myConfig.iSpeed;
	if (pData->iDropIndicatorOffset > 2*myData.dropIndicator.iHeight)
		pData->iDropIndicatorOffset -= 2*myData.dropIndicator.iHeight;
        
	double dt = cairo_dock_get_animation_delta_t (CAIRO_CONTAINER (pDock));
	pData->iDropIndicatorRotation += myConfig.fRotationSpeed * 360. * dt/1e3;
	
	if (pDock->bCanDrop)
	{
		pData->fAlphaHover -= delta_alpha;
		*bContinueAnimation = TRUE;
	}
	else
	{
		pData->fAlpha -= delta_alpha;
		if (!pDock->bIsDragging)
			pData->fAlphaHover -= delta_alpha;
		
		if (pData->fAlpha <= 0 && pData->fAlphaHover <= 0)
		{
			g_free (pData);
			pData = NULL;
			CD_APPLET_SET_MY_DOCK_DATA (pDock, NULL);
		}
		else
			*bContinueAnimation = TRUE;
	}
	
	GdkRectangle rect = {(int) pDock->container.iMouseX - myData.dropIndicator.iWidth/2,
		(int) (pDock->container.bDirectionUp ? 0 : pDock->iActiveHeight - 2*myData.dropIndicator.iHeight),
		(int) myData.dropIndicator.iWidth,
		(int) 2*myData.dropIndicator.iHeight};
	if (! pDock->container.bIsHorizontal)
	{
		rect.x = (int) (pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iActiveHeight : pDock->iActiveHeight - 2*myData.dropIndicator.iHeight);
		rect.y = (int) pDock->container.iMouseX - myData.dropIndicator.iWidth/2;
		rect.width = (int) 2*myData.dropIndicator.iHeight;
		rect.height = (int) myData.dropIndicator.iWidth;
	}
	//g_print ("rect (%d;%d) (%dx%d)\n", rect.x, rect.y, rect.width, rect.height);
	if (rect.width > 0 && rect.height > 0)
	{
		cairo_dock_redraw_container_area (CAIRO_CONTAINER (pDock), &rect);
	}
	
	if (pData && pData->fAlphaHover > 0)
	{
		Icon *pIcon = cairo_dock_get_pointed_icon (pDock->icons);
		if (pIcon != NULL)
			cairo_dock_redraw_icon (pIcon);
	}
	
	return GLDI_NOTIFICATION_LET_PASS;
}
void cd_do_show_listing (void)
{
	if (myData.pListing == NULL)
	{
		myData.pListing = cd_do_create_listing ();
		
		cairo_dock_register_notification_on_container (CAIRO_CONTAINER (myData.pListing),
			CAIRO_DOCK_UPDATE_DEFAULT_CONTAINER,
			(CairoDockNotificationFunc) cd_do_update_listing_notification,
			CAIRO_DOCK_RUN_AFTER,
			NULL);
		cairo_dock_register_notification_on_container (CAIRO_CONTAINER (myData.pListing),
			CAIRO_DOCK_RENDER_DEFAULT_CONTAINER,
			(CairoDockNotificationFunc) cd_do_render_listing_notification,
			CAIRO_DOCK_RUN_AFTER,
			NULL);
		if (myData.pScoobySurface == NULL)
		{
			cairo_t* pSourceContext = cairo_dock_create_context_from_container (CAIRO_CONTAINER (g_pMainDock));
			myData.pScoobySurface = cairo_dock_create_surface_from_image_simple (MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE,
				pSourceContext,
				2 * (myDialogs.dialogTextDescription.iSize + 2),
				2 * (myDialogs.dialogTextDescription.iSize + 2));
			cairo_destroy (pSourceContext);
		}
		if (myData.pActiveButtonSurface == NULL)
		{
			g_print ("load button : %dx%d\n", myDialogs.dialogTextDescription.iSize + 2, myData.pListing->container.iWidth);
			cairo_t* pSourceContext = cairo_dock_create_context_from_container (CAIRO_CONTAINER (g_pMainDock));
			myData.pActiveButtonSurface = cairo_dock_create_surface_from_image_simple (MY_APPLET_SHARE_DATA_DIR"/active-button.svg",
				pSourceContext,
				(myData.pListing->container.iWidth - (myDialogs.dialogTextDescription.iSize + 2) * 3) / 3,
				myDialogs.dialogTextDescription.iSize + 2);
			myData.pInactiveButtonSurface = cairo_dock_create_surface_from_image_simple (MY_APPLET_SHARE_DATA_DIR"/inactive-button.svg",
				pSourceContext,
				(myData.pListing->container.iWidth - (myDialogs.dialogTextDescription.iSize + 2) * 3) / 3,
				myDialogs.dialogTextDescription.iSize + 2);
			cairo_destroy (pSourceContext);
		}
	}
	else
	{
		gtk_widget_show (myData.pListing->container.pWidget);
		
		int iWidth = _listing_compute_width (pListing);
		int iHeight = _listing_compute_height (pListing);
		if (myData.pListing->container.iWidth != iWidth || myData.pListing->container.iHeight != iHeight)
		{
			gtk_window_resize (GTK_WINDOW (myData.pListing->container.pWidget),
				iWidth,
				iHeight);
		}
		_place_listing (myData.pListing);
		cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing));
	}
}
void rendering_free_caroussel_data (CairoDesklet *pDesklet)
{
	cairo_dock_remove_notification_func_on_container (CAIRO_CONTAINER (pDesklet), CAIRO_DOCK_UPDATE_DESKLET, (CairoDockNotificationFunc) on_update_desklet, NULL);
	cairo_dock_remove_notification_func_on_container (CAIRO_CONTAINER (pDesklet), CAIRO_DOCK_MOUSE_MOVED, (CairoDockNotificationFunc) on_mouse_move, NULL);
	
	CDCarousselParameters *pCaroussel = (CDCarousselParameters *) pDesklet->pRendererData;
	if (pCaroussel == NULL)
		return ;
	
	g_free (pCaroussel);
	pDesklet->pRendererData = NULL;
}
static void _cairo_dock_set_dialog_input_shape (CairoDialog *pDialog)
{
	if (pDialog->pShapeBitmap != NULL)
		cairo_region_destroy (pDialog->pShapeBitmap);
	
	pDialog->pShapeBitmap = gldi_container_create_input_shape (CAIRO_CONTAINER (pDialog),
		0,
		0,
		1,
		1);  // workaround a bug in X with fully transparent window => let 1 pixel ON.

	gldi_container_set_input_shape (CAIRO_CONTAINER (pDialog), pDialog->pShapeBitmap);
}
static gboolean on_expose_listing (GtkWidget *pWidget, GdkEventExpose *pExpose, CDListing *pListing)
{
	if (g_bUseOpenGL && pListing->container.glContext)
	{
		GdkGLContext *pGlContext = gtk_widget_get_gl_context (pWidget);
		GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable (pWidget);
		if (!gdk_gl_drawable_gl_begin (pGlDrawable, pGlContext))
			return FALSE;
		
		if (pExpose->area.x + pExpose->area.y != 0)
		{
			glEnable (GL_SCISSOR_TEST);
			glScissor ((int) pExpose->area.x,
				(int) (pListing->container.bIsHorizontal ? pListing->container.iHeight : pListing->container.iWidth) -
					pExpose->area.y - pExpose->area.height,  // lower left corner of the scissor box.
				(int) pExpose->area.width,
				(int) pExpose->area.height);
		}
		
		cairo_dock_notify_on_container (CAIRO_CONTAINER (pListing), CAIRO_DOCK_RENDER_DEFAULT_CONTAINER, pListing, NULL);
		
		glDisable (GL_SCISSOR_TEST);
		
		if (gdk_gl_drawable_is_double_buffered (pGlDrawable))
			gdk_gl_drawable_swap_buffers (pGlDrawable);
		else
			glFlush ();
		gdk_gl_drawable_gl_end (pGlDrawable);
	}
	else
	{
		cairo_t *pCairoContext;
		if (pExpose->area.x > 0 || pExpose->area.y > 0)
		{
			double fColor[4] = {0., 0., 0., 0.};
			pCairoContext = cairo_dock_create_drawing_context_on_area (CAIRO_CONTAINER (pListing), &pExpose->area, fColor);
		}
		else
		{
			pCairoContext = cairo_dock_create_drawing_context (CAIRO_CONTAINER (pListing));
		}
		
		cairo_dock_notify_on_container (CAIRO_CONTAINER (pListing), CAIRO_DOCK_RENDER_DEFAULT_CONTAINER, pListing, pCairoContext);
		
		cairo_destroy (pCairoContext);
	}
	return FALSE;
}
static void init_object (GldiObject *obj, gpointer attr)
{
	CairoDesklet *pDesklet = (CairoDesklet*)obj;
	CairoDeskletAttr *pAttributes = (CairoDeskletAttr*)attr;
	g_return_if_fail (pAttributes->pIcon != NULL);
	
	gldi_desklet_init_internals (pDesklet);
	
	// attach the main icon
	Icon *pIcon = pAttributes->pIcon;
	pDesklet->pIcon = pIcon;
	cairo_dock_set_icon_container (pIcon, pDesklet);
	if (CAIRO_DOCK_IS_APPLET (pIcon))
		gtk_window_set_title (GTK_WINDOW (pDesklet->container.pWidget), pIcon->pModuleInstance->pModule->pVisitCard->cModuleName);
	
	// configure the desklet
	gldi_desklet_configure (pDesklet, pAttributes);
	
	// load buttons images
	if (s_pRotateButtonBuffer.pSurface == NULL)
	{
		_load_desklet_buttons ();
	}
	
	// register the new desklet
	s_pDeskletList = g_list_prepend (s_pDeskletList, pDesklet);
	
	// start the appearance animation
	if (! cairo_dock_is_loading ())
	{
		pDesklet->container.fRatio = 0.1;
		pDesklet->bGrowingUp = TRUE;
		cairo_dock_launch_animation (CAIRO_CONTAINER (pDesklet));
	}
}
void cd_rendering_calculate_max_dock_size_3D_plane (CairoDock *pDock)
{
	pDock->pFirstDrawnElement = cairo_dock_calculate_icons_positions_at_rest_linear (pDock->icons, pDock->fFlatDockWidth, pDock->iScrollOffset);
	
	pDock->iMaxDockHeight = (int) ((1 + g_fAmplitude) * pDock->iMaxIconHeight + g_fReflectSize) + g_iconTextDescription.iSize + g_iDockLineWidth + g_iFrameMargin;
	
	double hi = g_fReflectSize + g_iFrameMargin;
	
	double fInclinationOnHorizon = 0, fExtraWidth = 0;
	pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., fExtraWidth));
	fInclinationOnHorizon = 0.5 * pDock->iMaxDockWidth / iVanishingPointY;
	pDock->iDecorationsHeight = hi + (pDock->iMaxIconHeight + g_iFrameMargin) / sqrt (1 + fInclinationOnHorizon * fInclinationOnHorizon);
	fExtraWidth = cairo_dock_calculate_extra_width_for_trapeze (pDock->iDecorationsHeight, fInclinationOnHorizon, g_iDockRadius, g_iDockLineWidth);
	cd_debug ("iMaxDockWidth <- %d; fInclinationOnHorizon <- %.2f; fExtraWidth <- %.2f", pDock->iMaxDockWidth, fInclinationOnHorizon, fExtraWidth);
	
	pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., fExtraWidth));
	cd_debug ("pDock->iMaxDockWidth <- %d", pDock->iMaxDockWidth);
	
	pDock->iDecorationsWidth = pDock->iMaxDockWidth;
	
	pDock->iMinDockWidth = pDock->fFlatDockWidth + fExtraWidth;
	pDock->iMinDockHeight = g_iDockLineWidth + g_iFrameMargin + g_fReflectSize + pDock->iMaxIconHeight;
	
	if (my_pFlatSeparatorSurface[0] == NULL && (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR))
		cd_rendering_load_flat_separator (CAIRO_CONTAINER (g_pMainDock));
}
static void _cd_do_execute_command (CDEntry *pEntry)
{
    gchar *cCommand = g_strdup_printf ("%s/calc.sh '%s'", MY_APPLET_SHARE_DATA_DIR, myData.sCurrentText->str);
    gchar *cResult = cairo_dock_launch_command_sync (cCommand);
    g_free (cCommand);
    if (cResult != NULL && strcmp (cResult, "0") != 0)
    {
        g_print (" resultat du calcul : '%s'\n", cResult);
        GtkClipboard *pClipBoard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
        gtk_clipboard_set_text (pClipBoard, cResult, -1);
        Icon *pIcon = cairo_dock_get_dialogless_icon ();
        cairo_dock_show_temporary_dialog_with_icon (D_("The value %s has been copied into the clipboard."),
                pIcon,
                CAIRO_CONTAINER (g_pMainDock),
                3000,
                MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE,
                cResult);
    }
    else  // le calcul n'a rien donne, on execute sans chercher.
    {
        g_print (" pas un calcul => on execute '%s'\n", myData.sCurrentText->str);
        cairo_dock_launch_command (myData.sCurrentText->str);
    }
    g_free (cResult);
}
static void reload (CairoConfigIndicators *pPrevIndicators, CairoConfigIndicators *pIndicators)
{
	CairoDock *pDock = g_pMainDock;
	double fMaxScale = cairo_dock_get_max_scale (pDock);
	cairo_t* pCairoContext = cairo_dock_create_context_from_window (CAIRO_CONTAINER (pDock));
	
	if (cairo_dock_strings_differ (pPrevIndicators->cIndicatorImagePath, pIndicators->cIndicatorImagePath) ||
		pPrevIndicators->bLinkIndicatorWithIcon != pIndicators->bLinkIndicatorWithIcon ||
		pPrevIndicators->fIndicatorRatio != pIndicators->fIndicatorRatio)
	{
		cairo_dock_load_task_indicator (myTaskBar.bShowAppli && myTaskBar.bMixLauncherAppli ? pIndicators->cIndicatorImagePath : NULL, pCairoContext, fMaxScale, pIndicators->fIndicatorRatio);
	}
	
	if (cairo_dock_strings_differ (pPrevIndicators->cActiveIndicatorImagePath, pIndicators->cActiveIndicatorImagePath) ||
		pPrevIndicators->iActiveCornerRadius != pIndicators->iActiveCornerRadius ||
		pPrevIndicators->iActiveLineWidth != pIndicators->iActiveLineWidth ||
		cairo_dock_colors_differ (pPrevIndicators->fActiveColor, pIndicators->fActiveColor))
	{
		cairo_dock_load_active_window_indicator (pCairoContext,
			pIndicators->cActiveIndicatorImagePath,
			fMaxScale,
			pIndicators->iActiveCornerRadius,
			pIndicators->iActiveLineWidth,
			pIndicators->fActiveColor);
	}
	
	if (cairo_dock_strings_differ (pPrevIndicators->cClassIndicatorImagePath, pIndicators->cClassIndicatorImagePath))
	{
		cairo_dock_load_class_indicator (myTaskBar.bShowAppli && myTaskBar.bGroupAppliByClass ? pIndicators->cClassIndicatorImagePath : NULL, pCairoContext, fMaxScale);
	}
	
	cairo_destroy (pCairoContext);
	
	cairo_dock_redraw_root_docks (FALSE);  // main dock inclus.
}
gboolean cairo_dock_set_class_use_xicon (const gchar *cClass, gboolean bUseXIcon)
{
	CairoDockClassAppli *pClassAppli = cairo_dock_get_class (cClass);
	g_return_val_if_fail (pClassAppli!= NULL, FALSE);
	
	if (pClassAppli->bUseXIcon == bUseXIcon)  // rien a faire.
		return FALSE;
	
	GList *pElement;
	Icon *pAppliIcon;
	cairo_t *pCairoContext = cairo_dock_create_context_from_window (CAIRO_CONTAINER (g_pMainDock));
	for (pElement = pClassAppli->pAppliOfClass; pElement != NULL; pElement = pElement->next)
	{
		pAppliIcon = pElement->data;
		if (bUseXIcon)
		{
			cd_message ("%s prend l'icone de X", pAppliIcon->acName);
		}
		else
		{
			cd_message ("%s n'utilise plus l'icone de X", pAppliIcon->acName);
		}
		cairo_dock_fill_one_icon_buffer (pAppliIcon, pCairoContext, (1 + g_fAmplitude), g_pMainDock->bHorizontalDock, TRUE, g_pMainDock->bDirectionUp);
	}
	cairo_destroy (pCairoContext);
	
	return TRUE;
}
void cd_do_set_status (const gchar *cStatus)
{
	g_free (myData.cStatus);
	myData.cStatus = g_strdup (cStatus);
	if (myData.pListing)
		cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing));
}
void cd_do_select_nth_entry_in_listing (int iNumEntry)
{
	myData.pListing->fPreviousOffset = myData.pListing->fCurrentOffset;
	
	int i = MIN (iNumEntry, myData.pListing->iNbEntries - 1);
	myData.pListing->pCurrentEntry = g_list_nth (myData.pListing->pEntries, i);
	
	myData.pListing->fAimedOffset = i * (myDialogs.dialogTextDescription.iSize + 2);
	
	myData.pListing->iCurrentEntryAnimationCount = NB_STEPS_FOR_CURRENT_ENTRY;
	myData.pListing->iScrollAnimationCount = NB_STEPS_FOR_SCROLL;
	myData.pListing->iTitleOffset = 0;
	myData.pListing->sens = 1;
	cairo_dock_launch_animation (CAIRO_CONTAINER (myData.pListing));
	cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing));
}
Пример #16
0
static gboolean _update_fade_out_dock (G_GNUC_UNUSED gpointer pUserData, CairoDock *pDock, gboolean *bContinueAnimation)
{
	pDock->iFadeCounter += (pDock->bFadeInOut ? 1 : -1);  // fade out, puis fade in.
	
	if (pDock->iFadeCounter >= myBackendsParam.iHideNbSteps)
	{
		pDock->bFadeInOut = FALSE;
		//g_print ("set below\n");
		gtk_window_set_keep_below (GTK_WINDOW (pDock->container.pWidget), TRUE);
		// si fenetre maximisee, on met direct iFadeCounter a 0.
		// malheureusement X met du temps a faire passer le dock derriere, et ca donne un "sursaut" :-/
	}
	
	//g_print ("pDock->iFadeCounter : %d\n", pDock->iFadeCounter);
	if (pDock->iFadeCounter > 0)
	{
		*bContinueAnimation = TRUE;
	}
	else
	{
		gldi_object_remove_notification (pDock,
			NOTIFICATION_UPDATE,
			(GldiNotificationFunc) _update_fade_out_dock,
			NULL);
	}
	
	cairo_dock_redraw_container (CAIRO_CONTAINER (pDock));
	return GLDI_NOTIFICATION_LET_PASS;
}
Пример #17
0
void cairo_dock_pop_down (CairoDock *pDock)
{
	//g_print ("%s (%d, %d)\n", __func__, pDock->bIsBelow, pDock->container.bInside);
	if (! pDock->bIsBelow && pDock->iVisibility == CAIRO_DOCK_VISI_KEEP_BELOW && ! pDock->container.bInside)
	{
		if (gldi_dock_search_overlapping_window (pDock) != NULL)
		{
			pDock->iFadeCounter = 0;
			pDock->bFadeInOut = TRUE;
			gldi_object_register_notification (pDock,
				NOTIFICATION_UPDATE,
				(GldiNotificationFunc) _update_fade_out_dock,
				GLDI_RUN_FIRST, NULL);
			if (g_pKeepingBelowBackend != NULL && g_pKeepingBelowBackend->init)
				g_pKeepingBelowBackend->init (pDock);
			cairo_dock_launch_animation (CAIRO_CONTAINER (pDock));
		}
		else
		{
			//g_print ("set below\n");
			gtk_window_set_keep_below (GTK_WINDOW (pDock->container.pWidget), TRUE);
		}
		pDock->bIsBelow = TRUE;
	}
}
void cairo_dock_update_visibility_on_inhibators (gchar *cClass, Window Xid, gboolean bIsHidden)
{
	CairoDockClassAppli *pClassAppli = cairo_dock_get_class (cClass);
	if (pClassAppli != NULL)
	{
		GList *pElement;
		Icon *pInhibatorIcon;
		for (pElement = pClassAppli->pIconsOfClass; pElement != NULL; pElement = pElement->next)
		{
			pInhibatorIcon = pElement->data;
			
			if (pInhibatorIcon->Xid == Xid)
			{
				cd_message (" %s aussi se %s", pInhibatorIcon->acName, (bIsHidden ? "cache" : "montre"));
				pInhibatorIcon->bIsHidden = bIsHidden;
				if (! CAIRO_DOCK_IS_APPLET (pInhibatorIcon) && g_fVisibleAppliAlpha != 0)
				{
					CairoDock *pInhibhatorDock = cairo_dock_search_dock_from_name (pInhibatorIcon->cParentDockName);
					pInhibatorIcon->fAlpha = 1;  // on triche un peu.
					cairo_dock_redraw_my_icon (pInhibatorIcon, CAIRO_CONTAINER (pInhibhatorDock));
				}
			}
		}
	}
}
void cairo_dock_set_renderer (CairoDock *pDock, const gchar *cRendererName)
{
	g_return_if_fail (pDock != NULL);
	cd_message ("%s (%x:%s)", __func__, pDock, cRendererName);
	
	if (pDock->pRenderer && pDock->pRenderer->free_data)
	{
		pDock->pRenderer->free_data (pDock);
		pDock->pRendererData = NULL;
	}
	pDock->pRenderer = cairo_dock_get_renderer (cRendererName, (pDock->iRefCount == 0));
	
	pDock->fMagnitudeMax = 1.;
	pDock->container.bUseReflect = pDock->pRenderer->bUseReflect;
	
	int iAnimationDeltaT = pDock->container.iAnimationDeltaT;
	pDock->container.iAnimationDeltaT = (g_bUseOpenGL && pDock->pRenderer->render_opengl != NULL ? myContainersParam.iGLAnimationDeltaT : myContainersParam.iCairoAnimationDeltaT);
	if (pDock->container.iAnimationDeltaT == 0)
		pDock->container.iAnimationDeltaT = 30;  // le main dock est cree avant meme qu'on ait recupere la valeur en conf. Lorsqu'une vue lui sera attribuee, la bonne valeur sera renseignee, en attendant on met un truc non nul.
	if (iAnimationDeltaT != pDock->container.iAnimationDeltaT && pDock->container.iSidGLAnimation != 0)
	{
		g_source_remove (pDock->container.iSidGLAnimation);
		pDock->container.iSidGLAnimation = 0;
		cairo_dock_launch_animation (CAIRO_CONTAINER (pDock));
	}
	if (pDock->cRendererName != cRendererName)  // NULL ecrase le nom de l'ancienne vue.
	{
		g_free (pDock->cRendererName);
		pDock->cRendererName = g_strdup (cRendererName);
	}
}
Icon *gldi_stack_icon_add_new (CairoDock *pDock, double fOrder)
{
	//\_________________ add a launcher in the current theme
	const gchar *cDockName = gldi_dock_get_name (pDock);
	if (fOrder == CAIRO_DOCK_LAST_ORDER)  // the order is not defined -> place at the end
	{
		Icon *pLastIcon = cairo_dock_get_last_launcher (pDock->icons);
		fOrder = (pLastIcon ? pLastIcon->fOrder + 1 : 1);
	}
	gchar *cNewDesktopFileName = gldi_stack_icon_add_conf_file (cDockName, fOrder);
	g_return_val_if_fail (cNewDesktopFileName != NULL, NULL);
	
	//\_________________ load the new icon
	Icon *pNewIcon = gldi_user_icon_new (cNewDesktopFileName);
	g_free (cNewDesktopFileName);
	g_return_val_if_fail (pNewIcon, NULL);
	
	gldi_icon_insert_in_container (pNewIcon, CAIRO_CONTAINER(pDock), CAIRO_DOCK_ANIMATE_ICON);
	
	/// TODO: check without these 2 lines, with a box drawer...
	///if (pNewIcon->pSubDock != NULL)
	///	cairo_dock_trigger_redraw_subdock_content (pNewIcon->pSubDock);
	
	return pNewIcon;
}
void rendering_update_text (CairoDialog *pDialog, gpointer *pNewData)
{
	CDTextParameters *pText = (CDTextParameters *) pDialog->pRendererData;
	if (pText == NULL)
		return ;
	
	gchar *cNewText = (gchar *) pNewData;
	
	int iTextWidth, iTextHeight;
	double fTextXOffset, fTextYOffset;
	cairo_surface_destroy (pText->pTextSurface);
	pText->pTextSurface = NULL;
	
	cairo_t *pCairoContext = cairo_dock_create_context_from_window (CAIRO_CONTAINER (pDialog));
	g_return_if_fail (cairo_status (pCairoContext) == CAIRO_STATUS_SUCCESS);
	pText->pTextSurface = cairo_dock_create_surface_from_text (cNewText,
		pCairoContext,
		&pText->textDescription,
		1.,
		&iTextWidth, &iTextHeight, &fTextXOffset, &fTextYOffset);
	cairo_destroy (pCairoContext);
	
	if (iTextWidth > pDialog->iInteractiveWidth || iTextHeight > pDialog->iInteractiveHeight)
		gtk_widget_set_size_request (pDialog->pInteractiveWidget, iTextWidth, iTextHeight);
}
Пример #22
0
void cairo_dock_start_hiding (CairoDock *pDock)
{
	//g_print ("%s (%d)\n", __func__, pDock->bIsHiding);
	if (! pDock->bIsHiding && ! pDock->container.bInside)  // rien de plus desagreable que le dock qui se cache quand on est dedans.
	{
		// set current showing/hiding state
		pDock->bIsShowing = FALSE;
		pDock->bIsHiding = TRUE;
		
		// empty the input shape (so that the dock doesn't disturb us immediately)
		if (pDock->iInputState != CAIRO_DOCK_INPUT_HIDDEN)  // if pDock->pHiddenShapeBitmap == NULL (at the beginning), set iInputState anyway, so that when the input-shapes are created, pDock->pHiddenShapeBitmap will be applied to the dock.
		{
			//g_print ("+++ input shape hidden on start hiding\n");
			cairo_dock_set_input_shape_hidden (pDock);
			pDock->iInputState = CAIRO_DOCK_INPUT_HIDDEN;
		}
		
		// init the animation
		if (g_pHidingBackend != NULL && g_pHidingBackend->init)
			g_pHidingBackend->init (pDock);
		
		// and launch it
		cairo_dock_launch_animation (CAIRO_CONTAINER (pDock));
	}
}
static void _update_desklet_icons (CairoDesklet *pDesklet)
{
	// compute icons size
	if (pDesklet->pRenderer && pDesklet->pRenderer->calculate_icons != NULL)
		pDesklet->pRenderer->calculate_icons (pDesklet);
	
	// trigger load if changed
	Icon* pIcon = pDesklet->pIcon;
	if (pIcon)
	{
		if (cairo_dock_icon_get_allocated_width (pIcon) != pIcon->image.iWidth || cairo_dock_icon_get_allocated_height (pIcon) != pIcon->image.iHeight)
		{
			cairo_dock_trigger_load_icon_buffers (pIcon);
		}
	}
	
	GList* ic;
	for (ic = pDesklet->icons; ic != NULL; ic = ic->next)
	{
		pIcon = ic->data;
		if (cairo_dock_icon_get_allocated_width (pIcon) != pIcon->image.iWidth || cairo_dock_icon_get_allocated_height (pIcon) != pIcon->image.iHeight)
		{
			cairo_dock_trigger_load_icon_buffers (pIcon);
		}
	}
	
	// redraw
	cairo_dock_redraw_container (CAIRO_CONTAINER (pDesklet));
}
static gboolean _cairo_dock_write_desklet_position (CairoDesklet *pDesklet)
{
	if (pDesklet->pIcon != NULL && pDesklet->pIcon->pModuleInstance != NULL)
	{
		int iRelativePositionX = (pDesklet->container.iWindowPositionX + pDesklet->container.iWidth/2 <= gldi_desktop_get_width()/2 ? pDesklet->container.iWindowPositionX : pDesklet->container.iWindowPositionX - gldi_desktop_get_width());
		int iRelativePositionY = (pDesklet->container.iWindowPositionY + pDesklet->container.iHeight/2 <= gldi_desktop_get_height()/2 ? pDesklet->container.iWindowPositionY : pDesklet->container.iWindowPositionY - gldi_desktop_get_height());
		
		int iNumDesktop = -1;
		if (! gldi_desklet_is_sticky (pDesklet))
		{
			iNumDesktop = gldi_container_get_current_desktop_index (CAIRO_CONTAINER (pDesklet));
			//g_print ("desormais on place le desklet sur le bureau (%d,%d,%d)\n", iDesktop, iViewportX, iViewportY);
		}
		cd_debug ("%d; %d; %d", iNumDesktop, iRelativePositionX, iRelativePositionY);
		cairo_dock_update_conf_file (pDesklet->pIcon->pModuleInstance->cConfFilePath,
			G_TYPE_INT, "Desklet", "x position", iRelativePositionX,
			G_TYPE_INT, "Desklet", "y position", iRelativePositionY,
			G_TYPE_INT, "Desklet", "num desktop", iNumDesktop,
			G_TYPE_INVALID);
		gldi_object_notify (pDesklet, NOTIFICATION_CONFIGURE_DESKLET, pDesklet);
	}
	
	if (pDesklet->bSpaceReserved)  // l'espace est reserve, on reserve a la nouvelle position.
	{
		_reserve_space_for_desklet (pDesklet, TRUE);
	}
	if (pDesklet->pIcon && gldi_icon_has_dialog (pDesklet->pIcon))
	{
		gldi_dialogs_replace_all ();
	}
	pDesklet->iSidWritePosition = 0;
	return FALSE;
}
static gboolean _cd_do_fill_bookmark_entry (CDEntry *pEntry)
{
	if (pEntry->cIconName != NULL && pEntry->pIconSurface == NULL)
	{
		cairo_t* pSourceContext = cairo_dock_create_context_from_container (CAIRO_CONTAINER (g_pMainDock));
		GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data (const guchar *data,
			GDK_COLORSPACE_RGB,
			FALSE,  // has_alpha
			8,  // bits_per_sample
			16, 16,  // width, height
			16*3,  // rowstride
			NULL,
			NULL);
		double fImageWidth=0, fImageHeight=0;
		double fZoomX=0, fZoomY=0;
		pEntry->pIconSurface = cairo_dock_create_surface_from_pixbuf (pixbuf,
			pSourceContext,
			1.,
			myDialogs.dialogTextDescription.iSize, myDialogs.dialogTextDescription.iSize,
			0,
			&fImageWidth, &fImageHeight,
			&fZoomX, &fZoomY);
		g_object_unref (pixbuf);
		g_free (pEntry->cIconName);
		pEntry->cIconName = NULL;
		cairo_destroy (pSourceContext);
		return TRUE;
	}
static gboolean on_key_press_listing (GtkWidget *pWidget, GdkEventKey *pKey, CDListing *pListing)
{
	if (pKey->type == GDK_KEY_PRESS)
	{
		cairo_dock_notify_on_container (CAIRO_CONTAINER (pListing), CAIRO_DOCK_KEY_PRESSED, pListing, pKey->keyval, pKey->state, pKey->string);
	}
	return FALSE;
}
void cd_do_select_prev_next_page_in_listing (gboolean bNext)
{
	myData.pListing->fPreviousOffset = myData.pListing->fCurrentOffset;
	GList *e = myData.pListing->pCurrentEntry, *f = e;
	CDEntry *pEntry;
	int k = 0;
	if (bNext)
	{
		do
		{
			if (e->next == NULL)
				break;
			e = e->next;
			pEntry = e->data;
			if (! pEntry->bHidden)
			{
				f = e;
				k ++;
			}
		} while (k < myConfig.iNbLinesInListing);
	}
	else
	{
		do
		{
			if (e->prev == NULL)
				break;
			e = e->prev;
			pEntry = e->data;
			if (! pEntry->bHidden)
			{
				f = e;
				k ++;
			}
		} while (k < myConfig.iNbLinesInListing);
	}
	myData.pListing->pCurrentEntry = f;
	myData.pListing->fAimedOffset = g_list_position (myData.pListing->pEntries, f) * (myDialogs.dialogTextDescription.iSize + 2);
	
	myData.pListing->iCurrentEntryAnimationCount = NB_STEPS_FOR_CURRENT_ENTRY;
	myData.pListing->iScrollAnimationCount = NB_STEPS_FOR_SCROLL;
	myData.pListing->iTitleOffset = 0;
	myData.pListing->sens = 1;
	cairo_dock_launch_animation (CAIRO_CONTAINER (myData.pListing));
	cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing));
}
static void _cairo_dock_set_desklet_input_shape (CairoDesklet *pDesklet)
{
	gldi_container_set_input_shape (CAIRO_CONTAINER (pDesklet), NULL);
	
	if (pDesklet->bNoInput)
	{
		cairo_region_t *pShapeBitmap = gldi_container_create_input_shape (CAIRO_CONTAINER (pDesklet),
			pDesklet->container.iWidth - myDeskletsParam.iDeskletButtonSize,
			pDesklet->container.iHeight - myDeskletsParam.iDeskletButtonSize,
			myDeskletsParam.iDeskletButtonSize,
			myDeskletsParam.iDeskletButtonSize);
		
		gldi_container_set_input_shape (CAIRO_CONTAINER (pDesklet), pShapeBitmap);
		
		cairo_region_destroy (pShapeBitmap);
	}
}
void cd_illusion_update_black_hole (Icon *pIcon, CairoDock *pDock, CDIllusionData *pData)
{
	_calculate_grid (pData);
	
	_update_coords (pData);
	
	cairo_dock_redraw_container (CAIRO_CONTAINER (pDock));
}
void cd_do_search_matching_icons (void)
{
	if (myData.sCurrentText->len == 0)
		return;
	g_print ("%s (%s)\n", __func__, myData.sCurrentText->str);
	gchar *str = strchr (myData.sCurrentText->str, ' ');  // on ne compte pas les arguments d'une eventuelle commande deja tapee.
	int length = myData.sCurrentText->len;
	if (str != NULL)
	{
		g_string_set_size (myData.sCurrentText, str - myData.sCurrentText->str + 1);
		g_print (" on ne cherchera que '%s' (len=%d)\n", myData.sCurrentText->str, myData.sCurrentText->len);
	}
		
	if (myData.pMatchingIcons == NULL)
	{
		if (myData.bSessionStartedAutomatically)  // on cherche dans le dock courant.
		{
			g_print ("on cherche dans le dock\n");
			_cd_do_search_matching_icons_in_dock (myData.pCurrentDock);
			myData.pMatchingIcons = g_list_reverse (myData.pMatchingIcons);
		}
		else
		{
			g_print ("on cherche tout\n");
			// on parcours tous les docks.
			cairo_dock_foreach_icons_in_docks ((CairoDockForeachIconFunc) _cd_do_search_in_one_dock, NULL);
			myData.pMatchingIcons = g_list_reverse (myData.pMatchingIcons);
			
			// on rajoute les icones ne venant pas du dock.
			cd_do_find_matching_applications ();
		}
	}
	else  // optimisation : on peut se contenter de chercher parmi les icones deja trouvees.
	{
		g_print ("on se contente d'enlever celles en trop\n");
		GList *ic, *next_ic;
		Icon *pIcon;
		ic = myData.pMatchingIcons;
		while (ic != NULL)
		{
			pIcon = ic->data;
			next_ic = ic->next;
			if (! _cd_do_icon_match (pIcon, myData.sCurrentText->str, myData.sCurrentText->len))
				myData.pMatchingIcons = g_list_delete_link (myData.pMatchingIcons, ic);
			ic = next_ic;
		}
	}
	myData.pCurrentMatchingElement = NULL;
	myData.iMatchingGlideCount = 0;
	myData.iPreviousMatchingOffset = 0;
	myData.iCurrentMatchingOffset = 0;
	if (myData.pCurrentApplicationToLoad != NULL)  // on va continuer le chargement sur la sous-liste.
		myData.pCurrentApplicationToLoad = myData.pMatchingIcons;  // comme l'ordre de la liste n'a pas ete altere, on n'est sur de ne pas sauter d'icone.
	cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pCurrentDock));
	//g_print ("%d / %d\n", length , myData.sCurrentText->len);
	if (length != myData.sCurrentText->len)
		g_string_set_size (myData.sCurrentText, length);
}