static void _cairo_dock_set_same_indicator_on_sub_dock (Icon *pInhibhatorIcon) { CairoDock *pInhibhatorDock = cairo_dock_search_dock_from_name (pInhibhatorIcon->cParentDockName); if (pInhibhatorDock != NULL && pInhibhatorDock->iRefCount > 0) // l'inhibiteur est dans un sous-dock. { gboolean bSubDockHasIndicator = FALSE; if (pInhibhatorIcon->bHasIndicator) { bSubDockHasIndicator = TRUE; } else { GList* ic; Icon *icon; for (ic =pInhibhatorDock->icons ; ic != NULL; ic = ic->next) { icon = ic->data; if (icon->bHasIndicator) { bSubDockHasIndicator = TRUE; break; } } } Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (pInhibhatorDock, NULL); if (pPointingIcon != NULL) { cd_message (" pour le sous-dock %s : indicateur <- %d", pPointingIcon->acName, bSubDockHasIndicator); pPointingIcon->bHasIndicator = bSubDockHasIndicator; } } }
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; }
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); }
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; }
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); } }
void cd_do_change_current_icon (Icon *pIcon, CairoDock *pDock) { //\_________________ on gere le cachage et le montrage du dock precedent et actuel. if (myData.pCurrentDock != NULL && pDock != myData.pCurrentDock && myData.pCurrentDock != g_pMainDock) // on remet au repos dock precedemment anime. { cairo_dock_emit_leave_signal (myData.pCurrentDock); } if (pDock != NULL && pDock != g_pMainDock && pDock != myData.pCurrentDock) // on montre le nouveau dock { if (pDock != NULL) { if (pDock->iRefCount > 0) { CairoDock *pParentDock = NULL; Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (pDock, &pParentDock); if (pPointingIcon != NULL) { cairo_dock_show_subdock (pPointingIcon, pParentDock, FALSE); // utile pour le montrage des sous-docks au clic. } } else { cairo_dock_pop_up (pDock); } cairo_dock_emit_enter_signal (pDock); } } if (pDock != NULL) { gtk_window_present (GTK_WINDOW (pDock->pWidget)); } //\_________________ on gere l'allumage et l'eteignage de l'icone precedente et actuelle. if (myData.pCurrentIcon != NULL && pIcon != myData.pCurrentIcon) // on remet au repos l'icone precedemment anime. { myData.bIgnoreIconState = TRUE; cairo_dock_stop_icon_animation (myData.pCurrentIcon); myData.bIgnoreIconState = FALSE; cairo_dock_redraw_icon (myData.pCurrentIcon, CAIRO_CONTAINER (myData.pCurrentDock)); /// utile ?... } if (pIcon != NULL && myData.pCurrentIcon != pIcon) // on anime la nouvelle icone. { int x = pIcon->fXAtRest + pIcon->fWidth/2 + (- pDock->fFlatDockWidth + pDock->iMaxDockWidth)/2; int y = pIcon->fDrawY + pIcon->fHeight/2 * pIcon->fScale; if (1||myData.pCurrentDock != pDock) { cairo_dock_emit_motion_signal (pDock, x, y); } else { myData.iPrevMouseX = myData.iMouseX; myData.iPrevMouseY = myData.iMouseY; myData.iMotionCount = 10; } myData.iMouseX = x; myData.iMouseY = y; cairo_dock_request_icon_animation (pIcon, pDock, myConfig.cIconAnimation, 1e6); // interrompt l'animation de "mouse over". cairo_dock_launch_animation (CAIRO_CONTAINER (pDock)); //if (myAccessibility.bShowSubDockOnClick) // cairo_dock_show_subdock (pIcon, pDock, FALSE); } myData.pCurrentDock = pDock; myData.pCurrentIcon = pIcon; if (myData.pCurrentDock == NULL) gtk_window_present (GTK_WINDOW (g_pMainDock->pWidget)); }
gboolean cd_do_key_pressed (gpointer pUserData, GldiContainer *pContainer, guint iKeyVal, guint iModifierType, const gchar *string, int iKeyCode) { g_return_val_if_fail (cd_do_session_is_running (), GLDI_NOTIFICATION_LET_PASS); g_return_val_if_fail (myData.pCurrentDock != NULL, GLDI_NOTIFICATION_LET_PASS); const gchar *cKeyName = gdk_keyval_name (iKeyVal); guint32 iUnicodeChar = gdk_keyval_to_unicode (iKeyVal); cd_debug ("+ cKeyName : %s (%c, %s, %d)", cKeyName, iUnicodeChar, string, iKeyCode); if (myData.sCurrentText->len == 0) { GdkKeymapKey *keys = NULL; guint *keyvals = NULL; int i, n_entries = 0; int iKeyVal2; gdk_keymap_get_entries_for_keycode (gdk_keymap_get_default (), iKeyCode, &keys, &keyvals, &n_entries); for (i = 0; i < n_entries; i ++) { iKeyVal2 = keyvals[i]; if ((iKeyVal2 >= GDK_KEY_0 && iKeyVal2 <= GDK_KEY_9) || (iKeyVal2 >= GDK_KEY_KP_0 && iKeyVal2 <= GDK_KEY_KP_9)) { iKeyVal = iKeyVal2; break; } } g_free (keys); g_free (keyvals); } if (iKeyVal == GDK_KEY_Escape) // on clot la session. { // give the focus back to the window that had it before the user opened this session. if (myData.pPreviouslyActiveWindow != NULL) { gldi_window_show (myData.pPreviouslyActiveWindow); } cd_do_close_session (); } else if (iKeyVal == GDK_KEY_space && myData.sCurrentText->len == 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_Menu) // emulation du clic droit. { if (myData.pCurrentIcon != NULL) { myData.bIgnoreIconState = TRUE; gldi_icon_stop_animation (myData.pCurrentIcon); // car on va perdre le focus. myData.bIgnoreIconState = FALSE; GtkWidget *menu = gldi_container_build_menu (CAIRO_CONTAINER (myData.pCurrentDock), myData.pCurrentIcon); gldi_menu_popup (menu); } } else if (iKeyVal == GDK_KEY_BackSpace) // on efface la derniere lettre. { if (myData.sCurrentText->len > 0) { cd_debug ("we remove the last letter of %s (%d)", myData.sCurrentText->str, myData.sCurrentText->len); g_string_truncate (myData.sCurrentText, myData.sCurrentText->len-1); // on relance la recherche. if (myData.pCurrentIcon == NULL) // sinon l'icone actuelle convient toujours. cd_do_search_current_icon (FALSE); } } else if (iKeyVal == GDK_KEY_Tab) // jump to next icon. { if (myData.sCurrentText->len > 0) { //gboolean bPrevious = iModifierType & GDK_SHIFT_MASK; // on cherche l'icone suivante. cd_do_search_current_icon (TRUE); // pCurrentIcon peut etre NULL si elle s'est faite detruire pendant la recherche, auquel cas on cherchera juste normalement. } } else if (iKeyVal == GDK_KEY_Return) { if (myData.pCurrentIcon != NULL) { cd_debug ("we click on the icon '%s' [%d, %d]", myData.pCurrentIcon->cName, iModifierType, GDK_SHIFT_MASK); myData.bIgnoreIconState = TRUE; if (iModifierType & GDK_MOD1_MASK) // ALT { myData.bIgnoreIconState = TRUE; gldi_icon_stop_animation (myData.pCurrentIcon); // car aucune animation ne va la remplacer. myData.bIgnoreIconState = FALSE; gldi_object_notify (CAIRO_CONTAINER (myData.pCurrentDock), NOTIFICATION_MIDDLE_CLICK_ICON, myData.pCurrentIcon, myData.pCurrentDock); } else if (iModifierType & GDK_CONTROL_MASK) // CTRL { myData.bIgnoreIconState = TRUE; gldi_icon_stop_animation (myData.pCurrentIcon); // car on va perdre le focus. myData.bIgnoreIconState = FALSE; GtkWidget *menu = gldi_container_build_menu (CAIRO_CONTAINER (myData.pCurrentDock), myData.pCurrentIcon); gldi_menu_popup (menu); } else { cd_do_simulate_click (CAIRO_CONTAINER (myData.pCurrentDock), myData.pCurrentIcon, iModifierType); } gldi_icon_start_animation (myData.pCurrentIcon); myData.bIgnoreIconState = FALSE; myData.pCurrentIcon = NULL; // sinon on va interrompre l'animation en fermant la session. } cd_do_close_session (); } else if (iKeyVal == GDK_KEY_Left || iKeyVal == GDK_KEY_Right || iKeyVal == GDK_KEY_Up || iKeyVal == GDK_KEY_Down) { iKeyVal = _orient_arrow (pContainer, iKeyVal); if (iKeyVal == GDK_KEY_Up) { if (myData.pCurrentIcon != NULL && myData.pCurrentIcon->pSubDock != NULL) { cd_debug ("on monte dans le sous-dock %s", myData.pCurrentIcon->cName); Icon *pIcon = cairo_dock_get_first_icon (myData.pCurrentIcon->pSubDock->icons); cd_do_change_current_icon (pIcon, myData.pCurrentIcon->pSubDock); } } else if (iKeyVal == GDK_KEY_Down) { if (myData.pCurrentDock->iRefCount > 0) { CairoDock *pParentDock = NULL; Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (myData.pCurrentDock, &pParentDock); if (pPointingIcon != NULL) { cd_debug ("on redescend dans le dock parent via %s", pPointingIcon->cName); cd_do_change_current_icon (pPointingIcon, pParentDock); } } } else if (iKeyVal == GDK_KEY_Left) { if (myData.pCurrentDock->icons != NULL) { Icon *pPrevIcon = cairo_dock_get_previous_icon (myData.pCurrentDock->icons, myData.pCurrentIcon); if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pPrevIcon)) pPrevIcon = cairo_dock_get_previous_icon (myData.pCurrentDock->icons, pPrevIcon); if (pPrevIcon == NULL) // pas trouve ou bien 1ere icone. { pPrevIcon = cairo_dock_get_last_icon (myData.pCurrentDock->icons); } cd_debug ("on se deplace a gauche sur %s", pPrevIcon ? pPrevIcon->cName : "none"); cd_do_change_current_icon (pPrevIcon, myData.pCurrentDock); } } else // Gdk_Right. { if (myData.pCurrentDock->icons != NULL) { Icon *pNextIcon = cairo_dock_get_next_icon (myData.pCurrentDock->icons, myData.pCurrentIcon); if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pNextIcon)) pNextIcon = cairo_dock_get_next_icon (myData.pCurrentDock->icons, pNextIcon); if (pNextIcon == NULL) // pas trouve ou bien 1ere icone. { pNextIcon = cairo_dock_get_first_icon (myData.pCurrentDock->icons); } cd_debug ("on se deplace a gauche sur %s", pNextIcon ? pNextIcon->cName : "none"); cd_do_change_current_icon (pNextIcon, myData.pCurrentDock); } } } else if (iKeyVal == GDK_KEY_Page_Down || iKeyVal == GDK_KEY_Page_Up || iKeyVal == GDK_KEY_Home || iKeyVal == GDK_KEY_End) { if (iModifierType & GDK_CONTROL_MASK) // changement de dock principal { gpointer data[4] = {myData.pCurrentDock, NULL, GINT_TO_POINTER (FALSE), NULL}; gldi_docks_foreach_root ((GFunc) _find_next_dock, data); CairoDock *pNextDock = data[1]; if (pNextDock == NULL) pNextDock = data[3]; if (pNextDock != NULL) { Icon *pNextIcon = NULL; int n = g_list_length (pNextDock->icons); if (n > 0) { pNextIcon = g_list_nth_data (pNextDock->icons, (n-1) / 2); if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pNextIcon) && n > 1) pNextIcon = g_list_nth_data (pNextDock->icons, (n+1) / 2); } cd_do_change_current_icon (pNextIcon, pNextDock); } } Icon *pIcon = (iKeyVal == GDK_KEY_Page_Up || iKeyVal == GDK_KEY_Home ? cairo_dock_get_first_icon (myData.pCurrentDock->icons) : cairo_dock_get_last_icon (myData.pCurrentDock->icons)); cd_debug ("on se deplace a l'extremite sur %s", pIcon ? pIcon->cName : "none"); cd_do_change_current_icon (pIcon, myData.pCurrentDock); } else if ( ((iKeyVal >= GDK_KEY_0 && iKeyVal <= GDK_KEY_9) || (iKeyVal >= GDK_KEY_KP_0 && iKeyVal <= GDK_KEY_KP_9)) && myData.sCurrentText->len == 0) { _activate_nth_icon (iKeyVal, iModifierType); } else if (string) /// utiliser l'unichar ... { cd_debug ("string:'%s'", string); g_string_append_c (myData.sCurrentText, *string); cd_do_search_current_icon (FALSE); } return GLDI_NOTIFICATION_INTERCEPT; }
void cd_do_change_current_icon (Icon *pIcon, CairoDock *pDock) { //\_________________ on gere le cachage et le montrage du dock precedent et actuel. if (myData.pCurrentDock != NULL && pDock != myData.pCurrentDock) // on remet au repos le dock precedemment anime. { cd_debug ("leave this dock"); cairo_dock_emit_leave_signal (CAIRO_CONTAINER (myData.pCurrentDock)); cd_do_remove_icons_number (myData.pCurrentDock); gldi_object_remove_notification (myData.pCurrentDock, NOTIFICATION_RENDER, (GldiNotificationFunc) cd_do_render, NULL); gldi_object_remove_notification (myData.pCurrentDock, NOTIFICATION_UPDATE, (GldiNotificationFunc) cd_do_update_container, NULL); gldi_object_remove_notification (myData.pCurrentDock, NOTIFICATION_CLICK_ICON, (GldiNotificationFunc) cd_do_on_click, NULL); gldi_object_remove_notification (myData.pCurrentDock, NOTIFICATION_MIDDLE_CLICK_ICON, (GldiNotificationFunc) cd_do_on_click, NULL); } if (pDock != NULL && pDock != myData.pCurrentDock) // on montre le nouveau dock { cd_debug (" dock %p <- %p", myData.pCurrentDock, pDock); if (pDock->iRefCount > 0) { CairoDock *pParentDock = NULL; Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (pDock, &pParentDock); if (pPointingIcon != NULL) { cairo_dock_show_subdock (pPointingIcon, pParentDock); // utile pour le montrage des sous-docks au clic. } } else { /// utile de faire ca si on entre dedans ?... cd_debug ("enter this dock"); if (pDock->bAutoHide) cairo_dock_start_showing (pDock); if (pDock->iVisibility == CAIRO_DOCK_VISI_KEEP_BELOW) cairo_dock_pop_up (pDock); } cairo_dock_emit_enter_signal (CAIRO_CONTAINER (pDock)); cd_do_numberize_icons (pDock); gldi_object_register_notification (pDock, NOTIFICATION_UPDATE, (GldiNotificationFunc) cd_do_update_container, GLDI_RUN_AFTER, NULL); gldi_object_register_notification (pDock, NOTIFICATION_RENDER, (GldiNotificationFunc) cd_do_render, GLDI_RUN_AFTER, NULL); gldi_object_register_notification (pDock, NOTIFICATION_CLICK_ICON, (GldiNotificationFunc) cd_do_on_click, GLDI_RUN_AFTER, NULL); // we don't disable the clicks, rather we will close the session. gldi_object_register_notification (pDock, NOTIFICATION_MIDDLE_CLICK_ICON, (GldiNotificationFunc) cd_do_on_click, GLDI_RUN_AFTER, NULL); } if (pDock != NULL) { gtk_window_present (GTK_WINDOW (pDock->container.pWidget)); } //\_________________ on gere l'allumage et l'eteignage de l'icone precedente et actuelle. if (myData.pCurrentIcon != NULL && pIcon != myData.pCurrentIcon) // on remet au repos l'icone precedemment anime. { myData.bIgnoreIconState = TRUE; gldi_icon_stop_animation (myData.pCurrentIcon); myData.bIgnoreIconState = FALSE; cairo_dock_redraw_icon (myData.pCurrentIcon); /// utile ?... } if (pIcon != NULL && myData.pCurrentIcon != pIcon) // on anime la nouvelle icone. { int x = pIcon->fXAtRest + pIcon->fWidth/2 + (- pDock->fFlatDockWidth + pDock->iMaxDockWidth)/2; int y = pIcon->fDrawY + pIcon->fHeight/2 * pIcon->fScale; if (1||myData.pCurrentDock != pDock) { cairo_dock_emit_motion_signal (pDock, pDock->container.bIsHorizontal ? x : y, pDock->container.bIsHorizontal ? y : x); } else { myData.iPrevMouseX = myData.iMouseX; myData.iPrevMouseY = myData.iMouseY; myData.iMotionCount = 10; } myData.iMouseX = x; myData.iMouseY = y; gldi_icon_request_animation (pIcon, myConfig.cIconAnimation, 1e6); // interrompt l'animation de "mouse over". cairo_dock_launch_animation (CAIRO_CONTAINER (pDock)); } myData.pCurrentDock = pDock; myData.pCurrentIcon = pIcon; cd_debug ("myData.pCurrentDock <- %p", myData.pCurrentDock); }