/* 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); }
/* Called when the name of a view has changed */ static void _xfdashboard_view_selector_on_view_name_changed(XfdashboardView *inView, const gchar *inName, gpointer inUserData) { XfdashboardTooltipAction *action; g_return_if_fail(XFDASHBOARD_IS_VIEW(inView)); g_return_if_fail(XFDASHBOARD_IS_TOOLTIP_ACTION(inUserData)); action=XFDASHBOARD_TOOLTIP_ACTION(inUserData); xfdashboard_tooltip_action_set_text(action, inName); }
/* Set/get properties */ static void _xfdashboard_tooltip_action_set_property(GObject *inObject, guint inPropID, const GValue *inValue, GParamSpec *inSpec) { XfdashboardTooltipAction *self=XFDASHBOARD_TOOLTIP_ACTION(inObject); switch(inPropID) { case PROP_TOOLTIP_TEXT: xfdashboard_tooltip_action_set_text(self, g_value_get_string(inValue)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec); break; } }