/* * e-ui-manager.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with the program; if not, see * */ #include "e-ui-manager.h" #include "e-util-private.h" #include #define E_UI_MANAGER_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_UI_MANAGER, EUIManagerPrivate)) /* * --- NOTE TO SELF --- * * While creating this class I was tempted to add an "id" property which * EPluginUI could extract from a given EUIManager instead of having the * public EPluginUI functions take a separate "id" argument. Seemed like * a nice cleanup until I remembered that an EUIManager instance can have * multiple IDs ("aliases"), as in the case of EShellWindow's UI manager. * So the UI Manager ID and the instance still need to be kept separate. * * Mentioning it here in case I forget why I didn't go through with it. */ struct _EUIManagerPrivate { guint express_mode : 1; }; enum { PROP_0, PROP_EXPRESS_MODE }; static gpointer parent_class; static void ui_manager_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_EXPRESS_MODE: e_ui_manager_set_express_mode ( E_UI_MANAGER (object), g_value_get_boolean (value)); return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void ui_manager_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_EXPRESS_MODE: g_value_set_boolean ( value, e_ui_manager_get_express_mode ( E_UI_MANAGER (object))); return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static gchar * ui_manager_filter_ui (EUIManager *ui_manager, const gchar *ui_definition) { gchar **lines; gchar *filtered; gboolean express_mode; gboolean in_conditional = FALSE; gboolean include = TRUE; gint ii; express_mode = e_ui_manager_get_express_mode (ui_manager); /* * Very simple line based pre-processing based on comments: * \n ... \n\n */ lines = g_strsplit (ui_definition, "\n", -1); for (ii = 0; lines[ii] != NULL; ii++) { gchar *cp; if ((cp = strstr (lines[ii], "