/* Callback function for xfdashboard_traverse_actor() to find stage interface * used in xfdashboard_notify(). */ static gboolean _xfdashboard_notify_traverse_callback(ClutterActor *inActor, gpointer inUserData) { XfdashboardStage **outStageInterface; XfdashboardWindowTrackerMonitor *stageMonitor; g_return_val_if_fail(CLUTTER_IS_ACTOR(inActor), XFDASHBOARD_TRAVERSAL_CONTINUE); g_return_val_if_fail(inUserData, XFDASHBOARD_TRAVERSAL_CONTINUE); outStageInterface=(XfdashboardStage**)inUserData; /* If actor currently traverse is a stage interface then store * the actor in user-data and stop further traversal. */ if(XFDASHBOARD_IS_STAGE_INTERFACE(inActor)) { stageMonitor=xfdashboard_stage_interface_get_monitor(XFDASHBOARD_STAGE_INTERFACE(inActor)); if(xfdashboard_window_tracker_monitor_is_primary(stageMonitor)) { *outStageInterface=XFDASHBOARD_STAGE(clutter_actor_get_stage(inActor)); return(XFDASHBOARD_TRAVERSAL_STOP); } } /* If we get here a stage interface was not found so continue traversal */ return(XFDASHBOARD_TRAVERSAL_CONTINUE); }
/* Monitor changed primary state */ static void _xfdashboard_stage_interface_on_primary_changed(XfdashboardStageInterface *self, gpointer inUserData) { XfdashboardStageInterfacePrivate *priv; gboolean isPrimary; g_return_if_fail(XFDASHBOARD_IS_STAGE_INTERFACE(self)); priv=self->priv; /* Get new primary state of monitor */ isPrimary=xfdashboard_window_tracker_monitor_is_primary(priv->monitor); /* Depending on primary state set CSS class */ if(isPrimary) xfdashboard_stylable_add_class(XFDASHBOARD_STYLABLE(self), "primary-monitor"); else xfdashboard_stylable_remove_class(XFDASHBOARD_STYLABLE(self), "primary-monitor"); XFDASHBOARD_DEBUG(self, ACTOR, "Stage interface changed primary state to %s because of monitor %d", xfdashboard_window_tracker_monitor_is_primary(priv->monitor) ? "primary" : "non-primary", xfdashboard_window_tracker_monitor_get_number(priv->monitor)); }
/* Monitor size changed */ static void _xfdashboard_stage_interface_on_geometry_changed(XfdashboardStageInterface *self, gpointer inUserData) { XfdashboardStageInterfacePrivate *priv; gint x, y, w, h; g_return_if_fail(XFDASHBOARD_IS_STAGE_INTERFACE(self)); priv=self->priv; /* Resize actor to new monitor */ xfdashboard_window_tracker_monitor_get_geometry(priv->monitor, &x, &y, &w, &h); clutter_actor_set_position(CLUTTER_ACTOR(self), x, y); clutter_actor_set_size(CLUTTER_ACTOR(self), w, h); XFDASHBOARD_DEBUG(self, ACTOR, "Stage interface moved to %d,%d and resized to %dx%d because %s monitor %d changed geometry", x, y, w, h, xfdashboard_window_tracker_monitor_is_primary(priv->monitor) ? "primary" : "non-primary", xfdashboard_window_tracker_monitor_get_number(priv->monitor)); }
/** * 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); }