/* Theme's name was set so lookup pathes and initialize but do not load resources */ static void _xfdashboard_theme_set_theme_name(XfdashboardTheme *self, const gchar *inThemeName) { XfdashboardThemePrivate *priv; gchar *themePath; g_return_if_fail(XFDASHBOARD_IS_THEME(self)); g_return_if_fail(inThemeName && *inThemeName); priv=self->priv; /* The theme name must not be set already */ if(priv->themeName) { /* Show error message */ g_critical(_("Cannot change theme name to '%s' because it is already set to '%s'"), inThemeName, priv->themeName); return; } /* 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_critical(_("Theme '%s' not found"), inThemeName); /* Return here because looking up path failed */ return; } /* Set up internal variable and notify about property changes */ priv->themeName=g_strdup(inThemeName); g_object_notify_by_pspec(G_OBJECT(self), XfdashboardThemeProperties[PROP_NAME]); priv->themePath=g_strdup(themePath); g_object_notify_by_pspec(G_OBJECT(self), XfdashboardThemeProperties[PROP_PATH]); /* Initialize theme resources */ priv->styling=xfdashboard_theme_css_new(priv->themePath); priv->layout=xfdashboard_theme_layout_new(); priv->effects=xfdashboard_theme_effects_new(); /* Release allocated resources */ if(themePath) g_free(themePath); }
/* 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); }