/** * xfdashboard_notify: * @inSender: The sending #ClutterActor or %NULL * @inIconName: The icon name to display in notification or %NULL * @inFormat: A standard printf() format string for notification text * @...: The parameters to insert into the format string * * Shows a notification with the formatted text as specified in @inFormat * and the parameters at the monitor where the sending actor @inSender * is placed on. * * If @inSender is NULL the primary monitor is used. * * If @inIconName is NULL no icon will be shown in notification. */ void xfdashboard_notify(ClutterActor *inSender, const gchar *inIconName, const gchar *inFormat, ...) { XfdashboardStage *stage; va_list args; gchar *text; g_return_if_fail(inSender==NULL || CLUTTER_IS_ACTOR(inSender)); stage=NULL; /* Build text to display */ va_start(args, inFormat); text=g_strdup_vprintf(inFormat, args); va_end(args); /* Get stage of sending actor if available */ if(inSender) stage=XFDASHBOARD_STAGE(clutter_actor_get_stage(inSender)); /* No sending actor specified or no stage found so get default stage */ if(!stage) { XfdashboardCssSelector *selector; /* Traverse through actors to find stage */ selector=xfdashboard_css_selector_new_from_string("XfdashboardStageInterface"); xfdashboard_traverse_actor(NULL, selector, _xfdashboard_notify_traverse_callback, &stage); g_object_unref(selector); /* If we still do not have found a stage to show notification * stop further processing and show notification text as a critical * warning in addition to the critical warning that we could not * find any stage. */ if(!stage) { g_critical(_("Could find any stage to show notification: %s"), text); } } /* Show notification on stage (if any found) */ if(stage) xfdashboard_stage_show_notification(stage, inIconName, text); /* Release allocated resources */ g_free(text); }
/** * xfdashboard_notify: * @inSender: The sending #ClutterActor or %NULL * @inIconName: The icon name to display in notification or %NULL * @inFormat: A standard printf() format string for notification text * @...: The parameters to insert into the format string * * Shows a notification with the formatted text as specified in @inFormat * and the parameters at the monitor where the sending actor @inSender * is placed on. * * If @inSender is NULL the primary monitor is used. * * If @inIconName is NULL no icon will be shown in notification. */ void xfdashboard_notify(ClutterActor *inSender, const gchar *inIconName, const gchar *inFormat, ...) { XfdashboardStage *stage; ClutterStageManager *stageManager; va_list args; gchar *text; g_return_if_fail(inSender==NULL || CLUTTER_IS_ACTOR(inSender)); stage=NULL; /* Build text to display */ va_start(args, inFormat); text=g_strdup_vprintf(inFormat, args); va_end(args); /* Get stage of sending actor if available */ if(inSender) stage=XFDASHBOARD_STAGE(clutter_actor_get_stage(inSender)); /* No sending actor specified or no stage found so get default stage */ if(!stage) { const GSList *stages; const GSList *stagesIter; ClutterActorIter interfaceIter; ClutterActor *child; XfdashboardWindowTrackerMonitor *stageMonitor; /* Get stage manager to iterate through stages to find the one * for primary monitor or at least the first stage. */ stageManager=clutter_stage_manager_get_default(); /* Find stage for primary monitor and if we cannot find it * use first stage. */ if(stageManager && CLUTTER_IS_STAGE_MANAGER(stageManager)) { /* Get list of all stages */ stages=clutter_stage_manager_peek_stages(stageManager); /* Iterate through list of all stage and lookup the one for * primary monitor. */ for(stagesIter=stages; stagesIter && !stage; stagesIter=stagesIter->next) { /* Skip this stage if it is not a XfdashboardStage */ if(!XFDASHBOARD_IS_STAGE(stagesIter->data)) continue; /* Iterate through stage's children and lookup stage interfaces */ clutter_actor_iter_init(&interfaceIter, CLUTTER_ACTOR(stagesIter->data)); while(clutter_actor_iter_next(&interfaceIter, &child)) { if(XFDASHBOARD_IS_STAGE_INTERFACE(child)) { stageMonitor=xfdashboard_stage_interface_get_monitor(XFDASHBOARD_STAGE_INTERFACE(child)); if(xfdashboard_window_tracker_monitor_is_primary(stageMonitor)) { stage=XFDASHBOARD_STAGE(clutter_actor_get_stage(child)); } } } } /* If we did not get stage for primary monitor use first stage */ if(!stage && stages) { stage=XFDASHBOARD_STAGE(stages->data); } } /* If we still do not have found a stage to show notification * stop further processing and show notification text as a critical * warning in addition to the critical warning that we could not * find any stage. */ if(!stage) { g_critical(_("Could find any stage to show notification: %s"), text); } } /* Show notification on stage (if any found) */ if(stage) xfdashboard_stage_show_notification(stage, inIconName, text); /* Release allocated resources */ g_free(text); }