/* Lookup named theme and load resources */ gboolean xfdashboard_theme_load(XfdashboardTheme *self, GError **outError) { XfdashboardThemePrivate *priv; GError *error; g_return_val_if_fail(XFDASHBOARD_IS_THEME(self), FALSE); g_return_val_if_fail(outError==NULL || *outError==NULL, FALSE); priv=self->priv; error=NULL; /* Check if a theme was already loaded */ if(priv->loaded) { g_set_error(outError, XFDASHBOARD_THEME_ERROR, XFDASHBOARD_THEME_ERROR_ALREADY_LOADED, _("Theme '%s' was already loaded"), priv->themeName); return(FALSE); } /* We set the loaded flag regardless if loading will be successful or not * because if loading theme fails this object is in undefined state for * re-using it to load theme again. */ priv->loaded=TRUE; /* Load theme key file */ if(!_xfdashboard_theme_load_resources(self, &error)) { /* Set returned error */ g_propagate_error(outError, error); /* Return FALSE to indicate error */ return(FALSE); } /* If we found named themed and could load all resources successfully */ return(TRUE); }
/* Lookup named theme and load resources */ gboolean xfdashboard_theme_load(XfdashboardTheme *self, const gchar *inThemeName, GError **outError) { XfdashboardThemePrivate *priv; GError *error; gchar *themePath; g_return_val_if_fail(XFDASHBOARD_IS_THEME(self), FALSE); g_return_val_if_fail(inThemeName!=NULL && *inThemeName!=0, FALSE); g_return_val_if_fail(outError==NULL || *outError==NULL, FALSE); priv=self->priv; error=NULL; /* Freeze notifications about property changes and collect them */ g_object_freeze_notify(G_OBJECT(self)); /* Check if a theme was already loaded */ if(priv->themeName) { g_set_error(outError, XFDASHBOARD_THEME_ERROR, XFDASHBOARD_THEME_ERROR_ALREADY_LOADED, _("Theme '%s' requested but '%s' was already loaded"), inThemeName, priv->themeName); /* Thaw notifications and send them now */ g_object_thaw_notify(G_OBJECT(self)); return(FALSE); } /* Lookup path of theme by lookup at all possible paths for theme file */ themePath=_xfdashboard_theme_lookup_path_for_theme(self, inThemeName); if(!themePath) { g_set_error(outError, XFDASHBOARD_THEME_ERROR, XFDASHBOARD_THEME_ERROR_THEME_NOT_FOUND, _("Theme '%s' not found"), inThemeName); /* Thaw notifications and send them now */ g_object_thaw_notify(G_OBJECT(self)); /* Return FALSE to indicate error */ return(FALSE); } /* Load theme key file */ if(!_xfdashboard_theme_load_resources(self, themePath, &error)) { /* Set returned error */ g_propagate_error(outError, error); /* Release allocated resources */ if(themePath) g_free(themePath); /* Thaw notifications and send them now */ g_object_thaw_notify(G_OBJECT(self)); /* Return FALSE to indicate error */ return(FALSE); } /* Set up internal variables because theme was loaded successfully * and notify about property changes */ priv->themePath=g_strdup(themePath); g_object_notify_by_pspec(G_OBJECT(self), XfdashboardThemeProperties[PROP_PATH]); priv->themeName=g_strdup(inThemeName); g_object_notify_by_pspec(G_OBJECT(self), XfdashboardThemeProperties[PROP_NAME]); /* Release allocated resources */ if(themePath) g_free(themePath); /* Thaw notifications and send them now */ g_object_thaw_notify(G_OBJECT(self)); /* If we found named themed and could load all resources successfully */ return(TRUE); }