/* 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); }
/* Object initialization * Create private structure and set up default values */ static void xfdashboard_action_button_init(XfdashboardActionButton *self) { XfdashboardActionButtonPrivate *priv; priv=self->priv=XFDASHBOARD_ACTION_BUTTON_GET_PRIVATE(self); /* This actor is react on events */ clutter_actor_set_reactive(CLUTTER_ACTOR(self), TRUE); /* Set up default values */ priv->target=NULL; priv->action=FALSE; priv->focusManager=xfdashboard_focus_manager_get_default(); }
/* Actor got key focus */ static void _xfdashboard_text_box_key_focus_in(ClutterActor *inActor) { XfdashboardTextBox *self=XFDASHBOARD_TEXT_BOX(inActor); XfdashboardTextBoxPrivate *priv=self->priv; ClutterStage *stage; XfdashboardFocusManager *focusManager; /* Push key focus forward to text box */ stage=CLUTTER_STAGE(clutter_actor_get_stage(inActor)); clutter_stage_set_key_focus(stage, priv->actorTextBox); /* Update focus in focus manager */ focusManager=xfdashboard_focus_manager_get_default(); xfdashboard_focus_manager_set_focus(focusManager, XFDASHBOARD_FOCUSABLE(self)); g_object_unref(focusManager); }
/* 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); }
/* 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); }
/* Perform full initialization of this application instance */ static gboolean _xfdashboard_application_initialize_full(XfdashboardApplication *self, XfdashboardStage **outStage) { XfdashboardApplicationPrivate *priv; GError *error; ClutterActor *stage; #if !GARCON_CHECK_VERSION(0,3,0) const gchar *desktop; #endif g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(self), FALSE); g_return_val_if_fail(outStage==NULL || *outStage==NULL, FALSE); priv=self->priv; error=NULL; /* Initialize garcon for current desktop environment */ #if !GARCON_CHECK_VERSION(0,3,0) desktop=g_getenv("XDG_CURRENT_DESKTOP"); if(G_LIKELY(desktop==NULL)) { /* If we could not determine current desktop environment * assume Xfce as this application is developed for this DE. */ desktop="XFCE"; } /* If desktop enviroment was found but has no name * set NULL to get all menu items shown. */ else if(*desktop==0) desktop=NULL; garcon_set_environment(desktop); #else garcon_set_environment_xdg(GARCON_ENVIRONMENT_XFCE); #endif /* Setup the session management */ priv->sessionManagementClient=xfce_sm_client_get(); xfce_sm_client_set_priority(priv->sessionManagementClient, XFCE_SM_CLIENT_PRIORITY_DEFAULT); xfce_sm_client_set_restart_style(priv->sessionManagementClient, XFCE_SM_CLIENT_RESTART_IMMEDIATELY); g_signal_connect_swapped(priv->sessionManagementClient, "quit", G_CALLBACK(_xfdashboard_application_on_session_quit), self); if(!xfce_sm_client_connect(priv->sessionManagementClient, &error)) { g_warning("Failed to connect to session manager: %s", (error && error->message) ? error->message : _("unknown error")); g_clear_error(&error); } /* Initialize xfconf */ if(!xfconf_init(&error)) { g_critical(_("Could not initialize xfconf: %s"), (error && error->message) ? error->message : _("unknown error")); if(error) g_error_free(error); return(FALSE); } priv->xfconfChannel=xfconf_channel_get(XFDASHBOARD_XFCONF_CHANNEL); /* Set up keyboard and pointer bindings */ priv->bindings=xfdashboard_bindings_pool_get_default(); if(!priv->bindings) { g_critical(_("Could not initialize bindings")); return(FALSE); } if(!xfdashboard_bindings_pool_load(priv->bindings, &error)) { g_critical(_("Could not load bindings: %s"), (error && error->message) ? error->message : _("unknown error")); if(error!=NULL) g_error_free(error); return(FALSE); } /* Set up application database */ priv->appDatabase=xfdashboard_application_database_get_default(); if(!priv->appDatabase) { g_critical(_("Could not initialize application database")); return(FALSE); } if(!xfdashboard_application_database_load(priv->appDatabase, &error)) { g_critical(_("Could not load application database: %s"), (error && error->message) ? error->message : _("unknown error")); if(error!=NULL) g_error_free(error); return(FALSE); } /* Set up application tracker */ priv->appTracker=xfdashboard_application_tracker_get_default(); if(!priv->appTracker) { g_critical(_("Could not initialize application tracker")); return(FALSE); } /* Set up and load theme */ priv->xfconfThemeChangedSignalID=xfconf_g_property_bind(priv->xfconfChannel, THEME_NAME_XFCONF_PROP, G_TYPE_STRING, self, "theme-name"); if(!priv->xfconfThemeChangedSignalID) { g_warning(_("Could not create binding between xfconf property and local resource for theme change notification.")); } /* Set up default theme in Xfcond if property in channel does not exist * because it indicates first start. */ if(!xfconf_channel_has_property(priv->xfconfChannel, THEME_NAME_XFCONF_PROP)) { xfconf_channel_set_string(priv->xfconfChannel, THEME_NAME_XFCONF_PROP, DEFAULT_THEME_NAME); } /* At this time the theme must have been loaded, either because we * set the default theme name because of missing theme property in * xfconf channel or the value of xfconf channel property has been read * and set when setting up binding (between xfconf property and local property) * what caused a call to function to set theme name in this object * and also caused a reload of theme. * So if no theme object is set in this object then loading theme has * failed and we have to return FALSE. */ if(!priv->theme) return(FALSE); /* Register built-in views (order of registration is important) */ priv->viewManager=xfdashboard_view_manager_get_default(); xfdashboard_view_manager_register(priv->viewManager, XFDASHBOARD_TYPE_WINDOWS_VIEW); xfdashboard_view_manager_register(priv->viewManager, XFDASHBOARD_TYPE_APPLICATIONS_VIEW); xfdashboard_view_manager_register(priv->viewManager, XFDASHBOARD_TYPE_SEARCH_VIEW); /* Register built-in search providers */ priv->searchManager=xfdashboard_search_manager_get_default(); xfdashboard_search_manager_register(priv->searchManager, XFDASHBOARD_TYPE_APPLICATIONS_SEARCH_PROVIDER); /* Create single-instance of focus manager to keep it alive while * application is running. */ priv->focusManager=xfdashboard_focus_manager_get_default(); /* Create stage containing all monitors */ stage=xfdashboard_stage_new(); g_signal_connect_swapped(stage, "delete-event", G_CALLBACK(_xfdashboard_application_on_delete_stage), self); /* Emit signal 'theme-changed' to get current theme loaded at each stage created */ g_signal_emit(self, XfdashboardApplicationSignals[SIGNAL_THEME_CHANGED], 0, priv->theme); /* Set return results */ if(outStage) *outStage=XFDASHBOARD_STAGE(stage); /* Initialization was successful so return TRUE */ #ifdef DEBUG xfdashboard_notify(NULL, NULL, _("Welcome to %s (%s)!"), PACKAGE_NAME, PACKAGE_VERSION); #else xfdashboard_notify(NULL, NULL, _("Welcome to %s!"), PACKAGE_NAME); #endif return(TRUE); }