Ejemplo n.º 1
0
/* Determine if actor can get the focus */
static gboolean _xfdashboard_viewpad_focusable_can_focus(XfdashboardFocusable *inFocusable)
{
	XfdashboardViewpad			*self;
	XfdashboardViewpadPrivate	*priv;
	gboolean					canFocus;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_VIEWPAD(inFocusable), FALSE);

	self=XFDASHBOARD_VIEWPAD(inFocusable);
	priv=self->priv;

	/* Set current focusable result to FALSE (not focusable). It will be set
	 * to TRUE automatically if current active view is focusable and its
	 * virtual function will also return TRUE.
	 */
	canFocus=FALSE;

	/* Viewpad is just a proxy for the current active view.
	 * So check if current active view is focusable and call its
	 * virtual function.
	 */
	if(priv->activeView &&
		XFDASHBOARD_IS_FOCUSABLE(priv->activeView))
	{
		canFocus=xfdashboard_focusable_can_focus(XFDASHBOARD_FOCUSABLE(priv->activeView));
	}

	/* Return focusable state */
	return(canFocus);
}
Ejemplo n.º 2
0
/* Virtual function "handle_key_event" was called */
static gboolean _xfdashboard_viewpad_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
																const ClutterEvent *inEvent)
{
	XfdashboardViewpad			*self;
	XfdashboardViewpadPrivate	*priv;
	gboolean					handledEvent;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(XFDASHBOARD_IS_VIEWPAD(inFocusable), CLUTTER_EVENT_PROPAGATE);

	self=XFDASHBOARD_VIEWPAD(inFocusable);
	priv=self->priv;

	/* Set handled key eventto CLUTTER_EVENT_PROPAGATE. It might be set to
	 * CLUTTER_EVENT_STOP if current active view is focusable and it handled
	 * the key event by its virtual function.
	 */
	handledEvent=CLUTTER_EVENT_PROPAGATE;

	/* Viewpad is just a proxy for the current active view.
	 * So check if current active view is focusable and call its
	 * virtual function.
	 */
	if(priv->activeView &&
		XFDASHBOARD_IS_FOCUSABLE(priv->activeView))
	{
		handledEvent=xfdashboard_focusable_handle_key_event(XFDASHBOARD_FOCUSABLE(priv->activeView), inEvent);
	}

	/* Return focusable state */
	return(handledEvent);
}
Ejemplo n.º 3
0
/* Unset focus from actor */
static void _xfdashboard_viewpad_focusable_unset_focus(XfdashboardFocusable *inFocusable)
{
	XfdashboardViewpad				*self;
	XfdashboardViewpadPrivate		*priv;
	XfdashboardFocusableInterface	*selfIface;
	XfdashboardFocusableInterface	*parentIface;

	g_return_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable));
	g_return_if_fail(XFDASHBOARD_IS_VIEWPAD(inFocusable));

	self=XFDASHBOARD_VIEWPAD(inFocusable);
	priv=self->priv;

	/* Viewpad is just a proxy for the current active view.
	 * So check if current active view is focusable and call its
	 * virtual function.
	 */
	if(priv->activeView &&
		XFDASHBOARD_IS_FOCUSABLE(priv->activeView))
	{
		/* Call virtual function of view to unset focus */
		xfdashboard_focusable_unset_focus(XFDASHBOARD_FOCUSABLE(priv->activeView));

		/* Call parent class interface function of this actor */
		selfIface=XFDASHBOARD_FOCUSABLE_GET_IFACE(inFocusable);
		parentIface=g_type_interface_peek_parent(selfIface);

		if(parentIface && parentIface->unset_focus)
		{
			parentIface->unset_focus(inFocusable);
		}
	}
}
Ejemplo n.º 4
0
/* Unset focus from actor */
static void _xfdashboard_text_box_focusable_unset_focus(XfdashboardFocusable *inFocusable)
{
	ClutterActor					*self;
	XfdashboardFocusableInterface	*selfIface;
	XfdashboardFocusableInterface	*parentIface;
	ClutterStage					*stage;

	g_return_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable));
	g_return_if_fail(XFDASHBOARD_IS_ACTOR(inFocusable));

	self=CLUTTER_ACTOR(inFocusable);

	/* Call parent class interface function */
	selfIface=XFDASHBOARD_FOCUSABLE_GET_IFACE(inFocusable);
	parentIface=g_type_interface_peek_parent(selfIface);

	if(parentIface && parentIface->unset_focus)
	{
		parentIface->unset_focus(inFocusable);
	}

	/* Get stage of actor to tell it where the keyboard focus to set to */
	stage=CLUTTER_STAGE(clutter_actor_get_stage(self));
	if(!stage)
	{
		g_warning(_("Focusable actor %s is not on a stage"),
					G_OBJECT_TYPE_NAME(self));
		return;
	}

	clutter_stage_set_key_focus(stage, NULL);
}
Ejemplo n.º 5
0
/* Action signal to move selection was emitted */
static gboolean _xfdashboard_focusable_selection_move_to_direction(XfdashboardFocusable *self,
																	XfdashboardFocusable *inSource,
																	const gchar *inAction,
																	ClutterEvent *inEvent,
																	XfdashboardSelectionTarget inDirection)
{
	ClutterActor				*currentSelection;
	ClutterActor				*newSelection;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(inEvent, CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(inDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT, CLUTTER_EVENT_PROPAGATE);

	/* Check for key press or release event */
	if(clutter_event_type(inEvent)!=CLUTTER_KEY_PRESS &&
		clutter_event_type(inEvent)!=CLUTTER_KEY_RELEASE)
	{
		return(CLUTTER_EVENT_PROPAGATE);
	}

	/* If focusable actor does not support selections return here with event unhandled */
	if(!xfdashboard_focusable_supports_selection(self)) return(CLUTTER_EVENT_PROPAGATE);

	/* Find new selection */
	currentSelection=xfdashboard_focusable_get_selection(self);
	newSelection=xfdashboard_focusable_find_selection(self, currentSelection, inDirection);

	/* Set new selection */
	xfdashboard_focusable_set_selection(self, newSelection);

	/* All done so return and stop further processing of this action */
	return(CLUTTER_EVENT_STOP);
}
Ejemplo n.º 6
0
/* Call virtual function "activate_selection" */
gboolean xfdashboard_focusable_activate_selection(XfdashboardFocusable *self, ClutterActor *inSelection)
{
	XfdashboardFocusableInterface		*iface;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), FALSE);
	g_return_val_if_fail(CLUTTER_IS_ACTOR(inSelection), FALSE);

	iface=XFDASHBOARD_FOCUSABLE_GET_IFACE(self);

	/* If this focusable actor does not support selection we should ask for
	 * the current selection and avoid the warning being printed if this
	 * virtual function was not overridden.
	 */
	if(!xfdashboard_focusable_supports_selection(self)) return(FALSE);

	/* Call virtual function */
	if(iface->activate_selection)
	{
		return(iface->activate_selection(self, inSelection));
	}

	/* If we get here the virtual function was not overridden */
	XFDASHBOARD_FOCUSABLE_WARN_NOT_IMPLEMENTED(self, "activate_selection");
	return(FALSE);
}
Ejemplo n.º 7
0
/* Default implementation of virtual function "activate_selection" */
static gboolean _xfdashboard_focusable_real_activate_selection(XfdashboardFocusable *self, ClutterActor *inSelection)
{
	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), FALSE);

	/* By default (if not overidden) this actor cannot activate any selection */
	return(FALSE);
}
Ejemplo n.º 8
0
/* Default implementation of virtual function "supports_selection" */
static gboolean _xfdashboard_focusable_real_supports_selection(XfdashboardFocusable *self)
{
	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), FALSE);

	/* By default (if not overidden) this actor does not support selection */
	return(FALSE);
}
Ejemplo n.º 9
0
/* Call virtual function "find_selection" */
ClutterActor* xfdashboard_focusable_find_selection(XfdashboardFocusable *self, ClutterActor *inSelection, XfdashboardSelectionTarget inDirection)
{
	XfdashboardFocusableInterface		*iface;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), NULL);
	g_return_val_if_fail(!inSelection || CLUTTER_IS_ACTOR(inSelection), NULL);
	g_return_val_if_fail(inDirection>XFDASHBOARD_SELECTION_TARGET_NONE, NULL);
	g_return_val_if_fail(inDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT, NULL);

	iface=XFDASHBOARD_FOCUSABLE_GET_IFACE(self);

	/* If this focusable actor does not support selection we should ask for
	 * the current selection and avoid the warning being printed if this
	 * virtual function was not overridden.
	 */
	if(!xfdashboard_focusable_supports_selection(self)) return(NULL);

	/* Call virtual function */
	if(iface->find_selection)
	{
		return(iface->find_selection(self, inSelection, inDirection));
	}

	/* If we get here the virtual function was not overridden */
	XFDASHBOARD_FOCUSABLE_WARN_NOT_IMPLEMENTED(self, "find_selection");
	return(NULL);
}
Ejemplo n.º 10
0
/* Default implementation of virtual function "can_focus" */
static gboolean _xfdashboard_focusable_real_can_focus(XfdashboardFocusable *self)
{
	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), FALSE);

	/* By default (if not overidden) an focusable actor cannot be focused */
	return(FALSE);
}
Ejemplo n.º 11
0
/* Check if this focusable actor has the focus */
static gboolean _xfdashboard_focusable_has_focus(XfdashboardFocusable *self)
{
	XfdashboardFocusManager		*focusManager;
	gboolean					hasFocus;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), FALSE);

	hasFocus=FALSE;

	/* Ask focus manager which actor has the current focus and
	 * check if it is this focusable actor.
	 */
	focusManager=xfdashboard_focus_manager_get_default();
	hasFocus=xfdashboard_focus_manager_has_focus(focusManager, self);
	g_object_unref(focusManager);

	/* If focus manager says this focusable has not the focus then
	 * it might a proxy who has the focus (as seen by focus manager)
	 * but in real this focusable actor is the destination of the
	 * proxy so check for style class "focus" being set.
	 */
	if(!hasFocus &&
		XFDASHBOARD_IS_STYLABLE(self) &&
		xfdashboard_stylable_has_class(XFDASHBOARD_STYLABLE(self), "focus"))
	{
		hasFocus=TRUE;
	}

	return(hasFocus);
}
Ejemplo n.º 12
0
/* Determine if this actor supports selection */
static gboolean _xfdashboard_action_button_focusable_supports_selection(XfdashboardFocusable *inFocusable)
{
	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_ACTION_BUTTON(inFocusable), FALSE);

	/* This actor supports selection */
	return(TRUE);
}
Ejemplo n.º 13
0
/* Determine if this actor supports selection */
static gboolean _xfdashboard_workspace_selector_focusable_supports_selection(XfdashboardFocusable *inFocusable)
{
	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(inFocusable), FALSE);

	/* This actor supports selection */
	return(TRUE);
}
Ejemplo n.º 14
0
/* Get current selection */
static ClutterActor* _xfdashboard_action_button_focusable_get_selection(XfdashboardFocusable *inFocusable)
{
	XfdashboardActionButton		*self;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), NULL);
	g_return_val_if_fail(XFDASHBOARD_IS_ACTION_BUTTON(inFocusable), NULL);

	self=XFDASHBOARD_ACTION_BUTTON(inFocusable);

	/* Return the actor itself as current selection */
	return(CLUTTER_ACTOR(self));
}
Ejemplo n.º 15
0
/* Unset focus from actor */
static void _xfdashboard_actor_focusable_unset_focus(XfdashboardFocusable *self)
{
	XfdashboardActor	*actor;

	g_return_if_fail(XFDASHBOARD_IS_FOCUSABLE(self));
	g_return_if_fail(XFDASHBOARD_IS_ACTOR(self));

	actor=XFDASHBOARD_ACTOR(self);

	/* Set focus and style for focus */
	xfdashboard_stylable_remove_class(XFDASHBOARD_STYLABLE(actor), "focus");
}
Ejemplo n.º 16
0
/* Determine if a specific actor has the focus */
gboolean xfdashboard_focus_manager_has_focus(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable)
{
	XfdashboardFocusManagerPrivate	*priv;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUS_MANAGER(self), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);

	priv=self->priv;

	/* Return TRUE if given actor has the focus otherwise return FALSE */
	return(priv->currentFocus==inFocusable ? TRUE : FALSE);
}
Ejemplo n.º 17
0
/* A registered focusable actor is going to be destroyed so unregister it */
static void _xfdashboard_focus_manager_on_focusable_destroy(XfdashboardFocusManager *self,
															gpointer inUserData)
{
	XfdashboardFocusable			*focusable;

	g_return_if_fail(XFDASHBOARD_IS_FOCUS_MANAGER(self));
	g_return_if_fail(XFDASHBOARD_IS_FOCUSABLE(inUserData));

	focusable=XFDASHBOARD_FOCUSABLE(inUserData);

	/* Unregister going-to-be-destroyed focusable actor */
	xfdashboard_focus_manager_unregister(self, focusable);
}
Ejemplo n.º 18
0
/* Find previous focusable actor from given focusable actor */
XfdashboardFocusable* xfdashboard_focus_manager_get_previous_focusable(XfdashboardFocusManager *self,
																		XfdashboardFocusable *inBeginFocusable)
{
	XfdashboardFocusManagerPrivate	*priv;
	GList							*startIteration;
	GList							*iter;
	XfdashboardFocusable			*focusable;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUS_MANAGER(self), NULL);
	g_return_val_if_fail(!inBeginFocusable || XFDASHBOARD_IS_FOCUSABLE(inBeginFocusable), NULL);

	priv=self->priv;
	startIteration=NULL;

	/* Find starting point of iteration.
	 * If starting focusable actor for search for next focusable actor is NULL
	 * or if it is not registered start search at begin of list of focusable actors.
	 */
	if(inBeginFocusable) startIteration=g_list_find(priv->registeredFocusables, inBeginFocusable);
	if(startIteration) startIteration=g_list_previous(startIteration);
		else startIteration=priv->registeredFocusables;

	/* Iterate reverse through list of registered focusable actors beginning
	 * at given focusable actor (might be begin of this list) and return
	 * the first focusable actor which can be focused.
	 */
	for(iter=startIteration; iter; iter=g_list_previous(iter))
	{
		focusable=(XfdashboardFocusable*)iter->data;

		/* If focusable can be focused then return it */
		if(xfdashboard_focusable_can_focus(focusable)) return(focusable);
	}

	/* If we get here we have to continue search at the end of list
	 * of registered focusable actors. Iterate reverse through list of
	 * registered focusable actors from the beginning of that list up
	 * to the given focusable actor and return the first focusable actor
	 * which is focusable.
	 */
	for(iter=g_list_last(priv->registeredFocusables); iter!=startIteration; iter=g_list_previous(iter))
	{
		focusable=(XfdashboardFocusable*)iter->data;

		/* If focusable can be focused then return it */
		if(xfdashboard_focusable_can_focus(focusable)) return(focusable);
	}

	/* If we get here we could not find next focusable actor */
	return(NULL);
}
Ejemplo n.º 19
0
/* Check if given focusable actor is registered */
gboolean xfdashboard_focus_manager_is_registered(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable)
{
	XfdashboardFocusManagerPrivate	*priv;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUS_MANAGER(self), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);

	priv=self->priv;

	/* If given focusable actor is in list of registered ones return TRUE */
	if(g_list_find(priv->registeredFocusables, inFocusable)!=NULL) return(TRUE);

	/* If here get here the given focusable actor is not registered */
	return(FALSE);
}
Ejemplo n.º 20
0
/* Call virtual function "set_focus" */
void xfdashboard_focusable_set_focus(XfdashboardFocusable *self)
{
	XfdashboardFocusableInterface		*iface;
	ClutterActor						*selection;

	g_return_if_fail(XFDASHBOARD_IS_FOCUSABLE(self));

	iface=XFDASHBOARD_FOCUSABLE_GET_IFACE(self);

	/* Call virtual function */
	if(iface->set_focus)
	{
		iface->set_focus(self);
	}

	/* Style newly focused actor */
	if(XFDASHBOARD_IS_STYLABLE(self))
	{
		xfdashboard_stylable_add_class(XFDASHBOARD_STYLABLE(self), "focus");
	}

	/* If actor supports selection get current selection and style it */
	if(xfdashboard_focusable_supports_selection(self))
	{
		/* Get current selection. If no selection is available then select first item. */
		selection=xfdashboard_focusable_get_selection(self);
		if(!selection)
		{
			selection=xfdashboard_focusable_find_selection(self, NULL, XFDASHBOARD_SELECTION_TARGET_FIRST);
			if(selection) xfdashboard_focusable_set_selection(self, selection);
		}

		/* Style selection if available */
		if(selection &&
			XFDASHBOARD_IS_STYLABLE(selection))
		{
			xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(selection), "selected");
		}

		g_debug("Set selection to %s for focused actor %s",
				G_OBJECT_TYPE_NAME(self),
				selection ? G_OBJECT_TYPE_NAME(selection) : "<nil>");
	}

	/* Emit signal */
	g_signal_emit(self, XfdashboardFocusableSignals[SIGNAL_FOCUS_GAINED], 0, self);
	g_debug("Emitted signal 'focus-gained' for focused actor %s", G_OBJECT_TYPE_NAME(self));
}
Ejemplo n.º 21
0
/* Activate selection */
static gboolean _xfdashboard_action_button_focusable_activate_selection(XfdashboardFocusable *inFocusable,
																		ClutterActor *inSelection)
{
	XfdashboardActionButton				*self;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_ACTION_BUTTON(inFocusable), FALSE);
	g_return_val_if_fail(CLUTTER_IS_ACTOR(inSelection), FALSE);

	self=XFDASHBOARD_ACTION_BUTTON(inFocusable);

	/* Activate selection */
	_xfdashboard_action_button_clicked(XFDASHBOARD_BUTTON(self));

	return(TRUE);
}
Ejemplo n.º 22
0
/* Activate selection */
static gboolean _xfdashboard_workspace_selector_focusable_activate_selection(XfdashboardFocusable *inFocusable,
																				ClutterActor *inSelection)
{
	XfdashboardWorkspaceSelector			*self;
	XfdashboardLiveWorkspace				*actor;
	XfdashboardWindowTrackerWorkspace		*workspace;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_LIVE_WORKSPACE(inSelection), FALSE);

	self=XFDASHBOARD_WORKSPACE_SELECTOR(inFocusable);
	actor=XFDASHBOARD_LIVE_WORKSPACE(inSelection);
	workspace=NULL;

	/* Check that selection is a child of this actor */
	if(!xfdashboard_actor_contains_child_deep(CLUTTER_ACTOR(self), inSelection))
	{
		ClutterActor						*parent;

		parent=clutter_actor_get_parent(inSelection);
		g_warning(_("%s is a child of %s and cannot be selected at %s"),
					G_OBJECT_TYPE_NAME(inSelection),
					parent ? G_OBJECT_TYPE_NAME(parent) : "<nil>",
					G_OBJECT_TYPE_NAME(self));
	}

	/* Get workspace of new selection and set new selection*/
	workspace=xfdashboard_live_workspace_get_workspace(actor);
	if(workspace)
	{
		/* Activate workspace */
		xfdashboard_window_tracker_workspace_activate(workspace);

		/* Quit application */
		xfdashboard_application_quit();

		/* Activation was successful */
		return(TRUE);
	}

	/* Activation was unsuccessful if we get here */
	g_warning(_("Could not determine workspace of %s to set selection at %s"),
				G_OBJECT_TYPE_NAME(actor),
				G_OBJECT_TYPE_NAME(self));
	return(FALSE);
}
Ejemplo n.º 23
0
/* Set new selection */
static gboolean _xfdashboard_action_button_focusable_set_selection(XfdashboardFocusable *inFocusable,
																	ClutterActor *inSelection)
{
	XfdashboardActionButton				*self;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_ACTION_BUTTON(inFocusable), FALSE);
	g_return_val_if_fail(!inSelection || CLUTTER_IS_ACTOR(inSelection), FALSE);

	self=XFDASHBOARD_ACTION_BUTTON(inFocusable);

	/* Setting new selection always fails if it is not this actor itself */
	if(inSelection!=CLUTTER_ACTOR(self)) return(FALSE);

	/* Otherwise setting selection was successful because nothing has changed */
	return(TRUE);
}
Ejemplo n.º 24
0
/* Call virtual function "supports_selection" */
gboolean xfdashboard_focusable_supports_selection(XfdashboardFocusable *self)
{
	XfdashboardFocusableInterface		*iface;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), FALSE);

	iface=XFDASHBOARD_FOCUSABLE_GET_IFACE(self);

	/* Call virtual function */
	if(iface->supports_selection)
	{
		return(iface->supports_selection(self));
	}

	/* If we get here the virtual function was not overridden */
	XFDASHBOARD_FOCUSABLE_WARN_NOT_IMPLEMENTED(self, "supports_selection");
	return(FALSE);
}
Ejemplo n.º 25
0
/* Call virtual function "unset_focus" */
void xfdashboard_focusable_unset_focus(XfdashboardFocusable *self)
{
	XfdashboardFocusableInterface		*iface;
	ClutterActor						*selection;

	g_return_if_fail(XFDASHBOARD_IS_FOCUSABLE(self));

	iface=XFDASHBOARD_FOCUSABLE_GET_IFACE(self);

	/* Call virtual function */
	if(iface->unset_focus)
	{
		iface->unset_focus(self);
	}

	/* Remove style from unfocused actor */
	if(XFDASHBOARD_IS_STYLABLE(self))
	{
		xfdashboard_stylable_remove_class(XFDASHBOARD_STYLABLE(self), "focus");
	}

	/* If actor supports selection get current selection and unstyle it */
	if(xfdashboard_focusable_supports_selection(self))
	{
		/* Get current selection */
		selection=xfdashboard_focusable_get_selection(self);

		/* unstyle selection if available */
		if(selection &&
			XFDASHBOARD_IS_STYLABLE(selection))
		{
			xfdashboard_stylable_remove_pseudo_class(XFDASHBOARD_STYLABLE(selection), "selected");
		}

		g_debug("Unstyled selection %s for focus loosing actor %s",
				G_OBJECT_TYPE_NAME(self),
				selection ? G_OBJECT_TYPE_NAME(selection) : "<nil>");
	}

	/* Emit signal */
	g_signal_emit(self, XfdashboardFocusableSignals[SIGNAL_FOCUS_LOST], 0, self);
	g_debug("Emitted signal 'focus-lost' for focused actor %s", G_OBJECT_TYPE_NAME(self));
}
Ejemplo n.º 26
0
/* Find requested selection target depending of current selection */
static ClutterActor* _xfdashboard_action_button_focusable_find_selection(XfdashboardFocusable *inFocusable,
																			ClutterActor *inSelection,
																			XfdashboardSelectionTarget inDirection)
{
	XfdashboardActionButton				*self;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), NULL);
	g_return_val_if_fail(XFDASHBOARD_IS_ACTION_BUTTON(inFocusable), NULL);
	g_return_val_if_fail(!inSelection || CLUTTER_IS_ACTOR(inSelection), NULL);
	g_return_val_if_fail(inDirection>=0 && inDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT, NULL);

	self=XFDASHBOARD_ACTION_BUTTON(inFocusable);

	/* Regardless of "current" selection and direction requested for new selection
	 * we return this actor as new current selection resulting in no change of
	 * selection. It is and will be the actor itself.
	 */
	return(CLUTTER_ACTOR(self));
}
Ejemplo n.º 27
0
/* Determine if view has the focus */
gboolean xfdashboard_view_has_focus(XfdashboardView *self)
{
	XfdashboardViewPrivate		*priv;
	XfdashboardFocusManager		*focusManager;
	XfdashboardViewpad			*viewpad;

	g_return_val_if_fail(XFDASHBOARD_IS_VIEW(self), FALSE);

	priv=self->priv;

	/* The view can only have the focus if this view is enabled, active and
	 * has the current focus.
	 */
	if(!priv->isEnabled)
	{
		return(FALSE);
	}

	viewpad=_xfdashboard_view_find_viewpad(self);
	if(!viewpad)
	{
		return(FALSE);
	}

	if(xfdashboard_viewpad_get_active_view(XFDASHBOARD_VIEWPAD(viewpad))!=self)
	{
		return(FALSE);
	}

	focusManager=xfdashboard_focus_manager_get_default();
	if(!XFDASHBOARD_IS_FOCUSABLE(self) ||
		!xfdashboard_focus_manager_has_focus(focusManager, XFDASHBOARD_FOCUSABLE(self)))
	{
		g_object_unref(focusManager);
		return(FALSE);
	}

	/* Release allocated resources */
	g_object_unref(focusManager);

	/* All tests passed so this view has the focus */
	return(TRUE);
}
Ejemplo n.º 28
0
/* Determine if actor can get the focus */
static gboolean _xfdashboard_action_button_focusable_can_focus(XfdashboardFocusable *inFocusable)
{
	XfdashboardFocusableInterface		*selfIface;
	XfdashboardFocusableInterface		*parentIface;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE);
	g_return_val_if_fail(XFDASHBOARD_IS_ACTION_BUTTON(inFocusable), FALSE);

	/* Call parent class interface function */
	selfIface=XFDASHBOARD_FOCUSABLE_GET_IFACE(inFocusable);
	parentIface=g_type_interface_peek_parent(selfIface);

	if(parentIface && parentIface->can_focus)
	{
		if(!parentIface->can_focus(inFocusable)) return(FALSE);
	}

	/* If we get here this actor can be focused */
	return(TRUE);
}
Ejemplo n.º 29
0
/* Action signal to activate current selection was emitted */
static gboolean _xfdashboard_focusable_selection_activate(XfdashboardFocusable *self,
															XfdashboardFocusable *inSource,
															const gchar *inAction,
															ClutterEvent *inEvent)
{
	ClutterActor		*currentSelection;

	g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(inEvent, CLUTTER_EVENT_PROPAGATE);

	/* Get selection to activate from focusable actio. If no selection is available
	 * return here with event unhandled.
	 */
	currentSelection=xfdashboard_focusable_get_selection(self);
	if(!currentSelection) return(CLUTTER_EVENT_PROPAGATE);

	/* Activate selection */
	xfdashboard_focusable_activate_selection(self, currentSelection);

	/* All done so return and stop further processing of this event */
	return(CLUTTER_EVENT_STOP);
}
Ejemplo n.º 30
0
/* Action signal to close currently selected window was emitted */
static gboolean _xfdashboard_view_activate(XfdashboardView *self,
											XfdashboardFocusable *inSource,
											const gchar *inAction,
											ClutterEvent *inEvent)
{
	XfdashboardViewPrivate		*priv;
	XfdashboardViewpad			*viewpad;
	XfdashboardFocusManager		*focusManager;

	g_return_val_if_fail(XFDASHBOARD_IS_VIEW(self), CLUTTER_EVENT_PROPAGATE);

	priv=self->priv;

	/* Only enabled views can be activated */
	if(!priv->isEnabled) return(CLUTTER_EVENT_STOP);

	/* Find viewpad which contains this view */
	viewpad=_xfdashboard_view_find_viewpad(self);
	if(!viewpad) return(CLUTTER_EVENT_STOP);

	/* Activate view at viewpad if this view is not the active one */
	if(xfdashboard_viewpad_get_active_view(viewpad)!=self)
	{
		xfdashboard_viewpad_set_active_view(viewpad, self);
	}

	/* Set focus to view if it has not the focus */
	focusManager=xfdashboard_focus_manager_get_default();
	if(XFDASHBOARD_IS_FOCUSABLE(self) &&
		!xfdashboard_focus_manager_has_focus(focusManager, XFDASHBOARD_FOCUSABLE(self)))
	{
		xfdashboard_focus_manager_set_focus(focusManager, XFDASHBOARD_FOCUSABLE(self));
	}
	g_object_unref(focusManager);

	/* Action handled */
	return(CLUTTER_EVENT_STOP);
}