/* Plugin enable function */ static void plugin_enable(XfdashboardPlugin *self, gpointer inUserData) { XfdashboardViewManager *viewManager; /* Register view */ viewManager=xfdashboard_view_manager_get_default(); xfdashboard_view_manager_register(viewManager, PLUGIN_ID, XFDASHBOARD_TYPE_CLOCK_VIEW); g_object_unref(viewManager); }
/* 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); }