예제 #1
0
/* Called when a new view was added to viewpad */
static void _xfdashboard_view_selector_on_view_added(XfdashboardViewSelector *self,
														XfdashboardView *inView,
														gpointer inUserData)
{
	XfdashboardViewSelectorPrivate		*priv;
	ClutterActor						*button;
	gchar								*viewName;
	const gchar							*viewIcon;
	gboolean							isActive;
	ClutterAction						*action;

	g_return_if_fail(XFDASHBOARD_IS_VIEW_SELECTOR(self));
	g_return_if_fail(XFDASHBOARD_IS_VIEW(inView));

	priv=self->priv;

	/* Create button for newly added view */
	viewName=g_markup_printf_escaped("%s", xfdashboard_view_get_name(inView));
	viewIcon=xfdashboard_view_get_icon(inView);

	button=xfdashboard_toggle_button_new_full_with_icon_name(viewIcon, viewName);
	xfdashboard_toggle_button_set_auto_toggle(XFDASHBOARD_TOGGLE_BUTTON(button), FALSE);
	g_object_set_data(G_OBJECT(button), "view", inView);
	g_signal_connect_swapped(button, "clicked", G_CALLBACK(_xfdashboard_view_selector_on_view_button_clicked), self);

	/* Set toggle state depending of if view is active or not and connect
	 * signal to get notified if toggle state changes to proxy signal
	 */
	g_signal_connect_swapped(button, "toggled", G_CALLBACK(_xfdashboard_view_selector_on_toggle_button_state_changed), self);

	isActive=(xfdashboard_viewpad_get_active_view(priv->viewpad)==inView);
	xfdashboard_toggle_button_set_toggle_state(XFDASHBOARD_TOGGLE_BUTTON(button), isActive);

	/* Add tooltip */
	action=xfdashboard_tooltip_action_new();
	xfdashboard_tooltip_action_set_text(XFDASHBOARD_TOOLTIP_ACTION(action), viewName);
	clutter_actor_add_action(button, action);

	/* If view is disabled hide button otherwise show and connect signals
	 * to get notified if enabled state has changed
	 */
	if(!xfdashboard_view_get_enabled(inView)) clutter_actor_hide(button);
		else clutter_actor_show(button);

	g_signal_connect(inView, "disabled", G_CALLBACK(_xfdashboard_view_selector_on_view_enable_state_changed), button);
	g_signal_connect(inView, "enabled", G_CALLBACK(_xfdashboard_view_selector_on_view_enable_state_changed), button);
	g_signal_connect(inView, "activated", G_CALLBACK(_xfdashboard_view_selector_on_view_activated), button);
	g_signal_connect(inView, "deactivated", G_CALLBACK(_xfdashboard_view_selector_on_view_deactivated), button);
	g_signal_connect(inView, "icon-changed", G_CALLBACK(_xfdashboard_view_selector_on_view_icon_changed), button);
	g_signal_connect(inView, "name-changed", G_CALLBACK(_xfdashboard_view_selector_on_view_name_changed), action);

	/* Add button as child actor */
	clutter_actor_add_child(CLUTTER_ACTOR(self), button);

	/* Release allocated resources */
	g_free(viewName);
}
예제 #2
0
파일: view.c 프로젝트: paulmadore/luckyde
/* 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);
}
예제 #3
0
파일: view.c 프로젝트: paulmadore/luckyde
/* 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);
}