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)); }
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)); }
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; }
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 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)); }
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_tomboy_reload_desklet_renderer (void) { CD_APPLET_SET_DESKLET_RENDERER ("Slide"); cd_tomboy_draw_content_on_all_icons (); cairo_dock_redraw_container (myContainer); }
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); }
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 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); }
void cd_tomboy_show_results (GList *pIconsList) { //\_______________ On marque les icones du resultat. cd_tomboy_reset_icon_marks (FALSE); int iNbResults = 0; Icon *icon; GList *ic; for (ic = pIconsList; ic != NULL; ic = ic->next) { icon = ic->data; icon->bHasIndicator = TRUE; iNbResults ++; } //\_______________ On les montre. if (myDock) { cairo_dock_show_subdock (myIcon, myDock, FALSE); cairo_dock_redraw_container (CAIRO_CONTAINER (myIcon->pSubDock)); } else cairo_dock_redraw_container (myContainer); //\_______________ On affiche le resultat. if (myDock) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%d %s", iNbResults, iNbResults > 1 ? D_("results") : D_("result")); if (myData.iSidResetQuickInfo != 0) g_source_remove (myData.iSidResetQuickInfo); myData.iSidResetQuickInfo = g_timeout_add_seconds (5, _cd_tomboy_reset_quick_info, NULL); } else { cairo_dock_show_temporary_dialog_with_icon ("%d %s", pIconsList ? pIconsList->data : myDesklet->icons->data, myContainer, 3000, MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE, iNbResults, iNbResults > 1 ? D_("results") : D_("result")); } }
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; }
void cairo_dock_pop_up (CairoDock *pDock) { //g_print ("%s (%d)\n", __func__, pDock->bIsBelow); if (pDock->bIsBelow) { gldi_object_remove_notification (pDock, NOTIFICATION_UPDATE, (GldiNotificationFunc) _update_fade_out_dock, NULL); pDock->iFadeCounter = 0; cairo_dock_redraw_container (CAIRO_CONTAINER (pDock)); //g_print ("set above\n"); gtk_window_set_keep_below (GTK_WINDOW (pDock->container.pWidget), FALSE); // keep above pDock->bIsBelow = FALSE; } }
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)); }
void cd_do_select_previous_next_matching_icon (gboolean bNext) { GList *pMatchingElement = myData.pCurrentMatchingElement; do { if (!bNext) myData.pCurrentMatchingElement = cairo_dock_get_previous_element (myData.pCurrentMatchingElement, myData.pMatchingIcons); else myData.pCurrentMatchingElement = cairo_dock_get_next_element (myData.pCurrentMatchingElement, myData.pMatchingIcons); } while (myData.pCurrentMatchingElement != pMatchingElement && ((Icon*)myData.pCurrentMatchingElement->data)->image.pSurface == NULL); if (myData.pCurrentMatchingElement != pMatchingElement) // on complete le texte et on redessine. { Icon *pIcon = myData.pCurrentMatchingElement->data; if (pIcon->cCommand && *pIcon->cCommand != *myData.sCurrentText->str) // cas d'une commande avec un tiret. myData.iNbValidCaracters = 0; cd_do_delete_invalid_caracters (); if (pIcon->cBaseURI != NULL) { gchar *cFile = g_path_get_basename (pIcon->cCommand); g_string_assign (myData.sCurrentText, cFile); g_free (cFile); } else g_string_assign (myData.sCurrentText, pIcon->cCommand); cd_do_load_pending_caracters (); // on arme l'animation de decalage. myData.iMatchingGlideCount = 10; // on rembobine l'animation. myData.iPreviousMatchingOffset = myData.iCurrentMatchingOffset; // on part du point courant. int iWidth, iHeight; cairo_dock_get_icon_extent (pIcon, &iWidth, &iHeight); if (iHeight != 0) { double fZoom = (double) g_pMainDock->container.iHeight/2 / iHeight; myData.iMatchingAimPoint += (bNext ? 1 : -1) * iWidth * fZoom; // on cherche a atteindre le nouveau point. } // on repositionne les caracteres et on anime tout ca. cd_do_launch_appearance_animation (); cairo_dock_redraw_container (CAIRO_CONTAINER (g_pMainDock)); } }
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)); }
gboolean cd_do_update_listing_notification (gpointer pUserData, CDListing *pListing, gboolean *bContinueAnimation) { //g_print ("%s ()\n", __func__); if (pListing->iAppearanceAnimationCount > 0) { pListing->iAppearanceAnimationCount --; if (pListing->iAppearanceAnimationCount != 0) *bContinueAnimation = TRUE; } if (pListing->iCurrentEntryAnimationCount > 0) { pListing->iCurrentEntryAnimationCount --; if (pListing->iCurrentEntryAnimationCount != 0) *bContinueAnimation = TRUE; /// optimisation : ne retracer que la zone concernee... } if (pListing->iScrollAnimationCount > 0) { pListing->iScrollAnimationCount --; if (pListing->iScrollAnimationCount != 0) *bContinueAnimation = TRUE; double f = (double) pListing->iScrollAnimationCount / NB_STEPS_FOR_SCROLL; pListing->fCurrentOffset = pListing->fPreviousOffset * f + pListing->fAimedOffset * (1 - f); } double fRadius = MIN (6, myDialogs.dialogTextDescription.iSize/2+1); if (myData.pListing->iTitleWidth > myData.pListing->container.iWidth - 2*fRadius + 10) // 10 pixels de rab { myData.pListing->iTitleOffset += 2 * myData.pListing->sens; if (myData.pListing->container.iWidth - 2*fRadius + myData.pListing->iTitleOffset > myData.pListing->iTitleWidth) { myData.pListing->iTitleOffset = myData.pListing->iTitleWidth - (myData.pListing->container.iWidth - 2*fRadius); myData.pListing->sens = -1; } else if (myData.pListing->iTitleOffset < 0) { myData.pListing->iTitleOffset = 0; myData.pListing->sens = 1; } *bContinueAnimation = TRUE; /// optimisation : ne retracer que la zone concernee... } cairo_dock_redraw_container (CAIRO_CONTAINER (pListing)); }
static gboolean _animation_loop (GldiContainer *pContainer) { CairoDialog *pDialog = CAIRO_DIALOG (pContainer); gboolean bContinue = FALSE; gboolean bUpdateSlowAnimation = FALSE; pContainer->iAnimationStep ++; if (pContainer->iAnimationStep * pContainer->iAnimationDeltaT >= CAIRO_DOCK_MIN_SLOW_DELTA_T) { bUpdateSlowAnimation = TRUE; pContainer->iAnimationStep = 0; pContainer->bKeepSlowAnimation = FALSE; } if (pDialog->fAppearanceCounter < 1) { pDialog->fAppearanceCounter += .08; if (pDialog->fAppearanceCounter > .99) { pDialog->fAppearanceCounter = 1.; } else { bContinue = TRUE; } } if (bUpdateSlowAnimation) { gldi_object_notify (pDialog, NOTIFICATION_UPDATE_SLOW, pDialog, &pContainer->bKeepSlowAnimation); } gldi_object_notify (pDialog, NOTIFICATION_UPDATE, pDialog, &bContinue); cairo_dock_redraw_container (CAIRO_CONTAINER (pDialog)); if (! bContinue && ! pContainer->bKeepSlowAnimation) { pContainer->iSidGLAnimation = 0; return FALSE; } else return TRUE; }
void cd_tomboy_reset_icon_marks (gboolean bForceRedraw) { GList *pIconsList = CD_APPLET_MY_ICONS_LIST; Icon *icon; GList *ic; for (ic = pIconsList; ic != NULL; ic = ic->next) { icon = ic->data; icon->bHasIndicator = FALSE; } if (bForceRedraw) { if (myDock) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%d", g_hash_table_size (myData.hNoteTable)); CD_APPLET_REDRAW_MY_ICON; } cairo_dock_redraw_container (CD_APPLET_MY_ICONS_LIST_CONTAINER); } }
static gboolean _fill_entry_icon_idle (CDListing *pListing) { g_print ("%s (%x)", __func__, pListing->pEntryToFill); CDEntry *pEntry; gboolean bHasBeenFilled = FALSE; while (pListing->pEntryToFill != NULL && ! bHasBeenFilled) { pEntry = pListing->pEntryToFill->data; if (! pEntry->bHidden && pEntry->fill) bHasBeenFilled = pEntry->fill (pEntry); pListing->pEntryToFill = pListing->pEntryToFill->next; } if (pListing->pEntryToFill == NULL) // on a tout rempli. ajouter || bHasBeenFilled pour redessiner au fur et a mesure. { cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing)); pListing->iSidFillEntries = 0; return FALSE; } return TRUE; }
static gboolean on_style_changed (G_GNUC_UNUSED gpointer data) { cd_debug ("Desklets: style change to %s", myDeskletsParam.cDeskletDecorationsName); gboolean bUseDefaultColors = (!myDeskletsParam.cDeskletDecorationsName || strcmp (myDeskletsParam.cDeskletDecorationsName, "automatic") == 0); CairoDeskletDecoration * pDecoration = cairo_dock_get_desklet_decoration ("automatic"); if (pDecoration) pDecoration->iLeftMargin = pDecoration->iTopMargin = pDecoration->iRightMargin = pDecoration->iBottomMargin = myStyleParam.iLineWidth; CairoDesklet *pDesklet; GList *dl; for (dl = s_pDeskletList; dl != NULL; dl = dl->next) { pDesklet = dl->data; if ( ((pDesklet->cDecorationTheme == NULL || strcmp (pDesklet->cDecorationTheme, "default") == 0) && bUseDefaultColors) || strcmp (pDesklet->cDecorationTheme, "automatic") == 0) { cd_debug ("Reload desklet's bg..."); gldi_desklet_load_desklet_decorations (pDesklet); cairo_dock_redraw_container (CAIRO_CONTAINER (pDesklet)); } } return GLDI_NOTIFICATION_LET_PASS; }
gboolean cd_animations_update_wobbly (CairoDock *pDock, CDAnimationData *pData, double dt, gboolean bWillContinue) { const int n = 10; double k = myConfig.fSpringConstant; double f = myConfig.fFriction; dt /= 1e3 * n; CDAnimationGridNode *pNode, *pNode2; gboolean bContinue = FALSE; double dx, dy, l; int i,j,m; for (m=0; m<n; m++) { for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; pNode->fx = 0.; pNode->fy = 0.; if (i > 0) { _pulled_by (i-1, j); } if (i < 3) { _pulled_by (i+1, j); } if (j > 0) { _pulled_by (i, j-1); } if (j < 3) { _pulled_by (i, j+1); } } } double _vx, _vy; for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; pNode->fx -= f * pNode->vx; pNode->fy -= f * pNode->vy; _vx = pNode->vx; _vy = pNode->vy; pNode->vx += pNode->fx * dt; // Runge-Kutta d'ordre 1. pNode->vy += pNode->fy * dt; pNode->x += (pNode->vx + _vx)/2 * dt; pNode->y += (pNode->vy + _vy)/2 * dt; } } } for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; pData->pCtrlPts[j][i][0] = pNode->x; pData->pCtrlPts[j][i][1] = pNode->y; } } cairo_dock_redraw_container (CAIRO_CONTAINER (pDock)); return bContinue; }
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); 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 ()) { if (myData.pCharList == NULL) { //\___________________ animation du prompt. if (myData.iPromptAnimationCount > -1) { myData.iPromptAnimationCount ++; *bContinueAnimation = TRUE; } } else { //\___________________ animation des caracteres : deplacement vers la gauche/droite et apparition. myData.iAppearanceTime -= iDeltaT; if (myData.iAppearanceTime < 0) myData.iAppearanceTime = 0; else *bContinueAnimation = TRUE; double f = (double) myData.iAppearanceTime / myConfig.iAppearanceDuration; CDChar *pChar; GList *c; for (c = myData.pCharList; c != NULL; c = c->next) { pChar = c->data; pChar->iCurrentX = f * pChar->iInitialX + (1-f) * pChar->iFinalX; pChar->iCurrentY = f * pChar->iInitialY + (1-f) * pChar->iFinalY; if (pChar->fRotationAngle != 0) { pChar->fRotationAngle -= 10.; // 360. * iDeltaT / myConfig.iAppearanceDuration; if (pChar->fRotationAngle < 0) pChar->fRotationAngle = 0; } } } //\___________________ animation du decalage des icones d'appli correspondantes. if (myData.iMatchingGlideCount != 0) { myData.iMatchingGlideCount --; double f = (double) myData.iMatchingGlideCount / 10; myData.iCurrentMatchingOffset = myData.iPreviousMatchingOffset * f + myData.iMatchingAimPoint * (1 - f); } cairo_dock_redraw_container (pContainer); } return GLDI_NOTIFICATION_LET_PASS; }
gboolean cd_do_key_pressed (gpointer pUserData, GldiContainer *pContainer, guint iKeyVal, guint iModifierType, const gchar *string) { g_return_val_if_fail (cd_do_session_is_running (), GLDI_NOTIFICATION_LET_PASS); if (myData.sCurrentText == NULL) return GLDI_NOTIFICATION_LET_PASS; const gchar *cKeyName = gdk_keyval_name (iKeyVal); guint32 iUnicodeChar = gdk_keyval_to_unicode (iKeyVal); cd_debug ("+ cKeyName : %s (%c, %s)", cKeyName, iUnicodeChar, string); if (iKeyVal == GDK_KEY_Escape) // on clot la session. { cd_do_close_session (); } else if (iKeyVal == GDK_KEY_space && myData.iNbValidCaracters == 0) // pas d'espace en debut de chaine. { // on rejette. } else if (iKeyVal >= GDK_KEY_Shift_L && iKeyVal <= GDK_KEY_Hyper_R) // on n'ecrit pas les modificateurs. { // on rejette. } else if (iKeyVal == GDK_KEY_BackSpace) // on efface la derniere lettre. { if (myData.iNbValidCaracters > 0) { cd_debug ("on efface la derniere lettre de %s %d/%d", myData.sCurrentText->str, myData.iNbValidCaracters, myData.sCurrentText->len); if (myData.iNbValidCaracters == myData.sCurrentText->len) // pas de completion en cours => on efface la derniere lettre tapee. myData.iNbValidCaracters --; // on efface les lettres precedentes jusqu'a la derniere position validee. cd_do_delete_invalid_caracters (); // on relance la recherche. if (myData.pListingHistory == NULL) // recherche principale. { g_list_free (myData.pMatchingIcons); myData.pMatchingIcons = NULL; cd_do_search_matching_icons (); if (myData.pMatchingIcons == NULL && myData.sCurrentText->len > 0) // on n'a trouve aucun programme, on cherche des entrees. { if (myData.iSidLoadExternAppliIdle != 0) { g_source_remove (myData.iSidLoadExternAppliIdle); myData.iSidLoadExternAppliIdle = 0; } cd_do_launch_all_backends (); } else // on a trouve au moins un programme, on cache le listing des fichiers. { cd_do_hide_listing (); } } else // sous-recherche => on filtre. { cd_do_filter_current_listing (); } // on repositionne les caracteres et on anime tout ca. cd_do_launch_appearance_animation (); } } else if (iKeyVal == GDK_KEY_Tab) // completion. { if (myData.iNbValidCaracters > 0) { gboolean bPrevious = iModifierType & GDK_SHIFT_MASK; if (myData.pMatchingIcons != NULL) { cd_do_select_previous_next_matching_icon (!bPrevious); } else { // faire un truc ?... } } } else if (iKeyVal == GDK_KEY_Return) { cd_debug ("Enter (%s)", myData.cSearchText); if (myData.pMatchingIcons != NULL) // on a une appli a lancer. { Icon *pIcon = (myData.pCurrentMatchingElement ? myData.pCurrentMatchingElement->data : myData.pMatchingIcons->data); cairo_dock_launch_command (pIcon->cCommand); } else if (myData.pListing && myData.pListing->pCurrentEntry) // pas d'appli mais une entree => on l'execute. { CDEntry *pEntry = myData.pListing->pCurrentEntry->data; cd_debug ("on valide l'entree '%s ; %s'", pEntry->cName, pEntry->cPath); if (pEntry->execute) pEntry->execute (pEntry); else return GLDI_NOTIFICATION_INTERCEPT; } else if (myData.iNbValidCaracters > 0) // pas d'entree mais du texte => on l'execute tel quel. { cd_debug ("on execute '%s'", myData.sCurrentText->str); cairo_dock_launch_command (myData.sCurrentText->str); } if (!(iModifierType & GDK_CONTROL_MASK) && !(iModifierType & GDK_MOD1_MASK) && !(iModifierType & GDK_SHIFT_MASK)) cd_do_close_session (); } else if (iKeyVal == GDK_KEY_Left || iKeyVal == GDK_KEY_Right || iKeyVal == GDK_KEY_Up || iKeyVal == GDK_KEY_Down) { if (myData.pMatchingIcons != NULL) { cd_do_select_previous_next_matching_icon (iKeyVal == GDK_KEY_Right || iKeyVal == GDK_KEY_Down); } else if (myData.pListing != NULL && myData.pListing->pEntries != NULL) { if (iKeyVal == GDK_KEY_Down) { cd_do_select_prev_next_entry_in_listing (TRUE); // next } else if (iKeyVal == GDK_KEY_Up) { cd_do_select_prev_next_entry_in_listing (FALSE); // previous } else if (iKeyVal == GDK_KEY_Right) { cd_do_show_current_sub_listing (); } else if (iKeyVal == GDK_KEY_Left) { cd_do_show_previous_listing (); } } } else if (iKeyVal == GDK_KEY_Page_Down || iKeyVal == GDK_KEY_Page_Up || iKeyVal == GDK_KEY_Home || iKeyVal == GDK_KEY_End) { if (myData.pListing != NULL) { if (iKeyVal == GDK_KEY_Page_Down || iKeyVal == GDK_KEY_Page_Up) cd_do_select_prev_next_page_in_listing (iKeyVal == GDK_KEY_Page_Down); // TRUE <=> next page else cd_do_select_last_first_entry_in_listing (iKeyVal == GDK_KEY_End); // TRUE <=> last entry. } } else if (iKeyVal >= GDK_KEY_F1 && iKeyVal <= GDK_KEY_F9) { if (myData.pListing != NULL && gldi_container_is_visible (CAIRO_CONTAINER (myData.pListing))) { cd_debug ("modification du filtre : option n°%d", iKeyVal - GDK_KEY_F1); cd_do_activate_filter_option (iKeyVal - GDK_KEY_F1); cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing)); } } else if (string) /// utiliser l'unichar ... { cd_debug ("string:'%s'", string); guint iNbNewChar = 0; if ((iModifierType & GDK_CONTROL_MASK) && iUnicodeChar == 'v') // CTRL+v { cd_debug ("CTRL+v\n"); GtkClipboard *pClipBoard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); gchar *cText = gtk_clipboard_wait_for_text (pClipBoard); // la main loop s'execute pendant ce temps. if (cText != NULL) { cd_debug ("clipboard : '%s'", cText); iNbNewChar = strlen (cText); /// penser a l'UTF-8 ... gchar *str = strchr (cText, '\r'); if (str) *str = '\0'; str = strchr (cText, '\n'); if (str) *str = '\0'; g_string_append (myData.sCurrentText, cText); cd_do_load_pending_caracters (); cd_do_launch_appearance_animation (); myData.iNbValidCaracters = myData.sCurrentText->len; // cela valide le texte colle ainsi que les lettres precedemment ajoutee par completion. } } else // on rajoute la lettre au mot { iNbNewChar = 1; g_string_append_c (myData.sCurrentText, *string); myData.iNbValidCaracters = myData.sCurrentText->len; // l'utilisateur valide la nouvelle lettre ainsi que celles precedemment ajoutee par completion. } // on cherche la liste des icones qui correspondent. if (myData.pListingHistory == NULL) { //if (! (myData.bFoundNothing || (myData.pListing && myData.pListing->pEntries))) // on n'est pas deja dans une recherche de fichiers if (myData.iNbValidCaracters == iNbNewChar || myData.pMatchingIcons != NULL) // 1er ajout de lettre ou precedente recherche d'icones fructueuse => on remet ca. { cd_do_search_matching_icons (); } // si on n'a trouve aucun lanceur, on lance la recherche dans les backends. if (myData.pMatchingIcons == NULL) { cd_do_launch_all_backends (); } } else { cd_do_filter_current_listing (); } // on rajoute une surface/texture pour la/les nouvelle(s) lettre(s). myData.iNbValidCaracters -= iNbNewChar; // le nouveau caractere n'est pas encore charge. cd_do_load_pending_caracters (); myData.iNbValidCaracters += iNbNewChar; // on repositionne les caracteres et on anime tout ca. cd_do_launch_appearance_animation (); } return GLDI_NOTIFICATION_INTERCEPT; }
gboolean cd_animations_update_wobbly2 (CairoDock *pDock, CDAnimationData *pData, double dt, gboolean bWillContinue) { const int n = 20; double k = myConfig.fSpringConstant; double f = myConfig.fFriction; CDAnimationGridNode *pNode, *pNode2; gboolean bContinue = FALSE; int i,j; // k_1 = f ( t_n, y_n ) = f(Xn) for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; bContinue |= _calculate_forces (pNode, 0, pData); pNode->rk[1][0] = pNode->fx * dt/2; pNode->rk[1][1] = pNode->fy * dt/2; pNode->rk[1][2] = pNode->vx * dt/2; pNode->rk[1][3] = pNode->vy * dt/2; } } // k_2 = f ( t_n + {h / 2}, y_n + {h / 2} k_1 ) = f(Xn + dt/2*k_1) for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; _calculate_forces (pNode, 1, pData); pNode->rk[2][0] = pNode->fx * dt/2; pNode->rk[2][1] = pNode->fy * dt/2; pNode->rk[2][2] = pNode->vx * dt/2; pNode->rk[2][3] = pNode->vy * dt/2; } } // k_3 = f ( t_n + {h / 2}, y_n + {h / 2} k_2 ) = f(Xn + dt/2*k_2) for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; _calculate_forces (pNode, 2, pData); pNode->rk[3][0] = pNode->fx * dt; pNode->rk[3][1] = pNode->fy * dt; pNode->rk[3][2] = pNode->vx * dt; pNode->rk[3][3] = pNode->vy * dt; } } // k_4 = f ( t_n + h, y_n + h k_3) = f(Xn + dt*k_3) for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; _calculate_forces (pNode, 3, pData); pNode->rk[4][0] = pNode->fx * dt; pNode->rk[4][1] = pNode->fy * dt; pNode->rk[4][2] = pNode->vx * dt; pNode->rk[4][3] = pNode->vy * dt; } } // y_{n+1} = y_n + {h / 6} (k_1 + 2k_2 + 2k_3 + k_4) for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; pNode->vx = _sum_rk (0); pNode->vy = _sum_rk (1); pNode->x = _sum_rk (2); pNode->y = _sum_rk (3); } } for (i=0; i<4; i++) { for (j=0; j<4; j++) { pNode = &pData->gridNodes[i][j]; pData->pCtrlPts[j][i][0] = pNode->x; pData->pCtrlPts[j][i][1] = pNode->y; } } cairo_dock_redraw_container (CAIRO_CONTAINER (pDock)); return bContinue; }