diff options
118 files changed, 3419 insertions, 19508 deletions
diff --git a/applets/clock/Makefile.am b/applets/clock/Makefile.am index afda6eb2..17dc67e4 100644 --- a/applets/clock/Makefile.am +++ b/applets/clock/Makefile.am @@ -14,15 +14,6 @@ libsystem_timezone_la_SOURCES = \ system-timezone.h libsystem_timezone_la_LIBADD = $(TZ_LIBS) -if HAVE_LIBECAL -CALENDAR_SOURCES = \ - calendar-client.c \ - calendar-client.h \ - calendar-sources.c \ - calendar-sources.h \ - calendar-debug.h -endif - CLOCK_SOURCES = \ calendar-window.c \ calendar-window.h \ @@ -42,8 +33,7 @@ CLOCK_SOURCES = \ clock-utils.h \ set-timezone.c \ set-timezone.h \ - $(BUILT_SOURCES) \ - $(CALENDAR_SOURCES) + $(BUILT_SOURCES) CLOCK_CPPFLAGS = \ $(AM_CPPFLAGS) \ @@ -55,11 +45,10 @@ CLOCK_CPPFLAGS = \ -DBUILDERDIR=\""$(uidir)"\" \ -DCLOCK_MENU_UI_DIR=\""$(xmluidir)"\" \ -DICONDIR=\""$(datadir)/mate-panel/pixmaps"\" \ - -DCLOCK_EDS_ICONDIR="\"$(CLOCK_EDS_ICONDIR)\"" \ -DMATEWEATHER_I_KNOW_THIS_IS_UNSTABLE CLOCK_LDADD = \ - ../../libmate-panel-applet/libmate-panel-applet-3.la \ + ../../libmate-panel-applet/libmate-panel-applet-4.la \ $(CLOCK_LIBS) \ $(LIBMATE_PANEL_APPLET_LIBS) \ libsystem-timezone.la \ @@ -166,28 +155,13 @@ ui_DATA = clock.ui xmluidir = $(datadir)/mate-panel/ui xmlui_DATA = clock-menu.xml -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = clock.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) - -@INTLTOOL_SCHEMAS_RULE@ - -if MATECONF_SCHEMAS_INSTALL -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schemas_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/applets/clock/$$p ; \ - done \ - fi -uninstall-local: - for p in $(schema_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-uninstall-rule $(top_builddir)/applets/clock/$$p ; \ - done -endif +gsettings_SCHEMAS = org.mate.panel.applet.clock.gschema.xml +@INTLTOOL_XML_NOMERGE_RULE@ +@GSETTINGS_RULES@ EXTRA_DIST = \ org.mate.panel.ClockApplet.mate-panel-applet.in.in \ - $(schemas_in_files) \ + $(gsettings_SCHEMAS) \ $(xmlui_DATA) \ $(ui_DATA) \ clock-marshallers.list \ @@ -198,7 +172,6 @@ CLEANFILES = \ $(applet_DATA) \ $(applet_DATA).in \ $(service_DATA) \ - $(schemas_DATA) \ $(polkit_DATA) \ $(dbus_services_DATA) diff --git a/applets/clock/calendar-client.c b/applets/clock/calendar-client.c deleted file mode 100644 index 8619a3b6..00000000 --- a/applets/clock/calendar-client.c +++ /dev/null @@ -1,2171 +0,0 @@ -/* - * Copyright (C) 2004 Free Software Foundation, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - * William Jon McCann <[email protected]> - * Martin Grimme <[email protected]> - * Christian Kellner <[email protected]> - */ - -#include <config.h> - -#include "calendar-client.h" - -#include <mateconf/mateconf-client.h> - -#include <libintl.h> -#include <string.h> -#define HANDLE_LIBICAL_MEMORY -#include <libecal/e-cal.h> -#include <libecal/e-cal-time-util.h> -#include <libecal/e-cal-recur.h> - -#include "calendar-sources.h" - -#undef CALENDAR_ENABLE_DEBUG -#include "calendar-debug.h" - -#define CALENDAR_CONFIG_PREFIX "/apps/evolution/calendar" -#define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone" - -#ifndef _ -#define _(x) gettext(x) -#endif - -#ifndef N_ -#define N_(x) x -#endif - -#define CALENDAR_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_CLIENT, CalendarClientPrivate)) - -typedef struct _CalendarClientQuery CalendarClientQuery; -typedef struct _CalendarClientSource CalendarClientSource; - -struct _CalendarClientQuery -{ - ECalView *view; - GHashTable *events; -}; - -struct _CalendarClientSource -{ - CalendarClient *client; - ECal *source; - - CalendarClientQuery completed_query; - CalendarClientQuery in_progress_query; - - guint changed_signal_id; - - guint query_completed : 1; - guint query_in_progress : 1; -}; - -struct _CalendarClientPrivate -{ - CalendarSources *calendar_sources; - - GSList *appointment_sources; - GSList *task_sources; - - icaltimezone *zone; - - guint zone_listener; - MateConfClient *mateconf_client; - - guint day; - guint month; - guint year; -}; - -static void calendar_client_class_init (CalendarClientClass *klass); -static void calendar_client_init (CalendarClient *client); -static void calendar_client_finalize (GObject *object); -static void calendar_client_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void calendar_client_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static GSList *calendar_client_update_sources_list (CalendarClient *client, - GSList *sources, - GSList *esources, - guint changed_signal_id); -static void calendar_client_appointment_sources_changed (CalendarClient *client); -static void calendar_client_task_sources_changed (CalendarClient *client); - -static void calendar_client_stop_query (CalendarClient *client, - CalendarClientSource *source, - CalendarClientQuery *query); -static void calendar_client_start_query (CalendarClient *client, - CalendarClientSource *source, - const char *query); - -static void calendar_client_source_finalize (CalendarClientSource *source); -static void calendar_client_query_finalize (CalendarClientQuery *query); - -static void -calendar_client_update_appointments (CalendarClient *client); -static void -calendar_client_update_tasks (CalendarClient *client); - -enum -{ - PROP_O, - PROP_DAY, - PROP_MONTH, - PROP_YEAR -}; - -enum -{ - APPOINTMENTS_CHANGED, - TASKS_CHANGED, - LAST_SIGNAL -}; - -static GObjectClass *parent_class = NULL; -static guint signals [LAST_SIGNAL] = { 0, }; - -GType -calendar_client_get_type (void) -{ - static GType client_type = 0; - - if (!client_type) - { - static const GTypeInfo client_info = - { - sizeof (CalendarClientClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) calendar_client_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CalendarClient), - 0, /* n_preallocs */ - (GInstanceInitFunc) calendar_client_init, - }; - - client_type = g_type_register_static (G_TYPE_OBJECT, - "CalendarClient", - &client_info, 0); - } - - return client_type; -} - -static void -calendar_client_class_init (CalendarClientClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->finalize = calendar_client_finalize; - gobject_class->set_property = calendar_client_set_property; - gobject_class->get_property = calendar_client_get_property; - - g_type_class_add_private (klass, sizeof (CalendarClientPrivate)); - - g_object_class_install_property (gobject_class, - PROP_DAY, - g_param_spec_uint ("day", - "Day", - "The currently monitored day between 1 and 31 (0 denotes unset)", - 0, G_MAXUINT, 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_MONTH, - g_param_spec_uint ("month", - "Month", - "The currently monitored month between 0 and 11", - 0, G_MAXUINT, 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_YEAR, - g_param_spec_uint ("year", - "Year", - "The currently monitored year", - 0, G_MAXUINT, 0, - G_PARAM_READWRITE)); - - signals [APPOINTMENTS_CHANGED] = - g_signal_new ("appointments-changed", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalendarClientClass, tasks_changed), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - signals [TASKS_CHANGED] = - g_signal_new ("tasks-changed", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalendarClientClass, tasks_changed), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); -} - -/* Timezone code adapted from evolution/calendar/gui/calendar-config.c */ -/* The current timezone, e.g. "Europe/London". It may be NULL, in which case - you should assume UTC. */ -static gchar * -calendar_client_config_get_timezone (MateConfClient *mateconf_client) -{ - char *location; - - location = mateconf_client_get_string (mateconf_client, - CALENDAR_CONFIG_TIMEZONE, - NULL); - - return location; -} - -static icaltimezone * -calendar_client_config_get_icaltimezone (MateConfClient *mateconf_client) -{ - char *location; - icaltimezone *zone = NULL; - - location = calendar_client_config_get_timezone (mateconf_client); - if (!location) - return icaltimezone_get_utc_timezone (); - - zone = icaltimezone_get_builtin_timezone (location); - g_free (location); - - return zone; -} - -static void -calendar_client_set_timezone (CalendarClient *client) -{ - GSList *l; - GSList *esources; - - client->priv->zone = calendar_client_config_get_icaltimezone (client->priv->mateconf_client); - - esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources); - for (l = esources; l; l = l->next) { - ECal *source = l->data; - - e_cal_set_default_timezone (source, client->priv->zone, NULL); - } -} - -static void -calendar_client_timezone_changed_cb (MateConfClient *mateconf_client, - guint id, - MateConfEntry *entry, - CalendarClient *client) -{ - calendar_client_set_timezone (client); -} - -static void -cal_opened_cb (ECal *ecal, - ECalendarStatus status, - CalendarClientSource *cl_source) -{ - ECalSourceType s_type; - CalendarClient *client = cl_source->client; - - s_type = e_cal_get_source_type (ecal); - - if (status == E_CALENDAR_STATUS_BUSY && - e_cal_get_load_state (ecal) == E_CAL_LOAD_NOT_LOADED) - { - e_cal_open_async (ecal, FALSE); - return; - } - - g_signal_handlers_disconnect_by_func (ecal, cal_opened_cb, cl_source); - - if (status != E_CALENDAR_STATUS_OK) - { - if (s_type == E_CAL_SOURCE_TYPE_EVENT) - client->priv->appointment_sources = g_slist_remove (client->priv->appointment_sources, - cl_source); - else - client->priv->task_sources = g_slist_remove (client->priv->task_sources, - cl_source); - - calendar_client_source_finalize (cl_source); - g_free (cl_source); - - return; - } - - if (s_type == E_CAL_SOURCE_TYPE_EVENT) - calendar_client_update_appointments (client); - else - calendar_client_update_tasks (client); -} - -static void -load_calendars (CalendarClient *client, - CalendarEventType type) -{ - GSList *l, *clients; - - switch (type) - { - case CALENDAR_EVENT_APPOINTMENT: - clients = client->priv->appointment_sources; - break; - case CALENDAR_EVENT_TASK: - clients = client->priv->task_sources; - break; - default: - g_assert_not_reached (); - } - - for (l = clients; l != NULL; l = l->next) - { - ECal *ecal; - CalendarClientSource *cl_source = l->data; - - ecal = cl_source->source; - - if (e_cal_get_load_state (ecal) == E_CAL_LOAD_LOADED) - continue; - - g_signal_connect (G_OBJECT (ecal), "cal_opened", - G_CALLBACK (cal_opened_cb), cl_source); - e_cal_open_async (ecal, TRUE); - } -} - -static void -calendar_client_init (CalendarClient *client) -{ - GSList *esources; - - client->priv = CALENDAR_CLIENT_GET_PRIVATE (client); - - client->priv->calendar_sources = calendar_sources_get (); - client->priv->mateconf_client = mateconf_client_get_default (); - - esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources); - client->priv->appointment_sources = - calendar_client_update_sources_list (client, NULL, esources, signals [APPOINTMENTS_CHANGED]); - - esources = calendar_sources_get_task_sources (client->priv->calendar_sources); - client->priv->task_sources = - calendar_client_update_sources_list (client, NULL, esources, signals [TASKS_CHANGED]); - - /* set the timezone before loading the clients */ - calendar_client_set_timezone (client); - load_calendars (client, CALENDAR_EVENT_APPOINTMENT); - load_calendars (client, CALENDAR_EVENT_TASK); - - g_signal_connect_swapped (client->priv->calendar_sources, - "appointment-sources-changed", - G_CALLBACK (calendar_client_appointment_sources_changed), - client); - g_signal_connect_swapped (client->priv->calendar_sources, - "task-sources-changed", - G_CALLBACK (calendar_client_task_sources_changed), - client); - - mateconf_client_add_dir (client->priv->mateconf_client, - CALENDAR_CONFIG_PREFIX, - MATECONF_CLIENT_PRELOAD_NONE, - NULL); - - client->priv->zone_listener = mateconf_client_notify_add (client->priv->mateconf_client, - CALENDAR_CONFIG_TIMEZONE, - (MateConfClientNotifyFunc) calendar_client_timezone_changed_cb, - client, NULL, NULL); - - client->priv->day = -1; - client->priv->month = -1; - client->priv->year = -1; -} - -static void -calendar_client_finalize (GObject *object) -{ - CalendarClient *client = CALENDAR_CLIENT (object); - GSList *l; - - if (client->priv->zone_listener) - { - mateconf_client_notify_remove (client->priv->mateconf_client, - client->priv->zone_listener); - client->priv->zone_listener = 0; - } - - mateconf_client_remove_dir (client->priv->mateconf_client, - CALENDAR_CONFIG_PREFIX, - NULL); - - if (client->priv->mateconf_client) - g_object_unref (client->priv->mateconf_client); - client->priv->mateconf_client = NULL; - - for (l = client->priv->appointment_sources; l; l = l->next) - { - calendar_client_source_finalize (l->data); - g_free (l->data); - } - g_slist_free (client->priv->appointment_sources); - client->priv->appointment_sources = NULL; - - for (l = client->priv->task_sources; l; l = l->next) - { - calendar_client_source_finalize (l->data); - g_free (l->data); - } - g_slist_free (client->priv->task_sources); - client->priv->task_sources = NULL; - - if (client->priv->calendar_sources) - g_object_unref (client->priv->calendar_sources); - client->priv->calendar_sources = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -calendar_client_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - CalendarClient *client = CALENDAR_CLIENT (object); - - switch (prop_id) - { - case PROP_DAY: - calendar_client_select_day (client, g_value_get_uint (value)); - break; - case PROP_MONTH: - calendar_client_select_month (client, - g_value_get_uint (value), - client->priv->year); - break; - case PROP_YEAR: - calendar_client_select_month (client, - client->priv->month, - g_value_get_uint (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -calendar_client_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - CalendarClient *client = CALENDAR_CLIENT (object); - - switch (prop_id) - { - case PROP_DAY: - g_value_set_uint (value, client->priv->day); - break; - case PROP_MONTH: - g_value_set_uint (value, client->priv->month); - break; - case PROP_YEAR: - g_value_set_uint (value, client->priv->year); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -CalendarClient * -calendar_client_new (void) -{ - return g_object_new (CALENDAR_TYPE_CLIENT, NULL); -} - -/* @day and @month can happily be out of range as - * mktime() will normalize them correctly. From mktime(3): - * - * "If structure members are outside their legal interval, - * they will be normalized (so that, e.g., 40 October is - * changed into 9 November)." - * - * "What?", you say, "Something useful in libc?" - */ -static inline time_t -make_time_for_day_begin (int day, - int month, - int year) -{ - struct tm localtime_tm = { 0, }; - - localtime_tm.tm_mday = day; - localtime_tm.tm_mon = month; - localtime_tm.tm_year = year - 1900; - localtime_tm.tm_isdst = -1; - - return mktime (&localtime_tm); -} - -static inline char * -make_isodate_for_day_begin (int day, - int month, - int year) -{ - time_t utctime; - - utctime = make_time_for_day_begin (day, month, year); - - return utctime != -1 ? isodate_from_time_t (utctime) : NULL; -} - -static time_t -get_time_from_property (icalcomponent *ical, - icalproperty_kind prop_kind, - struct icaltimetype (* get_prop_func) (const icalproperty *prop), - icaltimezone *default_zone) -{ - icalproperty *prop; - struct icaltimetype ical_time; - icalparameter *param; - icaltimezone *timezone = NULL; - - prop = icalcomponent_get_first_property (ical, prop_kind); - if (!prop) - return 0; - - ical_time = get_prop_func (prop); - - param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); - if (param) - timezone = icaltimezone_get_builtin_timezone_from_tzid (icalparameter_get_tzid (param)); - else if (icaltime_is_utc (ical_time)) - timezone = icaltimezone_get_utc_timezone (); - else - timezone = default_zone; - - return icaltime_as_timet_with_zone (ical_time, timezone); -} - -static char * -get_ical_uid (icalcomponent *ical) -{ - return g_strdup (icalcomponent_get_uid (ical)); -} - -static char * -get_ical_rid (icalcomponent *ical) -{ - icalproperty *prop; - struct icaltimetype ical_time; - - prop = icalcomponent_get_first_property (ical, ICAL_RECURRENCEID_PROPERTY); - if (!prop) - return NULL; - - ical_time = icalproperty_get_recurrenceid (prop); - - return icaltime_is_valid_time (ical_time) && !icaltime_is_null_time (ical_time) ? - g_strdup (icaltime_as_ical_string (ical_time)) : NULL; -} - -static char * -get_ical_summary (icalcomponent *ical) -{ - icalproperty *prop; - - prop = icalcomponent_get_first_property (ical, ICAL_SUMMARY_PROPERTY); - if (!prop) - return NULL; - - return g_strdup (icalproperty_get_summary (prop)); -} - -static char * -get_ical_description (icalcomponent *ical) -{ - icalproperty *prop; - - prop = icalcomponent_get_first_property (ical, ICAL_DESCRIPTION_PROPERTY); - if (!prop) - return NULL; - - return g_strdup (icalproperty_get_description (prop)); -} - -static inline time_t -get_ical_start_time (icalcomponent *ical, - icaltimezone *default_zone) -{ - return get_time_from_property (ical, - ICAL_DTSTART_PROPERTY, - icalproperty_get_dtstart, - default_zone); -} - -static inline time_t -get_ical_end_time (icalcomponent *ical, - icaltimezone *default_zone) -{ - return get_time_from_property (ical, - ICAL_DTEND_PROPERTY, - icalproperty_get_dtend, - default_zone); -} - -static gboolean -get_ical_is_all_day (icalcomponent *ical, - time_t start_time, - icaltimezone *default_zone) -{ - icalproperty *prop; - struct tm *start_tm; - time_t end_time; - struct icaldurationtype duration; - struct icaltimetype start_icaltime; - - start_icaltime = icalcomponent_get_dtstart (ical); - if (start_icaltime.is_date) - return TRUE; - - start_tm = gmtime (&start_time); - if (start_tm->tm_sec != 0 || - start_tm->tm_min != 0 || - start_tm->tm_hour != 0) - return FALSE; - - if ((end_time = get_ical_end_time (ical, default_zone))) - return (end_time - start_time) % 86400 == 0; - - prop = icalcomponent_get_first_property (ical, ICAL_DURATION_PROPERTY); - if (!prop) - return FALSE; - - duration = icalproperty_get_duration (prop); - - return icaldurationtype_as_int (duration) % 86400 == 0; -} - -static inline time_t -get_ical_due_time (icalcomponent *ical, - icaltimezone *default_zone) -{ - return get_time_from_property (ical, - ICAL_DUE_PROPERTY, - icalproperty_get_due, - default_zone); -} - -static guint -get_ical_percent_complete (icalcomponent *ical) -{ - icalproperty *prop; - icalproperty_status status; - int percent_complete; - - status = icalcomponent_get_status (ical); - if (status == ICAL_STATUS_COMPLETED) - return 100; - - prop = icalcomponent_get_first_property (ical, ICAL_COMPLETED_PROPERTY); - if (prop) - return 100; - - prop = icalcomponent_get_first_property (ical, ICAL_PERCENTCOMPLETE_PROPERTY); - if (!prop) - return 0; - - percent_complete = icalproperty_get_percentcomplete (prop); - - return CLAMP (percent_complete, 0, 100); -} - -static inline time_t -get_ical_completed_time (icalcomponent *ical, - icaltimezone *default_zone) -{ - return get_time_from_property (ical, - ICAL_COMPLETED_PROPERTY, - icalproperty_get_completed, - default_zone); -} - -static int -get_ical_priority (icalcomponent *ical) -{ - icalproperty *prop; - - prop = icalcomponent_get_first_property (ical, ICAL_PRIORITY_PROPERTY); - if (!prop) - return -1; - - return icalproperty_get_priority (prop); -} - -static char * -get_source_color (ECal *esource) -{ - ESource *source; - - g_return_val_if_fail (E_IS_CAL (esource), NULL); - - source = e_cal_get_source (esource); - - return g_strdup (e_source_peek_color_spec (source)); -} - -static gchar * -get_source_uri (ECal *esource) -{ - ESource *source; - gchar *string; - gchar **list; - - g_return_val_if_fail (E_IS_CAL (esource), NULL); - - source = e_cal_get_source (esource); - string = g_strdup (e_source_get_uri (source)); - if (string) { - list = g_strsplit (string, ":", 2); - g_free (string); - - if (list[0]) { - string = g_strdup (list[0]); - g_strfreev (list); - return string; - } - g_strfreev (list); - } - return NULL; -} - -static inline int -null_safe_strcmp (const char *a, - const char *b) -{ - return (!a && !b) ? 0 : (a && !b) || (!a && b) ? 1 : strcmp (a, b); -} - -static inline gboolean -calendar_appointment_equal (CalendarAppointment *a, - CalendarAppointment *b) -{ - GSList *la, *lb; - - if (g_slist_length (a->occurrences) != g_slist_length (b->occurrences)) - return FALSE; - - for (la = a->occurrences, lb = b->occurrences; la && lb; la = la->next, lb = lb->next) - { - CalendarOccurrence *oa = la->data; - CalendarOccurrence *ob = lb->data; - - if (oa->start_time != ob->start_time || - oa->end_time != ob->end_time) - return FALSE; - } - - return - null_safe_strcmp (a->uid, b->uid) == 0 && - null_safe_strcmp (a->uri, b->uri) == 0 && - null_safe_strcmp (a->summary, b->summary) == 0 && - null_safe_strcmp (a->description, b->description) == 0 && - null_safe_strcmp (a->color_string, b->color_string) == 0 && - a->start_time == b->start_time && - a->end_time == b->end_time && - a->is_all_day == b->is_all_day; -} - -static void -calendar_appointment_copy (CalendarAppointment *appointment, - CalendarAppointment *appointment_copy) -{ - GSList *l; - - g_assert (appointment != NULL); - g_assert (appointment_copy != NULL); - - appointment_copy->occurrences = g_slist_copy (appointment->occurrences); - for (l = appointment_copy->occurrences; l; l = l->next) - { - CalendarOccurrence *occurrence = l->data; - CalendarOccurrence *occurrence_copy; - - occurrence_copy = g_new0 (CalendarOccurrence, 1); - occurrence_copy->start_time = occurrence->start_time; - occurrence_copy->end_time = occurrence->end_time; - - l->data = occurrence_copy; - } - - appointment_copy->uid = g_strdup (appointment->uid); - appointment_copy->uri = g_strdup (appointment->uri); - appointment_copy->summary = g_strdup (appointment->summary); - appointment_copy->description = g_strdup (appointment->description); - appointment_copy->color_string = g_strdup (appointment->color_string); - appointment_copy->start_time = appointment->start_time; - appointment_copy->end_time = appointment->end_time; - appointment_copy->is_all_day = appointment->is_all_day; -} - -static void -calendar_appointment_finalize (CalendarAppointment *appointment) -{ - GSList *l; - - for (l = appointment->occurrences; l; l = l->next) - g_free (l->data); - g_slist_free (appointment->occurrences); - appointment->occurrences = NULL; - - g_free (appointment->uid); - appointment->uid = NULL; - - g_free (appointment->rid); - appointment->rid = NULL; - - g_free (appointment->uri); - appointment->uri = NULL; - - g_free (appointment->summary); - appointment->summary = NULL; - - g_free (appointment->description); - appointment->description = NULL; - - g_free (appointment->color_string); - appointment->color_string = NULL; - - appointment->start_time = 0; - appointment->is_all_day = FALSE; -} - -static void -calendar_appointment_init (CalendarAppointment *appointment, - icalcomponent *ical, - CalendarClientSource *source, - icaltimezone *default_zone) -{ - appointment->uid = get_ical_uid (ical); - appointment->rid = get_ical_rid (ical); - appointment->uri = get_source_uri (source->source); - appointment->summary = get_ical_summary (ical); - appointment->description = get_ical_description (ical); - appointment->color_string = get_source_color (source->source); - appointment->start_time = get_ical_start_time (ical, default_zone); - appointment->end_time = get_ical_end_time (ical, default_zone); - appointment->is_all_day = get_ical_is_all_day (ical, - appointment->start_time, - default_zone); -} - -static icaltimezone * -resolve_timezone_id (const char *tzid, - ECal *source) -{ - icaltimezone *retval; - - retval = icaltimezone_get_builtin_timezone_from_tzid (tzid); - if (!retval) - { - e_cal_get_timezone (source, tzid, &retval, NULL); - } - - return retval; -} - -static gboolean -calendar_appointment_collect_occurrence (ECalComponent *component, - time_t occurrence_start, - time_t occurrence_end, - gpointer data) -{ - CalendarOccurrence *occurrence; - GSList **collect_loc = data; - - occurrence = g_new0 (CalendarOccurrence, 1); - occurrence->start_time = occurrence_start; - occurrence->end_time = occurrence_end; - - *collect_loc = g_slist_prepend (*collect_loc, occurrence); - - return TRUE; -} - -static void -calendar_appointment_generate_ocurrences (CalendarAppointment *appointment, - icalcomponent *ical, - ECal *source, - time_t start, - time_t end, - icaltimezone *default_zone) -{ - ECalComponent *ecal; - - g_assert (appointment->occurrences == NULL); - - ecal = e_cal_component_new (); - e_cal_component_set_icalcomponent (ecal, - icalcomponent_new_clone (ical)); - - e_cal_recur_generate_instances (ecal, - start, - end, - calendar_appointment_collect_occurrence, - &appointment->occurrences, - (ECalRecurResolveTimezoneFn) resolve_timezone_id, - source, - default_zone); - - g_object_unref (ecal); - - appointment->occurrences = g_slist_reverse (appointment->occurrences); -} - -static inline gboolean -calendar_task_equal (CalendarTask *a, - CalendarTask *b) -{ - return - null_safe_strcmp (a->uid, b->uid) == 0 && - null_safe_strcmp (a->summary, b->summary) == 0 && - null_safe_strcmp (a->description, b->description) == 0 && - null_safe_strcmp (a->color_string, b->color_string) == 0 && - a->start_time == b->start_time && - a->due_time == b->due_time && - a->percent_complete == b->percent_complete && - a->completed_time == b->completed_time && - a->priority == b->priority; -} - -static void -calendar_task_copy (CalendarTask *task, - CalendarTask *task_copy) -{ - g_assert (task != NULL); - g_assert (task_copy != NULL); - - task_copy->uid = g_strdup (task->uid); - task_copy->summary = g_strdup (task->summary); - task_copy->description = g_strdup (task->description); - task_copy->color_string = g_strdup (task->color_string); - task_copy->start_time = task->start_time; - task_copy->due_time = task->due_time; - task_copy->percent_complete = task->percent_complete; - task_copy->completed_time = task->completed_time; - task_copy->priority = task->priority; -} - -static void -calendar_task_finalize (CalendarTask *task) -{ - g_free (task->uid); - task->uid = NULL; - - g_free (task->summary); - task->summary = NULL; - - g_free (task->description); - task->description = NULL; - - g_free (task->color_string); - task->color_string = NULL; - - task->percent_complete = 0; -} - -static void -calendar_task_init (CalendarTask *task, - icalcomponent *ical, - CalendarClientSource *source, - icaltimezone *default_zone) -{ - task->uid = get_ical_uid (ical); - task->summary = get_ical_summary (ical); - task->description = get_ical_description (ical); - task->color_string = get_source_color (source->source); - task->start_time = get_ical_start_time (ical, default_zone); - task->due_time = get_ical_due_time (ical, default_zone); - task->percent_complete = get_ical_percent_complete (ical); - task->completed_time = get_ical_completed_time (ical, default_zone); - task->priority = get_ical_priority (ical); -} - -void -calendar_event_free (CalendarEvent *event) -{ - switch (event->type) - { - case CALENDAR_EVENT_APPOINTMENT: - calendar_appointment_finalize (CALENDAR_APPOINTMENT (event)); - break; - case CALENDAR_EVENT_TASK: - calendar_task_finalize (CALENDAR_TASK (event)); - break; - default: - g_assert_not_reached (); - break; - } - - g_free (event); -} - -static CalendarEvent * -calendar_event_new (icalcomponent *ical, - CalendarClientSource *source, - icaltimezone *default_zone) -{ - CalendarEvent *event; - - event = g_new0 (CalendarEvent, 1); - - switch (icalcomponent_isa (ical)) - { - case ICAL_VEVENT_COMPONENT: - event->type = CALENDAR_EVENT_APPOINTMENT; - calendar_appointment_init (CALENDAR_APPOINTMENT (event), - ical, - source, - default_zone); - break; - case ICAL_VTODO_COMPONENT: - event->type = CALENDAR_EVENT_TASK; - calendar_task_init (CALENDAR_TASK (event), - ical, - source, - default_zone); - break; - default: - g_warning ("Unknown calendar component type: %d\n", - icalcomponent_isa (ical)); - g_free (event); - return NULL; - } - - return event; -} - -static CalendarEvent * -calendar_event_copy (CalendarEvent *event) -{ - CalendarEvent *retval; - - if (!event) - return NULL; - - retval = g_new0 (CalendarEvent, 1); - - retval->type = event->type; - - switch (event->type) - { - case CALENDAR_EVENT_APPOINTMENT: - calendar_appointment_copy (CALENDAR_APPOINTMENT (event), - CALENDAR_APPOINTMENT (retval)); - break; - case CALENDAR_EVENT_TASK: - calendar_task_copy (CALENDAR_TASK (event), - CALENDAR_TASK (retval)); - break; - default: - g_assert_not_reached (); - break; - } - - return retval; -} - -static char * -calendar_event_get_uid (CalendarEvent *event) -{ - switch (event->type) - { - case CALENDAR_EVENT_APPOINTMENT: - return g_strdup_printf ("%s%s", CALENDAR_APPOINTMENT (event)->uid, CALENDAR_APPOINTMENT (event)->rid ? CALENDAR_APPOINTMENT (event)->rid : ""); - break; - case CALENDAR_EVENT_TASK: - return g_strdup (CALENDAR_TASK (event)->uid); - break; - default: - g_assert_not_reached (); - break; - } - - return NULL; -} - -static gboolean -calendar_event_equal (CalendarEvent *a, - CalendarEvent *b) -{ - if (!a && !b) - return TRUE; - - if ((a && !b) || (!a && b)) - return FALSE; - - if (a->type != b->type) - return FALSE; - - switch (a->type) - { - case CALENDAR_EVENT_APPOINTMENT: - return calendar_appointment_equal (CALENDAR_APPOINTMENT (a), - CALENDAR_APPOINTMENT (b)); - case CALENDAR_EVENT_TASK: - return calendar_task_equal (CALENDAR_TASK (a), - CALENDAR_TASK (b)); - default: - break; - } - - g_assert_not_reached (); - - return FALSE; -} - -static void -calendar_event_generate_ocurrences (CalendarEvent *event, - icalcomponent *ical, - ECal *source, - time_t start, - time_t end, - icaltimezone *default_zone) -{ - if (event->type != CALENDAR_EVENT_APPOINTMENT) - return; - - calendar_appointment_generate_ocurrences (CALENDAR_APPOINTMENT (event), - ical, - source, - start, - end, - default_zone); -} - -static inline void -calendar_event_debug_dump (CalendarEvent *event) -{ -#ifdef CALENDAR_ENABLE_DEBUG - switch (event->type) - { - case CALENDAR_EVENT_APPOINTMENT: - { - char *start_str; - char *end_str; - GSList *l; - - start_str = CALENDAR_APPOINTMENT (event)->start_time ? - isodate_from_time_t (CALENDAR_APPOINTMENT (event)->start_time) : - g_strdup ("(undefined)"); - end_str = CALENDAR_APPOINTMENT (event)->end_time ? - isodate_from_time_t (CALENDAR_APPOINTMENT (event)->end_time) : - g_strdup ("(undefined)"); - - dprintf ("Appointment: uid '%s', summary '%s', description '%s', " - "start_time '%s', end_time '%s', is_all_day %s\n", - CALENDAR_APPOINTMENT (event)->uid, - CALENDAR_APPOINTMENT (event)->summary, - CALENDAR_APPOINTMENT (event)->description, - start_str, - end_str, - CALENDAR_APPOINTMENT (event)->is_all_day ? "(true)" : "(false)"); - - g_free (start_str); - g_free (end_str); - - dprintf (" Occurrences:\n"); - for (l = CALENDAR_APPOINTMENT (event)->occurrences; l; l = l->next) - { - CalendarOccurrence *occurrence = l->data; - - start_str = occurrence->start_time ? - isodate_from_time_t (occurrence->start_time) : - g_strdup ("(undefined)"); - - end_str = occurrence->end_time ? - isodate_from_time_t (occurrence->end_time) : - g_strdup ("(undefined)"); - - dprintf (" start_time '%s', end_time '%s'\n", - start_str, end_str); - - g_free (start_str); - g_free (end_str); - } - } - break; - case CALENDAR_EVENT_TASK: - { - char *start_str; - char *due_str; - char *completed_str; - - start_str = CALENDAR_TASK (event)->start_time ? - isodate_from_time_t (CALENDAR_TASK (event)->start_time) : - g_strdup ("(undefined)"); - due_str = CALENDAR_TASK (event)->due_time ? - isodate_from_time_t (CALENDAR_TASK (event)->due_time) : - g_strdup ("(undefined)"); - completed_str = CALENDAR_TASK (event)->completed_time ? - isodate_from_time_t (CALENDAR_TASK (event)->completed_time) : - g_strdup ("(undefined)"); - - dprintf ("Task: uid '%s', summary '%s', description '%s', " - "start_time '%s', due_time '%s', percent_complete %d, completed_time '%s'\n", - CALENDAR_TASK (event)->uid, - CALENDAR_TASK (event)->summary, - CALENDAR_TASK (event)->description, - start_str, - due_str, - CALENDAR_TASK (event)->percent_complete, - completed_str); - - g_free (completed_str); - } - break; - default: - g_assert_not_reached (); - break; - } -#endif -} - -static inline CalendarClientQuery * -goddamn_this_is_crack (CalendarClientSource *source, - ECalView *view, - gboolean *emit_signal) -{ - g_assert (view != NULL); - - if (source->completed_query.view == view) - { - if (emit_signal) - *emit_signal = TRUE; - return &source->completed_query; - } - else if (source->in_progress_query.view == view) - { - if (emit_signal) - *emit_signal = FALSE; - return &source->in_progress_query; - } - - g_assert_not_reached (); - - return NULL; -} - -static void -calendar_client_handle_query_completed (CalendarClientSource *source, - ECalendarStatus status, - ECalView *view) -{ - CalendarClientQuery *query; - - query = goddamn_this_is_crack (source, view, NULL); - - dprintf ("Query %p completed: %s\n", query, e_cal_get_error_message (status)); - - if (status != E_CALENDAR_STATUS_OK) - { - g_warning ("Calendar query failed: %s\n", - e_cal_get_error_message (status)); - calendar_client_stop_query (source->client, source, query); - return; - } - - g_assert (source->query_in_progress != FALSE); - g_assert (query == &source->in_progress_query); - - calendar_client_query_finalize (&source->completed_query); - - source->completed_query = source->in_progress_query; - source->query_completed = TRUE; - - source->query_in_progress = FALSE; - source->in_progress_query.view = NULL; - source->in_progress_query.events = NULL; - - g_signal_emit (source->client, source->changed_signal_id, 0); -} - -static void -calendar_client_handle_query_result (CalendarClientSource *source, - GList *objects, - ECalView *view) -{ - CalendarClientQuery *query; - CalendarClient *client; - gboolean emit_signal; - gboolean events_changed; - GList *l; - time_t month_begin; - time_t month_end; - - client = source->client; - - query = goddamn_this_is_crack (source, view, &emit_signal); - - dprintf ("Query %p result: %d objects:\n", - query, g_list_length (objects)); - - month_begin = make_time_for_day_begin (1, - client->priv->month, - client->priv->year); - - month_end = make_time_for_day_begin (1, - client->priv->month + 1, - client->priv->year); - - events_changed = FALSE; - for (l = objects; l; l = l->next) - { - CalendarEvent *event; - CalendarEvent *old_event; - icalcomponent *ical = l->data; - char *uid; - - event = calendar_event_new (ical, source, client->priv->zone); - if (!event) - continue; - - calendar_event_generate_ocurrences (event, - ical, - source->source, - month_begin, - month_end, - client->priv->zone); - - uid = calendar_event_get_uid (event); - - old_event = g_hash_table_lookup (query->events, uid); - - if (!calendar_event_equal (event, old_event)) - { - dprintf ("Event %s: ", old_event ? "modified" : "added"); - - calendar_event_debug_dump (event); - - g_hash_table_replace (query->events, uid, event); - - events_changed = TRUE; - } - else - { - g_free (uid); - } - } - - if (emit_signal && events_changed) - { - g_signal_emit (source->client, source->changed_signal_id, 0); - } -} - -static gboolean -check_object_remove (gpointer key, - gpointer value, - gpointer data) -{ - char *uid = data; - ssize_t len; - - len = strlen (uid); - - if (len <= strlen (key) && strncmp (uid, key, len) == 0) - { - dprintf ("Event removed: "); - - calendar_event_debug_dump (value); - - return TRUE; - } - - return FALSE; -} - -static void -calendar_client_handle_objects_removed (CalendarClientSource *source, - GList *ids, - ECalView *view) -{ - CalendarClientQuery *query; - gboolean emit_signal; - gboolean events_changed; - GList *l; - - query = goddamn_this_is_crack (source, view, &emit_signal); - - events_changed = FALSE; - for (l = ids; l; l = l->next) - { - CalendarEvent *event; - ECalComponentId *id = l->data; - char *uid = g_strdup_printf ("%s%s", id->uid, id->rid ? id->rid : ""); - - if (!id->rid || !(*id->rid)) - { - int size = g_hash_table_size (query->events); - - g_hash_table_foreach_remove (query->events, check_object_remove, id->uid); - - if (size != g_hash_table_size (query->events)) - events_changed = TRUE; - } - else if ((event = g_hash_table_lookup (query->events, uid))) - { - dprintf ("Event removed: "); - - calendar_event_debug_dump (event); - - g_assert (g_hash_table_remove (query->events, uid)); - - events_changed = TRUE; - } - g_free (uid); - } - - if (emit_signal && events_changed) - { - g_signal_emit (source->client, source->changed_signal_id, 0); - } -} - -static void -calendar_client_query_finalize (CalendarClientQuery *query) -{ - if (query->view) - g_object_unref (query->view); - query->view = NULL; - - if (query->events) - g_hash_table_destroy (query->events); - query->events = NULL; -} - -static void -calendar_client_stop_query (CalendarClient *client, - CalendarClientSource *source, - CalendarClientQuery *query) -{ - if (query == &source->in_progress_query) - { - dprintf ("Stopping in progress query %p\n", query); - - g_assert (source->query_in_progress != FALSE); - - source->query_in_progress = FALSE; - } - else if (query == &source->completed_query) - { - dprintf ("Stopping completed query %p\n", query); - - g_assert (source->query_completed != FALSE); - - source->query_completed = FALSE; - } - else - g_assert_not_reached (); - - calendar_client_query_finalize (query); -} - -static void -calendar_client_start_query (CalendarClient *client, - CalendarClientSource *source, - const char *query) -{ - ECalView *view = NULL; - GError *error = NULL; - - if (!e_cal_get_query (source->source, query, &view, &error)) - { - g_warning ("Error preparing the query: '%s': %s\n", - query, error->message); - g_error_free (error); - return; - } - - g_assert (view != NULL); - - if (source->query_in_progress) - calendar_client_stop_query (client, source, &source->in_progress_query); - - dprintf ("Starting query %p: '%s'\n", &source->in_progress_query, query); - - source->query_in_progress = TRUE; - source->in_progress_query.view = view; - source->in_progress_query.events = - g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - (GDestroyNotify) calendar_event_free); - - g_signal_connect_swapped (view, "objects-added", - G_CALLBACK (calendar_client_handle_query_result), - source); - g_signal_connect_swapped (view, "objects-modified", - G_CALLBACK (calendar_client_handle_query_result), - source); - g_signal_connect_swapped (view, "objects-removed", - G_CALLBACK (calendar_client_handle_objects_removed), - source); - g_signal_connect_swapped (view, "view-done", - G_CALLBACK (calendar_client_handle_query_completed), - source); - - e_cal_view_start (view); -} - -static void -calendar_client_update_appointments (CalendarClient *client) -{ - GSList *l; - char *query; - char *month_begin; - char *month_end; - - if (client->priv->month == -1 || - client->priv->year == -1) - return; - - month_begin = make_isodate_for_day_begin (1, - client->priv->month, - client->priv->year); - - month_end = make_isodate_for_day_begin (1, - client->priv->month + 1, - client->priv->year); - - query = g_strdup_printf ("occur-in-time-range? (make-time \"%s\") " - "(make-time \"%s\")", - month_begin, month_end); - - for (l = client->priv->appointment_sources; l; l = l->next) - { - CalendarClientSource *cs = l->data; - - if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED) - continue; - - calendar_client_start_query (client, cs, query); - } - - g_free (month_begin); - g_free (month_end); - g_free (query); -} - -/* FIXME: - * perhaps we should use evo's "hide_completed_tasks" pref? - */ -static void -calendar_client_update_tasks (CalendarClient *client) -{ - GSList *l; - char *query; - -#ifdef FIX_BROKEN_TASKS_QUERY - /* FIXME: this doesn't work for tasks without a start or - * due date - * Look at filter_task() to see the behaviour we - * want. - */ - - char *day_begin; - char *day_end; - - if (client->priv->day == -1 || - client->priv->month == -1 || - client->priv->year == -1) - return; - - day_begin = make_isodate_for_day_begin (client->priv->day, - client->priv->month, - client->priv->year); - - day_end = make_isodate_for_day_begin (client->priv->day + 1, - client->priv->month, - client->priv->year); - if (!day_begin || !day_end) - { - g_warning ("Cannot run query with invalid date: %dd %dy %dm\n", - client->priv->day, - client->priv->month, - client->priv->year); - g_free (day_begin); - g_free (day_end); - return; - } - - query = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\") " - "(make-time \"%s\")) " - "(or (not is-completed?) " - "(and (is-completed?) " - "(not (completed-before? (make-time \"%s\"))))))", - day_begin, day_end, day_begin); -#else - query = g_strdup ("#t"); -#endif /* FIX_BROKEN_TASKS_QUERY */ - - for (l = client->priv->task_sources; l; l = l->next) - { - CalendarClientSource *cs = l->data; - - if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED) - continue; - - calendar_client_start_query (client, cs, query); - } - -#ifdef FIX_BROKEN_TASKS_QUERY - g_free (day_begin); - g_free (day_end); -#endif - g_free (query); -} - -static void -calendar_client_source_finalize (CalendarClientSource *source) -{ - source->client = NULL; - - if (source->source) { - g_signal_handlers_disconnect_by_func (source->source, - cal_opened_cb, source); - g_object_unref (source->source); - } - source->source = NULL; - - calendar_client_query_finalize (&source->completed_query); - calendar_client_query_finalize (&source->in_progress_query); - - source->query_completed = FALSE; - source->query_in_progress = FALSE; -} - -static int -compare_calendar_sources (CalendarClientSource *s1, - CalendarClientSource *s2) -{ - return (s1->source == s2->source) ? 0 : 1; -} - -static GSList * -calendar_client_update_sources_list (CalendarClient *client, - GSList *sources, - GSList *esources, - guint changed_signal_id) -{ - GSList *retval, *l; - - retval = NULL; - - for (l = esources; l; l = l->next) - { - CalendarClientSource dummy_source; - CalendarClientSource *new_source; - GSList *s; - ECal *esource = l->data; - - dummy_source.source = esource; - - dprintf ("update_sources_list: adding client %s: ", - e_source_peek_uid (e_cal_get_source (esource))); - - if ((s = g_slist_find_custom (sources, - &dummy_source, - (GCompareFunc) compare_calendar_sources))) - { - dprintf ("already on list\n"); - new_source = s->data; - sources = g_slist_delete_link (sources, s); - } - else - { - dprintf ("added\n"); - new_source = g_new0 (CalendarClientSource, 1); - new_source->client = client; - new_source->source = g_object_ref (esource); - new_source->changed_signal_id = changed_signal_id; - } - - retval = g_slist_prepend (retval, new_source); - } - - for (l = sources; l; l = l->next) - { - CalendarClientSource *source = l->data; - - dprintf ("Removing client %s from list\n", - e_source_peek_uid (e_cal_get_source (source->source))); - - calendar_client_source_finalize (source); - g_free (source); - } - g_slist_free (sources); - - return retval; -} - -static void -calendar_client_appointment_sources_changed (CalendarClient *client) -{ - GSList *esources; - - dprintf ("appointment_sources_changed: updating ...\n"); - - esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources); - - client->priv->appointment_sources = - calendar_client_update_sources_list (client, - client->priv->appointment_sources, - esources, - signals [APPOINTMENTS_CHANGED]); - - load_calendars (client, CALENDAR_EVENT_APPOINTMENT); - calendar_client_update_appointments (client); -} - -static void -calendar_client_task_sources_changed (CalendarClient *client) -{ - GSList *esources; - - dprintf ("task_sources_changed: updating ...\n"); - - esources = calendar_sources_get_task_sources (client->priv->calendar_sources); - - client->priv->task_sources = - calendar_client_update_sources_list (client, - client->priv->task_sources, - esources, - signals [TASKS_CHANGED]); - - load_calendars (client, CALENDAR_EVENT_TASK); - calendar_client_update_tasks (client); -} - -void -calendar_client_get_date (CalendarClient *client, - guint *year, - guint *month, - guint *day) -{ - g_return_if_fail (CALENDAR_IS_CLIENT (client)); - - if (year) - *year = client->priv->year; - - if (month) - *month = client->priv->month; - - if (day) - *day = client->priv->day; -} - -void -calendar_client_select_month (CalendarClient *client, - guint month, - guint year) -{ - g_return_if_fail (CALENDAR_IS_CLIENT (client)); - g_return_if_fail (month <= 11); - - if (client->priv->year != year || client->priv->month != month) - { - client->priv->month = month; - client->priv->year = year; - - calendar_client_update_appointments (client); - calendar_client_update_tasks (client); - - g_object_freeze_notify (G_OBJECT (client)); - g_object_notify (G_OBJECT (client), "month"); - g_object_notify (G_OBJECT (client), "year"); - g_object_thaw_notify (G_OBJECT (client)); - } -} - -void -calendar_client_select_day (CalendarClient *client, - guint day) -{ - g_return_if_fail (CALENDAR_IS_CLIENT (client)); - g_return_if_fail (day <= 31); - - if (client->priv->day != day) - { - client->priv->day = day; - - /* don't need to update appointments unless - * the selected month changes - */ -#ifdef FIX_BROKEN_TASKS_QUERY - calendar_client_update_tasks (client); -#endif - - g_object_notify (G_OBJECT (client), "day"); - } -} - -typedef struct -{ - CalendarClient *client; - GSList *events; - time_t start_time; - time_t end_time; -} FilterData; - -typedef void (* CalendarEventFilterFunc) (const char *uid, - CalendarEvent *event, - FilterData *filter_data); - -static void -filter_appointment (const char *uid, - CalendarEvent *event, - FilterData *filter_data) -{ - GSList *occurrences, *l; - - if (event->type != CALENDAR_EVENT_APPOINTMENT) - return; - - occurrences = CALENDAR_APPOINTMENT (event)->occurrences; - CALENDAR_APPOINTMENT (event)->occurrences = NULL; - - for (l = occurrences; l; l = l->next) - { - CalendarOccurrence *occurrence = l->data; - time_t start_time = occurrence->start_time; - time_t end_time = occurrence->end_time; - - if ((start_time >= filter_data->start_time && - start_time < filter_data->end_time) || - (start_time <= filter_data->start_time && - (end_time - 1) > filter_data->start_time)) - { - CalendarEvent *new_event; - - new_event = calendar_event_copy (event); - - CALENDAR_APPOINTMENT (new_event)->start_time = occurrence->start_time; - CALENDAR_APPOINTMENT (new_event)->end_time = occurrence->end_time; - - filter_data->events = g_slist_prepend (filter_data->events, new_event); - } - } - - CALENDAR_APPOINTMENT (event)->occurrences = occurrences; -} - -static void -filter_task (const char *uid, - CalendarEvent *event, - FilterData *filter_data) -{ -#ifdef FIX_BROKEN_TASKS_QUERY - CalendarTask *task; -#endif - - if (event->type != CALENDAR_EVENT_TASK) - return; - -#ifdef FIX_BROKEN_TASKS_QUERY - task = CALENDAR_TASK (event); - - if (task->start_time && task->start_time > filter_data->start_time) - return; - - if (task->completed_time && - (task->completed_time < filter_data->start_time || - task->completed_time > filter_data->end_time)) - return; -#endif /* FIX_BROKEN_TASKS_QUERY */ - - filter_data->events = g_slist_prepend (filter_data->events, - calendar_event_copy (event)); -} - -static GSList * -calendar_client_filter_events (CalendarClient *client, - GSList *sources, - CalendarEventFilterFunc filter_func, - time_t start_time, - time_t end_time) -{ - FilterData filter_data; - GSList *l; - GSList *retval; - - if (!sources) - return NULL; - - filter_data.client = client; - filter_data.events = NULL; - filter_data.start_time = start_time; - filter_data.end_time = end_time; - - retval = NULL; - for (l = sources; l; l = l->next) - { - CalendarClientSource *source = l->data; - - if (source->query_completed) - { - filter_data.events = NULL; - g_hash_table_foreach (source->completed_query.events, - (GHFunc) filter_func, - &filter_data); - - filter_data.events = g_slist_reverse (filter_data.events); - - retval = g_slist_concat (retval, filter_data.events); - } - } - - return retval; -} - -GSList * -calendar_client_get_events (CalendarClient *client, - CalendarEventType event_mask) -{ - GSList *appointments; - GSList *tasks; - time_t day_begin; - time_t day_end; - - g_return_val_if_fail (CALENDAR_IS_CLIENT (client), NULL); - g_return_val_if_fail (client->priv->day != -1 && - client->priv->month != -1 && - client->priv->year != -1, NULL); - - day_begin = make_time_for_day_begin (client->priv->day, - client->priv->month, - client->priv->year); - day_end = make_time_for_day_begin (client->priv->day + 1, - client->priv->month, - client->priv->year); - - appointments = NULL; - if (event_mask & CALENDAR_EVENT_APPOINTMENT) - { - appointments = calendar_client_filter_events (client, - client->priv->appointment_sources, - filter_appointment, - day_begin, - day_end); - } - - tasks = NULL; - if (event_mask & CALENDAR_EVENT_TASK) - { - tasks = calendar_client_filter_events (client, - client->priv->task_sources, - filter_task, - day_begin, - day_end); - } - - return g_slist_concat (appointments, tasks); -} - -static inline int -day_from_time_t (time_t t) -{ - struct tm *tm = localtime (&t); - - g_assert (tm == NULL || (tm->tm_mday >=1 && tm->tm_mday <= 31)); - - return tm ? tm->tm_mday : 0; -} - -void -calendar_client_foreach_appointment_day (CalendarClient *client, - CalendarDayIter iter_func, - gpointer user_data) -{ - GSList *appointments, *l; - gboolean marked_days [32] = { FALSE, }; - time_t month_begin; - time_t month_end; - int i; - - g_return_if_fail (CALENDAR_IS_CLIENT (client)); - g_return_if_fail (iter_func != NULL); - g_return_if_fail (client->priv->month != -1 && - client->priv->year != -1); - - month_begin = make_time_for_day_begin (1, - client->priv->month, - client->priv->year); - month_end = make_time_for_day_begin (1, - client->priv->month + 1, - client->priv->year); - - appointments = calendar_client_filter_events (client, - client->priv->appointment_sources, - filter_appointment, - month_begin, - month_end); - for (l = appointments; l; l = l->next) - { - CalendarAppointment *appointment = l->data; - - if (appointment->start_time) - { - time_t day_time = appointment->start_time; - - if (day_time >= month_begin) - marked_days [day_from_time_t (day_time)] = TRUE; - - if (appointment->end_time) - { - int day_offset; - int duration = appointment->end_time - appointment->start_time; - /* mark the days for the appointment, no need to add an extra one when duration is a multiple of 86400 */ - for (day_offset = 1; day_offset <= duration / 86400 && duration != day_offset * 86400; day_offset++) - { - time_t day_tm = appointment->start_time + day_offset * 86400; - - if (day_tm > month_end) - break; - if (day_tm >= month_begin) - marked_days [day_from_time_t (day_tm)] = TRUE; - } - } - } - calendar_event_free (CALENDAR_EVENT (appointment)); - } - - g_slist_free (appointments); - - for (i = 1; i < 32; i++) - { - if (marked_days [i]) - iter_func (client, i, user_data); - } -} - -void -calendar_client_set_task_completed (CalendarClient *client, - char *task_uid, - gboolean task_completed, - guint percent_complete) -{ - GSList *l; - ECal *esource; - icalcomponent *ical; - icalproperty *prop; - icalproperty_status status; - - g_return_if_fail (CALENDAR_IS_CLIENT (client)); - g_return_if_fail (task_uid != NULL); - g_return_if_fail (task_completed == FALSE || percent_complete == 100); - - ical = NULL; - esource = NULL; - for (l = client->priv->task_sources; l; l = l->next) - { - CalendarClientSource *source = l->data; - - esource = source->source; - e_cal_get_object (esource, task_uid, NULL, &ical, NULL); - if (ical) - break; - } - - if (!ical) - { - g_warning ("Cannot locate task with uid = '%s'\n", task_uid); - return; - } - - g_assert (esource != NULL); - - /* Completed time */ - prop = icalcomponent_get_first_property (ical, - ICAL_COMPLETED_PROPERTY); - if (task_completed) - { - struct icaltimetype completed_time; - - completed_time = icaltime_current_time_with_zone (client->priv->zone); - if (!prop) - { - icalcomponent_add_property (ical, - icalproperty_new_completed (completed_time)); - } - else - { - icalproperty_set_completed (prop, completed_time); - } - } - else if (prop) - { - icalcomponent_remove_property (ical, prop); - } - - /* Percent complete */ - prop = icalcomponent_get_first_property (ical, - ICAL_PERCENTCOMPLETE_PROPERTY); - if (!prop) - { - icalcomponent_add_property (ical, - icalproperty_new_percentcomplete (percent_complete)); - } - else - { - icalproperty_set_percentcomplete (prop, percent_complete); - } - - /* Status */ - status = task_completed ? ICAL_STATUS_COMPLETED : ICAL_STATUS_NEEDSACTION; - prop = icalcomponent_get_first_property (ical, ICAL_STATUS_PROPERTY); - if (prop) - { - icalproperty_set_status (prop, status); - } - else - { - icalcomponent_add_property (ical, - icalproperty_new_status (status)); - } - - e_cal_modify_object (esource, ical, CALOBJ_MOD_ALL, NULL); -} diff --git a/applets/clock/calendar-client.h b/applets/clock/calendar-client.h deleted file mode 100644 index 9d502ba0..00000000 --- a/applets/clock/calendar-client.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2004 Free Software Foundation, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - * William Jon McCann <[email protected]> - * Martin Grimme <[email protected]> - * Christian Kellner <[email protected]> - */ - -#ifndef __CALENDAR_CLIENT_H__ -#define __CALENDAR_CLIENT_H__ - -#include <glib-object.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum -{ - CALENDAR_EVENT_APPOINTMENT = 1 << 0, - CALENDAR_EVENT_TASK = 1 << 1, - CALENDAR_EVENT_ALL = (1 << 2) - 1 -} CalendarEventType; - -#define CALENDAR_TYPE_CLIENT (calendar_client_get_type ()) -#define CALENDAR_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CALENDAR_TYPE_CLIENT, CalendarClient)) -#define CALENDAR_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CALENDAR_TYPE_CLIENT, CalendarClientClass)) -#define CALENDAR_IS_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CALENDAR_TYPE_CLIENT)) -#define CALENDAR_IS_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CALENDAR_TYPE_CLIENT)) -#define CALENDAR_CLIENT_GET_CLASS(o)(G_TYPE_INSTANCE_GET_CLASS ((o), CALENDAR_TYPE_CLIENT, CalendarClientClass)) - -typedef struct _CalendarClient CalendarClient; -typedef struct _CalendarClientClass CalendarClientClass; -typedef struct _CalendarClientPrivate CalendarClientPrivate; - -struct _CalendarClient -{ - GObject parent; - CalendarClientPrivate *priv; -}; - -struct _CalendarClientClass -{ - GObjectClass parent_class; - - void (* appointments_changed) (CalendarClient *client); - void (* tasks_changed) (CalendarClient *client); -}; - - -typedef struct -{ - time_t start_time; - time_t end_time; -} CalendarOccurrence; - -typedef struct -{ - char *uid; - char *rid; - char *uri; - char *summary; - char *description; - char *color_string; - time_t start_time; - time_t end_time; - guint is_all_day : 1; - - /* Only used internally */ - GSList *occurrences; -} CalendarAppointment; - -typedef struct -{ - char *uid; - char *summary; - char *description; - char *color_string; - char *url; - time_t start_time; - time_t due_time; - guint percent_complete; - time_t completed_time; - int priority; -} CalendarTask; - -typedef struct -{ - union - { - CalendarAppointment appointment; - CalendarTask task; - } event; - CalendarEventType type; -} CalendarEvent; - -#define CALENDAR_EVENT(e) ((CalendarEvent *)(e)) -#define CALENDAR_APPOINTMENT(e) ((CalendarAppointment *)(e)) -#define CALENDAR_TASK(e) ((CalendarTask *)(e)) - -typedef void (* CalendarDayIter) (CalendarClient *client, - guint day, - gpointer user_data); - - -GType calendar_client_get_type (void) G_GNUC_CONST; -CalendarClient *calendar_client_new (void); - -void calendar_client_get_date (CalendarClient *client, - guint *year, - guint *month, - guint *day); -void calendar_client_select_month (CalendarClient *client, - guint month, - guint year); -void calendar_client_select_day (CalendarClient *client, - guint day); - -GSList *calendar_client_get_events (CalendarClient *client, - CalendarEventType event_mask); -void calendar_client_foreach_appointment_day (CalendarClient *client, - CalendarDayIter iter_func, - gpointer user_data); - -void calendar_client_set_task_completed (CalendarClient *client, - char *task_uid, - gboolean task_completed, - guint percent_complete); - -void calendar_event_free (CalendarEvent *event); - -#ifdef __cplusplus -} -#endif - -#endif /* __CALENDAR_CLIENT_H__ */ diff --git a/applets/clock/calendar-sources.c b/applets/clock/calendar-sources.c deleted file mode 100644 index 721ff062..00000000 --- a/applets/clock/calendar-sources.c +++ /dev/null @@ -1,658 +0,0 @@ -/* - * Copyright (C) 2004 Free Software Foundation, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - * William Jon McCann <[email protected]> - * Martin Grimme <[email protected]> - * Christian Kellner <[email protected]> - */ - -#include <config.h> - -#include "calendar-sources.h" - -#include <libintl.h> -#include <string.h> -#include <mateconf/mateconf-client.h> -#define HANDLE_LIBICAL_MEMORY -#include <libecal/e-cal.h> -#include <libedataserver/e-source-list.h> -#include <libedataserverui/e-passwords.h> - -#undef CALENDAR_ENABLE_DEBUG -#include "calendar-debug.h" - -#ifndef _ -#define _(x) gettext(x) -#endif - -#ifndef N_ -#define N_(x) x -#endif - -#define CALENDAR_SOURCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_SOURCES, CalendarSourcesPrivate)) - -#define CALENDAR_SOURCES_EVO_DIR "/apps/evolution" -#define CALENDAR_SOURCES_APPOINTMENT_SOURCES_KEY CALENDAR_SOURCES_EVO_DIR "/calendar/sources" -#define CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_DIR CALENDAR_SOURCES_EVO_DIR "/calendar/display" -#define CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_KEY CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_DIR "/selected_calendars" -#define CALENDAR_SOURCES_TASK_SOURCES_KEY CALENDAR_SOURCES_EVO_DIR "/tasks/sources" -#define CALENDAR_SOURCES_SELECTED_TASK_SOURCES_DIR CALENDAR_SOURCES_EVO_DIR "/calendar/tasks" -#define CALENDAR_SOURCES_SELECTED_TASK_SOURCES_KEY CALENDAR_SOURCES_SELECTED_TASK_SOURCES_DIR "/selected_tasks" - -typedef struct _CalendarSourceData CalendarSourceData; - -struct _CalendarSourceData -{ - ECalSourceType source_type; - CalendarSources *sources; - guint changed_signal; - - GSList *clients; - GSList *selected_sources; - ESourceList *esource_list; - - guint selected_sources_listener; - char *selected_sources_dir; - - guint timeout_id; - - guint loaded : 1; -}; - -struct _CalendarSourcesPrivate -{ - CalendarSourceData appointment_sources; - CalendarSourceData task_sources; - - MateConfClient *mateconf_client; -}; - -static void calendar_sources_class_init (CalendarSourcesClass *klass); -static void calendar_sources_init (CalendarSources *sources); -static void calendar_sources_finalize (GObject *object); - -static void backend_died_cb (ECal *client, CalendarSourceData *source_data); -static void calendar_sources_esource_list_changed (ESourceList *source_list, - CalendarSourceData *source_data); - -enum -{ - APPOINTMENT_SOURCES_CHANGED, - TASK_SOURCES_CHANGED, - LAST_SIGNAL -}; -static guint signals [LAST_SIGNAL] = { 0, }; - -static GObjectClass *parent_class = NULL; -static CalendarSources *calendar_sources_singleton = NULL; - -GType -calendar_sources_get_type (void) -{ - static GType sources_type = 0; - - if (!sources_type) - { - static const GTypeInfo sources_info = - { - sizeof (CalendarSourcesClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) calendar_sources_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CalendarSources), - 0, /* n_preallocs */ - (GInstanceInitFunc) calendar_sources_init, - }; - - sources_type = g_type_register_static (G_TYPE_OBJECT, - "CalendarSources", - &sources_info, 0); - } - - return sources_type; -} - -static void -calendar_sources_class_init (CalendarSourcesClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->finalize = calendar_sources_finalize; - - g_type_class_add_private (klass, sizeof (CalendarSourcesPrivate)); - - signals [APPOINTMENT_SOURCES_CHANGED] = - g_signal_new ("appointment-sources-changed", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalendarSourcesClass, - appointment_sources_changed), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - signals [TASK_SOURCES_CHANGED] = - g_signal_new ("task-sources-changed", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalendarSourcesClass, - task_sources_changed), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); -} - -static void -calendar_sources_init (CalendarSources *sources) -{ - sources->priv = CALENDAR_SOURCES_GET_PRIVATE (sources); - - sources->priv->appointment_sources.source_type = E_CAL_SOURCE_TYPE_EVENT; - sources->priv->appointment_sources.sources = sources; - sources->priv->appointment_sources.changed_signal = signals [APPOINTMENT_SOURCES_CHANGED]; - sources->priv->appointment_sources.timeout_id = 0; - - sources->priv->task_sources.source_type = E_CAL_SOURCE_TYPE_TODO; - sources->priv->task_sources.sources = sources; - sources->priv->task_sources.changed_signal = signals [TASK_SOURCES_CHANGED]; - sources->priv->task_sources.timeout_id = 0; - - sources->priv->mateconf_client = mateconf_client_get_default (); -} - -static void -calendar_sources_finalize_source_data (CalendarSources *sources, - CalendarSourceData *source_data) -{ - if (source_data->loaded) - { - GSList *l; - - if (source_data->selected_sources_dir) - { - mateconf_client_remove_dir (sources->priv->mateconf_client, - source_data->selected_sources_dir, - NULL); - - g_free (source_data->selected_sources_dir); - source_data->selected_sources_dir = NULL; - } - - if (source_data->selected_sources_listener) - { - mateconf_client_notify_remove (sources->priv->mateconf_client, - source_data->selected_sources_listener); - source_data->selected_sources_listener = 0; - } - - for (l = source_data->clients; l; l = l->next) - { - g_signal_handlers_disconnect_by_func (G_OBJECT (l->data), - G_CALLBACK (backend_died_cb), - source_data); - g_object_unref (l->data); - } - g_slist_free (source_data->clients); - source_data->clients = NULL; - - if (source_data->esource_list) - { - g_signal_handlers_disconnect_by_func (source_data->esource_list, - G_CALLBACK (calendar_sources_esource_list_changed), - source_data); - g_object_unref (source_data->esource_list); - } - source_data->esource_list = NULL; - - for (l = source_data->selected_sources; l; l = l->next) - g_free (l->data); - g_slist_free (source_data->selected_sources); - source_data->selected_sources = NULL; - - if (source_data->timeout_id != 0) - { - g_source_remove (source_data->timeout_id); - source_data->timeout_id = 0; - } - - source_data->loaded = FALSE; - } -} - -static void -calendar_sources_finalize (GObject *object) -{ - CalendarSources *sources = CALENDAR_SOURCES (object); - - calendar_sources_finalize_source_data (sources, &sources->priv->appointment_sources); - calendar_sources_finalize_source_data (sources, &sources->priv->task_sources); - - if (sources->priv->mateconf_client) - g_object_unref (sources->priv->mateconf_client); - sources->priv->mateconf_client = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -CalendarSources * -calendar_sources_get (void) -{ - gpointer singleton_location = &calendar_sources_singleton; - - if (calendar_sources_singleton) - return g_object_ref (calendar_sources_singleton); - - calendar_sources_singleton = g_object_new (CALENDAR_TYPE_SOURCES, NULL); - g_object_add_weak_pointer (G_OBJECT (calendar_sources_singleton), - singleton_location); - - return calendar_sources_singleton; -} - -static gboolean -is_source_selected (ESource *esource, - GSList *selected_sources) -{ - const char *uid; - GSList *l; - - uid = e_source_peek_uid (esource); - - for (l = selected_sources; l; l = l->next) - { - const char *source = l->data; - - if (!strcmp (source, uid)) - return TRUE; - } - - return FALSE; -} - -static char * -auth_func_cb (ECal *ecal, - const char *prompt, - const char *key, - gpointer user_data) -{ - ESource *source; - const gchar *auth_domain; - const gchar *component_name; - - source = e_cal_get_source (ecal); - auth_domain = e_source_get_property (source, "auth-domain"); - component_name = auth_domain ? auth_domain : "Calendar"; - - return e_passwords_get_password (component_name, key); -} - -/* The clients are just created here but not loaded */ -static ECal * -get_ecal_from_source (ESource *esource, - ECalSourceType source_type, - GSList *existing_clients) -{ - ECal *retval; - - if (existing_clients) - { - GSList *l; - - for (l = existing_clients; l; l = l->next) - { - ECal *client = E_CAL (l->data); - - if (e_source_equal (esource, e_cal_get_source (client))) - { - dprintf (" load_esource: found existing source ... returning that\n"); - - return g_object_ref (client); - } - } - } - - retval = e_cal_new (esource, source_type); - if (!retval) - { - g_warning ("Could not load source '%s' from '%s'\n", - e_source_peek_name (esource), - e_source_peek_relative_uri (esource)); - return NULL; - } - - e_cal_set_auth_func (retval, auth_func_cb, NULL); - - return retval; -} - -/* - Order doesn't matter - * - Can just compare object pointers since we - * re-use client connections - */ -static gboolean -compare_ecal_lists (GSList *a, - GSList *b) -{ - GSList *l; - - if (g_slist_length (a) != g_slist_length (b)) - return FALSE; - - for (l = a; l; l = l->next) - { - if (!g_slist_find (b, l->data)) - return FALSE; - } - - return TRUE; -} - -static inline void -debug_dump_selected_sources (GSList *selected_sources) -{ -#ifdef CALENDAR_ENABLE_DEBUG - GSList *l; - - dprintf ("Selected sources:\n"); - for (l = selected_sources; l; l = l->next) - { - char *source = l->data; - - dprintf (" %s\n", source); - } - dprintf ("\n"); -#endif -} - -static inline void -debug_dump_ecal_list (GSList *ecal_list) -{ -#ifdef CALENDAR_ENABLE_DEBUG - GSList *l; - - dprintf ("Loaded clients:\n"); - for (l = ecal_list; l; l = l->next) - { - ECal *client = l->data; - ESource *source = e_cal_get_source (client); - - dprintf (" %s %s %s\n", - e_source_peek_uid (source), - e_source_peek_name (source), - e_cal_get_uri (client)); - } -#endif -} - -static void -calendar_sources_load_esource_list (CalendarSourceData *source_data); - -static gboolean -backend_restart (gpointer data) -{ - CalendarSourceData *source_data = data; - - calendar_sources_load_esource_list (source_data); - - source_data->timeout_id = 0; - - return FALSE; -} - -static void -backend_died_cb (ECal *client, CalendarSourceData *source_data) -{ - const char *uristr; - - source_data->clients = g_slist_remove (source_data->clients, client); - if (g_slist_length (source_data->clients) < 1) - { - g_slist_free (source_data->clients); - source_data->clients = NULL; - } - uristr = e_cal_get_uri (client); - g_warning ("The calendar backend for %s has crashed.", uristr); - - if (source_data->timeout_id != 0) - { - g_source_remove (source_data->timeout_id); - source_data->timeout_id = 0; - } - - source_data->timeout_id = g_timeout_add_seconds (2, backend_restart, - source_data); -} - -static void -calendar_sources_load_esource_list (CalendarSourceData *source_data) -{ - GSList *clients = NULL; - GSList *groups, *l; - gboolean emit_signal = FALSE; - - g_return_if_fail (source_data->esource_list != NULL); - - debug_dump_selected_sources (source_data->selected_sources); - - dprintf ("Source groups:\n"); - groups = e_source_list_peek_groups (source_data->esource_list); - for (l = groups; l; l = l->next) - { - GSList *esources, *s; - - dprintf (" %s\n", e_source_group_peek_uid (l->data)); - dprintf (" sources:\n"); - - esources = e_source_group_peek_sources (l->data); - for (s = esources; s; s = s->next) - { - ESource *esource = E_SOURCE (s->data); - ECal *client; - - dprintf (" type = '%s' uid = '%s', name = '%s', relative uri = '%s': \n", - source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task", - e_source_peek_uid (esource), - e_source_peek_name (esource), - e_source_peek_relative_uri (esource)); - - if (is_source_selected (esource, source_data->selected_sources) && - (client = get_ecal_from_source (esource, source_data->source_type, source_data->clients))) - { - clients = g_slist_prepend (clients, client); - } - } - } - dprintf ("\n"); - - if (source_data->loaded && - !compare_ecal_lists (source_data->clients, clients)) - emit_signal = TRUE; - - for (l = source_data->clients; l; l = l->next) - { - g_signal_handlers_disconnect_by_func (G_OBJECT (l->data), - G_CALLBACK (backend_died_cb), - source_data); - - g_object_unref (l->data); - } - g_slist_free (source_data->clients); - source_data->clients = g_slist_reverse (clients); - - /* connect to backend_died after we disconnected the previous signal - * handlers. If we do it before, we'll lose some handlers (for clients that - * were already there before) */ - for (l = source_data->clients; l; l = l->next) - { - g_signal_connect (G_OBJECT (l->data), "backend_died", - G_CALLBACK (backend_died_cb), source_data); - } - - if (emit_signal) - { - dprintf ("Emitting %s-sources-changed signal\n", - source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task"); - g_signal_emit (source_data->sources, source_data->changed_signal, 0); - } - - debug_dump_ecal_list (source_data->clients); -} - -static void -calendar_sources_esource_list_changed (ESourceList *source_list, - CalendarSourceData *source_data) - -{ - dprintf ("ESourceList changed, reloading\n"); - - calendar_sources_load_esource_list (source_data); -} - -static void -calendar_sources_selected_sources_notify (MateConfClient *client, - guint cnx_id, - MateConfEntry *entry, - CalendarSourceData *source_data) -{ - GSList *l; - - if (!entry->value || - entry->value->type != MATECONF_VALUE_LIST || - mateconf_value_get_list_type (entry->value) != MATECONF_VALUE_STRING) - return; - - dprintf ("Selected sources key (%s) changed, reloading\n", entry->key); - - for (l = source_data->selected_sources; l; l = l->next) - g_free (l->data); - source_data->selected_sources = NULL; - - for (l = mateconf_value_get_list (entry->value); l; l = l->next) - { - const char *source = mateconf_value_get_string (l->data); - - source_data->selected_sources = - g_slist_prepend (source_data->selected_sources, - g_strdup (source)); - } - source_data->selected_sources = - g_slist_reverse (source_data->selected_sources); - - calendar_sources_load_esource_list (source_data); -} - -static void -calendar_sources_load_sources (CalendarSources *sources, - CalendarSourceData *source_data, - const char *sources_key, - const char *selected_sources_key, - const char *selected_sources_dir) -{ - MateConfClient *mateconf_client; - GError *error; - - dprintf ("---------------------------\n"); - dprintf ("Loading sources:\n"); - dprintf (" sources_key: %s\n", sources_key); - dprintf (" selected_sources_key: %s\n", selected_sources_key); - dprintf (" selected_sources_dir: %s\n", selected_sources_dir); - - mateconf_client = sources->priv->mateconf_client; - - error = NULL; - source_data->selected_sources = mateconf_client_get_list (mateconf_client, - selected_sources_key, - MATECONF_VALUE_STRING, - &error); - if (error) - { - g_warning ("Failed to get selected sources from '%s': %s\n", - selected_sources_key, - error->message); - g_error_free (error); - return; - } - - mateconf_client_add_dir (mateconf_client, - selected_sources_dir, - MATECONF_CLIENT_PRELOAD_NONE, - NULL); - source_data->selected_sources_dir = g_strdup (selected_sources_dir); - - source_data->selected_sources_listener = - mateconf_client_notify_add (mateconf_client, - selected_sources_dir, - (MateConfClientNotifyFunc) calendar_sources_selected_sources_notify, - source_data, NULL, NULL); - - source_data->esource_list = e_source_list_new_for_mateconf (mateconf_client, sources_key); - g_signal_connect (source_data->esource_list, "changed", - G_CALLBACK (calendar_sources_esource_list_changed), - source_data); - - calendar_sources_load_esource_list (source_data); - - source_data->loaded = TRUE; - - dprintf ("---------------------------\n"); -} - -GSList * -calendar_sources_get_appointment_sources (CalendarSources *sources) -{ - g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL); - - if (!sources->priv->appointment_sources.loaded) - { - calendar_sources_load_sources (sources, - &sources->priv->appointment_sources, - CALENDAR_SOURCES_APPOINTMENT_SOURCES_KEY, - CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_KEY, - CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_DIR); - } - - return sources->priv->appointment_sources.clients; -} - -GSList * -calendar_sources_get_task_sources (CalendarSources *sources) -{ - g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL); - - if (!sources->priv->task_sources.loaded) - { - calendar_sources_load_sources (sources, - &sources->priv->task_sources, - CALENDAR_SOURCES_TASK_SOURCES_KEY, - CALENDAR_SOURCES_SELECTED_TASK_SOURCES_KEY, - CALENDAR_SOURCES_SELECTED_TASK_SOURCES_DIR); - } - - return sources->priv->task_sources.clients; -} diff --git a/applets/clock/calendar-sources.h b/applets/clock/calendar-sources.h deleted file mode 100644 index 3f080c55..00000000 --- a/applets/clock/calendar-sources.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2004 Free Software Foundation, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - * William Jon McCann <[email protected]> - * Martin Grimme <[email protected]> - * Christian Kellner <[email protected]> - */ - -#ifndef __CALENDAR_SOURCES_H__ -#define __CALENDAR_SOURCES_H__ - -#include <glib-object.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define CALENDAR_TYPE_SOURCES (calendar_sources_get_type ()) -#define CALENDAR_SOURCES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CALENDAR_TYPE_SOURCES, CalendarSources)) -#define CALENDAR_SOURCES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CALENDAR_TYPE_SOURCES, CalendarSourcesClass)) -#define CALENDAR_IS_SOURCES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CALENDAR_TYPE_SOURCES)) -#define CALENDAR_IS_SOURCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CALENDAR_TYPE_SOURCES)) -#define CALENDAR_SOURCES_GET_CLASS(o)(G_TYPE_INSTANCE_GET_CLASS ((o), CALENDAR_TYPE_SOURCES, CalendarSourcesClass)) - -typedef struct _CalendarSources CalendarSources; -typedef struct _CalendarSourcesClass CalendarSourcesClass; -typedef struct _CalendarSourcesPrivate CalendarSourcesPrivate; - -struct _CalendarSources -{ - GObject parent; - CalendarSourcesPrivate *priv; -}; - -struct _CalendarSourcesClass -{ - GObjectClass parent_class; - - void (* appointment_sources_changed) (CalendarSources *sources); - void (* task_sources_changed) (CalendarSources *sources); -}; - - -GType calendar_sources_get_type (void) G_GNUC_CONST; -CalendarSources *calendar_sources_get (void); -GSList *calendar_sources_get_appointment_sources (CalendarSources *sources); -GSList *calendar_sources_get_task_sources (CalendarSources *sources); - -#ifdef __cplusplus -} -#endif - -#endif /* __CALENDAR_SOURCES_H__ */ diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c index 062e4d7e..c2a723d4 100644 --- a/applets/clock/calendar-window.c +++ b/applets/clock/calendar-window.c @@ -25,22 +25,12 @@ * Most of the original code comes from clock.c */ - /* - * Evolution calendar integration TODO: - * + Fix treeview scrolling and sizing - * + Tooltips for tasks/appointments - * + Do everything backwards if the clock is on the bottom - * + Double clicking appointments/tasks should open them in evo - * + Consider using different colours for different sources - * + Consider doing a GtkMenu tearoff type thing - */ - #include <config.h> #include <string.h> #include <glib/gi18n.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #define MATE_DESKTOP_USE_UNSTABLE_API #include <libmate/mate-desktop-utils.h> @@ -50,30 +40,14 @@ #include "clock.h" #include "clock-utils.h" #include "clock-typebuiltins.h" -#ifdef HAVE_LIBECAL -#include "calendar-client.h" -#endif #define CALENDAR_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_WINDOW, CalendarWindowPrivate)) -#define KEY_LOCATIONS_EXPANDED "expand_locations" -#ifdef HAVE_LIBECAL -/* For the following value, take into account the KEY_* that are not inside this #ifdef! */ -# define N_CALENDAR_WINDOW_MATECONF_PREFS 5 -# define KEY_APPOINTMENTS_EXPANDED "expand_appointments" -# define KEY_BIRTHDAYS_EXPANDED "expand_birthdays" -# define KEY_TASKS_EXPANDED "expand_tasks" -# define KEY_WEATHER_EXPANDED "expand_weather" - -# define KEY_CALENDAR_APP "/desktop/mate/applications/calendar" -# define KEY_TASKS_APP "/desktop/mate/applications/tasks" -#else -# define N_CALENDAR_WINDOW_MATECONF_PREFS 1 -#endif +#define KEY_LOCATIONS_EXPANDED "expand-locations" enum { - EDIT_LOCATIONS, - LAST_SIGNAL +EDIT_LOCATIONS, +LAST_SIGNAL }; static guint signals[LAST_SIGNAL]; @@ -81,7 +55,7 @@ static guint signals[LAST_SIGNAL]; struct _CalendarWindowPrivate { GtkWidget *calendar; - char *prefs_dir; + char *prefs_path; gboolean invert_order; gboolean show_weeks; @@ -89,28 +63,7 @@ struct _CalendarWindowPrivate { GtkWidget *locations_list; -#ifdef HAVE_LIBECAL - ClockFormat time_format; - - CalendarClient *client; - - GtkWidget *appointment_list; - GtkWidget *birthday_list; - GtkWidget *weather_list; - GtkWidget *task_list; - - GtkListStore *appointments_model; - GtkListStore *tasks_model; - - GtkTreeSelection *previous_selection; - - GtkTreeModelFilter *appointments_filter; - GtkTreeModelFilter *birthdays_filter; - GtkTreeModelFilter *tasks_filter; - GtkTreeModelFilter *weather_filter; -#endif /* HAVE_LIBECAL */ - - MateConfClient *mateconfclient; + GSettings *settings; }; G_DEFINE_TYPE (CalendarWindow, calendar_window, GTK_TYPE_WINDOW) @@ -119,1409 +72,22 @@ enum { PROP_0, PROP_INVERTORDER, PROP_SHOWWEEKS, -#ifdef HAVE_LIBECAL - PROP_TIMEFORMAT, -#endif PROP_CURRENTTIMEP, - PROP_PREFSDIR + PROP_PREFSPATH }; static time_t *calendar_window_get_current_time_p (CalendarWindow *calwin); static void calendar_window_set_current_time_p (CalendarWindow *calwin, time_t *current_time); -static const char *calendar_window_get_prefs_dir (CalendarWindow *calwin); -static void calendar_window_set_prefs_dir (CalendarWindow *calwin, - const char *prefs_dir); +static const char *calendar_window_get_prefs_path (CalendarWindow *calwin); +static void calendar_window_set_prefs_path (CalendarWindow *calwin, + const char *prefs_path); static GtkWidget * create_hig_frame (CalendarWindow *calwin, const char *title, const char *button_label, const char *key, GCallback callback); -#ifdef HAVE_LIBECAL - -static void -clock_launch_calendar_tasks_app (CalendarWindow *calwin, - const char *key_program, - const char *argument) -{ - char **argv; - int argc; - char *key; - char *program; - gboolean terminal; - char *command_line; - GdkScreen *screen; - GError *error; - gboolean result; - - key = g_strdup_printf ("%s%s", key_program, "/exec"); - program = mateconf_client_get_string (calwin->priv->mateconfclient, - key, NULL); - g_free (key); - - key = g_strdup_printf ("%s%s", key_program, "/needs_term"); - terminal = mateconf_client_get_bool (calwin->priv->mateconfclient, - key, NULL); - g_free (key); - - if (program == NULL) { - g_printerr ("Cannot launch calendar/tasks application: key not set\n"); - return; - } - - command_line = g_find_program_in_path (program); - if (command_line == NULL) { - g_printerr ("Cannot launch calendar/tasks application: %s in path\n", program); - g_free (program); - return; - } - g_free (command_line); - - if (argument) { - argc = 2; - argv = g_new0 (char *, 3); - argv[1] = g_strdup (argument); - } else { - argc = 1; - argv = g_new0 (char *, 2); - } - argv[0] = program; /* no strdup, and it will get freed for free */ - - screen = gtk_widget_get_screen (calwin->priv->calendar); - error = NULL; - - if (terminal) - mate_desktop_prepend_terminal_to_vector (&argc, &argv); - - result = gdk_spawn_on_screen (screen, - NULL, /* working directory */ - argv, - NULL, /* envp */ - G_SPAWN_SEARCH_PATH, - NULL, /* child setup func */ - NULL, /* user data */ - NULL, /* child pid */ - &error); - - if (!result) { - g_printerr ("Cannot launch calendar/tasks application: %s\n", - error->message); - g_error_free (error); - } - - g_strfreev (argv); -} - -static void -clock_launch_calendar_app (CalendarWindow *calwin, - const char *argument) -{ - clock_launch_calendar_tasks_app (calwin, KEY_CALENDAR_APP, argument); -} - -static void -clock_launch_tasks_app (CalendarWindow *calwin, - const char *argument) -{ - clock_launch_calendar_tasks_app (calwin, KEY_TASKS_APP, argument); -} - -static void -update_frame_visibility (GtkWidget *frame, - GtkTreeModel *model) -{ - GtkTreeIter iter; - gboolean model_empty; - - if (!frame) - return; - - model_empty = !gtk_tree_model_get_iter_first (model, &iter); - - if (model_empty) - gtk_widget_hide (frame); - else - gtk_widget_show (frame); -} - -enum { - APPOINTMENT_COLUMN_UID, - APPOINTMENT_COLUMN_URI, - APPOINTMENT_COLUMN_SUMMARY, - APPOINTMENT_COLUMN_DESCRIPTION, - APPOINTMENT_COLUMN_START_TIME, - APPOINTMENT_COLUMN_START_TEXT, - APPOINTMENT_COLUMN_END_TIME, - APPOINTMENT_COLUMN_ALL_DAY, - APPOINTMENT_COLUMN_PIXBUF, - N_APPOINTMENT_COLUMNS -}; - -enum { - TASK_COLUMN_UID, - TASK_COLUMN_SUMMARY, - TASK_COLUMN_DESCRIPTION, - TASK_COLUMN_START_TIME, - TASK_COLUMN_DUE_TIME, - TASK_COLUMN_PERCENT_COMPLETE, - TASK_COLUMN_PERCENT_COMPLETE_TEXT, - TASK_COLUMN_COMPLETED, - TASK_COLUMN_COMPLETED_TIME, - TASK_COLUMN_OVERDUE_ATTR, - TASK_COLUMN_COLOR, - TASK_COLUMN_PRIORITY, - N_TASK_COLUMNS -}; - -static char * -format_time (ClockFormat format, - time_t t, - guint year, - guint month, - guint day) -{ - struct tm *tm; - char *time_format; - char result [256] = { 0, }; - - if (!t) - return NULL; - - tm = localtime (&t); - if (!tm) - return NULL; - - if (year == (tm->tm_year + 1900) && - month == tm->tm_mon && - day == tm->tm_mday) { - if (format == CLOCK_FORMAT_12) - /* Translators: This is a strftime format string. - * It is used to display the time in 12-hours format - * (eg, like in the US: 8:10 am). The %p expands to - * am/pm. */ - time_format = g_locale_from_utf8 (_("%l:%M %p"), -1, NULL, NULL, NULL); - else - /* Translators: This is a strftime format string. - * It is used to display the time in 24-hours format - * (eg, like in France: 20:10). */ - time_format = g_locale_from_utf8 (_("%H:%M"), -1, NULL, NULL, NULL); - } - else { - /* Translators: This is a strftime format string. - * It is used to display the start date of an appointment, in - * the most abbreviated way possible. */ - time_format = g_locale_from_utf8 (_("%b %d"), -1, NULL, NULL, NULL); - } - - strftime (result, sizeof (result), time_format, tm); - g_free (time_format); - - return g_locale_to_utf8 (result, -1, NULL, NULL, NULL); -} - -static void -handle_tasks_changed (CalendarWindow *calwin) -{ - GSList *events, *l; - - gtk_list_store_clear (calwin->priv->tasks_model); - - events = calendar_client_get_events (calwin->priv->client, - CALENDAR_EVENT_TASK); - for (l = events; l; l = l->next) { - CalendarTask *task = l->data; - GtkTreeIter iter; - char *percent_complete_text; - - g_assert (CALENDAR_EVENT (task)->type == CALENDAR_EVENT_TASK); - - /* FIXME: should this format be locale specific ? */ - percent_complete_text = g_strdup_printf ("%d%%", task->percent_complete); - - gtk_list_store_append (calwin->priv->tasks_model, &iter); - gtk_list_store_set (calwin->priv->tasks_model, &iter, - TASK_COLUMN_UID, task->uid, - TASK_COLUMN_SUMMARY, task->summary, - TASK_COLUMN_DESCRIPTION, task->description, - TASK_COLUMN_START_TIME, (gint64)task->start_time, - TASK_COLUMN_DUE_TIME, (gint64)task->due_time, - TASK_COLUMN_PERCENT_COMPLETE, task->percent_complete, - TASK_COLUMN_PERCENT_COMPLETE_TEXT, percent_complete_text, - TASK_COLUMN_COMPLETED, task->percent_complete == 100, - TASK_COLUMN_COMPLETED_TIME, (gint64)task->completed_time, - TASK_COLUMN_COLOR, task->color_string, - TASK_COLUMN_PRIORITY, task->priority, - -1); - - g_free (percent_complete_text); - calendar_event_free (CALENDAR_EVENT (task)); - } - g_slist_free (events); - - update_frame_visibility (calwin->priv->task_list, - GTK_TREE_MODEL (calwin->priv->tasks_filter)); -} - -static void -handle_task_completed_toggled (CalendarWindow *calwin, - const char *path_str, - GtkCellRendererToggle *cell) -{ - GtkTreePath *child_path, *path; - GtkTreeIter iter; - char *uid; - gboolean task_completed; - guint percent_complete; - - path = gtk_tree_path_new_from_string (path_str); - child_path = gtk_tree_model_filter_convert_path_to_child_path (calwin->priv->tasks_filter, path); - gtk_tree_model_get_iter (GTK_TREE_MODEL (calwin->priv->tasks_model), - &iter, child_path); - gtk_tree_model_get (GTK_TREE_MODEL (calwin->priv->tasks_model), - &iter, - TASK_COLUMN_UID, &uid, - TASK_COLUMN_COMPLETED, &task_completed, - TASK_COLUMN_PERCENT_COMPLETE, &percent_complete, - -1); - - task_completed = !task_completed; - percent_complete = task_completed ? 100 : 0; - - calendar_client_set_task_completed (calwin->priv->client, - uid, - task_completed, - percent_complete); - - g_free (uid); - gtk_tree_path_free (path); - gtk_tree_path_free (child_path); -} - -static void -handle_task_percent_complete_edited (CalendarWindow *calwin, - const char *path_str, - const char *text, - GtkCellRendererText *cell) -{ - GtkTreePath *child_path, *path; - GtkTreeIter iter; - char *uid; - int percent_complete; - char *error = NULL, *text_copy; - - path = gtk_tree_path_new_from_string (path_str); - child_path = gtk_tree_model_filter_convert_path_to_child_path (calwin->priv->tasks_filter, path); - gtk_tree_model_get_iter (GTK_TREE_MODEL (calwin->priv->tasks_model), - &iter, child_path); - gtk_tree_model_get (GTK_TREE_MODEL (calwin->priv->tasks_model), - &iter, TASK_COLUMN_UID, &uid, - -1); - - text_copy = g_strdup (text); - text_copy = g_strdelimit (text_copy, "%", ' '); - text_copy = g_strstrip (text_copy); - percent_complete = (int) g_strtod (text_copy, &error); - if (!error || !error [0]) { - gboolean task_completed; - - percent_complete = CLAMP (percent_complete, 0, 100); - task_completed = (percent_complete == 100); - - calendar_client_set_task_completed (calwin->priv->client, - uid, - task_completed, - percent_complete); - } - - g_free (uid); - g_free (text_copy); - gtk_tree_path_free (path); - gtk_tree_path_free (child_path); -} - -static gboolean -is_appointment (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - gchar *uri; - - gtk_tree_model_get (model, iter, APPOINTMENT_COLUMN_URI, &uri, -1); - if (uri) - return (g_ascii_strcasecmp (uri, "file") == 0 || - g_ascii_strcasecmp (uri, "webcal") == 0 || - g_ascii_strcasecmp (uri, "caldav") == 0 || - g_ascii_strcasecmp (uri, "exchange") == 0 || - g_ascii_strcasecmp (uri, "groupwise") == 0 || - g_ascii_strcasecmp (uri, "google") == 0); - return FALSE; -} - -static gboolean -is_birthday (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - gchar *uri; - - gtk_tree_model_get (model, iter, APPOINTMENT_COLUMN_URI, &uri, -1); - if (uri) - return (g_ascii_strcasecmp (uri, "contacts") == 0); - return FALSE; -} - -static gboolean -is_weather (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - gchar *uri; - - gtk_tree_model_get (model, iter, APPOINTMENT_COLUMN_URI, &uri, -1); - if (uri) - return (g_ascii_strcasecmp (uri, "weather") == 0); - return FALSE; -} - -static gboolean -filter_out_tasks (GtkTreeModel *model, - GtkTreeIter *iter, - CalendarWindow *calwin) -{ - gint64 start_time64; - gint64 completed_time64; - time_t start_time; - time_t completed_time; - time_t one_day_ago; - gboolean visible; - - gtk_tree_model_get (model, iter, - TASK_COLUMN_START_TIME, &start_time64, - TASK_COLUMN_COMPLETED_TIME, &completed_time64, - -1); - start_time = start_time64; - completed_time = completed_time64; - - one_day_ago = *(calwin->priv->current_time) - (24 * 60 * 60); - - visible = !start_time || start_time <= *(calwin->priv->current_time); - if (visible) - visible = !completed_time || completed_time >= one_day_ago; - - return visible; -} - -static void -modify_task_text_attributes (GtkTreeModel *model, - GtkTreeIter *iter, - GValue *value, - gint column, - CalendarWindow *calwin) -{ - gint64 due_time64; - time_t due_time; - PangoAttrList *attr_list; - PangoAttribute *attr; - GtkTreeIter child_iter; - - gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), - &child_iter, - iter); - - if (column != TASK_COLUMN_OVERDUE_ATTR) { - memset (value, 0, sizeof (GValue)); - gtk_tree_model_get_value (GTK_TREE_MODEL (calwin->priv->tasks_model), - &child_iter, column, value); - - return; - } - - gtk_tree_model_get (GTK_TREE_MODEL (calwin->priv->tasks_model), - &child_iter, TASK_COLUMN_DUE_TIME, &due_time64, - -1); - due_time = due_time64; - - if (due_time && due_time > *(calwin->priv->current_time)) - return; - - attr_list = pango_attr_list_new (); - - attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); - attr->start_index = 0; - attr->end_index = G_MAXINT; - pango_attr_list_insert (attr_list, attr); - - g_value_take_boxed (value, attr_list); -} - -static gboolean -task_activated_cb (GtkTreeView *view, - GtkTreePath *path, - GtkTreeViewColumn *column, - CalendarWindow *calwin) -{ - GtkTreeIter iter; - GtkTreePath *child_path; - char *uid; - char *argument; - - child_path = gtk_tree_model_filter_convert_path_to_child_path (calwin->priv->tasks_filter, - path); - - gtk_tree_model_get_iter (GTK_TREE_MODEL (calwin->priv->tasks_model), - &iter, child_path); - gtk_tree_model_get (GTK_TREE_MODEL (calwin->priv->tasks_model), - &iter, TASK_COLUMN_UID, &uid, -1); - - argument = g_strdup_printf ("task:%s", uid); - - clock_launch_tasks_app (calwin, argument); - - g_free (argument); - g_free (uid); - gtk_tree_path_free (child_path); - - return TRUE; -} - -static void -set_renderer_pixbuf_color_by_column (GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gint column_number) -{ - char *color_string; - GdkPixbuf *pixbuf = NULL; - GdkColor color; - - gtk_tree_model_get (model, iter, column_number, &color_string, -1); - - if (color_string && gdk_color_parse (color_string, &color)) { - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 16, 16); - /* GdkColor has 16 bits per color, gdk_pixbuf only uses 8 bits - * per color. So just drop the least significant parts */ - gdk_pixbuf_fill (pixbuf, - (color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00)); - - g_object_set (renderer, "visible", pixbuf != NULL, "pixbuf", pixbuf, NULL); - - if (pixbuf) - g_object_unref (pixbuf); - - g_free (color_string); - } -} - -static void -set_renderer_pixbuf_pixmap (GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - const char *iconpath) -{ - GdkPixbuf *pixbuf = NULL; - GError *error = NULL; - - if (!g_file_test (iconpath, G_FILE_TEST_IS_REGULAR)) { - g_printerr ("File '%s' does not exist.\n", iconpath); - return; - } - - pixbuf = gdk_pixbuf_new_from_file (iconpath, &error); - if (error) { - g_printerr ("Cannot load '%s': %s\n", - iconpath, error->message); - g_error_free (error); - return; - } - - g_object_set (renderer, - "visible", pixbuf != NULL, - "pixbuf", pixbuf, - NULL); - - if (pixbuf) - g_object_unref (pixbuf); -} - -static void -set_renderer_pixbuf_pixmap_for_bday (GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gint data_column) -{ - const gchar *path = NULL; - gchar *type = NULL; - - gtk_tree_model_get (model, iter, data_column, &type, -1); - if (!type) - return; - - /* type should be in format like this: - * pas-id-4121A93E00000001-anniversary - * pas-id-41112AF900000003-birthday - * ... - */ - if (g_strrstr (type, "birthday") != NULL) - path = CLOCK_EDS_ICONDIR G_DIR_SEPARATOR_S "category_birthday_16.png"; - else if (g_strrstr (type, "anniversary") != NULL) - path = CLOCK_EDS_ICONDIR G_DIR_SEPARATOR_S "category_gifts_16.png"; - else - path = CLOCK_EDS_ICONDIR G_DIR_SEPARATOR_S "category_miscellaneous_16.png"; - - g_free (type); - - set_renderer_pixbuf_pixmap (renderer, model, iter, path); -} - -static void -set_renderer_pixbuf_pixmap_for_weather (GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter) -{ - set_renderer_pixbuf_pixmap (renderer, model, iter, - CLOCK_EDS_ICONDIR G_DIR_SEPARATOR_S "category_holiday_16.png"); -} - -static void -task_pixbuf_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - set_renderer_pixbuf_color_by_column (renderer, - model, - iter, - TASK_COLUMN_COLOR); -} - -static void -appointment_pixbuf_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - set_renderer_pixbuf_color_by_column (renderer, - model, - iter, - APPOINTMENT_COLUMN_PIXBUF); -} -static void -birthday_pixbuf_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - - /* APPOINTMENT_COLUMN_UID contains data to select between - * anniversary or birthday - */ - set_renderer_pixbuf_pixmap_for_bday (renderer, - model, - iter, - APPOINTMENT_COLUMN_UID); -} -static void -weather_pixbuf_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - - set_renderer_pixbuf_pixmap_for_weather (renderer, - model, - iter); -} - -static int -compare_tasks (GtkTreeModel *model, - GtkTreeIter *a, - GtkTreeIter *b, - gpointer user_data) -{ - gboolean done_a, done_b; - int priority_a, priority_b; - - gtk_tree_model_get (model, a, - TASK_COLUMN_COMPLETED, &done_a, - TASK_COLUMN_PRIORITY, &priority_a, - -1); - gtk_tree_model_get (model, b, - TASK_COLUMN_COMPLETED, &done_b, - TASK_COLUMN_PRIORITY, &priority_b, - -1); - - /* Always sort completed tasks last */ - if (done_a != done_b) - return done_a ? -1 : 1; - - /* We change undefined priorities so they appear as "Normal" */ - if (priority_a <= 0) - priority_a = 5; - if (priority_b <= 0) - priority_b = 5; - - /* We'll just use the ordering of the priority values. */ - if (priority_a < priority_b) - return -1; - else if (priority_a > priority_b) - return 1; - else { - gint64 due_time_a64, due_time_b64; - time_t due_time_a, due_time_b; - - gtk_tree_model_get (model, a, - TASK_COLUMN_DUE_TIME, &due_time_a64, -1); - gtk_tree_model_get (model, b, - TASK_COLUMN_DUE_TIME, &due_time_b64, -1); - due_time_a = due_time_a64; - due_time_b = due_time_b64; - - if (due_time_a < due_time_b) - return -1; - else if (due_time_a > due_time_b) - return 1; - else { - char *summary_a, *summary_b; - int res; - - gtk_tree_model_get (model, a, TASK_COLUMN_SUMMARY, &summary_a, -1); - gtk_tree_model_get (model, b, TASK_COLUMN_SUMMARY, &summary_b, -1); - - res = g_utf8_collate (summary_a ? summary_a: "", - summary_b ? summary_b: ""); - - g_free (summary_a); - g_free (summary_b); - - return res; - } - } -} - -static void -calendar_window_tree_selection_changed (GtkTreeSelection *selection, - CalendarWindow *calwin) -{ - if (selection == calwin->priv->previous_selection) - return; - - if (calwin->priv->previous_selection) { - g_signal_handlers_block_by_func (calwin->priv->previous_selection, - calendar_window_tree_selection_changed, - calwin); - gtk_tree_selection_unselect_all (calwin->priv->previous_selection); - g_signal_handlers_unblock_by_func (calwin->priv->previous_selection, - calendar_window_tree_selection_changed, - calwin); - } - - calwin->priv->previous_selection = selection; -} - -static void -edit_tasks (CalendarWindow *calwin) -{ - clock_launch_tasks_app (calwin, NULL); -} - -static GtkWidget * -create_task_list (CalendarWindow *calwin, - GtkWidget **tree_view, - GtkWidget **scrolled_window) -{ - GtkWidget *list; - GtkWidget *view; - GtkWidget *scrolled; - GtkCellRenderer *cell; - GtkTreeViewColumn *column; - GtkTreeSelection *selection; - - list = create_hig_frame (calwin, - _("Tasks"), _("Edit"), - KEY_TASKS_EXPANDED, - G_CALLBACK (edit_tasks)); - - *scrolled_window = scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), - GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - /* we show the widget before adding to the container, since adding to - * the container changes the visibility depending on the state of the - * expander */ - gtk_widget_show (scrolled); - gtk_container_add (GTK_CONTAINER (list), scrolled); - - g_assert (calwin->priv->tasks_model != NULL); - - *tree_view = view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (calwin->priv->tasks_filter)); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE); - - g_signal_connect (view, "row-activated", - G_CALLBACK (task_activated_cb), calwin); - - /* Source color */ - column = gtk_tree_view_column_new (); - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_set_cell_data_func (column, cell, - (GtkTreeCellDataFunc) task_pixbuf_cell_data_func, - NULL, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - /* Completed toggle */ - column = gtk_tree_view_column_new (); - cell = gtk_cell_renderer_toggle_new (); - g_object_set (cell, - "activatable", TRUE, - NULL); - g_signal_connect_swapped (cell, "toggled", - G_CALLBACK (handle_task_completed_toggled), - calwin); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, - "active", TASK_COLUMN_COMPLETED); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - /* Percent complete */ - column = gtk_tree_view_column_new (); - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, - "editable", TRUE, - NULL); - g_signal_connect_swapped (cell, "edited", - G_CALLBACK (handle_task_percent_complete_edited), - calwin); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, - "text", TASK_COLUMN_PERCENT_COMPLETE_TEXT); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - /* Summary */ - column = gtk_tree_view_column_new (); - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_set_attributes (column, cell, - "text", TASK_COLUMN_SUMMARY, - "strikethrough", TASK_COLUMN_COMPLETED, - "attributes", TASK_COLUMN_OVERDUE_ATTR, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - g_signal_connect (selection, "changed", - G_CALLBACK (calendar_window_tree_selection_changed), - calwin); - - gtk_container_add (GTK_CONTAINER (scrolled), view); - - gtk_widget_show (view); - - return list; -} - -static void -mark_day_on_calendar (CalendarClient *client, - guint day, - CalendarWindow *calwin) -{ - gtk_calendar_mark_day (GTK_CALENDAR (calwin->priv->calendar), day); -} - -static void -handle_appointments_changed (CalendarWindow *calwin) -{ - GSList *events, *l; - guint year, month, day; - - if (calwin->priv->calendar) { - gtk_calendar_clear_marks (GTK_CALENDAR (calwin->priv->calendar)); - - calendar_client_foreach_appointment_day (calwin->priv->client, - (CalendarDayIter) mark_day_on_calendar, - calwin); - } - - gtk_list_store_clear (calwin->priv->appointments_model); - - calendar_client_get_date (calwin->priv->client, &year, &month, &day); - - events = calendar_client_get_events (calwin->priv->client, - CALENDAR_EVENT_APPOINTMENT); - for (l = events; l; l = l->next) { - CalendarAppointment *appointment = l->data; - GtkTreeIter iter; - char *start_text; - - g_assert (CALENDAR_EVENT (appointment)->type == CALENDAR_EVENT_APPOINTMENT); - - if (appointment->is_all_day) - start_text = g_strdup (_("All Day")); - else - start_text = format_time (calwin->priv->time_format, - appointment->start_time, - year, month, day); - - - gtk_list_store_append (calwin->priv->appointments_model, - &iter); - gtk_list_store_set (calwin->priv->appointments_model, &iter, - APPOINTMENT_COLUMN_UID, appointment->uid, - APPOINTMENT_COLUMN_URI, appointment->uri, - APPOINTMENT_COLUMN_SUMMARY, appointment->summary, - APPOINTMENT_COLUMN_DESCRIPTION, appointment->description, - APPOINTMENT_COLUMN_START_TIME, (gint64)appointment->start_time, - APPOINTMENT_COLUMN_START_TEXT, start_text, - APPOINTMENT_COLUMN_END_TIME, (gint64)appointment->end_time, - APPOINTMENT_COLUMN_ALL_DAY, appointment->is_all_day, - APPOINTMENT_COLUMN_PIXBUF, appointment->color_string, - -1); - - g_free (start_text); - calendar_event_free (CALENDAR_EVENT (appointment)); - } - g_slist_free (events); - - update_frame_visibility (calwin->priv->appointment_list, - GTK_TREE_MODEL (calwin->priv->appointments_filter)); - update_frame_visibility (calwin->priv->birthday_list, - GTK_TREE_MODEL (calwin->priv->birthdays_filter)); - update_frame_visibility (calwin->priv->weather_list, - GTK_TREE_MODEL (calwin->priv->weather_filter)); -} - -static GtkWidget * -create_list_for_appointment_model (CalendarWindow *calwin, - const char *label, - GtkTreeModelFilter **filter, - GtkTreeModelFilterVisibleFunc is_for_filter, - GtkTreeCellDataFunc set_pixbuf_cell, - gboolean show_start, - GtkWidget **tree_view, - GtkWidget **scrolled_window, - const char *key, - GCallback callback) -{ - GtkWidget *list; - GtkWidget *view; - GtkWidget *scrolled; - GtkCellRenderer *cell; - GtkTreeViewColumn *column; - GtkTreeSelection *selection; - - - list = create_hig_frame (calwin, label, _("Edit"), key, callback); - - *scrolled_window = scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), - GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - /* we show the widget before adding to the container, since adding to - * the container changes the visibility depending on the state of the - * expander */ - gtk_widget_show (scrolled); - gtk_container_add (GTK_CONTAINER (list), scrolled); - - g_assert (calwin->priv->appointments_model != NULL); - - if (!*filter) { - *filter = - GTK_TREE_MODEL_FILTER ( - gtk_tree_model_filter_new (GTK_TREE_MODEL (calwin->priv->appointments_model), - NULL)); - gtk_tree_model_filter_set_visible_func ( - *filter, - (GtkTreeModelFilterVisibleFunc) is_for_filter, - calwin, - NULL); - } - - *tree_view = view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (*filter)); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE); - - /* Icon */ - column = gtk_tree_view_column_new (); - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_set_cell_data_func (column, cell, - (GtkTreeCellDataFunc) set_pixbuf_cell, - NULL, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - if (show_start) { - /* Start time */ - column = gtk_tree_view_column_new (); - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, - "text", APPOINTMENT_COLUMN_START_TEXT); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - } - - /* Summary */ - column = gtk_tree_view_column_new (); - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, - "text", APPOINTMENT_COLUMN_SUMMARY); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - g_signal_connect (selection, "changed", - G_CALLBACK (calendar_window_tree_selection_changed), - calwin); - - gtk_container_add (GTK_CONTAINER (scrolled), view); - - gtk_widget_show (view); - - return list; -} - -static void -edit_appointments (CalendarWindow *calwin) -{ - clock_launch_calendar_app (calwin, NULL); -} - -static GtkWidget * -create_appointment_list (CalendarWindow *calwin, - GtkWidget **tree_view, - GtkWidget **scrolled_window) -{ - return create_list_for_appointment_model ( - calwin, - _("Appointments"), - &calwin->priv->appointments_filter, - is_appointment, - appointment_pixbuf_cell_data_func, - TRUE, - tree_view, - scrolled_window, - KEY_APPOINTMENTS_EXPANDED, - G_CALLBACK (edit_appointments)); -} - -static void -edit_birthdays (CalendarWindow *calwin) -{ - clock_launch_calendar_app (calwin, NULL); -} - -static GtkWidget * -create_birthday_list (CalendarWindow *calwin, - GtkWidget **tree_view, - GtkWidget **scrolled_window) -{ - /* FIXME: Figure out how to get rid of useless localized message in front of the summary */ - return create_list_for_appointment_model ( - calwin, - _("Birthdays and Anniversaries"), - &calwin->priv->birthdays_filter, - is_birthday, - birthday_pixbuf_cell_data_func, - FALSE, - tree_view, - scrolled_window, - KEY_BIRTHDAYS_EXPANDED, - G_CALLBACK (edit_birthdays)); -} - -static void -edit_weather (CalendarWindow *calwin) -{ - clock_launch_calendar_app (calwin, NULL); -} - - -static GtkWidget * -create_weather_list (CalendarWindow *calwin, - GtkWidget **tree_view, - GtkWidget **scrolled_window) -{ - return create_list_for_appointment_model ( - calwin, - _("Weather Information"), - &calwin->priv->weather_filter, - is_weather, - weather_pixbuf_cell_data_func, - FALSE, - tree_view, - scrolled_window, - KEY_WEATHER_EXPANDED, - G_CALLBACK (edit_weather)); -} - -static void -calendar_window_create_tasks_model (CalendarWindow *calwin) -{ - GType column_types [N_TASK_COLUMNS] = { - G_TYPE_STRING, /* uid */ - G_TYPE_STRING, /* summary */ - G_TYPE_STRING, /* description */ - G_TYPE_INT64, /* start time */ - G_TYPE_INT64, /* due time */ - G_TYPE_UINT, /* percent complete */ - G_TYPE_STRING, /* percent complete text */ - G_TYPE_BOOLEAN, /* completed */ - G_TYPE_INT64, /* completed time */ - PANGO_TYPE_ATTR_LIST, /* summary text attributes */ - G_TYPE_STRING, /* color */ - G_TYPE_INT /* priority */ - }; - - calwin->priv->tasks_model = gtk_list_store_newv (N_TASK_COLUMNS, - column_types); - - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (calwin->priv->tasks_model), - TASK_COLUMN_PRIORITY, - compare_tasks, - NULL, NULL); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (calwin->priv->tasks_model), - TASK_COLUMN_PRIORITY, - GTK_SORT_ASCENDING); - - calwin->priv->tasks_filter = GTK_TREE_MODEL_FILTER ( - gtk_tree_model_filter_new (GTK_TREE_MODEL (calwin->priv->tasks_model), - NULL)); - gtk_tree_model_filter_set_visible_func ( - calwin->priv->tasks_filter, - (GtkTreeModelFilterVisibleFunc) filter_out_tasks, - calwin, - NULL); - gtk_tree_model_filter_set_modify_func ( - calwin->priv->tasks_filter, - N_TASK_COLUMNS, - column_types, - (GtkTreeModelFilterModifyFunc) modify_task_text_attributes, - calwin, - NULL); -} - -static void -calendar_window_create_appointments_model (CalendarWindow *calwin) -{ - calwin->priv->appointments_model = - gtk_list_store_new (N_APPOINTMENT_COLUMNS, - G_TYPE_STRING, /* uid */ - G_TYPE_STRING, /* uri */ - G_TYPE_STRING, /* summary */ - G_TYPE_STRING, /* description */ - G_TYPE_INT64, /* start time */ - G_TYPE_STRING, /* start time text */ - G_TYPE_INT64, /* end time */ - G_TYPE_BOOLEAN, /* all day */ - G_TYPE_STRING); /* color */ - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (calwin->priv->appointments_model), - APPOINTMENT_COLUMN_START_TIME, - GTK_SORT_ASCENDING); -} - -static void -calendar_day_activated (GtkCalendar *calendar, - CalendarWindow *calwin) -{ - unsigned int day; - unsigned int month; - unsigned int year; - time_t date; - struct tm utc_date_tm; - struct tm local_date_tm = { 0, }; - char *argument; - - gtk_calendar_get_date (calendar, &year, &month, &day); - - local_date_tm.tm_mday = (int) day; - local_date_tm.tm_mon = (int) month; - local_date_tm.tm_year = (int) year - 1900; - local_date_tm.tm_isdst = -1; - - /* convert the local date picked in the calendar to broken-down UTC */ - date = mktime (&local_date_tm); - gmtime_r (&date, &utc_date_tm); - - /* FIXME: once bug 409200 is fixed, we'll have to make this hh:mm:ss - * instead of hhmmss */ - argument = g_strdup_printf ("calendar:///?startdate=" - "%.4d%.2d%.2dT%.2d%.2d%.2dZ", - utc_date_tm.tm_year + 1900, - utc_date_tm.tm_mon + 1, - utc_date_tm.tm_mday, - utc_date_tm.tm_hour, - utc_date_tm.tm_min, - 0); - - clock_launch_calendar_app (calwin, argument); - - g_free (argument); -} - -static void -calendar_day_selected (GtkCalendar *calendar, - CalendarWindow *calwin) -{ - guint day; - - gtk_calendar_get_date (calendar, NULL, NULL, &day); - - calendar_client_select_day (calwin->priv->client, day); - - handle_appointments_changed (calwin); - handle_tasks_changed (calwin); -} - -static void -calendar_month_selected (GtkCalendar *calendar, - CalendarWindow *calwin) -{ - guint year, month; - - gtk_calendar_get_date (calendar, &year, &month, NULL); - - calendar_client_select_month (calwin->priv->client, month, year); - - handle_appointments_changed (calwin); - handle_tasks_changed (calwin); -} - -typedef struct -{ - GtkWidget *calendar; - GtkWidget *tree; -} ConstraintData; - -static void -constrain_list_size (GtkWidget *widget, - GtkRequisition *requisition, - ConstraintData *constraint) -{ - GtkRequisition req; - int screen_h; - int max_height; - - /* constrain width to the calendar width */ - gtk_widget_size_request (constraint->calendar, &req); - requisition->width = MIN (requisition->width, req.width); - - screen_h = gdk_screen_get_height (gtk_widget_get_screen (widget)); - /* constrain height to be the tree height up to a max */ - max_height = (screen_h - req.height) / 3; - gtk_widget_size_request (constraint->tree, &req); - - requisition->height = MIN (req.height, max_height); - requisition->height += 2 * gtk_widget_get_style (widget)->ythickness; -} - -static void -setup_list_size_constraint (GtkWidget *widget, - GtkWidget *calendar, - GtkWidget *tree) -{ - ConstraintData *constraint; - - constraint = g_new0 (ConstraintData, 1); - constraint->calendar = calendar; - constraint->tree = tree; - - g_signal_connect_data (widget, "size-request", - G_CALLBACK (constrain_list_size), constraint, - (GClosureNotify) g_free, 0); -} -#endif /* HAVE_LIBECAL */ - -static void -expander_activated (GtkExpander *expander, - CalendarWindow *calwin) -{ - const char *key; - - key = (const gchar*)g_object_get_data (G_OBJECT (expander), "mateconf-key"); - - if (mateconf_client_key_is_writable (calwin->priv->mateconfclient, - key, NULL)) { - mateconf_client_set_bool (calwin->priv->mateconfclient, key, - gtk_expander_get_expanded (expander), - NULL); - } -} - -static void -expanded_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - GtkExpander *expander) -{ - gboolean value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - value = mateconf_value_get_bool (entry->value); - - gtk_expander_set_expanded (expander, value); -} - -static void -remove_listener (gpointer data) -{ - MateConfClient *client; - - client = mateconf_client_get_default (); - mateconf_client_notify_remove (client, GPOINTER_TO_UINT (data)); - g_object_unref (client); -} - -static void -connect_expander_with_mateconf (CalendarWindow *calwin, - GtkWidget *expander, - const char *relative_key) -{ - char *key; - gboolean expanded; - guint listener; - - key = g_strdup_printf ("%s/%s", - calwin->priv->prefs_dir, relative_key); - - g_object_set_data_full (G_OBJECT (expander), "mateconf-key", (gpointer)key, g_free); - - expanded = mateconf_client_get_bool (calwin->priv->mateconfclient, key, - NULL); - gtk_expander_set_expanded (GTK_EXPANDER (expander), expanded); - - g_signal_connect_after (expander, "activate", - G_CALLBACK (expander_activated), - calwin); - - listener = mateconf_client_notify_add ( - calwin->priv->mateconfclient, key, - (MateConfClientNotifyFunc) expanded_changed, - expander, NULL, NULL); - - g_object_set_data_full (G_OBJECT (expander), "listener-id", - GUINT_TO_POINTER (listener), remove_listener); -} - -static void -calendar_window_pack_pim (CalendarWindow *calwin, - GtkWidget *vbox) -{ -#ifdef HAVE_LIBECAL - GtkWidget *list; - GtkWidget *tree_view; - GtkWidget *scrolled_window; - guint year, month, day; - - calendar_window_create_tasks_model (calwin); - calendar_window_create_appointments_model (calwin); - - list = create_task_list (calwin, &tree_view, &scrolled_window); - setup_list_size_constraint (scrolled_window, - calwin->priv->calendar, tree_view); - update_frame_visibility (list, - GTK_TREE_MODEL (calwin->priv->tasks_model)); - calwin->priv->task_list = list; - - list = create_birthday_list (calwin, &tree_view, &scrolled_window); - setup_list_size_constraint (scrolled_window, - calwin->priv->calendar, tree_view); - update_frame_visibility (list, - GTK_TREE_MODEL (calwin->priv->birthdays_filter)); - calwin->priv->birthday_list = list; - - list = create_weather_list (calwin, &tree_view, &scrolled_window); - setup_list_size_constraint (scrolled_window, - calwin->priv->calendar, tree_view); - update_frame_visibility (list, - GTK_TREE_MODEL (calwin->priv->weather_filter)); - calwin->priv->weather_list = list; - - list = create_appointment_list (calwin, &tree_view, &scrolled_window); - setup_list_size_constraint (scrolled_window, - calwin->priv->calendar, tree_view); - update_frame_visibility (list, - GTK_TREE_MODEL (calwin->priv->appointments_filter)); - calwin->priv->appointment_list = list; - - if (!calwin->priv->invert_order) { - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->task_list, - TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->appointment_list, - TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->birthday_list, - TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->weather_list, - TRUE, TRUE, 0); - } else { - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->weather_list, - TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->birthday_list, - TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->appointment_list, - TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), - calwin->priv->task_list, - TRUE, TRUE, 0); - } - - if (!calwin->priv->client) { - calwin->priv->client = calendar_client_new (); - - g_signal_connect_swapped (calwin->priv->client, - "tasks-changed", - G_CALLBACK (handle_tasks_changed), - calwin); - g_signal_connect_swapped (calwin->priv->client, - "appointments-changed", - G_CALLBACK (handle_appointments_changed), - calwin); - } - - gtk_calendar_get_date (GTK_CALENDAR (calwin->priv->calendar), - &year, &month, &day); - - calendar_client_select_day (calwin->priv->client, day); - calendar_client_select_month (calwin->priv->client, month, year); - - handle_tasks_changed (calwin); - handle_appointments_changed (calwin); - - g_signal_connect (calwin->priv->calendar, - "day-selected-double-click", - G_CALLBACK (calendar_day_activated), - calwin); - g_signal_connect (calwin->priv->calendar, - "day-selected", - G_CALLBACK (calendar_day_selected), - calwin); - g_signal_connect (calwin->priv->calendar, - "month-changed", - G_CALLBACK (calendar_month_selected), - calwin); -#endif /* HAVE_LIBECAL */ -} - static GtkWidget * calendar_window_create_calendar (CalendarWindow *calwin) { @@ -1635,7 +201,8 @@ create_hig_frame (CalendarWindow *calwin, g_signal_connect_swapped (button, "clicked", callback, calwin); } - connect_expander_with_mateconf (calwin, expander, key); + g_settings_bind (calwin->priv->settings, key, expander, "expanded", + G_SETTINGS_BIND_DEFAULT); return vbox; } @@ -1685,11 +252,9 @@ calendar_window_fill (CalendarWindow *calwin) if (!calwin->priv->invert_order) { gtk_box_pack_start (GTK_BOX (vbox), calwin->priv->calendar, TRUE, FALSE, 0); - calendar_window_pack_pim (calwin, vbox); calendar_window_pack_locations (calwin, vbox); } else { calendar_window_pack_locations (calwin, vbox); - calendar_window_pack_pim (calwin, vbox); gtk_box_pack_start (GTK_BOX (vbox), calwin->priv->calendar, TRUE, FALSE, 0); } @@ -1716,7 +281,7 @@ calendar_window_constructor (GType type, calwin = CALENDAR_WINDOW (obj); g_assert (calwin->priv->current_time != NULL); - g_assert (calwin->priv->prefs_dir != NULL); + g_assert (calwin->priv->prefs_path != NULL); calendar_window_fill (calwin); @@ -1744,19 +309,13 @@ calendar_window_get_property (GObject *object, g_value_set_boolean (value, calendar_window_get_show_weeks (calwin)); break; -#ifdef HAVE_LIBECAL - case PROP_TIMEFORMAT: - g_value_set_enum (value, - calendar_window_get_time_format (calwin)); - break; -#endif case PROP_CURRENTTIMEP: g_value_set_pointer (value, calendar_window_get_current_time_p (calwin)); break; - case PROP_PREFSDIR: + case PROP_PREFSPATH: g_value_set_string (value, - calendar_window_get_prefs_dir (calwin)); + calendar_window_get_prefs_path (calwin)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1785,19 +344,13 @@ calendar_window_set_property (GObject *object, calendar_window_set_show_weeks (calwin, g_value_get_boolean (value)); break; -#ifdef HAVE_LIBECAL - case PROP_TIMEFORMAT: - calendar_window_set_time_format (calwin, - g_value_get_enum (value)); - break; -#endif case PROP_CURRENTTIMEP: calendar_window_set_current_time_p (calwin, g_value_get_pointer (value)); break; - case PROP_PREFSDIR: - calendar_window_set_prefs_dir (calwin, - g_value_get_string (value)); + case PROP_PREFSPATH: + calendar_window_set_prefs_path (calwin, + g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1812,39 +365,9 @@ calendar_window_destroy (GtkObject *object) calwin = CALENDAR_WINDOW (object); -#ifdef HAVE_LIBECAL - if (calwin->priv->client) - g_object_unref (calwin->priv->client); - calwin->priv->client = NULL; - - if (calwin->priv->appointments_model) - g_object_unref (calwin->priv->appointments_model); - calwin->priv->appointments_model = NULL; - - if (calwin->priv->tasks_model) - g_object_unref (calwin->priv->tasks_model); - calwin->priv->tasks_model = NULL; - - if (calwin->priv->appointments_filter) - g_object_unref (calwin->priv->appointments_filter); - calwin->priv->appointments_filter = NULL; - - if (calwin->priv->birthdays_filter) - g_object_unref (calwin->priv->birthdays_filter); - calwin->priv->birthdays_filter = NULL; - - if (calwin->priv->tasks_filter) - g_object_unref (calwin->priv->tasks_filter); - calwin->priv->tasks_filter = NULL; - - if (calwin->priv->weather_filter) - g_object_unref (calwin->priv->weather_filter); - calwin->priv->weather_filter = NULL; -#endif /* HAVE_LIBECAL */ - - if (calwin->priv->mateconfclient) - g_object_unref (calwin->priv->mateconfclient); - calwin->priv->mateconfclient = NULL; + if (calwin->priv->settings) + g_object_unref (calwin->priv->settings); + calwin->priv->settings = NULL; GTK_OBJECT_CLASS (calendar_window_parent_class)->destroy (object); } @@ -1890,18 +413,6 @@ calendar_window_class_init (CalendarWindowClass *klass) FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); -#ifdef HAVE_LIBECAL - g_object_class_install_property ( - gobject_class, - PROP_TIMEFORMAT, - g_param_spec_enum ("time-format", - "Time Format", - "Time format used to display time", - CLOCK_TYPE_FORMAT, - clock_locale_format (), - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); -#endif - g_object_class_install_property ( gobject_class, PROP_CURRENTTIMEP, @@ -1912,10 +423,10 @@ calendar_window_class_init (CalendarWindowClass *klass) g_object_class_install_property ( gobject_class, - PROP_PREFSDIR, - g_param_spec_string ("prefs-dir", - "Preferences Directory", - "Preferences directory in MateConf", + PROP_PREFSPATH, + g_param_spec_string ("prefs-path", + "Preferences Path", + "Preferences path in GSettings", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } @@ -1934,16 +445,11 @@ calendar_window_init (CalendarWindow *calwin) gtk_window_stick (window); gtk_window_set_title (window, _("Calendar")); gtk_window_set_icon_name (window, CLOCK_ICON); - -#ifdef HAVE_LIBECAL - calwin->priv->previous_selection = NULL; -#endif - calwin->priv->mateconfclient = mateconf_client_get_default (); } GtkWidget * calendar_window_new (time_t *static_current_time, - const char *prefs_dir, + const char *prefs_path, gboolean invert_order) { CalendarWindow *calwin; @@ -1952,7 +458,7 @@ calendar_window_new (time_t *static_current_time, "type", GTK_WINDOW_TOPLEVEL, "current-time", static_current_time, "invert-order", invert_order, - "prefs-dir", prefs_dir, + "prefs-path", prefs_path, NULL); return GTK_WIDGET (calwin); @@ -1962,17 +468,6 @@ void calendar_window_refresh (CalendarWindow *calwin) { g_return_if_fail (CALENDAR_IS_WINDOW (calwin)); - -#ifdef HAVE_LIBECAL - if (calwin->priv->appointments_filter && calwin->priv->appointment_list) - gtk_tree_model_filter_refilter (calwin->priv->appointments_filter); - if (calwin->priv->birthdays_filter && calwin->priv->birthday_list) - gtk_tree_model_filter_refilter (calwin->priv->birthdays_filter); - if (calwin->priv->tasks_filter && calwin->priv->task_list) - gtk_tree_model_filter_refilter (calwin->priv->tasks_filter); - if (calwin->priv->weather_filter && calwin->priv->weather_list) - gtk_tree_model_filter_refilter (calwin->priv->weather_filter); -#endif } gboolean @@ -2040,33 +535,7 @@ calendar_window_get_time_format (CalendarWindow *calwin) g_return_val_if_fail (CALENDAR_IS_WINDOW (calwin), CLOCK_FORMAT_INVALID); -#ifdef HAVE_LIBECAL - return calwin->priv->time_format; -#else return CLOCK_FORMAT_INVALID; -#endif -} - -void -calendar_window_set_time_format (CalendarWindow *calwin, - ClockFormat time_format) -{ - g_return_if_fail (CALENDAR_IS_WINDOW (calwin)); - -#ifdef HAVE_LIBECAL - if (time_format != CLOCK_FORMAT_12 && time_format != CLOCK_FORMAT_24) - time_format = clock_locale_format (); - - if (time_format == calwin->priv->time_format) - return; - - calwin->priv->time_format = time_format; - /* Time to display for appointments has changed */ - if (calwin->priv->appointments_model) - handle_appointments_changed (calwin); - - g_object_notify (G_OBJECT (calwin), "time-format"); -#endif } static time_t * @@ -2092,32 +561,37 @@ calendar_window_set_current_time_p (CalendarWindow *calwin, } static const char * -calendar_window_get_prefs_dir (CalendarWindow *calwin) +calendar_window_get_prefs_path (CalendarWindow *calwin) { g_return_val_if_fail (CALENDAR_IS_WINDOW (calwin), NULL); - return calwin->priv->prefs_dir; + return calwin->priv->prefs_path; } static void -calendar_window_set_prefs_dir (CalendarWindow *calwin, - const char *prefs_dir) +calendar_window_set_prefs_path (CalendarWindow *calwin, + const char *prefs_path) { g_return_if_fail (CALENDAR_IS_WINDOW (calwin)); - if (!calwin->priv->prefs_dir && (!prefs_dir || !prefs_dir [0])) + if (!calwin->priv->prefs_path && (!prefs_path || !prefs_path [0])) return; - if (calwin->priv->prefs_dir && prefs_dir && prefs_dir [0] && - !strcmp (calwin->priv->prefs_dir, prefs_dir)) + if (calwin->priv->prefs_path && prefs_path && prefs_path [0] && + !strcmp (calwin->priv->prefs_path, prefs_path)) return; - if (calwin->priv->prefs_dir) - g_free (calwin->priv->prefs_dir); - calwin->priv->prefs_dir = NULL; + if (calwin->priv->prefs_path) + g_free (calwin->priv->prefs_path); + calwin->priv->prefs_path = NULL; + + if (prefs_path && prefs_path [0]) + calwin->priv->prefs_path = g_strdup (prefs_path); + + g_object_notify (G_OBJECT (calwin), "prefs-path"); - if (prefs_dir && prefs_dir [0]) - calwin->priv->prefs_dir = g_strdup (prefs_dir); + if (calwin->priv->settings) + g_object_unref (calwin->priv->settings); - g_object_notify (G_OBJECT (calwin), "prefs-dir"); + calwin->priv->settings = g_settings_new_with_path (CLOCK_SCHEMA, calwin->priv->prefs_path); } diff --git a/applets/clock/clock-face.c b/applets/clock/clock-face.c index 53f0e4f4..143eef12 100644 --- a/applets/clock/clock-face.c +++ b/applets/clock/clock-face.c @@ -289,7 +289,7 @@ update_time_and_face (ClockFace *this, localtime_r (&timet, &priv->time); } - /* FIXME this should be a mateconf setting + /* FIXME this should be a pref in gsetting * Or we could use some code from clock-sun.c? * currently we hardcode * morning 7-9 diff --git a/applets/clock/clock-location.c b/applets/clock/clock-location.c index 1b81c517..efbc5939 100644 --- a/applets/clock/clock-location.c +++ b/applets/clock/clock-location.c @@ -676,8 +676,12 @@ update_weather_info (gpointer data) DISTANCE_UNIT_KM }; - prefs.temperature_unit = priv->temperature_unit; - prefs.speed_unit = priv->speed_unit; + // set temperature and speed units only if different from + // invalid/default + if (priv->temperature_unit > TEMP_UNIT_DEFAULT) + prefs.temperature_unit = priv->temperature_unit; + if (priv->speed_unit > SPEED_UNIT_DEFAULT) + prefs.speed_unit = priv->speed_unit; weather_info_abort (priv->weather_info); weather_info_update (priv->weather_info, diff --git a/applets/clock/clock.c b/applets/clock/clock.c index 85e6f089..e7f3348e 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -27,6 +27,7 @@ * George Lebl * Gediminas Paulauskas * Mark McLoughlin + * Stefano Karapetsas */ #include "config.h" @@ -42,24 +43,20 @@ #include <locale.h> #include <mate-panel-applet.h> -#include <mate-panel-applet-mateconf.h> +#include <mate-panel-applet-gsettings.h> #include <glib/gi18n.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <gdk/gdkx.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include <libmateweather/mateweather-prefs.h> #include <libmateweather/mateweather-xml.h> #include <libmateweather/location-entry.h> #include <libmateweather/timezone-menu.h> -#ifdef HAVE_LIBECAL -#include <libedataserverui/e-passwords.h> -#endif - #include "clock.h" #include "calendar-window.h" @@ -75,26 +72,16 @@ #define NEVER_SENSITIVE "never_sensitive" -#define N_MATECONF_PREFS 11 /* Keep this in sync with the number of keys below! */ #define KEY_FORMAT "format" -#define KEY_SHOW_SECONDS "show_seconds" -#define KEY_SHOW_DATE "show_date" -#define KEY_SHOW_WEATHER "show_weather" -#define KEY_SHOW_TEMPERATURE "show_temperature" -#define KEY_CUSTOM_FORMAT "custom_format" -#define KEY_SHOW_WEEK "show_week_numbers" +#define KEY_SHOW_SECONDS "show-seconds" +#define KEY_SHOW_DATE "show-date" +#define KEY_SHOW_WEATHER "show-weather" +#define KEY_SHOW_TEMPERATURE "show-temperature" +#define KEY_CUSTOM_FORMAT "custom-format" +#define KEY_SHOW_WEEK "show-week-numbers" #define KEY_CITIES "cities" -#define KEY_TEMPERATURE_UNIT "temperature_unit" -#define KEY_SPEED_UNIT "speed_unit" - -static MateConfEnumStringPair format_type_enum_map [] = { - { CLOCK_FORMAT_12, "12-hour" }, - { CLOCK_FORMAT_24, "24-hour" }, - { CLOCK_FORMAT_UNIX, "unix" }, - { CLOCK_FORMAT_INTERNET, "internet" }, - { CLOCK_FORMAT_CUSTOM, "custom" }, - { 0, NULL } -}; +#define KEY_TEMPERATURE_UNIT "temperature-unit" +#define KEY_SPEED_UNIT "speed-unit" enum { COL_CITY_NAME = 0, @@ -163,8 +150,6 @@ struct _ClockData { gboolean show_weather; gboolean show_temperature; - gboolean use_temperature_default; - gboolean use_speed_default; TempUnit temperature_unit; SpeedUnit speed_unit; @@ -194,7 +179,7 @@ struct _ClockData { gboolean can_handle_format_12; - guint listeners [N_MATECONF_PREFS]; + GSettings *settings; }; /* Used to count the number of clock instances. It's there to know when we @@ -489,7 +474,8 @@ get_updated_timeformat (ClockData *cd) static void update_timeformat (ClockData *cd) { - g_free (cd->timeformat); + if (cd->timeformat) + g_free (cd->timeformat); cd->timeformat = get_updated_timeformat (cd); } @@ -671,21 +657,12 @@ update_tooltip (ClockData * cd) g_free (utf8); g_free (tip); } else { -#ifdef HAVE_LIBECAL - if (cd->calendar_popup) - gtk_widget_set_tooltip_text (cd->panel_button, - _("Click to hide your appointments and tasks")); - else - gtk_widget_set_tooltip_text (cd->panel_button, - _("Click to view your appointments and tasks")); -#else if (cd->calendar_popup) gtk_widget_set_tooltip_text (cd->panel_button, _("Click to hide month calendar")); else gtk_widget_set_tooltip_text (cd->panel_button, _("Click to view month calendar")); -#endif } } @@ -726,28 +703,23 @@ refresh_click_timeout_time_only (ClockData *cd) static void free_locations (ClockData *cd) { - GList *l; + if (cd->locations != NULL) { + GList *l; - for (l = cd->locations; l; l = l->next) - g_object_unref (l->data); + for (l = cd->locations; l; l = l->next) + g_object_unref (l->data); - g_list_free (cd->locations); + g_list_free (cd->locations); + } cd->locations = NULL; } static void destroy_clock (GtkWidget * widget, ClockData *cd) { - MateConfClient *client; - int i; - - client = mateconf_client_get_default (); - - for (i = 0; i < N_MATECONF_PREFS; i++) - mateconf_client_notify_remove ( - client, cd->listeners [i]); - - g_object_unref (G_OBJECT (client)); + if (cd->settings) + g_object_unref (cd->settings); + cd->settings = NULL; if (cd->timeout) g_source_remove (cd->timeout); @@ -766,7 +738,8 @@ destroy_clock (GtkWidget * widget, ClockData *cd) free_locations (cd); - g_list_free (cd->location_tiles); + if (cd->location_tiles) + g_list_free (cd->location_tiles); cd->location_tiles = NULL; if (cd->systz) { @@ -785,13 +758,6 @@ destroy_clock (GtkWidget * widget, ClockData *cd) } g_free (cd); - -#ifdef HAVE_LIBECAL - if (clock_numbers > 0) { - e_passwords_shutdown (); - clock_numbers--; - } -#endif } static gboolean @@ -830,18 +796,16 @@ static GtkWidget * create_calendar (ClockData *cd) { GtkWidget *window; - char *prefs_dir; + char *prefs_path; - prefs_dir = mate_panel_applet_get_preferences_key (MATE_PANEL_APPLET (cd->applet)); + prefs_path = mate_panel_applet_get_preferences_path (MATE_PANEL_APPLET (cd->applet)); window = calendar_window_new (&cd->current_time, - prefs_dir, + prefs_path, cd->orient == MATE_PANEL_APPLET_ORIENT_UP); - g_free (prefs_dir); + g_free (prefs_path); calendar_window_set_show_weeks (CALENDAR_WINDOW (window), cd->showweek); - calendar_window_set_time_format (CALENDAR_WINDOW (window), - cd->format); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (cd->applet)); @@ -1116,7 +1080,8 @@ create_cities_section (ClockData *cd) cd->cities_section = NULL; } - g_list_free (cd->location_tiles); + if (cd->location_tiles) + g_list_free (cd->location_tiles); cd->location_tiles = NULL; cd->cities_section = gtk_vbox_new (FALSE, 6); @@ -1209,7 +1174,8 @@ update_calendar_popup (ClockData *cd) cd->map_widget = NULL; cd->clock_vbox = NULL; - g_list_free (cd->location_tiles); + if (cd->location_tiles) + g_list_free (cd->location_tiles); cd->location_tiles = NULL; } update_tooltip (cd); @@ -1370,11 +1336,6 @@ weather_tooltip (GtkWidget *widget, static void create_clock_widget (ClockData *cd) { -#ifdef HAVE_LIBECAL - clock_numbers++; - e_passwords_init (); -#endif - /* Main toggle button */ cd->panel_button = create_main_clock_button (); g_signal_connect (cd->panel_button, "button_press_event", @@ -1882,20 +1843,12 @@ static const GtkActionEntry clock_menu_actions [] = { }; static void -format_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +format_changed (GSettings *settings, + gchar *key, ClockData *clock) { - const char *value; int new_format; - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - - value = mateconf_value_get_string (entry->value); - if (!mateconf_string_to_enum (format_type_enum_map, value, &new_format)) - return; + new_format = g_settings_get_enum (settings, key); if (!clock->can_handle_format_12 && new_format == CLOCK_FORMAT_12) new_format = CLOCK_FORMAT_24; @@ -1907,43 +1860,26 @@ format_changed (MateConfClient *client, refresh_clock_timeout (clock); if (clock->calendar_popup != NULL) { - calendar_window_set_time_format (CALENDAR_WINDOW (clock->calendar_popup), clock->format); position_calendar_popup (clock); } } static void -show_seconds_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - ClockData *clock) +show_seconds_changed (GSettings *settings, + gchar *key, + ClockData *clock) { - gboolean value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - value = mateconf_value_get_bool (entry->value); - - clock->showseconds = (value != 0); + clock->showseconds = g_settings_get_boolean (settings, key); refresh_clock_timeout (clock); } static void -show_date_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +show_date_changed (GSettings *settings, + gchar *key, ClockData *clock) { - gboolean value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - value = mateconf_value_get_bool (entry->value); - - clock->showdate = (value != 0); + clock->showdate = g_settings_get_boolean (settings, key); update_timeformat (clock); refresh_clock (clock); } @@ -1971,16 +1907,13 @@ update_panel_weather (ClockData *cd) } static void -update_weather_bool_value_and_toggle_from_mateconf (ClockData *cd, MateConfEntry *entry, +update_weather_bool_value_and_toggle_from_gsettings (ClockData *cd, gchar *key, gboolean *value_loc, const char *widget_name) { GtkWidget *widget; gboolean value; - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - value = mateconf_value_get_bool (entry->value); + value = g_settings_get_boolean (cd->settings, key); *value_loc = (value != 0); @@ -1993,21 +1926,19 @@ update_weather_bool_value_and_toggle_from_mateconf (ClockData *cd, MateConfEntry } static void -show_weather_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +show_weather_changed (GSettings *settings, + gchar *key, ClockData *cd) { - update_weather_bool_value_and_toggle_from_mateconf (cd, entry, &cd->show_weather, "weather_check"); + update_weather_bool_value_and_toggle_from_gsettings (cd, key, &cd->show_weather, "weather_check"); } static void -show_temperature_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +show_temperature_changed (GSettings *settings, + gchar *key, ClockData *cd) { - update_weather_bool_value_and_toggle_from_mateconf (cd, entry, &cd->show_temperature, "temperature_check"); + update_weather_bool_value_and_toggle_from_gsettings (cd, key, &cd->show_temperature, "temperature_check"); } static void @@ -2110,7 +2041,7 @@ typedef struct { ClockData *cd; } LocationParserData; -/* Parser for our serialized locations in mateconf */ +/* Parser for our serialized locations in gsettings */ static void location_start_element (GMarkupParseContext *context, const gchar *element_name, @@ -2194,13 +2125,11 @@ static GMarkupParser location_parser = { }; static void -cities_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +cities_changed (GSettings *settings, + gchar *key, ClockData *cd) { LocationParserData data; - GSList *cur = NULL; GMarkupParseContext *context; @@ -2208,17 +2137,13 @@ cities_changed (MateConfClient *client, data.cities = NULL; data.cd = cd; - if (!entry->value || entry->value->type != MATECONF_VALUE_LIST) - return; - context = g_markup_parse_context_new (&location_parser, 0, &data, NULL); - cur = mateconf_value_get_list (entry->value); + cur = mate_panel_applet_settings_get_gslist (settings, key); while (cur) { - const char *str = mateconf_value_get_string (cur->data); + const char *str = cur->data; g_markup_parse_context_parse (context, str, strlen (str), NULL); - cur = cur->next; } @@ -2229,22 +2154,6 @@ cities_changed (MateConfClient *client, } static void -update_temperature_combo (ClockData *cd) -{ - GtkWidget *widget; - int active_index; - - widget = _clock_get_widget (cd, "temperature_combo"); - - if (cd->use_temperature_default) - active_index = 0; - else - active_index = cd->temperature_unit - 1; - - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active_index); -} - -static void update_weather_locations (ClockData *cd) { GList *locations, *l; @@ -2269,43 +2178,6 @@ update_weather_locations (ClockData *cd) } static void -clock_migrate_to_26 (ClockData *clock) -{ - gboolean unixtime; - gboolean internettime; - int hourformat; - - internettime = mate_panel_applet_mateconf_get_bool (MATE_PANEL_APPLET (clock->applet), - "internet_time", - NULL); - unixtime = mate_panel_applet_mateconf_get_bool (MATE_PANEL_APPLET (clock->applet), - "unix_time", - NULL); - hourformat = mate_panel_applet_mateconf_get_int (MATE_PANEL_APPLET (clock->applet), - "hour_format", - NULL); - - if (unixtime) - clock->format = CLOCK_FORMAT_UNIX; - else if (internettime) - clock->format = CLOCK_FORMAT_INTERNET; - else if (hourformat == 12) - clock->format = CLOCK_FORMAT_12; - else if (hourformat == 24) - clock->format = CLOCK_FORMAT_24; - - /* It's still possible that we have none of the old keys, in which case - * we're not migrating from 2.6, but the config is simply wrong. So - * don't set the format key in this case. */ - if (clock->format != CLOCK_FORMAT_INVALID) - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (clock->applet), - KEY_FORMAT, - mateconf_enum_to_string (format_type_enum_map, - clock->format), - NULL); -} - -static void clock_timezone_changed (SystemTimezone *systz, const char *new_tz, ClockData *cd) @@ -2317,111 +2189,65 @@ clock_timezone_changed (SystemTimezone *systz, } static void -parse_and_set_temperature_string (const char *str, ClockData *cd) -{ - gint value = 0; - gboolean use_default = FALSE; - - value = mateweather_prefs_parse_temperature (str, &use_default); - - cd->use_temperature_default = use_default; - cd->temperature_unit = value; -} - -static void -parse_and_set_speed_string (const char *str, ClockData *cd) -{ - gint value = 0; - gboolean use_default = FALSE; - - value = mateweather_prefs_parse_speed (str, &use_default); - - cd->use_speed_default = use_default; - cd->speed_unit = value; -} - -static void -temperature_unit_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +temperature_unit_changed (GSettings *settings, + gchar *key, ClockData *cd) { - const gchar *value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - - value = mateconf_value_get_string (entry->value); - parse_and_set_temperature_string (value, cd); - update_temperature_combo (cd); + cd->temperature_unit = g_settings_get_enum (settings, key); + if (cd->temperature_unit > 0) + { + GtkWidget *widget; + gint oldvalue; + widget = _clock_get_widget (cd, "temperature_combo"); + oldvalue = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) + 1; + if (oldvalue != cd->speed_unit) + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), cd->temperature_unit -1); + } update_weather_locations (cd); } static void -update_speed_combo (ClockData *cd) -{ - GtkWidget *widget; - int active_index; - - widget = _clock_get_widget (cd, "wind_speed_combo"); - - if (cd->use_speed_default) - active_index = 0; - else - active_index = cd->speed_unit - 1; - - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active_index); -} - -static void -speed_unit_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +speed_unit_changed (GSettings *settings, + gchar *key, ClockData *cd) { - const gchar *value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - - value = mateconf_value_get_string (entry->value); - parse_and_set_speed_string (value, cd); - update_speed_combo (cd); + cd->speed_unit = g_settings_get_enum (settings, key); + if (cd->speed_unit > 0) + { + GtkWidget *widget; + gint oldvalue; + widget = _clock_get_widget (cd, "wind_speed_combo"); + oldvalue = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) + 1; + if (oldvalue != cd->speed_unit) + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), cd->speed_unit -1); + } update_weather_locations (cd); } static void -custom_format_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +custom_format_changed (GSettings *settings, + gchar *key, ClockData *clock) { - const char *value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - - value = mateconf_value_get_string (entry->value); + gchar *value; + value = g_settings_get_string (settings, key); g_free (clock->custom_format); clock->custom_format = g_strdup (value); if (clock->format == CLOCK_FORMAT_CUSTOM) refresh_clock (clock); + g_free (value); } static void -show_week_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +show_week_changed (GSettings *settings, + gchar *key, ClockData *clock) { gboolean value; - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - value = mateconf_value_get_bool (entry->value); + value = g_settings_get_boolean (settings, key); if (clock->showweek == (value != 0)) return; @@ -2434,71 +2260,39 @@ show_week_changed (MateConfClient *client, } } -static guint -setup_mateconf_preference (ClockData *cd, MateConfClient *client, const char *key_name, MateConfClientNotifyFunc callback) -{ - char *key; - guint id; - - key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (cd->applet), - key_name); - id = mateconf_client_notify_add (client, key, - callback, - cd, NULL, NULL); - g_free (key); - - return id; -} - static void -setup_mateconf (ClockData *cd) +setup_gsettings (ClockData *cd) { - struct { - const char *key_name; - MateConfClientNotifyFunc callback; - } prefs[] = { - { KEY_FORMAT, (MateConfClientNotifyFunc) format_changed }, - { KEY_SHOW_SECONDS, (MateConfClientNotifyFunc) show_seconds_changed }, - { KEY_SHOW_DATE, (MateConfClientNotifyFunc) show_date_changed }, - { KEY_SHOW_WEATHER, (MateConfClientNotifyFunc) show_weather_changed }, - { KEY_SHOW_TEMPERATURE, (MateConfClientNotifyFunc) show_temperature_changed }, - { KEY_CUSTOM_FORMAT, (MateConfClientNotifyFunc) custom_format_changed }, - { KEY_SHOW_WEEK, (MateConfClientNotifyFunc) show_week_changed }, - { KEY_CITIES, (MateConfClientNotifyFunc) cities_changed }, - { KEY_TEMPERATURE_UNIT, (MateConfClientNotifyFunc) temperature_unit_changed }, - { KEY_SPEED_UNIT, (MateConfClientNotifyFunc) speed_unit_changed }, - }; - - MateConfClient *client; - int i; - - client = mateconf_client_get_default (); - - for (i = 0; i < G_N_ELEMENTS (prefs); i++) - cd->listeners[i] = setup_mateconf_preference (cd, client, prefs[i].key_name, prefs[i].callback); - - g_object_unref (G_OBJECT (client)); + cd->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (cd->applet), CLOCK_SCHEMA); + g_signal_connect (cd->settings, "changed::" KEY_FORMAT, G_CALLBACK (format_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_SHOW_SECONDS, G_CALLBACK (show_seconds_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_SHOW_DATE, G_CALLBACK (show_date_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_SHOW_WEATHER, G_CALLBACK (show_weather_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_SHOW_TEMPERATURE, G_CALLBACK (show_temperature_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_CUSTOM_FORMAT, G_CALLBACK (custom_format_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_SHOW_WEEK, G_CALLBACK (show_week_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_CITIES, G_CALLBACK (cities_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_TEMPERATURE_UNIT, G_CALLBACK (temperature_unit_changed), cd); + g_signal_connect (cd->settings, "changed::" KEY_SPEED_UNIT, G_CALLBACK (speed_unit_changed), cd); } static GList * -parse_mateconf_cities (ClockData *cd, GSList *values) +parse_gsettings_cities (ClockData *cd, gchar **values) { - GSList *cur = values; + gint i; LocationParserData data; GMarkupParseContext *context; data.cities = NULL; data.cd = cd; - context = - g_markup_parse_context_new (&location_parser, 0, &data, NULL); - - while (cur) { - const char *str = (char *)cur->data; - g_markup_parse_context_parse (context, str, strlen(str), NULL); + context = g_markup_parse_context_new (&location_parser, 0, &data, NULL); - cur = cur->next; - } + if (values) { + for (i = 0; values[i]; i++) { + g_markup_parse_context_parse (context, values[i], strlen(values[i]), NULL); + } + } g_markup_parse_context_free (context); @@ -2506,70 +2300,37 @@ parse_mateconf_cities (ClockData *cd, GSList *values) } static void -load_mateconf_settings (ClockData *cd) +load_gsettings (ClockData *cd) { - MatePanelApplet *applet; - int format; - char *format_str; - char *value; - GError *error; - GSList *values = NULL; + gchar **values; GList *cities = NULL; - applet = MATE_PANEL_APPLET (cd->applet); - - cd->format = CLOCK_FORMAT_INVALID; - - format_str = mate_panel_applet_mateconf_get_string (applet, KEY_FORMAT, NULL); - if (format_str && - mateconf_string_to_enum (format_type_enum_map, format_str, &format)) - cd->format = format; - else - clock_migrate_to_26 (cd); - - g_free (format_str); + cd->format = g_settings_get_enum (cd->settings, KEY_FORMAT); if (cd->format == CLOCK_FORMAT_INVALID) cd->format = clock_locale_format (); - cd->custom_format = mate_panel_applet_mateconf_get_string (applet, KEY_CUSTOM_FORMAT, NULL); - cd->showseconds = mate_panel_applet_mateconf_get_bool (applet, KEY_SHOW_SECONDS, NULL); - - error = NULL; - cd->showdate = mate_panel_applet_mateconf_get_bool (applet, KEY_SHOW_DATE, &error); - if (error) { - g_error_free (error); - /* if on a small screen don't show date by default */ - if (gdk_screen_width () <= 800) - cd->showdate = FALSE; - else - cd->showdate = TRUE; - } - - cd->show_weather = mate_panel_applet_mateconf_get_bool (applet, KEY_SHOW_WEATHER, NULL); - cd->show_temperature = mate_panel_applet_mateconf_get_bool (applet, KEY_SHOW_TEMPERATURE, NULL); - cd->showweek = mate_panel_applet_mateconf_get_bool (applet, KEY_SHOW_WEEK, NULL); + cd->custom_format = g_settings_get_string (cd->settings, KEY_CUSTOM_FORMAT); + cd->showseconds = g_settings_get_boolean (cd->settings, KEY_SHOW_SECONDS); + cd->showdate = g_settings_get_boolean (cd->settings, KEY_SHOW_DATE); + cd->show_weather = g_settings_get_boolean (cd->settings, KEY_SHOW_WEATHER); + cd->show_temperature = g_settings_get_boolean (cd->settings, KEY_SHOW_TEMPERATURE); + cd->showweek = g_settings_get_boolean (cd->settings, KEY_SHOW_WEEK); cd->timeformat = NULL; cd->can_handle_format_12 = (clock_locale_format () == CLOCK_FORMAT_12); if (!cd->can_handle_format_12 && cd->format == CLOCK_FORMAT_12) cd->format = CLOCK_FORMAT_24; - value = mate_panel_applet_mateconf_get_string (applet, KEY_TEMPERATURE_UNIT, NULL); - parse_and_set_temperature_string (value, cd); - g_free (value); - - value = mate_panel_applet_mateconf_get_string (applet, KEY_SPEED_UNIT, NULL); - parse_and_set_speed_string (value, cd); - g_free (value); + cd->temperature_unit = g_settings_get_enum (cd->settings, KEY_TEMPERATURE_UNIT); + cd->speed_unit = g_settings_get_enum (cd->settings, KEY_SPEED_UNIT); - values = mate_panel_applet_mateconf_get_list (MATE_PANEL_APPLET (cd->applet), KEY_CITIES, - MATECONF_VALUE_STRING, NULL); + values = g_settings_get_strv (cd->settings, KEY_CITIES); - if (g_slist_length (values) == 0) { + if (!values || (g_strv_length (values) == 0)) { cities = NULL; } else { - cities = parse_mateconf_cities (cd, values); + cities = parse_gsettings_cities (cd, values); } set_locations (cd, cities); @@ -2585,7 +2346,6 @@ fill_clock_applet (MatePanelApplet *applet) char *filename; GError *error; - mate_panel_applet_add_preferences (applet, CLOCK_SCHEMA_DIR, NULL); mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR); cd = g_new0 (ClockData, 1); @@ -2594,8 +2354,8 @@ fill_clock_applet (MatePanelApplet *applet) cd->applet = GTK_WIDGET (applet); - setup_mateconf (cd); - load_mateconf_settings (cd); + setup_gsettings (cd); + load_gsettings (cd); cd->builder = gtk_builder_new (); gtk_builder_set_translation_domain (cd->builder, GETTEXT_PACKAGE); @@ -2665,181 +2425,6 @@ fill_clock_applet (MatePanelApplet *applet) return TRUE; } -/* FIXME old clock applet */ -#if 0 -static void -setup_writability_sensitivity (ClockData *clock, GtkWidget *w, GtkWidget *label, const char *key) -{ - /* FMQ: was used from old preferences dialog; fix this up */ - char *fullkey; - MateConfClient *client; - - client = mateconf_client_get_default (); - - fullkey = mate_panel_applet_mateconf_get_full_key - (MATE_PANEL_APPLET (clock->applet), key); - - if ( ! mateconf_client_key_is_writable (client, fullkey, NULL)) { - g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE, - GINT_TO_POINTER (1)); - gtk_widget_set_sensitive (w, FALSE); - if (label != NULL) { - g_object_set_data (G_OBJECT (label), NEVER_SENSITIVE, - GINT_TO_POINTER (1)); - gtk_widget_set_sensitive (label, FALSE); - } - } - - g_free (fullkey); - - g_object_unref (G_OBJECT (client)); -} - -static void -update_properties_for_format (ClockData *cd, - GtkComboBox *combo, - ClockFormat format) -{ - - /* show the custom format things the first time we actually - * have a custom format set in MateConf, but after that don't - * unshow it if the format changes - */ - if (!cd->custom_format_shown && - (cd->format == CLOCK_FORMAT_CUSTOM || - (cd->custom_format && cd->custom_format [0]))) { - gtk_widget_show (cd->custom_hbox); - gtk_widget_show (cd->custom_label); - gtk_widget_show (cd->custom_entry); - - gtk_combo_box_append_text (combo, _("Custom format")); - - cd->custom_format_shown = TRUE; - } - - /* Some combinations of options do not make sense */ - switch (format) { - case CLOCK_FORMAT_12: - case CLOCK_FORMAT_24: - gtk_widget_set_sensitive (cd->showseconds_check, TRUE); - gtk_widget_set_sensitive (cd->showdate_check, TRUE); - gtk_widget_set_sensitive (cd->custom_entry, FALSE); - gtk_widget_set_sensitive (cd->custom_label, FALSE); - break; - case CLOCK_FORMAT_UNIX: - gtk_widget_set_sensitive (cd->showseconds_check, FALSE); - gtk_widget_set_sensitive (cd->showdate_check, FALSE); - gtk_widget_set_sensitive (cd->custom_entry, FALSE); - gtk_widget_set_sensitive (cd->custom_label, FALSE); - break; - case CLOCK_FORMAT_INTERNET: - gtk_widget_set_sensitive (cd->showseconds_check, TRUE); - gtk_widget_set_sensitive (cd->showdate_check, FALSE); - gtk_widget_set_sensitive (cd->custom_entry, FALSE); - gtk_widget_set_sensitive (cd->custom_label, FALSE); - break; - case CLOCK_FORMAT_CUSTOM: - gtk_widget_set_sensitive (cd->showseconds_check, FALSE); - gtk_widget_set_sensitive (cd->showdate_check, FALSE); - gtk_widget_set_sensitive (cd->custom_entry, TRUE); - gtk_widget_set_sensitive (cd->custom_label, TRUE); - break; - default: - g_assert_not_reached (); - break; - } -} - -static void -set_format_cb (GtkComboBox *combo, - ClockData *cd) -{ - /* FMQ: was used from old preferences dialog; fix this up */ - ClockFormat format; - - /* valid values begin from 1 */ - if (cd->can_handle_format_12) - format = gtk_combo_box_get_active (combo) + 1; - else - format = gtk_combo_box_get_active (combo) + 2; - - update_properties_for_format (cd, combo, format); - - if (cd->format != format) - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (cd->applet), - KEY_FORMAT, - mateconf_enum_to_string (format_type_enum_map, format), - NULL); -} -#endif - -static void -set_show_seconds_cb (GtkWidget *w, - ClockData *clock) -{ - mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (clock->applet), - KEY_SHOW_SECONDS, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)), - NULL); -} - -static void -set_show_date_cb (GtkWidget *w, - ClockData *clock) -{ - mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (clock->applet), - KEY_SHOW_DATE, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)), - NULL); -} - -static void -set_show_weather_cb (GtkWidget *w, - ClockData *clock) -{ - mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (clock->applet), - KEY_SHOW_WEATHER, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)), - NULL); -} - -static void -set_show_temperature_cb (GtkWidget *w, - ClockData *clock) -{ - mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (clock->applet), - KEY_SHOW_TEMPERATURE, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)), - NULL); -} - -#if 0 -static void -set_show_zones_cb (GtkWidget *w, - ClockData *clock) -{ - mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (clock->applet), - KEY_SHOW_ZONES, - GTK_TOGGLE_BUTTON (w)->active, - NULL); -} -#endif - -/* FIXME old clock applet */ -#if 0 -static void -set_custom_format_cb (GtkEntry *entry, - ClockData *cd) -{ - /* FMQ: was used from old preferences dialog; fix this up */ - const char *custom_format; - - custom_format = gtk_entry_get_text (entry); - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (cd->applet), - KEY_CUSTOM_FORMAT, custom_format, NULL); -} -#endif - static void prefs_locations_changed (GtkTreeSelection *selection, ClockData *cd) { @@ -2882,28 +2467,26 @@ save_cities_store (ClockData *cd) { ClockLocation *loc; GList *node = cd->locations; - - GSList *root = NULL; - GSList *list = NULL; + gint len = g_list_length(cd->locations); + gchar **array[len + 1]; + gchar **array_reverse[len + 1]; + gint i = 0; while (node) { loc = CLOCK_LOCATION (node->data); - list = g_slist_prepend (list, loc_to_string (loc)); + array[i] = loc_to_string (loc); + i++; node = node->next; } + array[i] = NULL; - list = g_slist_reverse (list); - mate_panel_applet_mateconf_set_list (MATE_PANEL_APPLET (cd->applet), - KEY_CITIES, MATECONF_VALUE_STRING, list, NULL); - - root = list; - - while (list) { - g_free (list->data); - list = g_slist_next (list); + for (i = 0; i <= (len - 1); i++) { + array_reverse [len - i - 1] = g_strdup (array [i]); } + array_reverse[i] = NULL; - g_slist_free (root); + g_settings_set_strv (cd->settings, KEY_CITIES, (const gchar **) array_reverse); + /* FIXME free arrays */ } static void @@ -2980,7 +2563,7 @@ run_prefs_edit_save (GtkButton *button, ClockData *cd) g_free (city); /* This will update everything related to locations to take into - * account the new location (via the mateconf notification) */ + * account the new location (via the gsettings changed signal) */ save_cities_store (cd); edit_hide (edit_window, cd); @@ -3179,7 +2762,7 @@ remove_tree_row (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpoi g_object_unref (loc); /* This will update everything related to locations to take into - * account the removed location (via the mateconf notification) */ + * account the removed location (via the gsettings changed signal) */ save_cities_store (cd); } @@ -3293,7 +2876,6 @@ run_prefs_locations_edit (GtkButton *unused, ClockData *cd) static void set_12hr_format_radio_cb (GtkWidget *widget, ClockData *cd) { - const gchar *val; ClockFormat format; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) @@ -3301,10 +2883,7 @@ set_12hr_format_radio_cb (GtkWidget *widget, ClockData *cd) else format = CLOCK_FORMAT_24; - val = mateconf_enum_to_string (format_type_enum_map, format); - - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (cd->applet), - KEY_FORMAT, val, NULL); + g_settings_set_enum (cd->settings, KEY_FORMAT, format); } static void @@ -3315,19 +2894,12 @@ temperature_combo_changed (GtkComboBox *combo, ClockData *cd) const gchar *str; value = gtk_combo_box_get_active (combo) + 1; - - if (cd->use_temperature_default) - old_value = TEMP_UNIT_DEFAULT; - else - old_value = cd->temperature_unit; + old_value = cd->temperature_unit; if (value == old_value) return; - str = mateweather_prefs_temp_enum_to_string (value); - - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (cd->applet), - KEY_TEMPERATURE_UNIT, str, NULL); + g_settings_set_enum (cd->settings, KEY_TEMPERATURE_UNIT, value); } static void @@ -3338,21 +2910,15 @@ speed_combo_changed (GtkComboBox *combo, ClockData *cd) const gchar *str; value = gtk_combo_box_get_active (combo) + 1; - - if (cd->use_speed_default) - old_value = SPEED_UNIT_DEFAULT; - else - old_value = cd->speed_unit; + old_value = cd->speed_unit; if (value == old_value) return; - str = mateweather_prefs_speed_enum_to_string (value); - - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (cd->applet), - KEY_SPEED_UNIT, str, NULL); + g_settings_set_enum (cd->settings, KEY_SPEED_UNIT, value); } + static void fill_prefs_window (ClockData *cd) { @@ -3398,27 +2964,23 @@ fill_prefs_window (ClockData *cd) /* Set the "Show Date" checkbox */ widget = _clock_get_widget (cd, "date_check"); - g_signal_connect (widget, "toggled", - G_CALLBACK (set_show_date_cb), cd); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), cd->showdate); + g_settings_bind (cd->settings, KEY_SHOW_DATE, widget, "active", + G_SETTINGS_BIND_DEFAULT); /* Set the "Show Seconds" checkbox */ widget = _clock_get_widget (cd, "seconds_check"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), cd->showseconds); - g_signal_connect (widget, "toggled", - G_CALLBACK (set_show_seconds_cb), cd); + g_settings_bind (cd->settings, KEY_SHOW_SECONDS, widget, "active", + G_SETTINGS_BIND_DEFAULT); /* Set the "Show weather" checkbox */ widget = _clock_get_widget (cd, "weather_check"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), cd->show_weather); - g_signal_connect (widget, "toggled", - G_CALLBACK (set_show_weather_cb), cd); + g_settings_bind (cd->settings, KEY_SHOW_WEATHER, widget, "active", + G_SETTINGS_BIND_DEFAULT); /* Set the "Show temperature" checkbox */ widget = _clock_get_widget (cd, "temperature_check"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), cd->show_temperature); - g_signal_connect (widget, "toggled", - G_CALLBACK (set_show_temperature_cb), cd); + g_settings_bind (cd->settings, KEY_SHOW_TEMPERATURE, widget, "active", + G_SETTINGS_BIND_DEFAULT); /* Fill the Cities list */ widget = _clock_get_widget (cd, "cities_list"); @@ -3448,10 +3010,12 @@ fill_prefs_window (ClockData *cd) for (i = 0; temperatures[i] != -1; i++) gtk_combo_box_append_text (GTK_COMBO_BOX (widget), mateweather_prefs_get_temp_display_name (temperatures[i])); - - update_temperature_combo (cd); + + if (cd->temperature_unit > 0) + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), + cd->temperature_unit - 1); g_signal_connect (widget, "changed", - G_CALLBACK (temperature_combo_changed), cd); + G_CALLBACK (temperature_combo_changed), cd); /* Wind speed combo */ widget = _clock_get_widget (cd, "wind_speed_combo"); @@ -3465,7 +3029,9 @@ fill_prefs_window (ClockData *cd) gtk_combo_box_append_text (GTK_COMBO_BOX (widget), mateweather_prefs_get_speed_display_name (speeds[i])); - update_speed_combo (cd); + if (cd->speed_unit > 0) + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), + cd->speed_unit - 1); g_signal_connect (widget, "changed", G_CALLBACK (speed_combo_changed), cd); } @@ -3603,75 +3169,6 @@ display_properties_dialog (ClockData *cd, gboolean start_in_locations_page) gtk_window_present (GTK_WINDOW (cd->prefs_window)); refresh_click_timeout_time_only (cd); - - /* FMQ: cd->props was the old preferences window; remove references to it */ - /* FMQ: connect to the Help button by hand; look at properties_response_cb() for the help code */ -#if 0 - /* FMQ: check the code below; replace the proper parts */ - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *combo; - GtkWidget *label; - - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("24 hour")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("UNIX time")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Internet time")); - - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - gtk_widget_show (combo); - - cd->custom_hbox = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (vbox), cd->custom_hbox, TRUE, TRUE, 0); - - cd->custom_label = gtk_label_new_with_mnemonic (_("Custom _format:")); - gtk_label_set_use_markup (GTK_LABEL (cd->custom_label), TRUE); - gtk_label_set_justify (GTK_LABEL (cd->custom_label), - GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (cd->custom_label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (cd->custom_hbox), - cd->custom_label, - FALSE, FALSE, 0); - - cd->custom_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (cd->custom_hbox), - cd->custom_entry, - FALSE, FALSE, 0); - gtk_entry_set_text (GTK_ENTRY (cd->custom_entry), - cd->custom_format); - g_signal_connect (cd->custom_entry, "changed", - G_CALLBACK (set_custom_format_cb), - cd); - - g_signal_connect (cd->props, "destroy", - G_CALLBACK (gtk_widget_destroyed), - &cd->props); - g_signal_connect (cd->props, "response", - G_CALLBACK (properties_response_cb), - cd); - - cd->custom_format_shown = FALSE; - update_properties_for_format (cd, GTK_COMBO_BOX (combo), cd->format); - - /* valid values begin from 1 */ - if (cd->can_handle_format_12) - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), - cd->format - 1); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), - cd->format - 2); - - g_signal_connect (combo, "changed", - G_CALLBACK (set_format_cb), cd); - - /* Now set up the sensitivity based on mateconf key writability */ - setup_writability_sensitivity (cd, combo, label, KEY_FORMAT); - setup_writability_sensitivity (cd, cd->custom_entry, cd->custom_label, - KEY_CUSTOM_FORMAT); - setup_writability_sensitivity (cd, cd->showseconds_check, NULL, KEY_SHOW_SECONDS); - setup_writability_sensitivity (cd, cd->showdate_check, NULL, KEY_SHOW_DATE); - - gtk_widget_show (cd->props); -#endif } static void diff --git a/applets/clock/clock.h b/applets/clock/clock.h index f2347f68..190c29b5 100644 --- a/applets/clock/clock.h +++ b/applets/clock/clock.h @@ -32,7 +32,7 @@ extern "C" { #endif #define CLOCK_ICON "mate-panel-clock" -#define CLOCK_SCHEMA_DIR "/schemas/apps/clock_applet/prefs" +#define CLOCK_SCHEMA "org.mate.panel.applet.clock" #ifdef __cplusplus } diff --git a/applets/clock/clock.schemas.in b/applets/clock/clock.schemas.in deleted file mode 100644 index badec94e..00000000 --- a/applets/clock/clock.schemas.in +++ /dev/null @@ -1,313 +0,0 @@ -<?xml version="1.0"?> -<mateconfschemafile> - <schemalist> - - <schema> - <key>/schemas/apps/clock_applet/prefs/format</key> - <owner>clock-applet</owner> - <type>string</type> - <locale name="C"> - <default> - <!-- Translators: - This controls whether the MATE panel clock should display time in 24 hour mode - or 12 hour mode by default. The only valid values for this are "24-hour" and - "12-hour". If your locale uses 24 hour time notation, translate this to "24-hour". - If your locale uses 12 hour time notation with am/pm, translate this to "12-hour". - - Do NOT translate this into anything else than "24-hour" or "12-hour". For example, - if you translate this to "24 sata" or anything else that isn't "24-hour" or - "12-hour", things will not work. - --> - 24-hour - </default> - <short>Hour format</short> - <long> - This key specifies the hour format used by the clock applet. - Possible values are "12-hour", "24-hour", "internet", "unix" and - "custom". - If set to "internet", the clock will display Internet time. - The Internet time system divides the day into 1000 ".beats". There - are no time zones in this system, so time is the same all over the - world. - If set to "unix", the clock will display time in seconds since - Epoch, i.e. 1970-01-01. - If set to "custom", the clock will display time according to the - format specified in the custom_format key. - </long> - </locale> - <locale name="en_US"> - <default>12-hour</default> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/custom_format</key> - <owner>clock-applet</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Custom format of the clock</short> - <long> - This key specifies the format used by the clock applet when the - format key is set to "custom". You can use conversion specifiers - understood by strftime() to obtain a specific format. See the - strftime() manual for more information. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/show_seconds</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Show time with seconds</short> - <long>If true, display seconds in time.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/show_date</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Show date in clock</short> - <long>If true, display date in the clock, in addition to time.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/show_tooltip</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Show date in tooltip</short> - <long> - If true, show date in a tooltip when the pointer is over the clock. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/show_weather</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Show weather in clock</short> - <long>If true, display a weather icon.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/show_temperature</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Show temperature in clock</short> - <long>If true, show the temperature next to the weather icon.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/gmt_time</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Use UTC</short> - <long> - The use of this key was deprecated in MATE 2.28 in favour of the - use of timezones. The schema is retained for compatibility with - older versions. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/config_tool</key> - <owner>clock-applet</owner> - <type>string</type> - <default> </default> - <locale name="C"> - <short>Time configuration tool</short> - <long> - The use of this key was deprecated in MATE 2.22 with the use - of an internal time configuration tool. The schema is retained for - compatibility with older versions. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/show_week_numbers</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Show week numbers in calendar</short> - <long> - If true, show week numbers in the calendar. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/expand_appointments</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Expand list of appointments</short> - <long> - If true, expand the list of appointments in the calendar window. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/expand_birthdays</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Expand list of birthdays</short> - <long> - If true, expand the list of birthdays in the calendar window. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/expand_tasks</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Expand list of tasks</short> - <long> - If true, expand the list of tasks in the calendar window. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/expand_weather</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Expand list of weather information</short> - <long> - If true, expand the list of weather information in the calendar - window. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/expand_locations</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Expand list of locations</short> - <long> - If true, expand the list of locations in the calendar - window. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/hour_format</key> - <owner>clock-applet</owner> - <type>int</type> - <default>12</default> - <locale name="C"> - <short>Hour format</short> - <long> - The use of this key was deprecated in MATE 2.6 in favour of the - 'format' key. The schema is retained for compatibility with older - versions. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/unix_time</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Use UNIX time</short> - <long> - The use of this key was deprecated in MATE 2.6 in favour of the - 'format' key. The schema is retained for compatibility with older - versions. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/internet_time</key> - <owner>clock-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Use Internet time</short> - <long> - The use of this key was deprecated in MATE 2.6 in favour of the - 'format' key. The schema is retained for compatibility with older - versions. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/cities</key> - <owner>clock-applet</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>List of locations</short> - <long> - A list of locations to display in the calendar window. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/temperature_unit</key> - <owner>clock-applet</owner> - <type>string</type> - <default>Default</default> - <locale name="C"> - <short>Temperature unit</short> - <long> - The unit to use when showing temperatures. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/clock_applet/prefs/speed_unit</key> - <owner>clock-applet</owner> - <type>string</type> - <default>Default</default> - <locale name="C"> - <short>Speed unit</short> - <long> - The unit to use when showing wind speed. - </long> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/applets/clock/org.mate.panel.applet.clock.gschema.xml.in b/applets/clock/org.mate.panel.applet.clock.gschema.xml.in new file mode 100644 index 00000000..d2f7daca --- /dev/null +++ b/applets/clock/org.mate.panel.applet.clock.gschema.xml.in @@ -0,0 +1,88 @@ +<schemalist gettext-domain="@GETTEXT_PACKAGE@"> + <enum id="org.mate.panel.applet.clock.ClockFormat"> + <value nick="invalid" value="0"/> + <value nick="12-hour" value="1"/> + <value nick="24-hour" value="2"/> + <value nick="unix" value="3"/> + <value nick="internet" value="4"/> + <value nick="custom" value="5"/> + </enum> + <enum id="org.mate.panel.applet.clock.TemperatureUnit"> + <value nick="Invalid" value="0"/> + <value nick="Default" value="1"/> + <value nick="Kelvin" value="2"/> + <value nick="Centigrade" value="3"/> + <value nick="Fahrenheit" value="4"/> + </enum> + <enum id="org.mate.panel.applet.clock.SpeedUnit"> + <value nick="Invalid" value="0"/> + <value nick="Default" value="1"/> + <value nick="m/s" value="2"/> + <value nick="km/h" value="3"/> + <value nick="mph" value="4"/> + <value nick="knots" value="5"/> + <value nick="Beaufort scale" value="6"/> + </enum> + <schema id="org.mate.panel.applet.clock"> + <key name="format" enum="org.mate.panel.applet.clock.ClockFormat"> + <default>'24-hour'</default> + <summary>Hour format</summary> + <description>This key specifies the hour format used by the clock applet. Possible values are "12-hour", "24-hour", "internet", "unix" and "custom". If set to "internet", the clock will display Internet time. The Internet time system divides the day into 1000 ".beats". There are no time zones in this system, so time is the same all over the world. If set to "unix", the clock will display time in seconds since Epoch, i.e. 1970-01-01. If set to "custom", the clock will display time according to the format specified in the custom_format key.</description> + </key> + <key name="custom-format" type="s"> + <default>''</default> + <summary>Custom format of the clock</summary> + <description>This key specifies the format used by the clock applet when the format key is set to "custom". You can use conversion specifiers understood by strftime() to obtain a specific format. See the strftime() manual for more information.</description> + </key> + <key name="show-seconds" type="b"> + <default>false</default> + <summary>Show time with seconds</summary> + <description>If true, display seconds in time.</description> + </key> + <key name="show-date" type="b"> + <default>true</default> + <summary>Show date in clock</summary> + <description>If true, display date in the clock, in addition to time.</description> + </key> + <key name="show-tooltip" type="b"> + <default>true</default> + <summary>Show date in tooltip</summary> + <description>If true, show date in a tooltip when the pointer is over the clock.</description> + </key> + <key name="show-weather" type="b"> + <default>true</default> + <summary>Show weather in clock</summary> + <description>If true, display a weather icon.</description> + </key> + <key name="show-temperature" type="b"> + <default>true</default> + <summary>Show temperature in clock</summary> + <description>If true, show the temperature next to the weather icon.</description> + </key> + <key name="show-week-numbers" type="b"> + <default>true</default> + <summary>Show week numbers in calendar</summary> + <description>If true, show week numbers in the calendar.</description> + </key> + <key name="expand-locations" type="b"> + <default>false</default> + <summary>Expand list of locations</summary> + <description>If true, expand the list of locations in the calendar window.</description> + </key> + <key name="cities" type="as"> + <default>[]</default> + <summary>List of locations</summary> + <description>A list of locations to display in the calendar window.</description> + </key> + <key name="temperature-unit" enum="org.mate.panel.applet.clock.TemperatureUnit"> + <default>'Default'</default> + <summary>Temperature unit</summary> + <description>The unit to use when showing temperatures.</description> + </key> + <key name="speed-unit" enum="org.mate.panel.applet.clock.SpeedUnit"> + <default>'Default'</default> + <summary>Speed unit</summary> + <description>The unit to use when showing wind speed.</description> + </key> + </schema> +</schemalist> diff --git a/applets/fish/Makefile.am b/applets/fish/Makefile.am index 95433a87..d25c5eb0 100644 --- a/applets/fish/Makefile.am +++ b/applets/fish/Makefile.am @@ -15,7 +15,7 @@ AM_CFLAGS = $(WARN_CFLAGS) FISH_SOURCES = fish.c FISH_LDADD = \ - ../../libmate-panel-applet/libmate-panel-applet-3.la \ + ../../libmate-panel-applet/libmate-panel-applet-4.la \ $(FISH_LIBS) \ $(LIBMATE_PANEL_APPLET_LIBS) @@ -77,34 +77,19 @@ ui_DATA = fish.ui xmluidir = $(datadir)/mate-panel/ui xmlui_DATA = fish-menu.xml -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = fish.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) - -@INTLTOOL_SCHEMAS_RULE@ - -if MATECONF_SCHEMAS_INSTALL -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schemas_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/applets/fish/$$p ; \ - done \ - fi -uninstall-local: - for p in $(schema_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-uninstall-rule $(top_builddir)/applets/fish/$$p ; \ - done -endif +gsettings_SCHEMAS = org.mate.panel.applet.fish.gschema.xml +@INTLTOOL_XML_NOMERGE_RULE@ +@GSETTINGS_RULES@ EXTRA_DIST = \ wanda.svg \ $(fishbitmaps_DATA) \ org.mate.panel.FishApplet.mate-panel-applet.in.in \ $(service_in_files) \ - fish.schemas.in \ $(ui_DATA) \ - $(xmlui_DATA) + $(xmlui_DATA) \ + $(gsettings_SCHEMAS) -CLEANFILES = $(schemas_DATA) $(applet_DATA) $(applet_DATA).in $(service_DATA) +CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) -include $(top_srcdir)/git.mk diff --git a/applets/fish/fish.c b/applets/fish/fish.c index 1c30d7f8..315c5c45 100644 --- a/applets/fish/fish.c +++ b/applets/fish/fish.c @@ -22,6 +22,7 @@ * George Lebl <[email protected]> * Mark McLoughlin <[email protected]> * Vincent Untz <[email protected]> + * Stefano Karapetsas <[email protected]> */ #include <config.h> @@ -36,10 +37,10 @@ #include <glib-object.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#include <gio/gio.h> #include <mate-panel-applet.h> -#include <mate-panel-applet-mateconf.h> -#include <mateconf/mateconf-client.h> +#include <mate-panel-applet-gsettings.h> #define FISH_APPLET(o) \ (G_TYPE_CHECK_INSTANCE_CAST((o), fish_applet_get_type(), FishApplet)) @@ -48,17 +49,22 @@ #define FISH_ICON "mate-panel-fish" -#define N_FISH_PREFS 6 +#define FISH_SCHEMA "org.mate.panel.applet.fish" +#define FISH_NAME_KEY "name" +#define FISH_IMAGE_KEY "image" +#define FISH_COMMAND_KEY "command" +#define FISH_FRAMES_KEY "frames" +#define FISH_SPEED_KEY "speed" +#define FISH_ROTATE_KEY "rotate" -#define LOCKDOWN_COMMANDLINE_KEY "/desktop/mate/lockdown/disable_command_line" -#define N_FISH_LOCKDOWN 1 - -#define N_FISH_LISTENERS (N_FISH_PREFS + N_FISH_LOCKDOWN) +#define LOCKDOWN_SCHEMA "org.mate.lockdown" +#define LOCKDOWN_DISABLE_COMMAND_LINE_KEY "disable-command-line" typedef struct { MatePanelApplet applet; - MateConfClient *client; + GSettings *settings; + GSettings *lockdown_settings; char *name; char *image; @@ -100,8 +106,6 @@ typedef struct { GIOChannel *io_channel; gboolean april_fools; - - guint listeners [N_FISH_LISTENERS]; } FishApplet; typedef struct { @@ -201,14 +205,13 @@ static void name_value_changed(GtkEntry* entry, FishApplet* fish) if (!text || !text [0]) return; - mate_panel_applet_mateconf_set_string ( - MATE_PANEL_APPLET (fish), "name", text, NULL); + g_settings_set_string (fish->settings, FISH_NAME_KEY, text); } static void image_value_changed(GtkFileChooser* chooser, FishApplet* fish) { char *path; char *image; - char *path_mateconf; + char *path_gsettings; path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); @@ -217,13 +220,13 @@ static void image_value_changed(GtkFileChooser* chooser, FishApplet* fish) return; } - path_mateconf = get_image_path (fish); - if (!strcmp (path, path_mateconf)) { + path_gsettings = get_image_path (fish); + if (!strcmp (path, path_gsettings)) { g_free (path); - g_free (path_mateconf); + g_free (path_gsettings); return; } - g_free (path_mateconf); + g_free (path_gsettings); if (!strncmp (path, FISH_ICONDIR, strlen (FISH_ICONDIR))) { image = path + strlen (FISH_ICONDIR); @@ -232,8 +235,7 @@ static void image_value_changed(GtkFileChooser* chooser, FishApplet* fish) } else image = path; - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (fish), "image", - image, NULL); + g_settings_set_string (fish->settings, FISH_IMAGE_KEY, image); g_free (path); } @@ -245,8 +247,7 @@ static void command_value_changed(GtkEntry* entry, FishApplet *fish) text = gtk_entry_get_text (entry); if (!text || !text [0]) { - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (fish), - "command", "", NULL); + g_settings_set_string (fish->settings, FISH_COMMAND_KEY, ""); return; } @@ -279,29 +280,31 @@ static void command_value_changed(GtkEntry* entry, FishApplet *fish) } } - mate_panel_applet_mateconf_set_string ( - MATE_PANEL_APPLET (fish), "command", text, NULL); + g_settings_set_string (fish->settings, FISH_COMMAND_KEY, text); } static void n_frames_value_changed(GtkSpinButton* button, FishApplet* fish) { - mate_panel_applet_mateconf_set_int ( - MATE_PANEL_APPLET (fish), "frames", - gtk_spin_button_get_value_as_int (button), NULL); + g_settings_set_int ( + fish->settings, + FISH_FRAMES_KEY, + gtk_spin_button_get_value_as_int (button)); } static void speed_value_changed (GtkSpinButton* button, FishApplet* fish) { - mate_panel_applet_mateconf_set_float ( - MATE_PANEL_APPLET (fish), "speed", - gtk_spin_button_get_value (button), NULL); + g_settings_set_double ( + fish->settings, + FISH_SPEED_KEY, + gtk_spin_button_get_value (button)); } static void rotate_value_changed(GtkToggleButton* toggle, FishApplet* fish) { - mate_panel_applet_mateconf_set_bool ( - MATE_PANEL_APPLET (fish), "rotate", - gtk_toggle_button_get_active (toggle), NULL); + g_settings_set_boolean ( + fish->settings, + FISH_ROTATE_KEY, + gtk_toggle_button_get_active (toggle)); } static gboolean delete_event(GtkWidget* widget, FishApplet* fish) @@ -323,17 +326,11 @@ static void handle_response(GtkWidget* widget, int id, FishApplet* fish) static void setup_sensitivity(FishApplet* fish, GtkBuilder* builder, const char* wid, const char* label, const char* label_post, const char* key) { - MatePanelApplet *applet = (MatePanelApplet *) fish; - char *fullkey; GtkWidget *w; - fullkey = mate_panel_applet_mateconf_get_full_key (applet, key); - - if (mateconf_client_key_is_writable (fish->client, fullkey, NULL)) { - g_free (fullkey); + if (g_settings_is_writable (fish->settings, key)) { return; } - g_free (fullkey); w = GTK_WIDGET (gtk_builder_get_object (builder, wid)); g_assert (w != NULL); @@ -426,7 +423,7 @@ static void display_preferences_dialog(GtkAction* action, FishApplet* fish) "name_entry" /* wid */, "name_label" /* label */, NULL /* label_post */, - "name" /* key */); + FISH_NAME_KEY /* key */); fish->preview_image = GTK_WIDGET (gtk_builder_get_object (builder, "preview_image")); if (fish->pixbuf) @@ -458,7 +455,7 @@ static void display_preferences_dialog(GtkAction* action, FishApplet* fish) "image_chooser" /* wid */, "image_label" /* label */, NULL /* label_post */, - "image" /* key */); + FISH_IMAGE_KEY /* key */); fish->command_label = GTK_WIDGET (gtk_builder_get_object (builder, "command_label")); fish->command_entry = GTK_WIDGET (gtk_builder_get_object (builder, "command_entry")); @@ -471,11 +468,9 @@ static void display_preferences_dialog(GtkAction* action, FishApplet* fish) "command_entry" /* wid */, "command_label" /* label */, NULL /* label_post */, - "command" /* key */); + FISH_COMMAND_KEY /* key */); - if (mateconf_client_get_bool (fish->client, - LOCKDOWN_COMMANDLINE_KEY, - NULL)) { + if (g_settings_get_boolean (fish->lockdown_settings, LOCKDOWN_DISABLE_COMMAND_LINE_KEY)) { gtk_widget_set_sensitive (fish->command_label, FALSE); gtk_widget_set_sensitive (fish->command_entry, FALSE); } @@ -491,7 +486,7 @@ static void display_preferences_dialog(GtkAction* action, FishApplet* fish) "frames_spin" /* wid */, "frames_label" /* label */, "frames_post_label" /* label_post */, - "frames" /* key */); + FISH_FRAMES_KEY /* key */); fish->speed_spin = GTK_WIDGET (gtk_builder_get_object (builder, "speed_spin")); gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->speed_spin), fish->speed); @@ -503,7 +498,7 @@ static void display_preferences_dialog(GtkAction* action, FishApplet* fish) "speed_spin" /* wid */, "speed_label" /* label */, "speed_post_label" /* label_post */, - "speed" /* key */); + FISH_SPEED_KEY /* key */); fish->rotate_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "rotate_toggle")); gtk_toggle_button_set_active ( @@ -516,7 +511,7 @@ static void display_preferences_dialog(GtkAction* action, FishApplet* fish) "rotate_toggle" /* wid */, NULL /* label */, NULL /* label_post */, - "rotate" /* key */); + FISH_ROTATE_KEY /* key */); g_signal_connect (fish->preferences_dialog, "delete_event", G_CALLBACK (delete_event), fish); @@ -968,14 +963,11 @@ static void display_fortune_dialog(FishApplet* fish) gtk_window_present (GTK_WINDOW (fish->fortune_dialog)); } -static void name_changed_notify(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, FishApplet* fish) +static void name_changed_notify(GSettings* settings, gchar* key, FishApplet* fish) { - const char *value; + char *value; - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - - value = mateconf_value_get_string (entry->value); + value = g_settings_get_string (settings, key); if (!value [0] || (fish->name && !strcmp (fish->name, value))) return; @@ -991,16 +983,16 @@ static void name_changed_notify(MateConfClient* client, guint cnxn_id, MateConfE if (fish->name_entry && strcmp (gtk_entry_get_text (GTK_ENTRY (fish->name_entry)), fish->name)) gtk_entry_set_text (GTK_ENTRY (fish->name_entry), fish->name); + + if (value) + g_free (value); } -static void image_changed_notify(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, FishApplet* fish) +static void image_changed_notify(GSettings* settings, gchar* key, FishApplet* fish) { - const char *value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; + char *value; - value = mateconf_value_get_string (entry->value); + value = g_settings_get_string (settings, key); if (!value [0] || (fish->image && !strcmp (fish->image, value))) return; @@ -1013,28 +1005,28 @@ static void image_changed_notify(MateConfClient* client, guint cnxn_id, MateConf update_pixmap (fish); if (fish->image_chooser) { - char *path_mateconf; + char *path_gsettings; char *path_chooser; - path_mateconf = get_image_path (fish); + path_gsettings = get_image_path (fish); path_chooser = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fish->image_chooser)); - if (strcmp (path_mateconf, path_chooser)) + if (strcmp (path_gsettings, path_chooser)) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fish->image_chooser), - path_mateconf); + path_gsettings); - g_free (path_mateconf); + g_free (path_gsettings); g_free (path_chooser); } + + if (value) + g_free (value); } -static void command_changed_notify(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, FishApplet* fish) +static void command_changed_notify(GSettings* settings, gchar* key, FishApplet* fish) { - const char *value; - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; + char *value; - value = mateconf_value_get_string (entry->value); + value = g_settings_get_string (settings, key); if (fish->command && !strcmp (fish->command, value)) return; @@ -1046,16 +1038,16 @@ static void command_changed_notify(MateConfClient* client, guint cnxn_id, MateCo if (fish->command_entry && strcmp (gtk_entry_get_text (GTK_ENTRY (fish->command_entry)), fish->command)) gtk_entry_set_text (GTK_ENTRY (fish->command_entry), fish->command); + + if (value) + g_free (value); } -static void n_frames_changed_notify(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, FishApplet* fish) +static void n_frames_changed_notify(GSettings* settings, gchar* key, FishApplet* fish) { int value; - if (!entry->value || entry->value->type != MATECONF_VALUE_INT) - return; - - value = mateconf_value_get_int (entry->value); + value = g_settings_get_int (settings, key); if (fish->n_frames == value) return; @@ -1196,14 +1188,11 @@ static void setup_timeout(FishApplet *fish) fish); } -static void speed_changed_notify(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, FishApplet* fish) +static void speed_changed_notify(GSettings* settings, gchar* key, FishApplet* fish) { gdouble value; - if (!entry->value || entry->value->type != MATECONF_VALUE_FLOAT) - return; - - value = mateconf_value_get_float (entry->value); + value = g_settings_get_double (settings, key); if (fish->speed == value) return; @@ -1216,14 +1205,11 @@ static void speed_changed_notify(MateConfClient* client, guint cnxn_id, MateConf gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->speed_spin), fish->speed); } -static void rotate_changed_notify(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, FishApplet* fish) +static void rotate_changed_notify(GSettings* settings, gchar* key, FishApplet* fish) { gboolean value; - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - value = mateconf_value_get_bool (entry->value); + value = g_settings_get_boolean (settings, key); if (fish->rotate == value) return; @@ -1239,14 +1225,11 @@ static void rotate_changed_notify(MateConfClient* client, guint cnxn_id, MateCon GTK_TOGGLE_BUTTON (fish->rotate_toggle), fish->rotate); } -static void fish_disable_commande_line_notify(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, FishApplet* fish) +static void fish_disable_commande_line_notify(GSettings* settings, gchar* key, FishApplet* fish) { gboolean locked_down; - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - locked_down = !mateconf_value_get_bool (entry->value); + locked_down = !g_settings_get_boolean (settings, key); if (fish->command_label != NULL) gtk_widget_set_sensitive (fish->command_label, locked_down); @@ -1254,61 +1237,41 @@ static void fish_disable_commande_line_notify(MateConfClient* client, guint cnxn gtk_widget_set_sensitive (fish->command_entry, locked_down); } -static void setup_mateconf(FishApplet* fish) +static void setup_gsettings(FishApplet* fish) { MatePanelApplet *applet = (MatePanelApplet *) fish; - char *key; - int i = 0; - - key = mate_panel_applet_mateconf_get_full_key (applet, "name"); - fish->listeners [i++] = mateconf_client_notify_add ( - fish->client, key, - (MateConfClientNotifyFunc) name_changed_notify, - fish, NULL, NULL); - g_free (key); - - key = mate_panel_applet_mateconf_get_full_key (applet, "image"); - fish->listeners [i++] = mateconf_client_notify_add ( - fish->client, key, - (MateConfClientNotifyFunc) image_changed_notify, - fish, NULL, NULL); - g_free (key); - - key = mate_panel_applet_mateconf_get_full_key (applet, "command"); - fish->listeners [i++] = mateconf_client_notify_add ( - fish->client, key, - (MateConfClientNotifyFunc) command_changed_notify, - fish, NULL, NULL); - g_free (key); - - key = mate_panel_applet_mateconf_get_full_key (applet, "frames"); - fish->listeners [i++] = mateconf_client_notify_add ( - fish->client, key, - (MateConfClientNotifyFunc) n_frames_changed_notify, - fish, NULL, NULL); - g_free (key); - - key = mate_panel_applet_mateconf_get_full_key (applet, "speed"); - fish->listeners [i++] = mateconf_client_notify_add ( - fish->client, key, - (MateConfClientNotifyFunc) speed_changed_notify, - fish, NULL, NULL); - g_free (key); - - key = mate_panel_applet_mateconf_get_full_key (applet, "rotate"); - fish->listeners [i++] = mateconf_client_notify_add ( - fish->client, key, - (MateConfClientNotifyFunc) rotate_changed_notify, - fish, NULL, NULL); - g_free (key); - - fish->listeners [i++] = mateconf_client_notify_add ( - fish->client, - LOCKDOWN_COMMANDLINE_KEY, - (MateConfClientNotifyFunc) fish_disable_commande_line_notify, - fish, NULL, NULL); - - g_assert (i == N_FISH_LISTENERS); + + fish->settings = mate_panel_applet_settings_new (applet, FISH_SCHEMA); + fish->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA); + + g_signal_connect (fish->settings, + "changed::" FISH_NAME_KEY, + G_CALLBACK (name_changed_notify), + fish); + g_signal_connect (fish->settings, + "changed::" FISH_IMAGE_KEY, + G_CALLBACK (image_changed_notify), + fish); + g_signal_connect (fish->settings, + "changed::" FISH_COMMAND_KEY, + G_CALLBACK (command_changed_notify), + fish); + g_signal_connect (fish->settings, + "changed::" FISH_FRAMES_KEY, + G_CALLBACK (n_frames_changed_notify), + fish); + g_signal_connect (fish->settings, + "changed::" FISH_SPEED_KEY, + G_CALLBACK (speed_changed_notify), + fish); + g_signal_connect (fish->settings, + "changed::" FISH_ROTATE_KEY, + G_CALLBACK (rotate_changed_notify), + fish); + g_signal_connect (fish->lockdown_settings, + "changed::" LOCKDOWN_DISABLE_COMMAND_LINE_KEY, + G_CALLBACK (fish_disable_commande_line_notify), + fish); } static gboolean load_fish_image(FishApplet* fish) @@ -1710,100 +1673,38 @@ static const GtkActionEntry fish_menu_verbs[] = { G_CALLBACK (display_about_dialog) } }; -static void fish_migrate_to_210(FishApplet* fish) -{ - char *new_image; - - g_assert (fish->image); - - if (!strncmp (fish->image, "fish/", 5)) { - new_image = g_strdup (fish->image + 5); - g_free (fish->image); - fish->image = new_image; - mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (fish), "image", - fish->image, NULL); - } -} - static gboolean fish_applet_fill(FishApplet* fish) { MatePanelApplet* applet = (MatePanelApplet*) fish; GtkActionGroup* action_group; gchar* ui_path; - GError* error = NULL; fish->orientation = mate_panel_applet_get_orient (applet); - mate_panel_applet_add_preferences(applet, "/schemas/apps/fish_applet/prefs", NULL); - - setup_mateconf(fish); + setup_gsettings (fish); - fish->name = mate_panel_applet_mateconf_get_string(applet, "name", &error); - - if (error) - { - g_warning ("Error getting 'name' preference: %s", error->message); - g_error_free (error); - error = NULL; - } + fish->name = g_settings_get_string (fish->settings, FISH_NAME_KEY); if (!fish->name) { fish->name = g_strdup ("Wanda"); /* Fallback */ } - fish->image = mate_panel_applet_mateconf_get_string (applet, "image", &error); - - if (error) { - g_warning ("Error getting 'image' preference: %s", error->message); - g_error_free (error); - error = NULL; - } + fish->image = g_settings_get_string (fish->settings, FISH_IMAGE_KEY); if (!fish->image) fish->image = g_strdup ("fishanim.png"); /* Fallback */ - fish_migrate_to_210 (fish); - - fish->command = mate_panel_applet_mateconf_get_string (applet, "command", &error); - - if (error) { - g_warning ("Error getting 'command' preference: %s", error->message); - g_error_free (error); - error = NULL; - } - - fish->n_frames = mate_panel_applet_mateconf_get_int (applet, "frames", &error); + fish->command = g_settings_get_string (fish->settings, FISH_COMMAND_KEY); - if (error) { - g_warning ("Error getting 'frames' preference: %s", error->message); - g_error_free (error); - error = NULL; + fish->n_frames = g_settings_get_int (fish->settings, FISH_FRAMES_KEY); - fish->n_frames = 3; /* Fallback */ - } if (fish->n_frames <= 0) fish->n_frames = 1; - fish->speed = mate_panel_applet_mateconf_get_float (applet, "speed", &error); - - if (error) { - g_warning ("Error getting 'speed' preference: %s", error->message); - g_error_free (error); - error = NULL; - - fish->speed = 1.0; /* Fallback */ - } - - fish->rotate = mate_panel_applet_mateconf_get_bool (applet, "rotate", &error); - - if (error) { - g_warning ("Error getting 'rotate' preference: %s", error->message); - g_error_free (error); - error = NULL; + fish->speed = g_settings_get_double (fish->settings, FISH_SPEED_KEY); - fish->rotate = FALSE; /* Fallback */ - } + fish->rotate = g_settings_get_boolean (fish->settings, FISH_ROTATE_KEY); action_group = gtk_action_group_new ("Fish Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); @@ -1847,7 +1748,6 @@ static gboolean fishy_factory(MatePanelApplet* applet, const char* iid, gpointer static void fish_applet_destroy(GtkObject* object) { FishApplet* fish = (FishApplet*) object; - int i; if (fish->timeout) { @@ -1856,15 +1756,13 @@ static void fish_applet_destroy(GtkObject* object) fish->timeout = 0; - for (i = 0; i < N_FISH_LISTENERS; i++) - { - if (fish->client && fish->listeners [i] != 0) - { - mateconf_client_notify_remove(fish->client, fish->listeners [i]); - } + if (fish->settings) + g_object_unref (fish->settings); + fish->settings = NULL; - fish->listeners [i] = 0; - } + if (fish->lockdown_settings) + g_object_unref (fish->lockdown_settings); + fish->lockdown_settings = NULL; if (fish->name) g_free (fish->name); @@ -1878,10 +1776,6 @@ static void fish_applet_destroy(GtkObject* object) g_free (fish->command); fish->command = NULL; - if (fish->client) - g_object_unref (fish->client); - fish->client = NULL; - if (fish->pixmap) g_object_unref (fish->pixmap); fish->pixmap = NULL; @@ -1909,10 +1803,6 @@ static void fish_applet_destroy(GtkObject* object) static void fish_applet_instance_init(FishApplet* fish, FishAppletClass* klass) { - int i; - - fish->client = mateconf_client_get_default(); - fish->name = NULL; fish->image = NULL; fish->command = NULL; @@ -1958,9 +1848,6 @@ static void fish_applet_instance_init(FishApplet* fish, FishAppletClass* klass) fish->source_id = 0; fish->io_channel = NULL; - for (i = 0; i < N_FISH_LISTENERS; i++) - fish->listeners [i] = 0; - fish->april_fools = FALSE; mate_panel_applet_set_flags (MATE_PANEL_APPLET (fish), MATE_PANEL_APPLET_EXPAND_MINOR); diff --git a/applets/fish/fish.schemas.in b/applets/fish/fish.schemas.in deleted file mode 100644 index 3431ac33..00000000 --- a/applets/fish/fish.schemas.in +++ /dev/null @@ -1,91 +0,0 @@ -<mateconfschemafile> - <schemalist> - - <schema> - <key>/schemas/apps/fish_applet/prefs/name</key> - <owner>fish-applet</owner> - <type>string</type> - <default>Wanda</default> - <locale name="C"> - <short>The fish's name</short> - <long> - A fish without a name is a pretty dull fish. Bring your fish to - life by naming him. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/fish_applet/prefs/image</key> - <owner>fish-applet</owner> - <type>string</type> - <default>wanda.png</default> - <locale name="C"> - <short>The fish's animation pixmap</short> - <long> - This key specifies the filename of the pixmap which will be used - for the animation displayed in the fish applet relative to the - pixmap directory. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/fish_applet/prefs/command</key> - <owner>fish-applet</owner> - <type>string</type> - <default>fortune</default> - <locale name="C"> - <short>Command to execute on click</short> - <long> - This key specifies the command that will be tried to execute when - the fish is clicked. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/fish_applet/prefs/frames</key> - <owner>fish-applet</owner> - <type>int</type> - <default>8</default> - <locale name="C"> - <short>Frames in fish's animation</short> - <long> - This key specifies the number of frames that will be displayed in - the fish's animation. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/fish_applet/prefs/speed</key> - <owner>fish-applet</owner> - <type>float</type> - <default>0.3</default> - <locale name="C"> - <short>Pause per frame</short> - <long> - This key specifies the number of seconds each frame will be - displayed. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/fish_applet/prefs/rotate</key> - <owner>fish-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Rotate on vertical panels</short> - <long> - If true, the fish's animation will be displayed rotated on vertical - panels. - </long> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/applets/fish/org.mate.panel.applet.fish.gschema.xml.in b/applets/fish/org.mate.panel.applet.fish.gschema.xml.in new file mode 100644 index 00000000..a3c3fe77 --- /dev/null +++ b/applets/fish/org.mate.panel.applet.fish.gschema.xml.in @@ -0,0 +1,34 @@ +<schemalist gettext-domain="@GETTEXT_PACKAGE@"> + <schema id="org.mate.panel.applet.fish"> + <key name="name" type="s"> + <default>'Wanda'</default> + <summary>The fish's name</summary> + <description>A fish without a name is a pretty dull fish. Bring your fish to life by naming him.</description> + </key> + <key name="image" type="s"> + <default>'wanda.png'</default> + <summary>The fish's animation pixmap</summary> + <description>This key specifies the filename of the pixmap which will be used for the animation displayed in the fish applet relative to the pixmap directory.</description> + </key> + <key name="command" type="s"> + <default>'fortune'</default> + <summary>Command to execute on click</summary> + <description>This key specifies the command that will be tried to execute when the fish is clicked.</description> + </key> + <key name="frames" type="i"> + <default>8</default> + <summary>Frames in fish's animation</summary> + <description>This key specifies the number of frames that will be displayed in the fish's animation.</description> + </key> + <key name="speed" type="d"> + <default>0.3</default> + <summary>Pause per frame</summary> + <description>This key specifies the number of seconds each frame will be displayed.</description> + </key> + <key name="rotate" type="b"> + <default>false</default> + <summary>Rotate on vertical panels</summary> + <description>If true, the fish's animation will be displayed rotated on vertical panels.</description> + </key> + </schema> +</schemalist> diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 00000000..0ff699e1 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,14 @@ +default_layoutdir = $(datadir)/mate-panel +default_layout_DATA = panel-default-layout.mate + +@INTLTOOL_XML_NOMERGE_RULE@ + +gsettings_ENUM_NAMESPACE = org.mate.panel +gsettings_ENUM_FILES = $(top_srcdir)/mate-panel/panel-enums-gsettings.h + +gsettings_SCHEMAS = \ + org.mate.panel.gschema.xml \ + org.mate.panel.object.gschema.xml \ + org.mate.panel.toplevel.gschema.xml + +@GSETTINGS_RULES@ diff --git a/data/org.mate.panel.gschema.xml.in b/data/org.mate.panel.gschema.xml.in new file mode 100644 index 00000000..e4dd0a25 --- /dev/null +++ b/data/org.mate.panel.gschema.xml.in @@ -0,0 +1,78 @@ +<schemalist> + <schema id="org.mate.panel" path="/org/mate/panel/general/"> + <key name="enable-program-list" type="b"> + <default>true</default> + <_summary>Enable program list in "Run Application" dialog</_summary> + <_description>If true, the "Known Applications" listing in the "Run Application" dialog is made available. Whether or not the listing is expanded when the dialog is shown is controlled by the show_program_list key.</_description> + </key> + <key name="show-program-list" type="b"> + <default>false</default> + <_summary>Expand program list in "Run Application" dialog</_summary> + <_description>If true, the "Known Applications" listing in the "Run Application" dialog is expanded when the dialog is opened. This key is only relevant if the enable_program_list key is true.</_description> + </key> + <key name="enable-autocompletion" type="b"> + <default>true</default> + <_summary>Enable autocompletion in "Run Application" dialog</_summary> + <_description>If true, autocompletion in the "Run Application" dialog is made available.</_description> + </key> + <key name="history-mate-run" type="as"> + <default>[]</default> + <_summary>History for "Run Application" dialog</_summary> + <_description>This is the list of commands used in "Run Application" dialog.</_description> + </key> + <key name="toplevel-id-list" type="as"> + <default>[]</default> + <_summary>Panel ID list</_summary> + <_description>A list of panel IDs. Each ID identifies an individual toplevel panel. The settings for each of these panels are stored in /apps/panel/toplevels/$(id).</_description> + </key> + <key name="object-id-list" type="as"> + <default>[]</default> + <_summary>Panel object ID list</_summary> + <_description>A list of panel object IDs. Each ID identifies an individual panel object (e.g. a launcher, action button or menu button/bar). The settings for each of these objects are stored in /apps/panel/objects/$(id).</_description> + </key> + <key name="tooltips-enabled" type="b"> + <default>true</default> + <_summary>Enable tooltips</_summary> + <_description>If true, tooltips are shown for objects in panels.</_description> + </key> + <key name="enable-animations" type="b"> + <default>true</default> + <_summary>Enable animations</_summary> + </key> + <key name="drawer-autoclose" type="b"> + <default>true</default> + <_summary>Autoclose drawer</_summary> + <_description>If true, a drawer will automatically be closed when the user clicks a launcher in it.</_description> + </key> + <key name="confirm-panel-remove" type="b"> + <default>true</default> + <_summary>Confirm panel removal</_summary> + <_description>If true, a dialog is shown asking for confirmation if the user wants to remove a panel.</_description> + </key> + <key name="highlight-launchers-on-mouseover" type="b"> + <default>true</default> + <_summary>Highlight launchers on mouseover</_summary> + <_description>If true, a launcher is highlighted when the user moves the pointer over it.</_description> + </key> + <key name="locked-down" type="b"> + <default>false</default> + <_summary>Complete panel lockdown</_summary> + <_description>If true, the panel will not allow any changes to the configuration of the panel. Individual applets may need to be locked down separately however. The panel must be restarted for this to take effect.</_description> + </key> + <key name="disabled-applets" type="as"> + <default>[]</default> + <_summary>Applet IIDs to disable from loading</_summary> + <_description>A list of applet IIDs that the panel will ignore. This way you can disable certain applets from loading or showing up in the menu. For example to disable the mini-commander applet add 'OAFIID:MATE_MiniCommanderApplet' to this list. The panel must be restarted for this to take effect.</_description> + </key> + <key name="disable-log-out" type="b"> + <default>false</default> + <_summary>Disable Logging Out</_summary> + <_description>If true, the panel will not allow a user to log out, by removing access to the log out menu entries.</_description> + </key> + <key name="disable-force-quit" type="b"> + <default>false</default> + <_summary>Disable Force Quit</_summary> + <_description>If true, the panel will not allow a user to force an application to quit by removing access to the force quit button.</_description> + </key> + </schema> +</schemalist> diff --git a/data/org.mate.panel.object.gschema.xml.in b/data/org.mate.panel.object.gschema.xml.in new file mode 100644 index 00000000..e4582fd9 --- /dev/null +++ b/data/org.mate.panel.object.gschema.xml.in @@ -0,0 +1,79 @@ +<schemalist> + <schema id="org.mate.panel.object"> + <key name="object-type" enum="org.mate.panel.PanelObjectType"> + <default>'launcher'</default> + <_summary>Panel object type</_summary> + <_description>The type of this panel object.</_description> + </key> + <key name="toplevel-id" type="s"> + <default>''</default> + <_summary>Toplevel panel containing object</_summary> + <_description>The identifier of the toplevel panel which contains this object.</_description> + </key> + <key name="position" type="i"> + <default>0</default> + <_summary>Object's position on the panel</_summary> + <_description>The position of this panel object. The position is specified by the number of pixels from the left (or top if vertical) panel edge.</_description> + </key> + <key name="panel-right-stick" type="b"> + <default>false</default> + <_summary>Interpret position relative to bottom/right edge</_summary> + <_description>If true, the position of the object is interpreted relative to the right (or bottom if vertical) edge of the panel.</_description> + </key> + <key name="locked" type="b"> + <default>false</default> + <_summary>Lock the object to the panel</_summary> + <_description>If true, the user may not move the applet without first unlocking the object using the "Unlock" menuitem.</_description> + </key> + <key name="applet-iid" type="s"> + <default>''</default> + <_summary>Applet IID</_summary> + <_description>The implementation ID of the applet - e.g. "ClockAppletFactory::ClockApplet". This key is only relevant if the object_type key is "external-applet" (or the deprecated "matecomponent-applet").</_description> + </key> + <key name="attached-toplevel-id" type="s"> + <default>''</default> + <_summary>Panel attached to drawer</_summary> + <_description>The identifier of the panel attached to this drawer. This key is only relevant if the object_type key is "drawer-object".</_description> + </key> + <key name="tooltip" type="s"> + <default>''</default> + <_summary>Tooltip displayed for drawer or menu</_summary> + <_description>The text to display in a tooltip for this drawer or this menu. This key is only relevant if the object_type key is "drawer-object" or "menu-object".</_description> + </key> + <key name="use-custom-icon" type="b"> + <default>false</default> + <_summary>Use custom icon for object's button</_summary> + <_description>If true, the custom_icon key is used as a custom icon for the button. If false, the custom_icon key is ignored. This key is only relevant if the object_type key is "menu-object" or "drawer-object".</_description> + </key> + <key name="custom-icon" type="s"> + <default>''</default> + <_summary>Icon used for object's button</_summary> + <_description>The location of the image file used as the icon for the object's button. This key is only relevant if the object_type key is "drawer-object" or "menu-object" and the use_custom_icon key is true.</_description> + </key> + <key name="use-menu-path" type="b"> + <default>false</default> + <_summary>Use custom path for menu contents</_summary> + <_description>If true, the menu_path key is used as the path from which the menu contents should be constructed. If false, the menu_path key is ignored. This key is only relevant if the object_type key is "menu-object".</_description> + </key> + <key name="menu-path" type="s"> + <default>'applications:/'</default> + <_summary>Menu content path</_summary> + <_description>The path from which the menu contents is contructed. This key is only relevant if the use_menu_path key is true and the object_type key is "menu-object".</_description> + </key> + <key name="has-arrow" type="b"> + <default>true</default> + <_summary>Draw arrow in menu button</_summary> + <_description>If true, an arrow is drawn over the menu button icon. If false, menu button has only the icon.</_description> + </key> + <key name="launcher-location" type="s"> + <default>''</default> + <_summary>Launcher location</_summary> + <_description>The location of the .desktop file describing the launcher. This key is only relevant if the object_type key is "launcher-object".</_description> + </key> + <key name="action-type" enum="org.mate.panel.PanelActionButtonType"> + <default>'none'</default> + <_summary>Action button type</_summary> + <_description>The action type this button represents. Possible values are "lock", "logout", "run", "search" and "screenshot". This key is only relevant if the object_type key is "action-applet".</_description> + </key> + </schema> +</schemalist> diff --git a/data/org.mate.panel.toplevel.gschema.xml.in b/data/org.mate.panel.toplevel.gschema.xml.in new file mode 100644 index 00000000..c3b5944d --- /dev/null +++ b/data/org.mate.panel.toplevel.gschema.xml.in @@ -0,0 +1,142 @@ +<schemalist> + <schema id="org.mate.panel.toplevel"> + <key name="name" type="s"> + <default>''</default> + <_summary>Name to identify panel</_summary> + <_description>This is a human readable name which you can use to identify a panel. Its main purpose is to serve as the panel's window title which is useful when navigating between panels.</_description> + </key> + <key name="screen" type="i"> + <default>0</default> + <_summary>X screen where the panel is displayed</_summary> + <_description>With a multi-screen setup, you may have panels on each individual screen. This key identifies the current screen the panel is displayed on.</_description> + </key> + <key name="monitor" type="i"> + <default>0</default> + <_summary>Xinerama monitor where the panel is displayed</_summary> + <_description>In a Xinerama setup, you may have panels on each individual monitor. This key identifies the current monitor the panel is displayed on.</_description> + </key> + <key name="expand" type="b"> + <default>true</default> + <_summary>Expand to occupy entire screen width</_summary> + <_description>If true, the panel will occupy the entire screen width (height if this is a vertical panel). In this mode the panel can only be placed at a screen edge. If false, the panel will only be large enough to accommodate the applets, launchers and buttons on the panel.</_description> + </key> + <key name="orientation" enum="org.mate.panel.PanelOrientation"> + <default>'top'</default> + <_summary>Panel orientation</_summary> + <_description>The orientation of the panel. Possible values are "top", "bottom", "left", "right". In expanded mode the key specifies which screen edge the panel is on. In un-expanded mode the difference between "top" and "bottom" is less important - both indicate that this is a horizontal panel - but still give a useful hint as to how some panel objects should behave. For example, on a "top" panel a menu button will pop up its menu below the panel, whereas on a "bottom" panel the menu will be popped up above the panel.</_description> + </key> + <key name="size" type="i"> + <default>24</default> + <_summary>Panel size</_summary> + <_description>The height (width for a vertical panel) of the panel. The panel will determine at runtime a minimum size based on the font size and other indicators. The maximum size is fixed at one quarter of the screen height (or width).</_description> + </key> + <key name="x" type="i"> + <default>0</default> + <_summary>X co-ordinate of panel</_summary> + <_description>The location of the panel along the x-axis. This key is only relevant in un-expanded mode. In expanded mode this key is ignored and the panel is placed at the screen edge specified by the orientation key.</_description> + </key> + <key name="y" type="i"> + <default>0</default> + <_summary>Y co-ordinate of panel</_summary> + <_description>The location of the panel along the y-axis. This key is only relevant in un-expanded mode. In expanded mode this key is ignored and the panel is placed at the screen edge specified by the orientation key.</_description> + </key> + <key name="x-right" type="i"> + <default>-1</default> + <_summary>X co-ordinate of panel, starting from the right of the screen</_summary> + <_description>The location of the panel along the x-axis, starting from the right of the screen. If set to -1, the value is ignored and the value of the x key is used. If the value is greater than 0, then the value of the x key is ignored. This key is only relevant in un-expanded mode. In expanded mode this key is ignored and the panel is placed at the screen edge specified by the orientation key.</_description> + </key> + <key name="y-bottom" type="i"> + <default>-1</default> + <_summary>Y co-ordinate of panel, starting from the bottom of the screen</_summary> + <_description>The location of the panel along the y-axis, starting from the bottom of the screen. If set to -1, the value is ignored and the value of the y key is used. If the value is greater than 0, then the value of the y key is ignored. This key is only relevant in un-expanded mode. In expanded mode this key is ignored and the panel is placed at the screen edge specified by the orientation key.</_description> + </key> + <key name="x-centered" type="b"> + <default>false</default> + <_summary>Center panel on x-axis</_summary> + <_description>If true, the x and x_right keys are ignored and the panel is placed at the center of the x-axis of the screen. If the panel is resized it will remain at that position - i.e. the panel will grow on both sides. If false, the x and x_right keys specify the location of the panel.</_description> + </key> + <key name="y-centered" type="b"> + <default>false</default> + <_summary>Center panel on y-axis</_summary> + <_description>If true, the y and y_bottom keys are ignored and the panel is placed at the center of the y-axis of the screen. If the panel is resized it will remain at that position - i.e. the panel will grow on both sides. If false, the y and y_bottom keys specify the location of the panel.</_description> + </key> + <key name="auto-hide" type="b"> + <default>false</default> + <_summary>Automatically hide panel into corner</_summary> + <_description>If true, the panel is automatically hidden into a corner of the screen when the pointer leaves the panel area. Moving the pointer to that corner again will cause the panel to re-appear.</_description> + </key> + <key name="enable-animations" type="b"> + <default>true</default> + <_summary>Enable animations</_summary> + <_description>If true, hiding and un-hiding of this panel will be animated rather than happening instantly.</_description> + </key> + <key name="enable-buttons" type="b"> + <default>false</default> + <_summary>Enable hide buttons</_summary> + <_description>If true, buttons will be placed on each side of the panel which may be used to move the panel to edge of the screen, leaving only a button showing.</_description> + </key> + <key name="enable-arrows" type="b"> + <default>true</default> + <_summary>Enable arrows on hide buttons</_summary> + <_description>If true, arrows will be placed on the hide buttons. This key is only relevant if the enable_buttons key is true.</_description> + </key> + <key name="hide-delay" type="i"> + <default>300</default> + <_summary>Panel autohide delay</_summary> + <_description>Specifies the number of milliseconds delay after the pointer leaves the panel area before the panel is automatically hidden. This key is only relevant if the auto_hide key is true.</_description> + </key> + <key name="unhide-delay" type="i"> + <default>100</default> + <_summary>Panel autounhide delay</_summary> + <_description>Specifies the number of milliseconds delay after the pointer enters the panel area before the panel is automatically re-shown. This key is only relevant if the auto_hide key is true.</_description> + </key> + <key name="auto-hide-size" type="i"> + <default>1</default> + <_summary>Visible pixels when hidden</_summary> + <_description>Specifies the number of pixels visible when the panel is automatically hidden into a corner. This key is only relevant if the auto_hide key is true.</_description> + </key> + <key name="animation-speed" enum="org.mate.panel.PanelAnimationSpeed"> + <default>'fast'</default> + <_summary>Animation speed</_summary> + <_description>The speed in which panel animations should occur. Possible values are "slow", "medium" and "fast". This key is only relevant if the enable_animations key is true.</_description> + </key> + <child name="background" schema="org.mate.panel.toplevel.background"/> + </schema> + <schema id="org.mate.panel.toplevel.background"> + <key name="type" enum="org.mate.panel.PanelBackgroundType"> + <default>'none'</default> + <_summary>Background type</_summary> + <_description>Which type of background should be used for this panel. Possible values are "none" - the default GTK+ widget background will be used, "color" - the color key will be used as background color or "image" - the image specified by the image key will be used as background.</_description> + </key> + <key name="color" type="s"> + <default>'#ffffff'</default> + <_summary>Background color</_summary> + <_description>Specifies the background color for the panel in #RGB format.</_description> + </key> + <key name="opacity" type="i"> + <default>6000</default> + <_summary>Background color opacity</_summary> + <_description>Specifies the opacity of the background color format. If the color is not completely opaque (a value of less than 65535), the color will be composited onto the desktop background image.</_description> + </key> + <key name="image" type="s"> + <default>''</default> + <_summary>Background image</_summary> + <_description>Specifies the file to be used for the background image. If the image contains an alpha channel it will be composited onto the desktop background image.</_description> + </key> + <key name="fit" type="b"> + <default>false</default> + <_summary>Fit image to panel</_summary> + <_description>If true, the image will be scaled (retaining the aspect ratio of the image) to the panel height (if horizontal).</_description> + </key> + <key name="stretch" type="b"> + <default>false</default> + <_summary>Stretch image to panel</_summary> + <_description>If true, the image will be scaled to the panel dimensions. The aspect ratio of the image will not be maintained.</_description> + </key> + <key name="rotate" type="b"> + <default>false</default> + <_summary>Rotate image on vertical panels</_summary> + <_description>If true, the background image will be rotated when the panel is oriented vertically.</_description> + </key> + </schema> +</schemalist> diff --git a/data/panel-default-layout.mate b/data/panel-default-layout.mate new file mode 100644 index 00000000..77923b42 --- /dev/null +++ b/data/panel-default-layout.mate @@ -0,0 +1,53 @@ +[Toplevel top] +expand=true +orientation=top +size=24 + +[Toplevel bottom] +expand=true +orientation=bottom +size=24 + +[Object menu-bar] +object-type=menu-bar +toplevel-id=top +position=0 +locked=true + +[Object notification-area] +object-type=applet +applet-iid=NotificationAreaAppletFactory::NotificationArea +toplevel-id=top +position=10 +panel-right-stick=true +locked=true + +[Object clock] +object-type=applet +applet-iid=ClockAppletFactory::ClockApplet +toplevel-id=top +position=0 +panel-right-stick=true +locked=true + +[Object show-desktop] +object-type=applet +applet-iid=WnckletFactory::ShowDesktopApplet +toplevel-id=bottom +position=0 +locked=true + +[Object window-list] +object-type=applet +applet-iid=WnckletFactory::WindowListApplet +toplevel-id=bottom +position=20 +locked=true + +[Object workspace-switcher] +object-type=applet +applet-iid=WnckletFactory::WorkspaceSwitcherApplet +toplevel-id=bottom +position=0 +panel-right-stick=true +locked=true diff --git a/doc/reference/mate-panel-applet/html/mate-panel-applet-Panel-Applet-MateConf-Utilities.html b/doc/reference/mate-panel-applet/html/mate-panel-applet-Panel-Applet-MateConf-Utilities.html deleted file mode 100644 index ed0de262..00000000 --- a/doc/reference/mate-panel-applet/html/mate-panel-applet-Panel-Applet-MateConf-Utilities.html +++ /dev/null @@ -1,655 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<title>Panel Applet MateConf Utilities</title> -<meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> -<link rel="home" href="index.html" title="Panel Applet Library Reference Manual"> -<link rel="up" href="mate-panel-applet.html" title="The Panel Applet Library"> -<link rel="prev" href="mate-panel-applet-mate-panel-applet.html" title="MatePanelApplet"> -<meta name="generator" content="GTK-Doc V1.15.1 (XML mode)"> -<link rel="stylesheet" href="style.css" type="text/css"> -</head> -<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> -<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> -<tr valign="middle"> -<td><a accesskey="p" href="mate-panel-applet-mate-panel-applet.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> -<td><a accesskey="u" href="mate-panel-applet.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> -<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> -<th width="100%" align="center">Panel Applet Library Reference Manual</th> -<td> </td> -</tr> -<tr><td colspan="5" class="shortcuts"> -<a href="#mate-panel-applet-Panel-Applet-MateConf-Utilities.synopsis" class="shortcut">Top</a> -  | - <a href="#mate-panel-applet-Panel-Applet-MateConf-Utilities.description" class="shortcut">Description</a> -</td></tr> -</table> -<div class="refentry"> -<a name="mate-panel-applet-Panel-Applet-MateConf-Utilities"></a><div class="titlepage"></div> -<div class="refnamediv"><table width="100%"><tr> -<td valign="top"> -<h2><span class="refentrytitle"><a name="mate-panel-applet-Panel-Applet-MateConf-Utilities.top_of_page"></a>Panel Applet MateConf Utilities</span></h2> -<p>Panel Applet MateConf Utilities — Utility methods for manipulating per-applet MateConf preferences.</p> -</td> -<td valign="top" align="right"></td> -</tr></table></div> -<div class="refsynopsisdiv"> -<a name="mate-panel-applet-Panel-Applet-MateConf-Utilities.synopsis"></a><h2>Synopsis</h2> -<pre class="synopsis"> -#include <mate-panel-applet-mateconf.h> - -<span class="returnvalue">gchar</span> * <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-get-full-key" title="mate_panel_applet_mateconf_get_full_key ()">mate_panel_applet_mateconf_get_full_key</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>); -<span class="returnvalue">gboolean</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-get-bool" title="mate_panel_applet_mateconf_get_bool ()">mate_panel_applet_mateconf_get_bool</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">gint</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-get-int" title="mate_panel_applet_mateconf_get_int ()">mate_panel_applet_mateconf_get_int</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">gchar</span> * <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-get-string" title="mate_panel_applet_mateconf_get_string ()">mate_panel_applet_mateconf_get_string</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">gdouble</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-get-float" title="mate_panel_applet_mateconf_get_float ()">mate_panel_applet_mateconf_get_float</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">GSList</span> * <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-get-list" title="mate_panel_applet_mateconf_get_list ()">mate_panel_applet_mateconf_get_list</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValueType"><span class="type">MateConfValueType</span></a> list_type</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValue"><span class="returnvalue">MateConfValue</span></a> * <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-get-value" title="mate_panel_applet_mateconf_get_value ()">mate_panel_applet_mateconf_get_value</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">void</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-set-bool" title="mate_panel_applet_mateconf_set_bool ()">mate_panel_applet_mateconf_set_bool</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">gboolean</span> the_bool</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">void</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-set-int" title="mate_panel_applet_mateconf_set_int ()">mate_panel_applet_mateconf_set_int</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">gint</span> the_int</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">void</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-set-string" title="mate_panel_applet_mateconf_set_string ()">mate_panel_applet_mateconf_set_string</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *the_string</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">void</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-set-float" title="mate_panel_applet_mateconf_set_float ()">mate_panel_applet_mateconf_set_float</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">gdouble</span> the_float</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">void</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-set-list" title="mate_panel_applet_mateconf_set_list ()">mate_panel_applet_mateconf_set_list</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValueType"><span class="type">MateConfValueType</span></a> list_type</code></em>, - <em class="parameter"><code><span class="type">GSList</span> *list</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -<span class="returnvalue">void</span> <a class="link" href="mate-panel-applet-Panel-Applet-MateConf-Utilities.html#mate-panel-applet-mateconf-set-value" title="mate_panel_applet_mateconf_set_value ()">mate_panel_applet_mateconf_set_value</a> (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValue"><span class="type">MateConfValue</span></a> *value</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>); -</pre> -</div> -<div class="refsect1"> -<a name="mate-panel-applet-Panel-Applet-MateConf-Utilities.description"></a><h2>Description</h2> -<p> -Applets typically define a set of preferences using a schemas -file and <a class="link" href="mate-panel-applet-mate-panel-applet.html#mate-panel-applet-add-preferences" title="mate_panel_applet_add_preferences ()"><code class="function">mate_panel_applet_add_preferences()</code></a>. Such preferences apply -only to an individual applet instance. For example, you may add -two clock applets to the panel and configure them differently. -</p> -<p> -In order for the preferences to only apply to a single applet, -each applet must have a seperate MateConf key for each of these -preferences. The methods described below provide convient wrappers -around the usual <span class="type">MateConfClient</span> functions and operate on these -per-applet keys. -</p> -</div> -<div class="refsect1"> -<a name="mate-panel-applet-Panel-Applet-MateConf-Utilities.details"></a><h2>Details</h2> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-get-full-key"></a><h3>mate_panel_applet_mateconf_get_full_key ()</h3> -<pre class="programlisting"><span class="returnvalue">gchar</span> * mate_panel_applet_mateconf_get_full_key (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>);</pre> -<p> -Access the full path for an individual per-applet MateConf key. Using -the returned path you may directly modify the preference using -the usual MateConf functions without using any of the convenience -wrappers described below. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> -<td>The full MateConf key - free using <code class="function">g_free()</code>. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-get-bool"></a><h3>mate_panel_applet_mateconf_get_bool ()</h3> -<pre class="programlisting"><span class="returnvalue">gboolean</span> mate_panel_applet_mateconf_get_bool (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-bool"><code class="function">mateconf_client_get_bool()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-bool"><code class="function">mateconf_client_get_bool()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -<tr> -<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> -<td>The bool value of the key. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-get-int"></a><h3>mate_panel_applet_mateconf_get_int ()</h3> -<pre class="programlisting"><span class="returnvalue">gint</span> mate_panel_applet_mateconf_get_int (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-int"><code class="function">mateconf_client_get_int()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-int"><code class="function">mateconf_client_get_int()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -<tr> -<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> -<td>The integer value of the key. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-get-string"></a><h3>mate_panel_applet_mateconf_get_string ()</h3> -<pre class="programlisting"><span class="returnvalue">gchar</span> * mate_panel_applet_mateconf_get_string (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-string"><code class="function">mateconf_client_get_string()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-string"><code class="function">mateconf_client_get_string()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -<tr> -<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> -<td>The string value of the key, or <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if unset. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-get-float"></a><h3>mate_panel_applet_mateconf_get_float ()</h3> -<pre class="programlisting"><span class="returnvalue">gdouble</span> mate_panel_applet_mateconf_get_float (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-float"><code class="function">mateconf_client_get_float()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-float"><code class="function">mateconf_client_get_float()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -<tr> -<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> -<td>The floating point value of the key. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-get-list"></a><h3>mate_panel_applet_mateconf_get_list ()</h3> -<pre class="programlisting"><span class="returnvalue">GSList</span> * mate_panel_applet_mateconf_get_list (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValueType"><span class="type">MateConfValueType</span></a> list_type</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-list"><code class="function">mateconf_client_get_list()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-get-list"><code class="function">mateconf_client_get_list()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>list_type</code></em> :</span></p></td> -<td>The MateConf value type of the list elements. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -<tr> -<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> -<td>The list of values set for the key. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-get-value"></a><h3>mate_panel_applet_mateconf_get_value ()</h3> -<pre class="programlisting"><a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValue"><span class="returnvalue">MateConfValue</span></a> * mate_panel_applet_mateconf_get_value (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <code class="function">mateconf_client_get_value()</code> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <code class="function">mateconf_client_get_value()</code> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -<tr> -<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> -<td>The MateConf value set for the key. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-set-bool"></a><h3>mate_panel_applet_mateconf_set_bool ()</h3> -<pre class="programlisting"><span class="returnvalue">void</span> mate_panel_applet_mateconf_set_bool (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">gboolean</span> the_bool</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-bool"><code class="function">mateconf_client_set_bool()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-bool"><code class="function">mateconf_client_set_bool()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>the_bool</code></em> :</span></p></td> -<td>The boolean value to set the key with. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-set-int"></a><h3>mate_panel_applet_mateconf_set_int ()</h3> -<pre class="programlisting"><span class="returnvalue">void</span> mate_panel_applet_mateconf_set_int (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">gint</span> the_int</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-int"><code class="function">mateconf_client_set_int()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-int"><code class="function">mateconf_client_set_int()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>the_int</code></em> :</span></p></td> -<td>The integer value to set the key with. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-set-string"></a><h3>mate_panel_applet_mateconf_set_string ()</h3> -<pre class="programlisting"><span class="returnvalue">void</span> mate_panel_applet_mateconf_set_string (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *the_string</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-string"><code class="function">mateconf_client_set_string()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-string"><code class="function">mateconf_client_set_string()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>the_string</code></em> :</span></p></td> -<td>The string value to set the key with. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-set-float"></a><h3>mate_panel_applet_mateconf_set_float ()</h3> -<pre class="programlisting"><span class="returnvalue">void</span> mate_panel_applet_mateconf_set_float (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><span class="type">gdouble</span> the_float</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-float"><code class="function">mateconf_client_set_float()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-float"><code class="function">mateconf_client_set_float()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>the_float</code></em> :</span></p></td> -<td>The floating point value to set the key with. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-set-list"></a><h3>mate_panel_applet_mateconf_set_list ()</h3> -<pre class="programlisting"><span class="returnvalue">void</span> mate_panel_applet_mateconf_set_list (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValueType"><span class="type">MateConfValueType</span></a> list_type</code></em>, - <em class="parameter"><code><span class="type">GSList</span> *list</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-list"><code class="function">mateconf_client_set_list()</code></a> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-client.html#mateconf-client-set-list"><code class="function">mateconf_client_set_list()</code></a> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>list_type</code></em> :</span></p></td> -<td>The MateConf value type of the list items. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td> -<td>The list of values to set the key with. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -</tbody> -</table></div> -</div> -<hr> -<div class="refsect2"> -<a name="mate-panel-applet-mateconf-set-value"></a><h3>mate_panel_applet_mateconf_set_value ()</h3> -<pre class="programlisting"><span class="returnvalue">void</span> mate_panel_applet_mateconf_set_value (<em class="parameter"><code><a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a> *applet</code></em>, - <em class="parameter"><code>const <span class="type">gchar</span> *key</code></em>, - <em class="parameter"><code><a href="/mate/usr/share/gtk-doc/html/mateconf/mateconf-mateconf-value.html#MateConfValue"><span class="type">MateConfValue</span></a> *value</code></em>, - <em class="parameter"><code><span class="type">GError</span> **opt_error</code></em>);</pre> -<p> -Convience wrapper for <code class="function">mateconf_client_set_value()</code> which operates -on the individual per-applet key. -</p> -<p> -If you pass <a href="/mate/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>opt_error</code></em>, this function will print -a warning message from any <span class="type">GError</span> which <code class="function">mateconf_client_set_value()</code> -returns. -</p> -<div class="variablelist"><table border="0"> -<col align="left" valign="top"> -<tbody> -<tr> -<td><p><span class="term"><em class="parameter"><code>applet</code></em> :</span></p></td> -<td>The <a class="link" href="mate-panel-applet-mate-panel-applet.html#MatePanelApplet"><span class="type">MatePanelApplet</span></a>. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td> -<td>The key name of the preference. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td> -<td>The MateConf value to set the key with. -</td> -</tr> -<tr> -<td><p><span class="term"><em class="parameter"><code>opt_error</code></em> :</span></p></td> -<td>Optional <span class="type">GError</span>**. -</td> -</tr> -</tbody> -</table></div> -</div> -</div> -</div> -<div class="footer"> -<hr> - Generated by GTK-Doc V1.15.1</div> -</body> -</html>
\ No newline at end of file diff --git a/doc/reference/mate-panel-applet/tmpl/mate-panel-applet-mateconf.sgml b/doc/reference/mate-panel-applet/tmpl/mate-panel-applet-mateconf.sgml deleted file mode 100644 index 2ff1e459..00000000 --- a/doc/reference/mate-panel-applet/tmpl/mate-panel-applet-mateconf.sgml +++ /dev/null @@ -1,263 +0,0 @@ -<!-- ##### SECTION Title ##### --> -Panel Applet MateConf Utilities - -<!-- ##### SECTION Short_Description ##### --> -Utility methods for manipulating per-applet MateConf preferences. - -<!-- ##### SECTION Long_Description ##### --> -<para> -Applets typically define a set of preferences using a schemas -file and mate_panel_applet_add_preferences(). Such preferences apply -only to an individual applet instance. For example, you may add -two clock applets to the panel and configure them differently. -</para> - -<para> -In order for the preferences to only apply to a single applet, -each applet must have a seperate MateConf key for each of these -preferences. The methods described below provide convient wrappers -around the usual #MateConfClient functions and operate on these -per-applet keys. -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> -</para> - -<!-- ##### SECTION Stability_Level ##### --> - - -<!-- ##### SECTION Image ##### --> - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_get_full_key ##### --> -<para> -Access the full path for an individual per-applet MateConf key. Using -the returned path you may directly modify the preference using -the usual MateConf functions without using any of the convenience -wrappers described below. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@Returns: The full MateConf key - free using g_free(). - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_get_bool ##### --> -<para> -Convience wrapper for mateconf_client_get_bool() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_get_bool() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@opt_error: Optional #GError**. -@Returns: The bool value of the key. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_get_int ##### --> -<para> -Convience wrapper for mateconf_client_get_int() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_get_int() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@opt_error: Optional #GError**. -@Returns: The integer value of the key. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_get_string ##### --> -<para> -Convience wrapper for mateconf_client_get_string() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_get_string() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@opt_error: Optional #GError**. -@Returns: The string value of the key, or %NULL if unset. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_get_float ##### --> -<para> -Convience wrapper for mateconf_client_get_float() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_get_float() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@opt_error: Optional #GError**. -@Returns: The floating point value of the key. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_get_list ##### --> -<para> -Convience wrapper for mateconf_client_get_list() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_get_list() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@list_type: The MateConf value type of the list elements. -@opt_error: Optional #GError**. -@Returns: The list of values set for the key. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_get_value ##### --> -<para> -Convience wrapper for mateconf_client_get_value() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_get_value() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@opt_error: Optional #GError**. -@Returns: The MateConf value set for the key. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_set_bool ##### --> -<para> -Convience wrapper for mateconf_client_set_bool() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_set_bool() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@the_bool: The boolean value to set the key with. -@opt_error: Optional #GError**. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_set_int ##### --> -<para> -Convience wrapper for mateconf_client_set_int() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_set_int() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@the_int: The integer value to set the key with. -@opt_error: Optional #GError**. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_set_string ##### --> -<para> -Convience wrapper for mateconf_client_set_string() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_set_string() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@the_string: The string value to set the key with. -@opt_error: Optional #GError**. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_set_float ##### --> -<para> -Convience wrapper for mateconf_client_set_float() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_set_float() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@the_float: The floating point value to set the key with. -@opt_error: Optional #GError**. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_set_list ##### --> -<para> -Convience wrapper for mateconf_client_set_list() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_set_list() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@list_type: The MateConf value type of the list items. -@list: The list of values to set the key with. -@opt_error: Optional #GError**. - - -<!-- ##### FUNCTION mate_panel_applet_mateconf_set_value ##### --> -<para> -Convience wrapper for mateconf_client_set_value() which operates -on the individual per-applet key. -</para> - -<para> -If you pass %NULL for @opt_error, this function will print -a warning message from any #GError which mateconf_client_set_value() -returns. -</para> - -@applet: The #MatePanelApplet. -@key: The key name of the preference. -@value: The MateConf value to set the key with. -@opt_error: Optional #GError**. - - diff --git a/libmate-panel-applet/Makefile.am b/libmate-panel-applet/Makefile.am index 3465e1a1..244d5d41 100644 --- a/libmate-panel-applet/Makefile.am +++ b/libmate-panel-applet/Makefile.am @@ -1,4 +1,4 @@ -lib_LTLIBRARIES = libmate-panel-applet-3.la +lib_LTLIBRARIES = libmate-panel-applet-4.la noinst_PROGRAMS = test-dbus-applet AM_CPPFLAGS = \ @@ -9,34 +9,34 @@ AM_CPPFLAGS = \ AM_CFLAGS = $(WARN_CFLAGS) -libmate_panel_appletincludedir = $(includedir)/mate-panel-3.0/libmate-panel-applet +libmate_panel_appletincludedir = $(includedir)/mate-panel-4.0/libmate-panel-applet libmate_panel_appletinclude_HEADERS = \ mate-panel-applet.h \ - mate-panel-applet-mateconf.h \ + mate-panel-applet-gsettings.h \ mate-panel-applet-enums.h -libmate_panel_applet_3_la_SOURCES = \ +libmate_panel_applet_4_la_SOURCES = \ $(BUILT_SOURCES) \ mate-panel-applet.h \ mate-panel-applet.c \ mate-panel-applet-factory.h \ mate-panel-applet-factory.c \ - mate-panel-applet-mateconf.c \ - mate-panel-applet-mateconf.h + mate-panel-applet-gsettings.c \ + mate-panel-applet-gsettings.h -libmate_panel_applet_3_la_LIBADD = \ +libmate_panel_applet_4_la_LIBADD = \ $(LIBMATE_PANEL_APPLET_LIBS) \ $(X_LIBS) -libmate_panel_applet_3_la_LDFLAGS = \ +libmate_panel_applet_4_la_LDFLAGS = \ -version-info $(LIB_MATE_PANEL_APPLET_LT_VERSION) \ -no-undefined test_dbus_applet_LDADD = \ $(LIBMATE_PANEL_APPLET_LIBS) \ - libmate-panel-applet-3.la + libmate-panel-applet-4.la -$(libmate_panel_applet_3_la_OBJECTS) $(test_dbus_applet_OBJECTS): $(BUILT_SOURCES) +$(libmate_panel_applet_4_la_OBJECTS) $(test_dbus_applet_OBJECTS): $(BUILT_SOURCES) mate-panel-applet-marshal.h: mate-panel-applet-marshal.list $(GLIB_GENMARSHAL) $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=mate_panel_applet_marshal > $@ @@ -82,7 +82,7 @@ BUILT_SOURCES = \ mate-panel-applet-marshal.h pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libmatepanelapplet-3.0.pc +pkgconfig_DATA = libmatepanelapplet-4.0.pc appletdir = $(datadir)/mate-panel/applets applet_in_files = org.mate.panel.TestApplet.mate-panel-applet.in @@ -93,8 +93,8 @@ noinst_DATA = $(applet_in_files:.mate-panel-applet.in=.mate-panel-applet) EXTRA_DIST = \ org.mate.panel.TestApplet.mate-panel-applet.in \ mate-panel-applet-marshal.list \ - libmatepanelapplet-3.0.pc.in \ - libmatepanelapplet-3.0-uninstalled.pc.in + libmatepanelapplet-4.0.pc.in \ + libmatepanelapplet-4.0-uninstalled.pc.in CLEANFILES = $(BUILT_SOURCES) $(noinst_DATA) @@ -110,21 +110,21 @@ if HAVE_INTROSPECTION introspection_sources = \ mate-panel-applet.c \ mate-panel-applet.h \ - mate-panel-applet-mateconf.c \ - mate-panel-applet-mateconf.h + mate-panel-applet-gsettings.c \ + mate-panel-applet-gsettings.h built_introspection_sources = \ mate-panel-applet-enums.c \ mate-panel-applet-enums.h -MatePanelApplet-3.0.gir: libmate-panel-applet-3.la -MatePanelApplet_3_0_gir_INCLUDES = GObject-2.0 Gtk-2.0 MateConf-2.0 -MatePanelApplet_3_0_gir_CFLAGS = $(AM_CPPFLAGS) -MatePanelApplet_3_0_gir_LIBS = libmate-panel-applet-3.la -MatePanelApplet_3_0_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources)) $(addprefix $(builddir)/,$(built_introspection_sources)) +MatePanelApplet-4.0.gir: libmate-panel-applet-4.la +MatePanelApplet_4_0_gir_INCLUDES = GObject-2.0 Gtk-2.0 Gio-2.0 +MatePanelApplet_4_0_gir_CFLAGS = $(AM_CPPFLAGS) +MatePanelApplet_4_0_gir_LIBS = libmate-panel-applet-4.la +MatePanelApplet_4_0_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources)) $(addprefix $(builddir)/,$(built_introspection_sources)) # When requiring gobject-introspection 0.9.5, use this: -#MatePanelApplet_3_0_gir_SCANNERFLAGS = --identifier-prefix=Panel --symbol-prefix=panel --pkg-export=libmatepanelapplet-3.0 -MatePanelApplet_3_0_gir_SCANNERFLAGS = --strip-prefix=MatePanel --pkg-export=libmatepanelapplet-3.0 -INTROSPECTION_GIRS += MatePanelApplet-3.0.gir +#MatePanelApplet_4_0_gir_SCANNERFLAGS = --identifier-prefix=Panel --symbol-prefix=panel --pkg-export=libmatepanelapplet-4.0 +MatePanelApplet_4_0_gir_SCANNERFLAGS = --strip-prefix=MatePanel --pkg-export=libmatepanelapplet-4.0 +INTROSPECTION_GIRS += MatePanelApplet-4.0.gir girdir = $(INTROSPECTION_GIRDIR) gir_DATA = $(INTROSPECTION_GIRS) diff --git a/libmate-panel-applet/libmatepanelapplet-3.0-uninstalled.pc.in b/libmate-panel-applet/libmatepanelapplet-3.0-uninstalled.pc.in deleted file mode 100644 index 40f02130..00000000 --- a/libmate-panel-applet/libmatepanelapplet-3.0-uninstalled.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libmate-panel-applet-3 -Description: libmate-panel-applet-3 -Requires: glib-2.0 mateconf-2.0 gtk+-2.0 -Version: @VERSION@ -Libs: ${pc_top_builddir}/${pcfiledir}/libmate-panel-applet-3.la -Cflags: -I${pc_top_builddir}/${pcfiledir} diff --git a/libmate-panel-applet/libmatepanelapplet-3.0.pc.in b/libmate-panel-applet/libmatepanelapplet-3.0.pc.in deleted file mode 100644 index 97fee38a..00000000 --- a/libmate-panel-applet/libmatepanelapplet-3.0.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libmate-panel-applet-3 -Description: libmate-panel-applet-3 -Requires: glib-2.0 mateconf-2.0 gtk+-2.0 -Version: @VERSION@ -Libs: -L${libdir} -lmate-panel-applet-3 -Cflags: -I${includedir}/mate-panel-3.0/libmate-panel-applet diff --git a/libmate-panel-applet/libmatepanelapplet-4.0-uninstalled.pc.in b/libmate-panel-applet/libmatepanelapplet-4.0-uninstalled.pc.in new file mode 100644 index 00000000..d693e648 --- /dev/null +++ b/libmate-panel-applet/libmatepanelapplet-4.0-uninstalled.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmate-panel-applet-4 +Description: libmate-panel-applet-4 +Requires: glib-2.0 gio-2.0 gtk+-2.0 +Version: @VERSION@ +Libs: ${pc_top_builddir}/${pcfiledir}/libmate-panel-applet-4.la +Cflags: -I${pc_top_builddir}/${pcfiledir} diff --git a/libmate-panel-applet/libmatepanelapplet-4.0.pc.in b/libmate-panel-applet/libmatepanelapplet-4.0.pc.in new file mode 100644 index 00000000..5c3058c8 --- /dev/null +++ b/libmate-panel-applet/libmatepanelapplet-4.0.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmate-panel-applet-4 +Description: libmate-panel-applet-4 +Requires: glib-2.0 gio-2.0 gtk+-2.0 +Version: @VERSION@ +Libs: -L${libdir} -lmate-panel-applet-4 +Cflags: -I${includedir}/mate-panel-4.0/libmate-panel-applet diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.c b/libmate-panel-applet/mate-panel-applet-gsettings.c new file mode 100644 index 00000000..0acda0e8 --- /dev/null +++ b/libmate-panel-applet/mate-panel-applet-gsettings.c @@ -0,0 +1,108 @@ +/* + * mate-panel-applet-gsettings.c: panel applet preferences handling. + * + * Copyright (C) 2012 Stefano Karapetsas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Stefano Karapetsas <[email protected]> + */ + +#include <gtk/gtk.h> +#include <gio/gio.h> + +#include "mate-panel-applet.h" +#include "mate-panel-applet-gsettings.h" + +GSettings * +mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema) +{ + GSettings *settings = NULL; + gchar *path; + + g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); + + path = mate_panel_applet_get_preferences_path (applet); + + if (path) + settings = g_settings_new_with_path (schema, path); + g_free (path); + + return settings; +} + +GList* +mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key) +{ + gchar **array; + GList *list = NULL; + gint i; + array = g_settings_get_strv (settings, key); + if (array != NULL) { + for (i = 0; array[i]; i++) { + list = g_list_append (list, g_strdup (array[i])); + } + } + g_strfreev (array); + return list; +} + +void +mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list) +{ + gchar **array; + GList *l; + gint i; + for (l = list; l; l = l->next) { + array[i] = g_strdup (l->data); + i++; + } + array[i] = NULL; + g_settings_set_strv (settings, key, (const gchar **) array); + g_strfreev (array); +} + +GSList* +mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key) +{ + gchar **array; + GSList *list = NULL; + gint i; + array = g_settings_get_strv (settings, key); + if (array != NULL) { + for (i = 0; array[i]; i++) { + list = g_slist_append (list, g_strdup (array[i])); + } + } + g_strfreev (array); + return list; +} + +void +mate_panel_applet_settings_set_gslist (GSettings *settings, gchar *key, GSList *list) +{ + gchar **array; + GSList *l; + gint i; + for (l = list; l; l = l->next) { + array[i] = g_strdup (l->data); + i++; + } + array[i] = NULL; + g_settings_set_strv (settings, key, (const gchar **) array); + g_strfreev (array); +} diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.h b/libmate-panel-applet/mate-panel-applet-gsettings.h new file mode 100644 index 00000000..a8426256 --- /dev/null +++ b/libmate-panel-applet/mate-panel-applet-gsettings.h @@ -0,0 +1,45 @@ +/* + * mate-panel-applet-gsettings.h: panel applet preferences handling. + * + * Copyright (C) 2012 Stefano Karapetsas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Stefano Karapetsas <[email protected]> + */ + +#ifndef __MATE_PANEL_APPLET_GSETTINGS_H__ +#define __MATE_PANEL_APPLET_GSETTINGS_H__ + +#include <glib.h> +#include <gio/gio.h> + +#include <mate-panel-applet.h> + +#define PANEL_OBJECT_PREFS_PATH "/org/mate/panel/objects/%s/prefs" + +G_BEGIN_DECLS + +GSettings* mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema); +GList* mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key); +void mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list); +GSList* mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key); +void mate_panel_applet_settings_set_gslist (GSettings *settings, gchar *key, GSList *list); + +G_END_DECLS + +#endif /* __MATE_PANEL_APPLET_GSETTINGS_H__ */ diff --git a/libmate-panel-applet/mate-panel-applet-mateconf.c b/libmate-panel-applet/mate-panel-applet-mateconf.c deleted file mode 100644 index 0c7f4763..00000000 --- a/libmate-panel-applet/mate-panel-applet-mateconf.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * mate-panel-applet-mateconf.c: panel applet preferences handling. - * - * Copyright (C) 2001-2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#include <mateconf/mateconf-client.h> - -#include "mate-panel-applet-mateconf.h" - -static MateConfClient * -mate_panel_applet_mateconf_get_client (void) -{ - static MateConfClient *client = NULL; - - if (!client) - client = mateconf_client_get_default (); - - return client; -} - -gchar * -mate_panel_applet_mateconf_get_full_key (MatePanelApplet *applet, - const gchar *key) -{ - gchar *prefs_key; - gchar *full_key; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (!key) - return NULL; - - prefs_key = mate_panel_applet_get_preferences_key (applet); - - full_key = g_strdup_printf ("%s/%s", prefs_key, key); - - g_free (prefs_key); - - return full_key; -} - -void -mate_panel_applet_mateconf_set_bool (MatePanelApplet *applet, - const gchar *key, - gboolean the_bool, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_bool (client, full_key, the_bool, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_int (MatePanelApplet *applet, - const gchar *key, - gint the_int, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_int (client, full_key, the_int, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_string (MatePanelApplet *applet, - const gchar *key, - const gchar *the_string, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_string (client, full_key, the_string, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_float (MatePanelApplet *applet, - const gchar *key, - gdouble the_float, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_float (client, full_key, the_float, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GSList *list, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_list (client, full_key, list_type, list, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_value (MatePanelApplet *applet, - const gchar *key, - MateConfValue *value, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set (client, full_key, value, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -gboolean -mate_panel_applet_mateconf_get_bool (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gboolean retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_bool (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gint -mate_panel_applet_mateconf_get_int (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gint retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), -1); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_int (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gchar * -mate_panel_applet_mateconf_get_string (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gchar *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_string (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gdouble -mate_panel_applet_mateconf_get_float (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gdouble retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), 0.0); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_float (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -MateConfValue * -mate_panel_applet_mateconf_get_value (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - MateConfValue *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -GSList * -mate_panel_applet_mateconf_get_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GSList *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_list (client, full_key, list_type, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} diff --git a/libmate-panel-applet/mate-panel-applet-mateconf.h b/libmate-panel-applet/mate-panel-applet-mateconf.h deleted file mode 100644 index 2eb523a4..00000000 --- a/libmate-panel-applet/mate-panel-applet-mateconf.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * mate-panel-applet-mateconf.h: panel applet preferences handling. - * - * Copyright (C) 2001-2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifndef __MATE_PANEL_APPLET_MATECONF_H__ -#define __MATE_PANEL_APPLET_MATECONF_H__ - -#include <glib.h> -#include <mateconf/mateconf-value.h> - -#include <mate-panel-applet.h> - -#ifdef __cplusplus -extern "C" { -#endif - -gchar *mate_panel_applet_mateconf_get_full_key (MatePanelApplet *applet, - const gchar *key); - -void mate_panel_applet_mateconf_set_bool (MatePanelApplet *applet, - const gchar *key, - gboolean the_bool, - GError **opt_error); -void mate_panel_applet_mateconf_set_int (MatePanelApplet *applet, - const gchar *key, - gint the_int, - GError **opt_error); -void mate_panel_applet_mateconf_set_string (MatePanelApplet *applet, - const gchar *key, - const gchar *the_string, - GError **opt_error); -void mate_panel_applet_mateconf_set_float (MatePanelApplet *applet, - const gchar *key, - gdouble the_float, - GError **opt_error); -void mate_panel_applet_mateconf_set_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GSList *list, - GError **opt_error); -void mate_panel_applet_mateconf_set_value (MatePanelApplet *applet, - const gchar *key, - MateConfValue *value, - GError **opt_error); - -gboolean mate_panel_applet_mateconf_get_bool (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gint mate_panel_applet_mateconf_get_int (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gchar *mate_panel_applet_mateconf_get_string (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gdouble mate_panel_applet_mateconf_get_float (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -GSList *mate_panel_applet_mateconf_get_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GError **opt_error); -MateConfValue *mate_panel_applet_mateconf_get_value (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); - -#ifdef __cplusplus -} -#endif - -#endif /* __MATE_PANEL_APPLET_MATECONF_H__ */ diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 6993505e..e9e46e57 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -37,8 +37,6 @@ #include <gdk/gdkx.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> -#include <mateconf/mateconf.h> -#include <mateconf/mateconf-client.h> #include <X11/Xatom.h> #include "mate-panel-applet.h" @@ -51,14 +49,13 @@ struct _MatePanelAppletPrivate { GtkWidget *plug; GtkWidget *applet; - MateConfClient *client; GDBusConnection *connection; char *id; GClosure *closure; char *object_path; guint object_id; - char *prefs_key; + char *prefs_path; GtkUIManager *ui_manager; GtkActionGroup *applet_action_group; @@ -98,7 +95,7 @@ enum { PROP_ID, PROP_CLOSURE, PROP_CONNECTION, - PROP_PREFS_KEY, + PROP_PREFS_PATH, PROP_ORIENT, PROP_SIZE, PROP_BACKGROUND, @@ -152,179 +149,33 @@ G_DEFINE_TYPE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX) #define MATE_PANEL_APPLET_INTERFACE "org.mate.panel.applet.Applet" #define MATE_PANEL_APPLET_OBJECT_PATH "/org/mate/panel/applet/%s/%d" -static void -mate_panel_applet_associate_schemas_in_dir (MateConfClient *client, - const gchar *prefs_key, - const gchar *schema_dir, - GError **error) -{ - GSList *list, *l; - - list = mateconf_client_all_entries (client, schema_dir, error); - - if (*error != NULL) - return; - - for (l = list; l; l = l->next) { - MateConfEntry *entry = l->data; - const gchar *schema_key; - MateConfEntry *applet_entry; - const gchar *applet_schema_key; - gchar *key; - gchar *tmp; - - schema_key = mateconf_entry_get_key (entry); - tmp = g_path_get_basename (schema_key); - - if (strchr (tmp, '-')) - g_warning ("Applet key '%s' contains a hyphen. Please " - "use underscores in mateconf keys\n", tmp); - - key = g_strdup_printf ("%s/%s", prefs_key, tmp); - g_free (tmp); - - /* Associating a schema is potentially expensive, so let's try - * to avoid this by doing it only when needed. So we check if - * the key is already correctly associated. */ - - applet_entry = mateconf_client_get_entry (client, key, - NULL, TRUE, NULL); - if (applet_entry) - applet_schema_key = mateconf_entry_get_schema_name (applet_entry); - else - applet_schema_key = NULL; - - if (g_strcmp0 (schema_key, applet_schema_key) != 0) { - mateconf_engine_associate_schema (client->engine, - key, schema_key, error); - - if (applet_entry == NULL || - mateconf_entry_get_value (applet_entry) == NULL || - mateconf_entry_get_is_default (applet_entry)) { - /* unset the key: mateconf_client_get_entry() - * brought an invalid entry in the client - * cache, and we want to fix this */ - mateconf_client_unset (client, key, NULL); - } - } - - g_free (key); - - if (applet_entry) - mateconf_entry_unref (applet_entry); - mateconf_entry_unref (entry); - - if (*error) { - g_slist_free (list); - return; - } - } - - g_slist_free (list); - - list = mateconf_client_all_dirs (client, schema_dir, error); - - for (l = list; l; l = l->next) { - gchar *subdir = l->data; - gchar *prefs_subdir; - gchar *schema_subdir; - gchar *tmp; - - tmp = g_path_get_basename (subdir); - - prefs_subdir = g_strdup_printf ("%s/%s", prefs_key, tmp); - schema_subdir = g_strdup_printf ("%s/%s", schema_dir, tmp); - - mate_panel_applet_associate_schemas_in_dir (client, - prefs_subdir, - schema_subdir, - error); - - g_free (prefs_subdir); - g_free (schema_subdir); - g_free (subdir); - g_free (tmp); - - if (*error) { - g_slist_free (list); - return; - } - } - - g_slist_free (list); -} - -void -mate_panel_applet_add_preferences (MatePanelApplet *applet, - const gchar *schema_dir, - GError **opt_error) -{ - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (schema_dir != NULL); - - if (!applet->priv->prefs_key) - return; - - if (opt_error) - error = opt_error; - else - error = &our_error; - - mate_panel_applet_associate_schemas_in_dir (applet->priv->client, - applet->priv->prefs_key, - schema_dir, - error); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": failed to add preferences from '%s' : '%s'", - schema_dir, our_error->message); - g_error_free (our_error); - } -} - char * -mate_panel_applet_get_preferences_key (MatePanelApplet *applet) +mate_panel_applet_get_preferences_path (MatePanelApplet *applet) { g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - if (!applet->priv->prefs_key) + if (!applet->priv->prefs_path) return NULL; - return g_strdup (applet->priv->prefs_key); + return g_strdup (applet->priv->prefs_path); } static void -mate_panel_applet_set_preferences_key (MatePanelApplet *applet, - const char *prefs_key) +mate_panel_applet_set_preferences_path (MatePanelApplet *applet, + const char *prefs_path) { - if (applet->priv->prefs_key == prefs_key) + if (applet->priv->prefs_path == prefs_path) return; - if (g_strcmp0 (applet->priv->prefs_key, prefs_key) == 0) + if (g_strcmp0 (applet->priv->prefs_path, prefs_path) == 0) return; - if (applet->priv->prefs_key) { - mateconf_client_remove_dir (applet->priv->client, - applet->priv->prefs_key, - NULL); + if (prefs_path) { + applet->priv->prefs_path = g_strdup (prefs_path); - g_free (applet->priv->prefs_key); - applet->priv->prefs_key = NULL; } - if (prefs_key) { - applet->priv->prefs_key = g_strdup (prefs_key); - - mateconf_client_add_dir (applet->priv->client, - applet->priv->prefs_key, - MATECONF_CLIENT_PRELOAD_RECURSIVE, - NULL); - } - - g_object_notify (G_OBJECT (applet), "prefs-key"); + g_object_notify (G_OBJECT (applet), "prefs-path"); } MatePanelAppletFlags @@ -878,11 +729,7 @@ mate_panel_applet_finalize (GObject *object) applet->priv->object_path = NULL; } - mate_panel_applet_set_preferences_key (applet, NULL); - - if (applet->priv->client) - g_object_unref (applet->priv->client); - applet->priv->client = NULL; + mate_panel_applet_set_preferences_path (applet, NULL); if (applet->priv->applet_action_group) { g_object_unref (applet->priv->applet_action_group); @@ -900,7 +747,7 @@ mate_panel_applet_finalize (GObject *object) } g_free (applet->priv->size_hints); - g_free (applet->priv->prefs_key); + g_free (applet->priv->prefs_path); g_free (applet->priv->background); g_free (applet->priv->id); @@ -1650,8 +1497,8 @@ mate_panel_applet_get_property (GObject *object, case PROP_CONNECTION: g_value_set_object (value, applet->priv->connection); break; - case PROP_PREFS_KEY: - g_value_set_string (value, applet->priv->prefs_key); + case PROP_PREFS_PATH: + g_value_set_string (value, applet->priv->prefs_path); break; case PROP_ORIENT: g_value_set_uint (value, applet->priv->orient); @@ -1710,8 +1557,8 @@ mate_panel_applet_set_property (GObject *object, case PROP_CONNECTION: applet->priv->connection = g_value_dup_object (value); break; - case PROP_PREFS_KEY: - mate_panel_applet_set_preferences_key (applet, g_value_get_string (value)); + case PROP_PREFS_PATH: + mate_panel_applet_set_preferences_path (applet, g_value_get_string (value)); break; case PROP_ORIENT: mate_panel_applet_set_orient (applet, g_value_get_uint (value)); @@ -1811,8 +1658,6 @@ mate_panel_applet_init (MatePanelApplet *applet) applet->priv->orient = MATE_PANEL_APPLET_ORIENT_UP; applet->priv->size = 24; - applet->priv->client = mateconf_client_get_default (); - applet->priv->panel_action_group = gtk_action_group_new ("PanelActions"); gtk_action_group_set_translation_domain (applet->priv->panel_action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (applet->priv->panel_action_group, @@ -1909,10 +1754,10 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, - PROP_PREFS_KEY, - g_param_spec_string ("prefs-key", - "PrefsKey", - "MateConf Preferences Key", + PROP_PREFS_PATH, + g_param_spec_string ("prefs-path", + "PrefsPath", + "GSettings Preferences Path", NULL, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, @@ -2064,9 +1909,9 @@ get_property_cb (GDBusConnection *connection, MatePanelApplet *applet = MATE_PANEL_APPLET (user_data); GVariant *retval = NULL; - if (g_strcmp0 (property_name, "PrefsKey") == 0) { - retval = g_variant_new_string (applet->priv->prefs_key ? - applet->priv->prefs_key : ""); + if (g_strcmp0 (property_name, "PrefsPath") == 0) { + retval = g_variant_new_string (applet->priv->prefs_path ? + applet->priv->prefs_path : ""); } else if (g_strcmp0 (property_name, "Orient") == 0) { retval = g_variant_new_uint32 (applet->priv->orient); } else if (g_strcmp0 (property_name, "Size") == 0) { @@ -2107,8 +1952,8 @@ set_property_cb (GDBusConnection *connection, { MatePanelApplet *applet = MATE_PANEL_APPLET (user_data); - if (g_strcmp0 (property_name, "PrefsKey") == 0) { - mate_panel_applet_set_preferences_key (applet, g_variant_get_string (value, NULL)); + if (g_strcmp0 (property_name, "PrefsPath") == 0) { + mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL)); } else if (g_strcmp0 (property_name, "Orient") == 0) { mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value)); } else if (g_strcmp0 (property_name, "Size") == 0) { @@ -2139,7 +1984,7 @@ static const gchar introspection_xml[] = "<arg name='button' type='u' direction='in'/>" "<arg name='time' type='u' direction='in'/>" "</method>" - "<property name='PrefsKey' type='s' access='readwrite'/>" + "<property name='PrefsPath' type='s' access='readwrite'/>" "<property name='Orient' type='u' access='readwrite' />" "<property name='Size' type='u' access='readwrite'/>" "<property name='Background' type='s' access='readwrite'/>" diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h index 8c75e29f..dfc1c079 100644 --- a/libmate-panel-applet/mate-panel-applet.h +++ b/libmate-panel-applet/mate-panel-applet.h @@ -92,9 +92,7 @@ MatePanelAppletBackgroundType mate_panel_applet_get_background(MatePanelApplet* void mate_panel_applet_set_background_widget(MatePanelApplet* applet, GtkWidget* widget); -gchar* mate_panel_applet_get_preferences_key(MatePanelApplet* applet); - -void mate_panel_applet_add_preferences(MatePanelApplet* applet, const gchar* schema_dir, GError** opt_error); +gchar* mate_panel_applet_get_preferences_path(MatePanelApplet* applet); MatePanelAppletFlags mate_panel_applet_get_flags(MatePanelApplet* applet); void mate_panel_applet_set_flags(MatePanelApplet* applet, MatePanelAppletFlags flags); diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am index f6384132..03cae874 100644 --- a/mate-panel/Makefile.am +++ b/mate-panel/Makefile.am @@ -14,6 +14,7 @@ AM_CPPFLAGS = \ -I$(top_builddir)/mate-panel/libpanel-util \ -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DBUILDERDIR=\""$(uidir)"\" \ + -DPANELDATADIR=\""$(datadir)/mate-panel"\" \ -DICONDIR=\""$(datadir)/mate-panel/pixmaps"\" \ $(DISABLE_DEPRECATED_CFLAGS) @@ -29,13 +30,12 @@ panel_sources = \ button-widget.c \ xstuff.c \ panel-session.c \ - panel-compatibility.c \ panel.c \ applet.c \ drawer.c \ panel-config-global.c \ panel-util.c \ - panel-mateconf.c \ + panel-gsettings.c \ panel-properties-dialog.c \ panel-run-dialog.c \ menu.c \ @@ -61,6 +61,7 @@ panel_sources = \ panel-multiscreen.c \ panel-a11y.c \ panel-bindings.c \ + panel-layout.c \ panel-profile.c \ panel-force-quit.c \ panel-lockdown.c \ @@ -77,14 +78,13 @@ panel_headers = \ button-widget.h \ xstuff.h \ panel-session.h \ - panel-compatibility.h \ panel.h \ applet.h \ drawer.h \ panel-util.h \ panel-properties-dialog.h \ panel-config-global.h \ - panel-mateconf.h \ + panel-gsettings.h \ panel-run-dialog.h \ menu.h \ panel-context-menu.h \ @@ -109,6 +109,7 @@ panel_headers = \ panel-multiscreen.h \ panel-a11y.h \ panel-bindings.h \ + panel-layout.h \ panel-profile.h \ panel-enums.h \ panel-force-quit.h \ @@ -118,7 +119,8 @@ panel_headers = \ panel-icon-names.h \ panel-modules.h \ mate-panel-applet-info.h \ - panel-reset.h + panel-reset.h \ + panel-schemas.h mate_panel_SOURCES = \ $(panel_sources) \ @@ -181,6 +183,7 @@ mate-panel-add: mate-panel-add.in Makefile panel_enum_headers = \ $(top_srcdir)/mate-panel/panel-enums.h \ + $(top_srcdir)/mate-panel/panel-enums-gsettings.h \ $(top_srcdir)/mate-panel/panel-types.h panel-marshal.h: panel-marshal.list $(GLIB_GENMARSHAL) @@ -239,40 +242,10 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ -entriesdir = $(MATECONF_SCHEMA_FILE_DIR) -entries_DATA = panel-default-setup.entries - -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = \ - panel-global.schemas.in \ - panel-general.schemas.in \ - panel-toplevel.schemas.in \ - panel-object.schemas.in -schemas_DATA = panel-compatibility.schemas $(schemas_in_files:.schemas.in=.schemas) - -@INTLTOOL_SCHEMAS_RULE@ - -if MATECONF_SCHEMAS_INSTALL -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schemas_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/mate-panel/$$p ; \ - done ; \ - $(MATECONFTOOL) --direct --config-source=$(MATECONF_SCHEMA_CONFIG_SOURCE) --load $(srcdir)/panel-default-setup.entries ; \ - $(MATECONFTOOL) --direct --config-source=$(MATECONF_SCHEMA_CONFIG_SOURCE) --load $(srcdir)/panel-default-setup.entries /apps/panel ; \ - fi -uninstall-local: - for p in $(schema_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-uninstall-rule $(top_builddir)/applets/mate-panel/$$p ; \ - done -endif - EXTRA_DIST = \ $(ui_DATA) \ nothing.cP \ nothing.h \ - $(schemas_in_files) \ - panel-compatibility.schemas \ panel-marshal.list \ mate-panelrc \ $(entries_DATA) \ @@ -281,7 +254,6 @@ EXTRA_DIST = \ CLEANFILES = \ $(BUILT_SOURCES) \ - $(schemas_in_files:.schemas.in=.schemas) \ $(sys_DATA) \ $(desktop_DATA) \ mate-panel-add diff --git a/mate-panel/applet.c b/mate-panel/applet.c index e20e1faa..11fa617f 100644 --- a/mate-panel/applet.c +++ b/mate-panel/applet.c @@ -13,6 +13,7 @@ #include <glib/gi18n.h> #include <gdk/gdkx.h> +#include <gio/gio.h> #include <libpanel-util/panel-show.h> @@ -20,13 +21,11 @@ #include "drawer.h" #include "launcher.h" #include "panel-addto.h" -#include "panel-mateconf.h" #include "panel-config-global.h" #include "mate-panel-applet-frame.h" #include "panel-action-button.h" #include "panel-menu-bar.h" #include "panel-separator.h" -#include "panel-compatibility.h" #include "panel-toplevel.h" #include "panel-util.h" #include "panel-profile.h" @@ -34,6 +33,7 @@ #include "panel-globals.h" #include "panel-properties-dialog.h" #include "panel-lockdown.h" +#include "panel-schemas.h" #define SMALL_ICON_SIZE 20 @@ -171,12 +171,10 @@ mate_panel_applet_recreate_menu (AppletInfo *info) } static void -mate_panel_applet_locked_change_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - GtkWidget *applet) +mate_panel_applet_locked_change_notify (GSettings *settings, + gchar *key, + GtkWidget *applet) { - MateConfValue *value; gboolean locked; gboolean applet_locked; AppletInfo *info; @@ -189,11 +187,7 @@ mate_panel_applet_locked_change_notify (MateConfClient *client, if (info == NULL) return; - value = mateconf_entry_get_value (entry); - if (value == NULL || value->type != MATECONF_VALUE_BOOL) - return; - - locked = mateconf_value_get_bool (value); + locked = g_settings_get_boolean (settings, key); panel_widget = mate_panel_applet_get_panel_widget (info); applet_locked = panel_widget_get_applet_locked (panel_widget, @@ -749,6 +743,11 @@ mate_panel_applet_destroy (GtkWidget *widget, info->widget = NULL; + if (info->settings) { + g_object_unref (info->settings); + info->settings = NULL; + } + registered_applets = g_slist_remove (registered_applets, info); queued_position_saves = @@ -950,43 +949,33 @@ mate_panel_applet_load_idle_handler (gpointer dummy) switch (applet_type) { case PANEL_OBJECT_APPLET: - mate_panel_applet_frame_load_from_mateconf ( + mate_panel_applet_frame_load_from_gsettings ( panel_widget, applet->locked, applet->position, applet->id); break; case PANEL_OBJECT_DRAWER: - drawer_load_from_mateconf (panel_widget, + drawer_load_from_gsettings (panel_widget, applet->locked, applet->position, applet->id); break; case PANEL_OBJECT_MENU: - panel_menu_button_load_from_mateconf (panel_widget, + panel_menu_button_load_from_gsettings (panel_widget, applet->locked, applet->position, TRUE, applet->id); break; case PANEL_OBJECT_LAUNCHER: - launcher_load_from_mateconf (panel_widget, + launcher_load_from_gsettings (panel_widget, applet->locked, applet->position, applet->id); break; - case PANEL_OBJECT_LOGOUT: - case PANEL_OBJECT_LOCK: - panel_action_button_load_compatible ( - applet->type, - panel_widget, - applet->locked, - applet->position, - TRUE, - applet->id); - break; case PANEL_OBJECT_ACTION: - panel_action_button_load_from_mateconf ( + panel_action_button_load_from_gsettings ( panel_widget, applet->locked, applet->position, @@ -994,7 +983,7 @@ mate_panel_applet_load_idle_handler (gpointer dummy) applet->id); break; case PANEL_OBJECT_MENU_BAR: - panel_menu_bar_load_from_mateconf ( + panel_menu_bar_load_from_gsettings ( panel_widget, applet->locked, applet->position, @@ -1002,7 +991,7 @@ mate_panel_applet_load_idle_handler (gpointer dummy) applet->id); break; case PANEL_OBJECT_SEPARATOR: - panel_separator_load_from_mateconf (panel_widget, + panel_separator_load_from_gsettings (panel_widget, applet->locked, applet->position, applet->id); @@ -1136,10 +1125,7 @@ mate_panel_applet_save_position (AppletInfo *applet_info, const char *id, gboolean immediate) { - PanelMateConfKeyType key_type; - MateConfClient *client; PanelWidget *panel_widget; - const char *key; const char *toplevel_id; char *old_toplevel_id; gboolean right_stick; @@ -1165,19 +1151,14 @@ mate_panel_applet_save_position (AppletInfo *applet_info, if (!(toplevel_id = mate_panel_applet_get_toplevel_id (applet_info))) return; - client = panel_mateconf_get_client (); - - key_type = applet_info->type == PANEL_OBJECT_APPLET ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS; - panel_widget = mate_panel_applet_get_panel_widget (applet_info); /* FIXME: Instead of getting keys, comparing and setting, there should be a dirty flag */ - key = panel_mateconf_full_key (key_type, id, "toplevel_id"); - old_toplevel_id = mateconf_client_get_string (client, key, NULL); + old_toplevel_id = g_settings_get_string (applet_info->settings, PANEL_OBJECT_TOPLEVEL_ID_KEY); if (old_toplevel_id == NULL || strcmp (old_toplevel_id, toplevel_id) != 0) - mateconf_client_set_string (client, key, toplevel_id, NULL); + g_settings_set_string (applet_info->settings, PANEL_OBJECT_TOPLEVEL_ID_KEY, toplevel_id); g_free (old_toplevel_id); /* Note: changing some properties of the panel that may not be locked down @@ -1186,25 +1167,21 @@ mate_panel_applet_save_position (AppletInfo *applet_info, So check if these are writable before attempting to write them */ right_stick = panel_is_applet_right_stick (applet_info->widget) ? 1 : 0; - key = panel_mateconf_full_key ( - key_type, id, "panel_right_stick"); - if (mateconf_client_key_is_writable (client, key, NULL) && - (mateconf_client_get_bool (client, key, NULL) ? 1 : 0) != right_stick) - mateconf_client_set_bool (client, key, right_stick, NULL); + if (g_settings_is_writable (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY) && + (g_settings_get_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY) ? 1 : 0) != right_stick) + g_settings_set_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, right_stick); position = mate_panel_applet_get_position (applet_info); if (right_stick && !panel_widget->packed) position = panel_widget->size - position; - key = panel_mateconf_full_key (key_type, id, "position"); - if (mateconf_client_key_is_writable (client, key, NULL) && - mateconf_client_get_int (client, key, NULL) != position) - mateconf_client_set_int (client, key, position, NULL); + if (g_settings_is_writable (applet_info->settings, PANEL_OBJECT_POSITION_KEY) && + g_settings_get_int (applet_info->settings, PANEL_OBJECT_POSITION_KEY) != position) + g_settings_set_int (applet_info->settings, PANEL_OBJECT_POSITION_KEY, position); locked = panel_widget_get_applet_locked (panel_widget, applet_info->widget) ? 1 : 0; - key = panel_mateconf_full_key (key_type, id, "locked"); - if (mateconf_client_get_bool (client, key, NULL) ? 1 : 0 != locked) - mateconf_client_set_bool (client, key, locked, NULL); + if (g_settings_get_boolean (applet_info->settings, PANEL_OBJECT_LOCKED_KEY) ? 1 : 0 != locked) + g_settings_set_boolean (applet_info->settings, PANEL_OBJECT_LOCKED_KEY, locked); } const char * @@ -1287,7 +1264,8 @@ mate_panel_applet_register (GtkWidget *applet, const char *id) { AppletInfo *info; - const char *key; + gchar *path; + gchar *locked_changed; g_return_val_if_fail (applet != NULL && panel != NULL, NULL); @@ -1307,18 +1285,21 @@ mate_panel_applet_register (GtkWidget *applet, info->move_item = NULL; info->id = g_strdup (id); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + info->settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_free (path); + g_object_set_data (G_OBJECT (applet), "applet_info", info); if (type != PANEL_OBJECT_APPLET) panel_lockdown_notify_add (G_CALLBACK (mate_panel_applet_recreate_menu), info); - key = panel_mateconf_full_key ((type == PANEL_OBJECT_APPLET) ? - PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS, - id, "locked"); - panel_mateconf_notify_add_while_alive (key, - (MateConfClientNotifyFunc) mate_panel_applet_locked_change_notify, - G_OBJECT (applet)); + locked_changed = g_strdup_printf ("changed::%s", PANEL_OBJECT_LOCKED_KEY); + g_signal_connect (info->settings, + locked_changed, + G_CALLBACK (mate_panel_applet_locked_change_notify), + G_OBJECT (applet)); if (type == PANEL_OBJECT_DRAWER) { Drawer *drawer = data; @@ -1403,27 +1384,16 @@ mate_panel_applet_get_position (AppletInfo *applet) gboolean mate_panel_applet_can_freely_move (AppletInfo *applet) { - MateConfClient *client; - PanelMateConfKeyType key_type; - const char *key; - if (panel_lockdown_get_locked_down ()) return FALSE; - client = panel_mateconf_get_client (); - - key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS; - - key = panel_mateconf_full_key (key_type, applet->id, "position"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (applet->settings, PANEL_OBJECT_POSITION_KEY)) return FALSE; - key = panel_mateconf_full_key (key_type, applet->id, "toplevel_id"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (applet->settings, PANEL_OBJECT_TOPLEVEL_ID_KEY)) return FALSE; - key = panel_mateconf_full_key (key_type, applet->id, "panel_right_stick"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (applet->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY)) return FALSE; return TRUE; @@ -1432,18 +1402,9 @@ mate_panel_applet_can_freely_move (AppletInfo *applet) gboolean mate_panel_applet_lockable (AppletInfo *applet) { - MateConfClient *client; - PanelMateConfKeyType key_type; - const char *key; - if (panel_lockdown_get_locked_down ()) return FALSE; - client = panel_mateconf_get_client (); - - key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS; - - key = panel_mateconf_full_key (key_type, applet->id, "locked"); - return mateconf_client_key_is_writable (client, key, NULL); + return g_settings_is_writable (applet->settings, PANEL_OBJECT_LOCKED_KEY); } diff --git a/mate-panel/applet.h b/mate-panel/applet.h index 531e7e20..2ee60659 100644 --- a/mate-panel/applet.h +++ b/mate-panel/applet.h @@ -3,8 +3,8 @@ #include <glib.h> #include <gdk/gdk.h> +#include <gio/gio.h> #include "panel-widget.h" -#include "panel-mateconf.h" #include "panel-enums.h" #ifdef __cplusplus @@ -27,6 +27,8 @@ typedef struct { gpointer data; GDestroyNotify data_destroy; + GSettings *settings; + char *id; } AppletInfo; diff --git a/mate-panel/button-widget.c b/mate-panel/button-widget.c index 6f2fd6b8..7748a821 100644 --- a/mate-panel/button-widget.c +++ b/mate-panel/button-widget.c @@ -15,6 +15,8 @@ #include "panel-marshal.h" #include "panel-typebuiltins.h" #include "panel-globals.h" +#include "panel-enums.h" +#include "panel-enums-gsettings.h" #define BUTTON_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BUTTON_TYPE_WIDGET, ButtonWidgetPrivate)) diff --git a/mate-panel/drawer.c b/mate-panel/drawer.c index 924acb42..727924b2 100644 --- a/mate-panel/drawer.c +++ b/mate-panel/drawer.c @@ -17,19 +17,20 @@ #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> +#include <gio/gio.h> #include "drawer.h" #include "applet.h" #include "button-widget.h" #include "panel-config-global.h" -#include "panel-mateconf.h" #include "panel-profile.h" #include "panel-util.h" #include "xstuff.h" #include "panel-globals.h" #include "panel-lockdown.h" #include "panel-icon-names.h" +#include "panel-schemas.h" static void drawer_click (GtkWidget *w, Drawer *drawer) @@ -52,17 +53,6 @@ static void destroy_drawer (GtkWidget *widget, Drawer *drawer) { - MateConfClient *client; - int i; - - client = panel_mateconf_get_client (); - - for (i = 0; i < PANEL_DRAWER_N_LISTENERS; i++) { - if (drawer->listeners [i]) - mateconf_client_notify_remove (client, drawer->listeners [i]); - drawer->listeners [i] = 0; - } - if (drawer->toplevel) gtk_widget_destroy (GTK_WIDGET (drawer->toplevel)); drawer->toplevel = NULL; @@ -385,27 +375,20 @@ create_drawer_applet (PanelToplevel *toplevel, } static PanelToplevel * -create_drawer_toplevel (const char *drawer_id) +create_drawer_toplevel (const char *drawer_id, GSettings *settings) { PanelToplevel *toplevel; - MateConfClient *client; - const char *key; char *toplevel_id; - client = panel_mateconf_get_client (); - - toplevel_id = panel_profile_find_new_id (PANEL_MATECONF_TOPLEVELS); - - toplevel = panel_profile_load_toplevel (client, PANEL_CONFIG_DIR, - PANEL_MATECONF_TOPLEVELS, toplevel_id); + toplevel_id = panel_profile_find_new_id (PANEL_GSETTINGS_TOPLEVELS); + toplevel = panel_profile_load_toplevel (toplevel_id); if (!toplevel) { g_free (toplevel_id); return NULL; } - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer_id, "attached_toplevel_id"); - mateconf_client_set_string (client, key, toplevel_id, NULL); + g_settings_set_string (settings, PANEL_OBJECT_ATTACHED_TOPLEVEL_ID_KEY, toplevel_id); g_free (toplevel_id); panel_profile_set_toplevel_enable_buttons (toplevel, TRUE); @@ -428,24 +411,17 @@ drawer_button_size_allocated (GtkWidget *widget, } static void -panel_drawer_use_custom_icon_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +panel_drawer_use_custom_icon_changed (GSettings *settings, + gchar *key, Drawer *drawer) { gboolean use_custom_icon; char *custom_icon = NULL; - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - use_custom_icon = mateconf_value_get_bool (entry->value); + use_custom_icon = g_settings_get_boolean (settings, key); if (use_custom_icon) { - const char *key; - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer->info->id, "custom_icon"); - custom_icon = mateconf_client_get_string (client, key, NULL); + custom_icon = g_settings_get_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY); } button_widget_set_icon_name (BUTTON_WIDGET (drawer->button), custom_icon); @@ -454,70 +430,45 @@ panel_drawer_use_custom_icon_changed (MateConfClient *client, } static void -panel_drawer_custom_icon_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - Drawer *drawer) +panel_drawer_custom_icon_changed (GSettings *settings, + gchar *key, + Drawer *drawer) { const char *custom_icon; - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - - custom_icon = mateconf_value_get_string (entry->value); + custom_icon = g_settings_get_string (settings, key); if (custom_icon && custom_icon [0]) { - const char *key; gboolean use_custom_icon; - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer->info->id, "use_custom_icon"); - use_custom_icon = mateconf_client_get_bool (client, key, NULL); + use_custom_icon = g_settings_get_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY); if (use_custom_icon) button_widget_set_icon_name (BUTTON_WIDGET (drawer->button), custom_icon); } } static void -panel_drawer_tooltip_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +panel_drawer_tooltip_changed (GSettings *settings, + gchar *key, Drawer *drawer) { - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - set_tooltip_and_name (drawer, - mateconf_value_get_string (entry->value)); + g_settings_get_string (settings, key)); } static void -panel_drawer_connect_to_mateconf (Drawer *drawer) +panel_drawer_connect_to_gsettings (Drawer *drawer) { - MateConfClient *client; - const char *key; - int i = 0; - - client = panel_mateconf_get_client (); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer->info->id, "use_custom_icon"); - drawer->listeners [i++] = - mateconf_client_notify_add (client, key, - (MateConfClientNotifyFunc) panel_drawer_use_custom_icon_changed, - drawer, NULL, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer->info->id, "custom_icon"); - drawer->listeners [i++] = - mateconf_client_notify_add (client, key, - (MateConfClientNotifyFunc) panel_drawer_custom_icon_changed, - drawer, NULL, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer->info->id, "tooltip"); - drawer->listeners [i++] = - mateconf_client_notify_add (client, key, - (MateConfClientNotifyFunc) panel_drawer_tooltip_changed, - drawer, NULL, NULL); - - g_assert (i == PANEL_DRAWER_N_LISTENERS); + g_signal_connect (drawer->info->settings, + "changed::" PANEL_OBJECT_USE_CUSTOM_ICON_KEY, + G_CALLBACK (panel_drawer_use_custom_icon_changed), + drawer); + g_signal_connect (drawer->info->settings, + "changed::" PANEL_OBJECT_CUSTOM_ICON_KEY, + G_CALLBACK (panel_drawer_custom_icon_changed), + drawer); + g_signal_connect (drawer->info->settings, + "changed::" PANEL_OBJECT_TOOLTIP_KEY, + G_CALLBACK (panel_drawer_tooltip_changed), + drawer); } static gboolean @@ -528,6 +479,7 @@ drawer_changes_enabled (void) static void load_drawer_applet (char *toplevel_id, + GSettings *settings, const char *custom_icon, gboolean use_custom_icon, const char *tooltip, @@ -548,7 +500,7 @@ load_drawer_applet (char *toplevel_id, toplevel = panel_profile_get_toplevel_by_id (toplevel_id); if (!toplevel) - toplevel = create_drawer_toplevel (id); + toplevel = create_drawer_toplevel (id, settings); if (toplevel) { panel_toplevel_hide (toplevel, FALSE, -1); @@ -601,7 +553,7 @@ load_drawer_applet (char *toplevel_id, _("_Help"), NULL); - panel_drawer_connect_to_mateconf (drawer); + panel_drawer_connect_to_gsettings (drawer); } static void @@ -611,45 +563,45 @@ panel_drawer_prepare (const char *drawer_id, const char *tooltip, char **attached_toplevel_id) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); + GSettings *settings; + char *path; + + path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH, drawer_id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_free (path); if (tooltip) { - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer_id, "tooltip"); - mateconf_client_set_string (client, key, tooltip, NULL); + g_settings_set_string (settings, PANEL_OBJECT_TOOLTIP_KEY, tooltip); } - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer_id, "use_custom_icon"); - mateconf_client_set_bool (client, key, use_custom_icon, NULL); + g_settings_set_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY, use_custom_icon); if (custom_icon) { - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer_id, "custom_icon"); - mateconf_client_set_string (client, key, custom_icon, NULL); + g_settings_set_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY, custom_icon); } if (attached_toplevel_id) { char *toplevel_id; - char *toplevel_dir; + char *toplevel_path; + GSettings *toplevel_settings; - toplevel_id = panel_profile_find_new_id (PANEL_MATECONF_TOPLEVELS); + toplevel_id = panel_profile_find_new_id (PANEL_GSETTINGS_TOPLEVELS); - toplevel_dir = g_strdup_printf (PANEL_CONFIG_DIR "/toplevels/%s", + toplevel_path = g_strdup_printf (PANEL_TOPLEVEL_PATH "%s/", toplevel_id); - panel_mateconf_associate_schemas_in_dir (client, toplevel_dir, PANEL_SCHEMAS_DIR "/toplevels"); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, drawer_id, "attached_toplevel_id"); - mateconf_client_set_string (client, key, toplevel_id, NULL); - key = panel_mateconf_full_key (PANEL_MATECONF_TOPLEVELS, toplevel_id, "enable_buttons"); - mateconf_client_set_bool (client, key, TRUE, NULL); + toplevel_settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, toplevel_path); - key = panel_mateconf_full_key (PANEL_MATECONF_TOPLEVELS, toplevel_id, "enable_arrows"); - mateconf_client_set_bool (client, key, TRUE, NULL); + g_settings_set_string (settings, PANEL_OBJECT_ATTACHED_TOPLEVEL_ID_KEY, toplevel_id); + g_settings_set_boolean (toplevel_settings, PANEL_TOPLEVEL_ENABLE_BUTTONS_KEY, TRUE); + g_settings_set_boolean (toplevel_settings, PANEL_TOPLEVEL_ENABLE_ARROWS_KEY, TRUE); *attached_toplevel_id = toplevel_id; + + g_object_unref (toplevel_settings); + g_free (toplevel_path); } + g_object_unref (settings); } void @@ -665,7 +617,7 @@ panel_drawer_create (PanelToplevel *toplevel, panel_drawer_prepare (id, custom_icon, use_custom_icon, tooltip, NULL); - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); + panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (id); } @@ -684,7 +636,7 @@ panel_drawer_create_with_id (const char *toplevel_id, panel_drawer_prepare (id, custom_icon, use_custom_icon, tooltip, &attached_toplevel_id); - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); + panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (id); @@ -692,38 +644,36 @@ panel_drawer_create_with_id (const char *toplevel_id, } void -drawer_load_from_mateconf (PanelWidget *panel_widget, - gboolean locked, - gint position, - const char *id) +drawer_load_from_gsettings (PanelWidget *panel_widget, + gboolean locked, + gint position, + const char *id) { - MateConfClient *client; - const char *key; gboolean use_custom_icon; char *toplevel_id; char *custom_icon; char *tooltip; + gchar *path; + GSettings *settings; g_return_if_fail (panel_widget != NULL); g_return_if_fail (id != NULL); - client = panel_mateconf_get_client (); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "attached_toplevel_id"); - toplevel_id = mateconf_client_get_string (client, key, NULL); + path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH, id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_free (path); - panel_profile_load_toplevel (client, PANEL_CONFIG_DIR, PANEL_MATECONF_TOPLEVELS, toplevel_id); + toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_ATTACHED_TOPLEVEL_ID_KEY); - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_custom_icon"); - use_custom_icon = mateconf_client_get_bool (client, key, NULL); + panel_profile_load_toplevel (toplevel_id); - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "custom_icon"); - custom_icon = mateconf_client_get_string (client, key, NULL); + use_custom_icon = g_settings_get_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY); + custom_icon = g_settings_get_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY); - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "tooltip"); - tooltip = mateconf_client_get_string (client, key, NULL); + tooltip = g_settings_get_string (settings, PANEL_OBJECT_TOOLTIP_KEY); load_drawer_applet (toplevel_id, + settings, custom_icon, use_custom_icon, tooltip, diff --git a/mate-panel/drawer.h b/mate-panel/drawer.h index 800e1a86..4365befc 100644 --- a/mate-panel/drawer.h +++ b/mate-panel/drawer.h @@ -7,8 +7,6 @@ extern "C" { #endif -#define PANEL_DRAWER_N_LISTENERS 3 - typedef struct { char *tooltip; @@ -19,8 +17,6 @@ typedef struct { guint close_timeout_id; AppletInfo *info; - - guint listeners [PANEL_DRAWER_N_LISTENERS]; } Drawer; void panel_drawer_create (PanelToplevel *toplevel, @@ -38,7 +34,7 @@ char *panel_drawer_create_with_id (const char *toplevel_id, void panel_drawer_set_dnd_enabled (Drawer *drawer, gboolean dnd_enabled); -void drawer_load_from_mateconf (PanelWidget *panel_widget, +void drawer_load_from_gsettings (PanelWidget *panel_widget, gboolean locked, gint position, const char *id); diff --git a/mate-panel/launcher.c b/mate-panel/launcher.c index 657bc0c8..24e4e846 100644 --- a/mate-panel/launcher.c +++ b/mate-panel/launcher.c @@ -33,7 +33,6 @@ #include "button-widget.h" #include "panel-util.h" #include "panel-config-global.h" -#include "panel-mateconf.h" #include "panel-profile.h" #include "xstuff.h" #include "panel-toplevel.h" @@ -41,9 +40,9 @@ #include "panel-globals.h" #include "panel-multiscreen.h" #include "panel-lockdown.h" -#include "panel-compatibility.h" #include "panel-ditem-editor.h" #include "panel-icon-names.h" +#include "panel-schemas.h" static GdkScreen * launcher_get_screen (Launcher *launcher) @@ -414,7 +413,7 @@ static Launcher * create_launcher (const char *location) { GKeyFile *key_file; - gboolean loaded; + gboolean loaded = FALSE; Launcher *launcher; GError *error = NULL; char *new_location; @@ -686,21 +685,13 @@ launcher_saved (GtkWidget *dialog, Launcher *launcher) { const char *uri; - MateConfClient *client; - const char *key; - uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog)); if (panel_launcher_get_filename (uri) != NULL) uri = panel_launcher_get_filename (uri); if (uri && launcher->location && strcmp (uri, launcher->location)) { - client = panel_mateconf_get_client (); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, - launcher->info->id, - "launcher_location"); - mateconf_client_set_string (client, key, uri, NULL); + g_settings_set_string (launcher->info->settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY, uri); if (launcher->location) g_free (launcher->location); @@ -817,28 +808,28 @@ load_launcher_applet (const char *location, } void -launcher_load_from_mateconf (PanelWidget *panel_widget, - gboolean locked, - int position, - const char *id) +launcher_load_from_gsettings (PanelWidget *panel_widget, + gboolean locked, + int position, + const char *id) { - MateConfClient *client; + GSettings *settings; + char *path; Launcher *launcher; - const char *key; char *launcher_location; g_return_if_fail (panel_widget != NULL); g_return_if_fail (id != NULL); - client = panel_mateconf_get_client (); + path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH, id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_free (path); - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "launcher_location"); - panel_compatibility_migrate_applications_scheme (client, key); - launcher_location = mateconf_client_get_string (client, key, NULL); + launcher_location = g_settings_get_string (settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY); if (!launcher_location) { g_printerr (_("Key %s is not set, cannot load launcher\n"), - key); + PANEL_OBJECT_LAUNCHER_LOCATION_KEY); return; } @@ -850,8 +841,7 @@ launcher_load_from_mateconf (PanelWidget *panel_widget, id); if (launcher) { - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "launcher_location"); - if (!mateconf_client_key_is_writable (client, key, NULL)) { + if (!g_settings_is_writable (settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY)) { AppletUserMenu *menu; menu = mate_panel_applet_get_callback (launcher->info->user_menu, @@ -862,6 +852,7 @@ launcher_load_from_mateconf (PanelWidget *panel_widget, } g_free (launcher_location); + g_object_unref (settings); } static void @@ -976,21 +967,23 @@ panel_launcher_create_with_id (const char *toplevel_id, int position, const char *location) { - MateConfClient *client; - const char *key; + GSettings *settings; + char *path; char *id; char *no_uri; const char *new_location; g_return_if_fail (location != NULL); - client = panel_mateconf_get_client (); - id = panel_profile_prepare_object_with_id (PANEL_OBJECT_LAUNCHER, toplevel_id, position, FALSE); + path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH, id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_free (path); + no_uri = NULL; /* if we have an URI, it might contain escaped characters (? : etc) * that might get unescaped on disk */ @@ -1003,15 +996,13 @@ panel_launcher_create_with_id (const char *toplevel_id, if (new_location == NULL) new_location = no_uri; - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, - id, - "launcher_location"); - mateconf_client_set_string (client, key, new_location, NULL); + g_settings_set_string (settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY, new_location); - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); + panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (no_uri); g_free (id); + g_object_unref (settings); } void diff --git a/mate-panel/launcher.h b/mate-panel/launcher.h index 1b2d7b88..28cfd117 100644 --- a/mate-panel/launcher.h +++ b/mate-panel/launcher.h @@ -26,7 +26,7 @@ typedef struct { GKeyFile *key_file; GtkWidget *prop_dialog; - GSList *error_dialogs; + GSList *error_dialogs; gulong destroy_handler; } Launcher; @@ -53,10 +53,10 @@ void launcher_launch (Launcher *launcher, void launcher_properties (Launcher *launcher); -void launcher_load_from_mateconf (PanelWidget *panel_widget, - gboolean locked, - gint position, - const char *id); +void launcher_load_from_gsettings (PanelWidget *panel_widget, + gboolean locked, + gint position, + const char *id); void panel_launcher_delete (Launcher *launcher); diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c index 1076ff1d..00ef79c4 100644 --- a/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c @@ -53,7 +53,7 @@ typedef struct { } AppletPropertyInfo; static const AppletPropertyInfo applet_properties [] = { - { "prefs-key", "PrefsKey" }, + { "prefs-path", "PrefsPath" }, { "orient", "Orient" }, { "size", "Size" }, { "size-hints", "SizeHints" }, diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.c b/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.c index 3a694773..e2f69fc4 100644 --- a/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.c +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-frame-dbus.c @@ -435,7 +435,7 @@ mate_panel_applet_frame_dbus_load (const gchar *iid, g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_add (&builder, "{sv}", - "prefs-key", + "prefs-path", g_variant_new_string (conf_path)); g_variant_builder_add (&builder, "{sv}", "orient", diff --git a/mate-panel/libpanel-util/Makefile.am b/mate-panel/libpanel-util/Makefile.am index 377e26e5..699f4b2a 100644 --- a/mate-panel/libpanel-util/Makefile.am +++ b/mate-panel/libpanel-util/Makefile.am @@ -15,6 +15,8 @@ libpanel_util_la_SOURCES = \ panel-cleanup.h \ panel-dbus-service.c \ panel-dbus-service.h \ + panel-dconf.c \ + panel-dconf.h \ panel-error.c \ panel-error.h \ panel-glib.c \ diff --git a/mate-panel/libpanel-util/panel-dconf.c b/mate-panel/libpanel-util/panel-dconf.c new file mode 100644 index 00000000..21830da9 --- /dev/null +++ b/mate-panel/libpanel-util/panel-dconf.c @@ -0,0 +1,109 @@ +/* + * panel-dconf.c: helper API for dconf + * + * Copyright (C) 2011 Novell, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Authors: + * Vincent Untz <[email protected]> + * Stefano Karapetsas <[email protected]> + */ + +#include <string.h> + +#include <dconf.h> + +#include "panel-dconf.h" + +static DConfClient * +panel_dconf_client_get (void) +{ +#ifdef HAVE_DCONF_0_13 + return dconf_client_new (); +#else + return dconf_client_new (NULL, NULL, NULL, NULL); +#endif +} + +gboolean +panel_dconf_write_sync (const gchar *key, + GVariant *value, + GError **error) +{ + gboolean ret; + DConfClient *client = panel_dconf_client_get (); + +#ifdef HAVE_DCONF_0_13 + ret = dconf_client_write_sync (client, key, value, NULL, NULL, error); +#else + ret = dconf_client_write (client, key, value, NULL, NULL, error); +#endif + + g_object_unref (client); + + return ret; +} + +gboolean +panel_dconf_recursive_reset (const gchar *dir, + GError **error) +{ + gboolean ret; + DConfClient *client = panel_dconf_client_get (); + +#ifdef HAVE_DCONF_0_13 + ret = dconf_client_write_sync (client, dir, NULL, NULL, NULL, error); +#else + ret = dconf_client_write (client, dir, NULL, NULL, NULL, error); +#endif + + g_object_unref (client); + + return ret; +} + +gchar ** +panel_dconf_list_subdirs (const gchar *dir, + gboolean remove_trailing_slash) +{ + GArray *array; + gchar **children; + int len; + int i; + DConfClient *client = panel_dconf_client_get (); + + array = g_array_new (TRUE, TRUE, sizeof (gchar *)); + + children = dconf_client_list (client, dir, &len); + + g_object_unref (client); + + for (i = 0; children[i] != NULL; i++) { + if (dconf_is_rel_dir (children[i], NULL)) { + char *val = g_strdup (children[i]); + + if (remove_trailing_slash) + val[strlen (val) - 1] = '\0'; + + array = g_array_append_val (array, val); + } + } + + g_strfreev (children); + + return (gchar **) g_array_free (array, FALSE); +} diff --git a/applets/clock/calendar-debug.h b/mate-panel/libpanel-util/panel-dconf.h index a7ea2a79..e4ef1e45 100644 --- a/applets/clock/calendar-debug.h +++ b/mate-panel/libpanel-util/panel-dconf.h @@ -1,5 +1,7 @@ /* - * Copyright (C) 2004 Free Software Foundation, Inc. + * panel-dconf.h: helper API for dconf + * + * Copyright (C) 2011 Novell, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,40 +19,26 @@ * 02111-1307, USA. * * Authors: - * Mark McLoughlin <[email protected]> + * Vincent Untz <[email protected]> */ -#ifndef __CALENDAR_DEBUG_H__ -#define __CALENDAR_DEBUG_H__ +#ifndef __PANEL_DCONF_H__ +#define __PANEL_DCONF_H__ #include <glib.h> -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CALENDAR_ENABLE_DEBUG - -#include <stdio.h> - -#ifdef G_HAVE_ISO_VARARGS -# define dprintf(...) fprintf (stderr, __VA_ARGS__); -#elif defined(G_HAVE_GNUC_VARARGS) -# define dprintf(args...) fprintf (stderr, args); -#endif +G_BEGIN_DECLS -#else /* if !defined (CALENDAR_DEBUG) */ +gboolean panel_dconf_write_sync (const gchar *key, + GVariant *value, + GError **error); -#ifdef G_HAVE_ISO_VARARGS -# define dprintf(...) -#elif defined(G_HAVE_GNUC_VARARGS) -# define dprintf(args...) -#endif +gboolean panel_dconf_recursive_reset (const gchar *dir, + GError **error); -#endif /* CALENDAR_ENABLE_DEBUG */ +gchar **panel_dconf_list_subdirs (const gchar *dir, + gboolean remove_trailing_slash); -#ifdef __cplusplus -} -#endif +G_END_DECLS -#endif /* __CALENDAR_DEBUG_H__ */ +#endif /* __PANEL_DCONF_H__ */ diff --git a/mate-panel/main.c b/mate-panel/main.c index 7721fade..52535542 100644 --- a/mate-panel/main.c +++ b/mate-panel/main.c @@ -20,7 +20,6 @@ #include <libpanel-util/panel-cleanup.h> #include <libpanel-util/panel-glib.h> -#include "panel-mateconf.h" #include "panel-profile.h" #include "panel-config-global.h" #include "panel-shell.h" @@ -115,11 +114,6 @@ main (int argc, char **argv) panel_multiscreen_init (); panel_init_stock_icons_and_items (); - mateconf_client_add_dir (panel_mateconf_get_client (), - "/desktop/mate/interface", - MATECONF_CLIENT_PRELOAD_NONE, - NULL); - panel_global_config_load (); panel_lockdown_init (); panel_profile_load (); @@ -143,10 +137,6 @@ main (int argc, char **argv) panel_lockdown_finalize (); - mateconf_client_remove_dir (panel_mateconf_get_client (), - "/desktop/mate/interface", - NULL); - panel_cleanup_do (); return 0; diff --git a/mate-panel/mate-desktop-item-edit.c b/mate-panel/mate-desktop-item-edit.c index f94b9254..4860cf84 100644 --- a/mate-panel/mate-desktop-item-edit.c +++ b/mate-panel/mate-desktop-item-edit.c @@ -14,8 +14,6 @@ /* FIXME Symbols needed by panel-util.c - sucky */ #include "applet.h" GSList *mate_panel_applet_list_applets (void) { return NULL; } -#include "panel-mateconf.h" -MateConfClient *panel_mateconf_get_client (void) { return NULL; } #include "panel-config-global.h" gboolean panel_global_config_get_tooltips_enabled (void) { return FALSE; } #include "panel-lockdown.h" diff --git a/mate-panel/mate-panel-applet-frame.c b/mate-panel/mate-panel-applet-frame.c index e950d789..b6f6e773 100644 --- a/mate-panel/mate-panel-applet-frame.c +++ b/mate-panel/mate-panel-applet-frame.c @@ -29,7 +29,7 @@ #include <glib/gi18n.h> -#include <mateconf/mateconf.h> +#include <gio/gio.h> #include <gdk/gdk.h> #include <gdk/gdkx.h> @@ -42,7 +42,7 @@ #include "panel-lockdown.h" #include "panel-stock-icons.h" #include "xstuff.h" -#include "panel-compatibility.h" +#include "panel-schemas.h" #include "mate-panel-applet-frame.h" @@ -74,7 +74,7 @@ G_DEFINE_TYPE (MatePanelAppletFrame, mate_panel_applet_frame, GTK_TYPE_EVENT_BOX #define MATE_PANEL_APPLET_FRAME_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_FRAME, MatePanelAppletFramePrivate)) #define HANDLE_SIZE 10 -#define MATE_PANEL_APPLET_PREFS_KEY "/apps/panel/applets/%s/prefs" +#define MATE_PANEL_APPLET_PREFS_PATH "/org/mate/panel/objects/%s/prefs/" struct _MatePanelAppletFramePrivate { PanelWidget *panel; @@ -834,7 +834,7 @@ mate_panel_applet_frame_activating_get_locked_down (MatePanelAppletFrameActivati gchar * mate_panel_applet_frame_activating_get_conf_path (MatePanelAppletFrameActivating *frame_act) { - return g_strdup_printf (MATE_PANEL_APPLET_PREFS_KEY, frame_act->id); + return g_strdup_printf (MATE_PANEL_APPLET_PREFS_PATH, frame_act->id); } static void @@ -857,7 +857,7 @@ mate_panel_applet_frame_loading_failed_response (GtkWidget *dialog, item); } - panel_profile_remove_from_list (PANEL_MATECONF_APPLETS, id); + panel_profile_remove_from_list (PANEL_GSETTINGS_OBJECTS, id); } g_free (id); @@ -962,17 +962,24 @@ mate_panel_applet_frame_load (const gchar *iid, } void -mate_panel_applet_frame_load_from_mateconf (PanelWidget *panel_widget, +mate_panel_applet_frame_load_from_gsettings (PanelWidget *panel_widget, gboolean locked, int position, const char *id) { + GSettings *settings; + gchar *path; gchar *applet_iid; g_return_if_fail (panel_widget != NULL); g_return_if_fail (id != NULL); - applet_iid = panel_compatibility_get_applet_iid (id); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + applet_iid = g_settings_get_string (settings, PANEL_OBJECT_APPLET_IID_KEY); + g_object_unref (settings); + g_free (path); + if (!applet_iid) { mate_panel_applet_stop_loading (id); return; @@ -989,20 +996,21 @@ mate_panel_applet_frame_create (PanelToplevel *toplevel, int position, const char *iid) { - MateConfClient *client; - const char *key; + GSettings *settings; + gchar *path; char *id; g_return_if_fail (iid != NULL); - client = panel_mateconf_get_client (); - id = panel_profile_prepare_object (PANEL_OBJECT_APPLET, toplevel, position, FALSE); - key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "applet_iid"); - mateconf_client_set_string (client, key, iid, NULL); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_settings_set_string (settings, PANEL_OBJECT_APPLET_IID_KEY, iid); - panel_profile_add_to_list (PANEL_MATECONF_APPLETS, id); + panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (id); + g_free (path); + g_object_unref (settings); } diff --git a/mate-panel/mate-panel-applet-frame.h b/mate-panel/mate-panel-applet-frame.h index b4e1e1cd..ad5fbc75 100644 --- a/mate-panel/mate-panel-applet-frame.h +++ b/mate-panel/mate-panel-applet-frame.h @@ -82,7 +82,7 @@ void mate_panel_applet_frame_create (PanelToplevel *toplevel, int position, const char *iid); -void mate_panel_applet_frame_load_from_mateconf (PanelWidget *panel_widget, +void mate_panel_applet_frame_load_from_gsettings (PanelWidget *panel_widget, gboolean locked, int position, const char *id); diff --git a/mate-panel/menu.c b/mate-panel/menu.c index 8b60058c..48831c43 100644 --- a/mate-panel/menu.c +++ b/mate-panel/menu.c @@ -29,7 +29,6 @@ #include <glib/gi18n.h> #include <gio/gio.h> #include <gdk/gdkkeysyms.h> -#include <mateconf/mateconf-client.h> #include <libpanel-util/panel-keyfile.h> #include <libpanel-util/panel-xdg.h> @@ -48,6 +47,7 @@ #include "panel-run-dialog.h" #include "panel-lockdown.h" #include "panel-icon-names.h" +#include "panel-schemas.h" typedef struct { GtkWidget *pixmap; @@ -89,7 +89,12 @@ static gboolean panel_menu_key_press_handler (GtkWidget *widget, static inline gboolean desktop_is_home_dir(void) { - return mateconf_client_get_bool(panel_mateconf_get_client(), "/apps/caja/preferences/desktop_is_home_dir", NULL); + gboolean retval; + GSettings *settings; + settings = g_settings_new (CAJA_PREFS_SCHEMA); + retval = g_settings_get_boolean (settings, CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY); + g_object_unref (settings); + return retval; } GtkWidget * diff --git a/mate-panel/panel-action-button.c b/mate-panel/panel-action-button.c index 04536fff..3680ad5f 100644 --- a/mate-panel/panel-action-button.c +++ b/mate-panel/panel-action-button.c @@ -31,6 +31,7 @@ #include "panel-action-button.h" #include <glib/gi18n.h> +#include <gio/gio.h> #include <libpanel-util/panel-error.h> #include <libpanel-util/panel-launch.h> @@ -39,7 +40,6 @@ #include "applet.h" #include "panel-config-global.h" -#include "panel-mateconf.h" #include "panel-profile.h" #include "panel-typebuiltins.h" #include "panel-force-quit.h" @@ -49,15 +49,13 @@ #include "panel-run-dialog.h" #include "panel-a11y.h" #include "panel-lockdown.h" -#include "panel-compatibility.h" #include "panel-icon-names.h" +#include "panel-schemas.h" G_DEFINE_TYPE (PanelActionButton, panel_action_button, BUTTON_TYPE_WIDGET) #define PANEL_ACTION_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_ACTION_BUTTON, PanelActionButtonPrivate)) -#define LOGOUT_PROMPT_KEY "/apps/mate-session/options/logout_prompt" - enum { PROP_0, PROP_ACTION_TYPE, @@ -67,13 +65,25 @@ enum { struct _PanelActionButtonPrivate { PanelActionButtonType type; AppletInfo *info; - - guint mateconf_notify; + GSettings *settings; guint dnd_enabled : 1; }; -static MateConfEnumStringPair panel_action_type_map [] = { +static void +panel_action_button_type_changed (GSettings *settings, + gchar *key, + PanelActionButton *button); + +/* Utility function converts enumerations to and from strings */ +typedef struct _ObsoleteEnumStringPair ObsoleteEnumStringPair; + +struct _ObsoleteEnumStringPair { + gint enum_value; + const gchar* str; +}; + +static ObsoleteEnumStringPair panel_action_type_map [] = { { PANEL_ACTION_NONE, "none" }, { PANEL_ACTION_LOCK, "lock" }, { PANEL_ACTION_LOGOUT, "logout" }, @@ -82,11 +92,49 @@ static MateConfEnumStringPair panel_action_type_map [] = { { PANEL_ACTION_FORCE_QUIT, "force-quit" }, { PANEL_ACTION_CONNECT_SERVER, "connect-server" }, { PANEL_ACTION_SHUTDOWN, "shutdown" }, - /* compatibility with MATE < 2.13.90 */ - { PANEL_ACTION_SCREENSHOT, "screenshot" }, { 0, NULL }, }; +/* FIXME obsolete way to get string for enum */ +/* taken from deprecated mate-conf code */ +static const gchar* +obsolete_enum_to_string (ObsoleteEnumStringPair lookup_table[], + gint enum_value) +{ + int i = 0; + + while (lookup_table[i].str != NULL) + { + if (lookup_table[i].enum_value == enum_value) + return lookup_table[i].str; + + ++i; + } + + return NULL; +} + +static gboolean +obsolete_string_to_enum (ObsoleteEnumStringPair lookup_table[], + const gchar* str, + gint* enum_value_retloc) +{ + int i = 0; + + while (lookup_table[i].str != NULL) + { + if (g_ascii_strcasecmp (lookup_table[i].str, str) == 0) + { + *enum_value_retloc = lookup_table[i].enum_value; + return TRUE; + } + + ++i; + } + + return FALSE; +} + /* Lock Screen */ static void panel_action_lock_screen(GtkWidget* widget) @@ -158,17 +206,16 @@ static void panel_action_logout (GtkWidget *widget) { PanelSessionManager *manager; - gboolean not_prompt; + gboolean prompt; - not_prompt = mateconf_client_get_bool (panel_mateconf_get_client (), - LOGOUT_PROMPT_KEY, NULL); - /* this avoids handling errors from mateconf since prompting is - * safer */ - not_prompt = !not_prompt; + GSettings *msm_settings; + msm_settings = g_settings_new (MATE_SESSION_SCHEMA); + prompt = g_settings_get_boolean (msm_settings, MATE_SESSION_LOGOUT_PROMPT_KEY); + g_object_unref (msm_settings); manager = panel_session_manager_get (); - if (not_prompt) + if (!prompt) panel_session_manager_request_logout (manager, PANEL_SESSION_MANAGER_LOGOUT_MODE_NO_CONFIRMATION); else @@ -350,31 +397,14 @@ static PanelAction actions [] = { "ACTION:shutdown:NEW", panel_action_shutdown, NULL, NULL, panel_action_shutdown_reboot_is_disabled - }, - /* deprecated actions */ - { - PANEL_ACTION_SCREENSHOT, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL } }; -static gboolean -panel_action_get_is_deprecated (PanelActionButtonType type) -{ - g_return_val_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST, FALSE); - - return (type >= PANEL_ACTION_SCREENSHOT); -} - gboolean panel_action_get_is_disabled (PanelActionButtonType type) { g_return_val_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST, FALSE); - if (panel_action_get_is_deprecated (type)) - return TRUE; - if (actions [type].is_disabled) return actions [type].is_disabled (); @@ -432,16 +462,16 @@ panel_action_button_finalize (GObject *object) { PanelActionButton *button = PANEL_ACTION_BUTTON (object); + if (button->priv->settings) + g_object_unref (button->priv->settings); + button->priv->settings = NULL; + button->priv->info = NULL; button->priv->type = PANEL_ACTION_NONE; panel_lockdown_notify_remove (G_CALLBACK (panel_action_button_update_sensitivity), button); - mateconf_client_notify_remove (panel_mateconf_get_client (), - button->priv->mateconf_notify); - button->priv->mateconf_notify = 0; - G_OBJECT_CLASS (panel_action_button_parent_class)->finalize (object); } @@ -512,7 +542,7 @@ panel_action_button_drag_data_get (GtkWidget *widget, button = PANEL_ACTION_BUTTON (widget); drag_data = g_strdup_printf ("ACTION:%s:%d", - mateconf_enum_to_string (panel_action_type_map, button->priv->type), + obsolete_enum_to_string (panel_action_type_map, button->priv->type), panel_find_applet_index (widget)); gtk_selection_data_set ( @@ -592,7 +622,6 @@ panel_action_button_init (PanelActionButton *button) button->priv->type = PANEL_ACTION_NONE; button->priv->info = NULL; - button->priv->mateconf_notify = 0; button->priv->dnd_enabled = FALSE; } @@ -602,9 +631,6 @@ panel_action_button_set_type (PanelActionButton *button, { g_return_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST); - if (panel_action_get_is_deprecated (type)) - return; - if (type == button->priv->type) return; @@ -621,39 +647,33 @@ panel_action_button_set_type (PanelActionButton *button, } static void -panel_action_button_type_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - PanelActionButton *button) +panel_action_button_type_changed (GSettings *settings, + gchar *key, + PanelActionButton *button) { int type; - const char *action_type; - g_return_if_fail (PANEL_IS_ACTION_BUTTON (button)); - - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - return; - - action_type = mateconf_value_get_string (entry->value); - - if (!mateconf_string_to_enum (panel_action_type_map, action_type, &type)) - return; - + type = g_settings_get_enum (settings, key); panel_action_button_set_type (button, type); } static void -panel_action_button_connect_to_mateconf (PanelActionButton *button) +panel_action_button_connect_to_gsettings (PanelActionButton *button) { - const char *key; + gchar *settings_path; + gchar *signal_name; + + settings_path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", button->priv->info->id); + button->priv->settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, settings_path); - key = panel_mateconf_full_key ( - PANEL_MATECONF_OBJECTS, button->priv->info->id, "action_type"); + signal_name = g_strdup_printf ("changed::%s", PANEL_OBJECT_ACTION_TYPE_KEY); + g_signal_connect (button->priv->settings, + signal_name, + G_CALLBACK (panel_action_button_type_changed), + button); - button->priv->mateconf_notify = - mateconf_client_notify_add (panel_mateconf_get_client (), key, - (MateConfClientNotifyFunc) panel_action_button_type_changed, - button, NULL, NULL); + g_free (signal_name); + g_free (settings_path); panel_lockdown_notify_add (G_CALLBACK (panel_action_button_update_sensitivity), button); @@ -672,8 +692,7 @@ panel_action_button_load (PanelActionButtonType type, gboolean locked, int position, gboolean exactpos, - const char *id, - gboolean compatibility) + const char *id) { PanelActionButton *button; PanelObjectType object_type; @@ -684,18 +703,6 @@ panel_action_button_load (PanelActionButtonType type, object_type = PANEL_OBJECT_ACTION; - if (compatibility) - { /* Backward compatibility with MATE 2.0.x */ - if (type == PANEL_ACTION_LOCK) - { - object_type = PANEL_OBJECT_LOCK; - } - else if (type == PANEL_ACTION_LOGOUT) - { - object_type = PANEL_OBJECT_LOGOUT; - } - } - button->priv->info = mate_panel_applet_register (GTK_WIDGET (button), NULL, NULL, panel, locked, position, @@ -717,7 +724,7 @@ panel_action_button_load (PanelActionButtonType type, if (actions [button->priv->type].setup_menu) actions [button->priv->type].setup_menu (button); - panel_action_button_connect_to_mateconf (button); + panel_action_button_connect_to_gsettings (button); g_signal_connect (button, "style-set", G_CALLBACK (panel_action_button_style_set), NULL); @@ -728,76 +735,47 @@ panel_action_button_create (PanelToplevel *toplevel, int position, PanelActionButtonType type) { - MateConfClient *client; - const char *key; + GSettings *settings; char *id; - - client = panel_mateconf_get_client (); + char *path; id = panel_profile_prepare_object (PANEL_OBJECT_ACTION, toplevel, position, FALSE); - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "action_type"); - mateconf_client_set_string (client, - key, - mateconf_enum_to_string (panel_action_type_map, type), - NULL); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); + g_settings_set_enum (settings, + PANEL_OBJECT_ACTION_TYPE_KEY, + type); - g_free (id); -} - -/* This is only for backwards compatibility with 2.0.x - * We load an old-style lock/logout button as an action - * button but make sure to retain the lock/logout configuration - * so logging back into 2.0.x still works. - */ -void -panel_action_button_load_compatible (PanelObjectType object_type, - PanelWidget *panel, - gboolean locked, - int position, - gboolean exactpos, - const char *id) -{ - PanelActionButtonType action_type; - - g_assert (object_type == PANEL_OBJECT_LOGOUT || object_type == PANEL_OBJECT_LOCK); - - action_type = object_type == PANEL_OBJECT_LOGOUT ? PANEL_ACTION_LOGOUT : PANEL_ACTION_LOCK; + panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); - panel_action_button_load (action_type, panel, locked, position, exactpos, id, TRUE); + g_free (id); + g_free (path); + g_object_unref (settings); } void -panel_action_button_load_from_mateconf (PanelWidget *panel, +panel_action_button_load_from_gsettings (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, const char *id) { - int type; - const char *key; - char *action_type; + GSettings *settings; + PanelActionButtonType type; + char *path; - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "action_type"); - action_type = mateconf_client_get_string (panel_mateconf_get_client (), key, NULL); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); - if (!mateconf_string_to_enum (panel_action_type_map, action_type, &type)) { - g_warning ("Unkown action type '%s' from %s", action_type, key); - g_free (action_type); - return; - } + type = g_settings_get_enum (settings, PANEL_OBJECT_ACTION_TYPE_KEY); - g_free (action_type); + g_free (path); + g_object_unref (settings); - /* compatibility: migrate from MATE < 2.13.90 */ - if (type == PANEL_ACTION_SCREENSHOT) - panel_compatibility_migrate_screenshot_action (panel_mateconf_get_client (), - id); - else - panel_action_button_load (type, panel, locked, - position, exactpos, id, FALSE); + panel_action_button_load (type, panel, locked, + position, exactpos, id); } void @@ -849,16 +827,13 @@ panel_action_button_load_from_drag (PanelToplevel *toplevel, return retval; } - if (!mateconf_string_to_enum (panel_action_type_map, elements [1], (gpointer) &type)) { + if (!obsolete_string_to_enum (panel_action_type_map, elements [1], (gpointer) &type)) { g_strfreev (elements); return retval; } g_return_val_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST, FALSE); - if (panel_action_get_is_deprecated (type)) - return retval; - if (strcmp (elements [2], "NEW")) { *old_applet_idx = strtol (elements [2], NULL, 10); retval = TRUE; /* Remove the old applet */ diff --git a/mate-panel/panel-action-button.h b/mate-panel/panel-action-button.h index 7139aef6..bc5e5da1 100644 --- a/mate-panel/panel-action-button.h +++ b/mate-panel/panel-action-button.h @@ -65,14 +65,7 @@ void panel_action_button_create (PanelToplevel *toplevel void panel_action_button_set_type (PanelActionButton *button, PanelActionButtonType type); -void panel_action_button_load_from_mateconf (PanelWidget *panel, - gboolean locked, - int position, - gboolean exactpos, - const char *id); - -void panel_action_button_load_compatible (PanelObjectType object_type, - PanelWidget *panel, +void panel_action_button_load_from_gsettings (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, diff --git a/mate-panel/panel-addto.c b/mate-panel/panel-addto.c index 150d83de..81d79ff0 100644 --- a/mate-panel/panel-addto.c +++ b/mate-panel/panel-addto.c @@ -26,6 +26,7 @@ #include <string.h> #include <glib/gi18n.h> +#include <gio/gio.h> #include <matemenu-tree.h> @@ -48,6 +49,7 @@ #include "panel-profile.h" #include "panel-addto.h" #include "panel-icon-names.h" +#include "panel-schemas.h" typedef struct { PanelWidget *panel_widget; @@ -72,8 +74,6 @@ typedef struct { gchar *search_text; gchar *applet_search_text; - guint name_notify; - int insertion_position; } PanelAddtoDialog; @@ -939,16 +939,18 @@ panel_addto_dialog_free_application_list (GSList *application_list) } static void +panel_addto_name_notify (GSettings *settings, + gchar *key, + PanelAddtoDialog *dialog); + +static void panel_addto_dialog_free (PanelAddtoDialog *dialog) { - MateConfClient *client; GSList *item; - client = panel_mateconf_get_client (); - - if (dialog->name_notify) - mateconf_client_notify_remove (client, dialog->name_notify); - dialog->name_notify = 0; + g_signal_handlers_disconnect_by_func(dialog->panel_widget->toplevel->settings, + G_CALLBACK (panel_addto_name_notify), + dialog); if (dialog->search_text) g_free (dialog->search_text); @@ -1030,27 +1032,11 @@ panel_addto_name_change (PanelAddtoDialog *dialog, } static void -panel_addto_name_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +panel_addto_name_notify (GSettings *settings, + gchar *key, PanelAddtoDialog *dialog) { - MateConfValue *value; - const char *key; - const char *text = NULL; - - key = panel_mateconf_basename (mateconf_entry_get_key (entry)); - - if (strcmp (key, "name")) - return; - - value = mateconf_entry_get_value (entry); - - if (value && value->type == MATECONF_VALUE_STRING) - text = mateconf_value_get_string (value); - - if (text) - panel_addto_name_change (dialog, text); + panel_addto_name_change (dialog, g_settings_get_string (settings, key)); } static gboolean @@ -1253,13 +1239,11 @@ panel_addto_dialog_new (PanelWidget *panel_widget) (GDestroyNotify) panel_addto_dialog_free); dialog->panel_widget = panel_widget; - dialog->name_notify = - panel_profile_toplevel_notify_add ( - dialog->panel_widget->toplevel, - "name", - (MateConfClientNotifyFunc) panel_addto_name_notify, - dialog); + g_signal_connect (dialog->panel_widget->toplevel->settings, + "changed::" PANEL_TOPLEVEL_NAME_KEY, + G_CALLBACK (panel_addto_name_notify), + dialog); dialog->addto_dialog = gtk_dialog_new (); gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog), diff --git a/mate-panel/panel-bindings.c b/mate-panel/panel-bindings.c index 5b580005..e0a81945 100644 --- a/mate-panel/panel-bindings.c +++ b/mate-panel/panel-bindings.c @@ -28,14 +28,12 @@ #include <string.h> #include <glib/gi18n.h> +#include <gio/gio.h> -#include "panel-mateconf.h" +#include "panel-schemas.h" #include "panel-profile.h" #include "panel-xutils.h" -#define BINDINGS_PREFIX "/apps/marco/window_keybindings" -#define MOUSE_MODIFIER_DIR "/apps/marco/general" -#define MOUSE_MODIFIER_KEY "/apps/marco/general/mouse_button_modifier" #define DEFAULT_MOUSE_MODIFIER GDK_MOD1_MASK typedef struct { @@ -46,15 +44,17 @@ typedef struct { } PanelBinding; static gboolean initialised = FALSE; +static GSettings *marco_settings = NULL; +static GSettings *marco_keybindings_settings = NULL; static PanelBinding bindings [] = { - { "activate_window_menu", "popup-panel-menu", 0, 0 }, - { "toggle_maximized", "toggle-expand", 0, 0 }, - { "maximize", "expand", 0, 0 }, - { "unmaximize", "unexpand", 0, 0 }, - { "toggle_shaded", "toggle-hidden", 0, 0 }, - { "begin_move", "begin-move", 0, 0 }, - { "begin_resize", "begin-resize", 0, 0 }, + { MARCO_ACTIVATE_WINDOW_MENU_KEY, "popup-panel-menu", 0, 0 }, + { MARCO_TOGGLE_MAXIMIZED_KEY, "toggle-expand", 0, 0 }, + { MARCO_MAXIMIZE_KEY, "expand", 0, 0 }, + { MARCO_UNMAXIMIZE_KEY, "unexpand", 0, 0 }, + { MARCO_TOGGLE_SHADED_KEY, "toggle-hidden", 0, 0 }, + { MARCO_BEGIN_MOVE_KEY, "begin-move", 0, 0 }, + { MARCO_BEGIN_RESIZE_KEY, "begin-resize", 0, 0 }, }; static guint mouse_button_modifier_keymask = DEFAULT_MOUSE_MODIFIER; @@ -120,25 +120,17 @@ panel_binding_set_entry (PanelBinding *binding, } static void -panel_binding_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - PanelBinding *binding) +panel_binding_changed (GSettings *settings, + gchar *key, + PanelBinding *binding) { - MateConfValue *value; - if (binding->keyval) panel_binding_clear_entry (binding, NULL); binding->keyval = 0; binding->modifiers = 0; - value = mateconf_entry_get_value (entry); - - if (!value || value->type != MATECONF_VALUE_STRING) - return; - - panel_binding_set_from_string (binding, mateconf_value_get_string (value)); + panel_binding_set_from_string (binding, g_settings_get_string (settings, key)); if (!binding->keyval) return; @@ -150,16 +142,13 @@ static void panel_binding_watch (PanelBinding *binding, const char *key) { - GError *error = NULL; - - mateconf_client_notify_add (panel_mateconf_get_client (), key, - (MateConfClientNotifyFunc) panel_binding_changed, - binding, NULL, &error); - if (error) { - g_warning ("Error watching mateconf key '%s': %s", - key, error->message); - g_error_free (error); - } + gchar *signal_name; + signal_name = g_strdup_printf ("changed::%s", key); + g_signal_connect (marco_keybindings_settings, + signal_name, + G_CALLBACK (panel_binding_changed), + binding); + g_free (signal_name); } static void @@ -182,95 +171,42 @@ panel_bindings_mouse_modifier_set_from_string (const char *str) } static void -panel_bindings_mouse_modifier_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +panel_bindings_mouse_modifier_changed (GSettings *settings, + gchar *key, + gpointer user_data) { - MateConfValue *value; - const char *str; - - value = mateconf_entry_get_value (entry); - - if (!value || value->type != MATECONF_VALUE_STRING) - return; - - str = mateconf_value_get_string (value); - panel_bindings_mouse_modifier_set_from_string (str); + panel_bindings_mouse_modifier_set_from_string (g_settings_get_string (settings, key)); } static void panel_bindings_initialise (void) { - MateConfClient *client; - GError *error; int i; char *str; if (initialised) return; - client = panel_mateconf_get_client (); - - error = NULL; - mateconf_client_add_dir (client, BINDINGS_PREFIX, - MATECONF_CLIENT_PRELOAD_ONELEVEL, &error); - if (error) { - g_warning ("Error loading mateconf directory '%s': %s", - BINDINGS_PREFIX, error->message), - g_error_free (error); - } + marco_settings = g_settings_new (MARCO_SCHEMA); + marco_keybindings_settings = g_settings_new (MARCO_KEYBINDINGS_SCHEMA); for (i = 0; i < G_N_ELEMENTS (bindings); i++) { - const char *key; - - key = panel_mateconf_sprintf ("%s/%s", BINDINGS_PREFIX, bindings [i].key); - - error = NULL; - str = mateconf_client_get_string (client, key, &error); - if (error) { - g_warning ("Error getting value for '%s': %s", - key, error->message); - g_error_free (error); - continue; - } - + str = g_settings_get_string (marco_keybindings_settings, bindings [i].key); panel_binding_set_from_string (&bindings [i], str); - panel_binding_watch (&bindings [i], key); - + panel_binding_watch (&bindings [i], bindings [i].key); g_free (str); } /* mouse button modifier */ - error = NULL; - mateconf_client_add_dir (client, MOUSE_MODIFIER_DIR, - MATECONF_CLIENT_PRELOAD_NONE, &error); - if (error) { - g_warning ("Error loading mateconf directory '%s': %s", - MOUSE_MODIFIER_DIR, error->message), - g_error_free (error); - } - error = NULL; - mateconf_client_notify_add (client, MOUSE_MODIFIER_KEY, - panel_bindings_mouse_modifier_changed, - NULL, NULL, &error); - if (error) { - g_warning ("Error watching mateconf key '%s': %s", - MOUSE_MODIFIER_KEY, error->message); - g_error_free (error); - } + g_signal_connect (marco_settings, + "changed::" MARCO_MOUSE_BUTTON_MODIFIER_KEY, + G_CALLBACK (panel_bindings_mouse_modifier_changed), + NULL); - error = NULL; - str = mateconf_client_get_string (client, MOUSE_MODIFIER_KEY, &error); - if (error) { - g_warning ("Error getting value for '%s': %s", - MOUSE_MODIFIER_KEY, error->message); - g_error_free (error); - } else { - panel_bindings_mouse_modifier_set_from_string (str); - g_free (str); - } + str = g_settings_get_string (marco_settings, MARCO_MOUSE_BUTTON_MODIFIER_KEY); + panel_bindings_mouse_modifier_set_from_string (str); + g_free (str); initialised = TRUE; } diff --git a/mate-panel/panel-compatibility.c b/mate-panel/panel-compatibility.c deleted file mode 100644 index a746f695..00000000 --- a/mate-panel/panel-compatibility.c +++ /dev/null @@ -1,1167 +0,0 @@ -/* - * panel-compatibility.c: panel backwards compatibility support - * - * Copyright (C) 2003 Sun Microsystems, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Mark McLoughlin <[email protected]> - */ - -#include <config.h> - -#include "string.h" - -#include <libpanel-util/panel-glib.h> - -#include "panel-compatibility.h" - -#include "panel-profile.h" -#include "panel-menu-bar.h" -#include "mate-panel-applet-frame.h" -#include "mate-panel-applets-manager.h" -#include "panel-globals.h" -#include "panel-util.h" - -typedef enum { - PANEL_ORIENT_UP, - PANEL_ORIENT_DOWN, - PANEL_ORIENT_LEFT, - PANEL_ORIENT_RIGHT, -} PanelOrient; - -static MateConfEnumStringPair panel_orient_map [] = { - { PANEL_ORIENT_UP, "panel-orient-up" }, - { PANEL_ORIENT_DOWN, "panel-orient-down" }, - { PANEL_ORIENT_LEFT, "panel-orient-left" }, - { PANEL_ORIENT_RIGHT, "panel-orient-right" }, - { 0, NULL } -}; - -static gboolean -panel_compatibility_map_orient_string (const char *str, - PanelOrient *orient) -{ - int mapped; - - g_return_val_if_fail (orient != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_orient_map, str, &mapped)) - return FALSE; - - *orient = mapped; - - return TRUE; -} - -static MateConfEnumStringPair panel_orientation_map [] = { - { GTK_ORIENTATION_HORIZONTAL, "panel-orientation-horizontal" }, - { GTK_ORIENTATION_VERTICAL, "panel-orientation-vertical" }, - { 0, NULL } -}; - - -static gboolean -panel_compatibility_map_orientation_string (const char *str, - GtkOrientation *orientation) -{ - int mapped; - - g_return_val_if_fail (orientation != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_orientation_map, str, &mapped)) - return FALSE; - - *orientation = mapped; - - return TRUE; -} - -typedef enum { - BORDER_TOP, - BORDER_RIGHT, - BORDER_BOTTOM, - BORDER_LEFT -} BorderEdge; - -static MateConfEnumStringPair panel_edge_map [] = { - { BORDER_TOP, "panel-edge-top" }, - { BORDER_RIGHT, "panel-edge-right" }, - { BORDER_BOTTOM, "panel-edge-bottom" }, - { BORDER_LEFT, "panel-edge-left" }, - { 0, NULL } -}; - -static gboolean -panel_compatibility_map_edge_string (const char *str, - BorderEdge *edge) -{ - int mapped; - - g_return_val_if_fail (edge != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_edge_map, str, &mapped)) - return FALSE; - - *edge = mapped; - - return TRUE; -} - -typedef enum { - EDGE_PANEL, - DRAWER_PANEL, - ALIGNED_PANEL, - SLIDING_PANEL, - FLOATING_PANEL, - MENU_PANEL -} PanelType; - -static MateConfEnumStringPair panel_type_map [] = { - { EDGE_PANEL, "edge-panel" }, - { DRAWER_PANEL, "drawer-panel" }, - { ALIGNED_PANEL, "aligned-panel" }, - { SLIDING_PANEL, "sliding-panel" }, - { FLOATING_PANEL, "floating-panel" }, - { MENU_PANEL, "menu-panel" }, - { 0, NULL } -}; - -static gboolean -panel_compatibility_map_panel_type_string (const char *str, - PanelType *type) -{ - int mapped; - - g_return_val_if_fail (type != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_type_map, str, &mapped)) - return FALSE; - - *type = mapped; - - return TRUE; -} - -enum { - PANEL_SIZE_XX_SMALL = 12, - PANEL_SIZE_X_SMALL = 24, - PANEL_SIZE_SMALL = 36, - PANEL_SIZE_MEDIUM = 48, - PANEL_SIZE_LARGE = 64, - PANEL_SIZE_X_LARGE = 80, - PANEL_SIZE_XX_LARGE = 128 -}; - -static MateConfEnumStringPair panel_size_map [] = { - { PANEL_SIZE_XX_SMALL, "panel-size-xx-small" }, - { PANEL_SIZE_X_SMALL, "panel-size-x-small" }, - { PANEL_SIZE_SMALL, "panel-size-small" }, - { PANEL_SIZE_MEDIUM, "panel-size-medium" }, - { PANEL_SIZE_LARGE, "panel-size-large" }, - { PANEL_SIZE_X_LARGE, "panel-size-x-large" }, - { PANEL_SIZE_XX_LARGE, "panel-size-xx-large" }, - { 0, NULL } -}; - -static gboolean -panel_compatibility_map_panel_size_string (const char *str, - int *size) -{ - int mapped; - - g_return_val_if_fail (size != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_size_map, str, &mapped)) - return FALSE; - - *size = mapped; - - return TRUE; -} - -static MateConfEnumStringPair panel_background_type_map [] = { - { PANEL_BACK_NONE, "no-background" }, - { PANEL_BACK_COLOR, "color-background" }, - { PANEL_BACK_IMAGE, "pixmap-background" }, - { 0, NULL } -}; - -static gboolean -panel_compatibility_map_background_type_string (const char *str, - PanelBackgroundType *type) -{ - int mapped; - - g_return_val_if_fail (type != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_background_type_map, str, &mapped)) - return FALSE; - - *type = mapped; - - return TRUE; -} - -static void -panel_compatibility_migrate_background_settings (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) -{ - PanelBackgroundType type; - const char *key; - char *background_dir; - char *type_str; - char *color_str; - char *image_str; - gboolean fit; - gboolean stretch; - gboolean rotate; - int opacity; - - background_dir = mateconf_concat_dir_and_key (toplevel_dir, "background"); - - /* panel_background_type -> background/type */ - key = panel_mateconf_sprintf ("%s/panel_background_type", panel_dir); - type_str = mateconf_client_get_string (client, key, NULL); - - if (panel_compatibility_map_background_type_string (type_str, &type)) { - key = panel_mateconf_sprintf ("%s/type", background_dir); - mateconf_client_set_string (client, - key, - panel_profile_map_background_type (type), - NULL); - } - - g_free (type_str); - - /* panel_background_color -> background/color */ - key = panel_mateconf_sprintf ("%s/panel_background_color", panel_dir); - color_str = mateconf_client_get_string (client, key, NULL); - - if (color_str) { - key = panel_mateconf_sprintf ("%s/color", background_dir); - mateconf_client_set_string (client, key, color_str, NULL); - } - - g_free (color_str); - - /* panel_background_color_alpha -> background/opacity */ - key = panel_mateconf_sprintf ("%s/panel_background_color_alpha", panel_dir); - opacity = mateconf_client_get_int (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/opacity", background_dir); - mateconf_client_set_int (client, key, opacity, NULL); - - /* panel_background_pixmap -> background/image */ - key = panel_mateconf_sprintf ("%s/panel_background_pixmap", panel_dir); - image_str = mateconf_client_get_string (client, key, NULL); - - if (image_str) { - key = panel_mateconf_sprintf ("%s/image", background_dir); - mateconf_client_set_string (client, key, image_str, NULL); - } - - g_free (image_str); - - /* panel_background_pixmap_fit -> background/fit */ - key = panel_mateconf_sprintf ("%s/panel_background_pixmap_fit", panel_dir); - fit = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/fit", background_dir); - mateconf_client_set_bool (client, key, fit, NULL); - - /* panel_background_pixmap_stretch -> background/stretch */ - key = panel_mateconf_sprintf ("%s/panel_background_pixmap_stretch", panel_dir); - stretch = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/stretch", background_dir); - mateconf_client_set_bool (client, key, stretch, NULL); - - /* panel_background_pixmap_rotate -> background/rotate */ - key = panel_mateconf_sprintf ("%s/panel_background_pixmap_rotate", panel_dir); - rotate = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/rotate", background_dir); - mateconf_client_set_bool (client, key, rotate, NULL); - - g_free (background_dir); -} - -static void -panel_compatibility_migrate_edge_setting (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) -{ - BorderEdge edge; - const char *key; - char *edge_str; - - key = panel_mateconf_sprintf ("%s/screen_edge", panel_dir); - edge_str = mateconf_client_get_string (client, key, NULL); - - if (panel_compatibility_map_edge_string (edge_str, &edge)) { - PanelOrientation orientation; - - switch (edge) { - case BORDER_TOP: - orientation = PANEL_ORIENTATION_TOP; - break; - case BORDER_BOTTOM: - orientation = PANEL_ORIENTATION_BOTTOM; - break; - case BORDER_LEFT: - orientation = PANEL_ORIENTATION_LEFT; - break; - case BORDER_RIGHT: - orientation = PANEL_ORIENTATION_RIGHT; - break; - default: - orientation = 0; - g_assert_not_reached (); - break; - } - - key = panel_mateconf_sprintf ("%s/orientation", toplevel_dir); - mateconf_client_set_string (client, - key, - panel_profile_map_orientation (orientation), - NULL); - } - - g_free (edge_str); -} - -static void -panel_compatibility_migrate_edge_panel_settings (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) -{ - const char *key; - - key = panel_mateconf_sprintf ("%s/expand", toplevel_dir); - mateconf_client_set_bool (client, key, TRUE, NULL); - - panel_compatibility_migrate_edge_setting (client, toplevel_dir, panel_dir); -} - -static void -panel_compatibility_migrate_drawer_panel_settings (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) -{ - PanelOrient orient; - const char *key; - char *orient_str; - - key = panel_mateconf_sprintf ("%s/expand", toplevel_dir); - mateconf_client_set_bool (client, key, FALSE, NULL); - - key = panel_mateconf_sprintf ("%s/panel_orient", panel_dir); - orient_str = mateconf_client_get_string (client, key, NULL); - - if (panel_compatibility_map_orient_string (orient_str, &orient)) { - PanelOrientation orientation; - - switch (orient) { - case PANEL_ORIENT_DOWN: - orientation = PANEL_ORIENTATION_TOP; - break; - case PANEL_ORIENT_UP: - orientation = PANEL_ORIENTATION_BOTTOM; - break; - case PANEL_ORIENT_RIGHT: - orientation = PANEL_ORIENTATION_LEFT; - break; - case PANEL_ORIENT_LEFT: - orientation = PANEL_ORIENTATION_RIGHT; - break; - default: - orientation = 0; - g_assert_not_reached (); - break; - } - - key = panel_mateconf_sprintf ("%s/orientation", toplevel_dir); - mateconf_client_set_string (client, - key, - panel_profile_map_orientation (orientation), - NULL); - } - - g_free (orient_str); -} - -static void -panel_compatibility_migrate_corner_panel_settings (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) - -{ - const char *key; - - key = panel_mateconf_sprintf ("%s/expand", toplevel_dir); - mateconf_client_set_bool (client, key, FALSE, NULL); - - /* screen edge */ - panel_compatibility_migrate_edge_setting (client, toplevel_dir, panel_dir); - - g_warning ("FIXME: implement migrating the 'panel_align' setting"); -} - -static void -panel_compatibility_migrate_sliding_panel_settings (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) -{ - const char *key; - - key = panel_mateconf_sprintf ("%s/expand", toplevel_dir); - mateconf_client_set_bool (client, key, FALSE, NULL); - - /* screen edge */ - panel_compatibility_migrate_edge_setting (client, toplevel_dir, panel_dir); - - g_warning ("FIXME: implement migrating the 'panel_anchor' and 'panel_offset' settings"); -} - -static void -panel_compatibility_migrate_floating_panel_settings (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) -{ - GtkOrientation orientation; - const char *key; - char *orientation_str; - int x, y; - - key = panel_mateconf_sprintf ("%s/expand", toplevel_dir); - mateconf_client_set_bool (client, key, FALSE, NULL); - - key = panel_mateconf_sprintf ("%s/panel_orient", panel_dir); - orientation_str = mateconf_client_get_string (client, key, NULL); - - if (panel_compatibility_map_orientation_string (orientation_str, &orientation)) { - PanelOrientation panel_orientation; - - switch (orientation) { - case GTK_ORIENTATION_HORIZONTAL: - panel_orientation = PANEL_ORIENTATION_TOP; - break; - case GTK_ORIENTATION_VERTICAL: - panel_orientation = PANEL_ORIENTATION_LEFT; - break; - default: - panel_orientation = 0; - g_assert_not_reached (); - break; - } - - key = panel_mateconf_sprintf ("%s/orientation", toplevel_dir); - mateconf_client_set_string (client, - key, - panel_profile_map_orientation (panel_orientation), - NULL); - } - - g_free (orientation_str); - - /* x */ - key = panel_mateconf_sprintf ("%s/panel_x_position", panel_dir); - x = mateconf_client_get_int (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/x", toplevel_dir); - mateconf_client_set_int (client, key, x, NULL); - - /* y */ - key = panel_mateconf_sprintf ("%s/panel_y_position", panel_dir); - y = mateconf_client_get_int (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/y", toplevel_dir); - mateconf_client_set_int (client, key, y, NULL); -} - -static void -panel_compatibility_migrate_menu_panel_settings (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir) -{ - const char *key; - const char *toplevel_id; - char *id; - - key = panel_mateconf_sprintf ("%s/expand", toplevel_dir); - mateconf_client_set_bool (client, key, TRUE, NULL); - - key = panel_mateconf_sprintf ("%s/orientation", toplevel_dir); - mateconf_client_set_string (client, key, - panel_profile_map_orientation (PANEL_ORIENTATION_TOP), - NULL); - - toplevel_id = panel_mateconf_basename (toplevel_dir); - - /* menu bar on far right corner */ - id = panel_profile_prepare_object_with_id (PANEL_OBJECT_MENU_BAR, toplevel_id, 0, FALSE); - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); - g_free (id); - - /* window menu on far left corner */ - id = panel_profile_prepare_object_with_id (PANEL_OBJECT_APPLET, toplevel_id, 0, TRUE); - - key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "matecomponent_iid"); - mateconf_client_set_string (client, key, "OAFIID:MATE_WindowMenuApplet", NULL); - - panel_profile_add_to_list (PANEL_MATECONF_APPLETS, id); - g_free (id); -} - -static void -panel_compatibility_migrate_panel_type (MateConfClient *client, - const char *toplevel_dir, - const char *panel_dir, - gboolean *is_drawer) -{ - PanelType type; - const char *key; - char *type_str; - - key = panel_mateconf_sprintf ("%s/panel_type", panel_dir); - type_str = mateconf_client_get_string (client, key, NULL); - - if (!panel_compatibility_map_panel_type_string (type_str, &type)) { - g_free (type_str); - return; - } - - g_free (type_str); - - switch (type) { - case EDGE_PANEL: - panel_compatibility_migrate_edge_panel_settings (client, toplevel_dir, panel_dir); - break; - case DRAWER_PANEL: - panel_compatibility_migrate_drawer_panel_settings (client, toplevel_dir, panel_dir); - *is_drawer = TRUE; - break; - case ALIGNED_PANEL: - panel_compatibility_migrate_corner_panel_settings (client, toplevel_dir, panel_dir); - break; - case SLIDING_PANEL: - panel_compatibility_migrate_sliding_panel_settings (client, toplevel_dir, panel_dir); - break; - case FLOATING_PANEL: - panel_compatibility_migrate_floating_panel_settings (client, toplevel_dir, panel_dir); - break; - case MENU_PANEL: - panel_compatibility_migrate_menu_panel_settings (client, toplevel_dir, panel_dir); - break; - default: - g_assert_not_reached (); - break; - } -} - -static char * -panel_compatibility_migrate_panel_settings (MateConfClient *client, - GSList *toplevel_id_list, - const char *panel_id, - gboolean *is_drawer) -{ - const char *key; - char *toplevel_id; - char *toplevel_dir; - char *panel_dir; - char *size_str; - int screen; - int monitor; - int size; - gboolean enable_buttons; - gboolean enable_arrows; - gboolean auto_hide; - - toplevel_id = panel_profile_find_new_id (PANEL_MATECONF_TOPLEVELS); - - toplevel_dir = g_strdup_printf (PANEL_CONFIG_DIR "/toplevels/%s", toplevel_id); - panel_dir = g_strdup_printf (PANEL_CONFIG_DIR "/panels/%s", panel_id); - - panel_mateconf_associate_schemas_in_dir ( - client, toplevel_dir, PANEL_SCHEMAS_DIR "/toplevels"); - - /* screen */ - key = panel_mateconf_sprintf ("%s/screen", panel_dir); - screen = mateconf_client_get_int (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/screen", toplevel_dir); - mateconf_client_set_int (client, key, screen, NULL); - - /* monitor */ - key = panel_mateconf_sprintf ("%s/monitor", panel_dir); - monitor = mateconf_client_get_int (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/monitor", toplevel_dir); - mateconf_client_set_int (client, key, monitor, NULL); - - /* size */ - key = panel_mateconf_sprintf ("%s/panel_size", panel_dir); - size_str = mateconf_client_get_string (client, key, NULL); - - if (panel_compatibility_map_panel_size_string (size_str, &size)) { - key = panel_mateconf_sprintf ("%s/size", toplevel_dir); - mateconf_client_set_int (client, key, size, NULL); - } - - g_free (size_str); - - /* enable_buttons */ - key = panel_mateconf_sprintf ("%s/hide_buttons_enabled", panel_dir); - enable_buttons = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/enable_buttons", toplevel_dir); - mateconf_client_set_bool (client, key, enable_buttons, NULL); - - /* enable_arrows */ - key = panel_mateconf_sprintf ("%s/hide_button_pixmaps_enabled", panel_dir); - enable_arrows = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/enable_arrows", toplevel_dir); - mateconf_client_set_bool (client, key, enable_arrows, NULL); - - /* auto hide */ - key = panel_mateconf_sprintf ("%s/panel_hide_mode", panel_dir); - auto_hide = mateconf_client_get_int (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/auto_hide", toplevel_dir); - mateconf_client_set_bool (client, key, auto_hide, NULL); - - /* migrate different panel types to toplevels */ - panel_compatibility_migrate_panel_type (client, toplevel_dir, panel_dir, is_drawer); - - /* background settings */ - panel_compatibility_migrate_background_settings (client, toplevel_dir, panel_dir); - - g_free (toplevel_dir); - g_free (panel_dir); - - return toplevel_id; -} - -static gboolean -panel_compatibility_migrate_panel_id (MateConfClient *client, - PanelMateConfKeyType key_type, - const char *object_id, - GHashTable *panel_id_hash) -{ - const char *key; - char *panel_id; - char *toplevel_id; - gboolean retval = FALSE; - - /* panel_id -> toplevel_id */ - key = panel_mateconf_full_key (key_type, object_id, "panel_id"); - panel_id = mateconf_client_get_string (client, key, NULL); - - if (panel_id && (toplevel_id = g_hash_table_lookup (panel_id_hash, panel_id))) { - key = panel_mateconf_full_key (key_type, object_id, "toplevel_id"); - mateconf_client_set_string (client, key, toplevel_id, NULL); - - retval = TRUE; - } - - g_free (panel_id); - - return retval; -} - -static void -panel_compatibility_migrate_drawer_settings (MateConfClient *client, - PanelMateConfKeyType key_type, - const char *object_id, - GHashTable *panel_id_hash) -{ - const char *key; - char *toplevel_id; - char *panel_id; - char *custom_icon; - char *pixmap; - - /* unique-drawer-panel-id -> attached_toplevel_id */ - key = panel_mateconf_full_key (key_type, object_id, "attached_toplevel_id"); - toplevel_id = mateconf_client_get_string (client, key, NULL); - - key = panel_mateconf_full_key (key_type, object_id, "unique-drawer-panel-id"); - panel_id = mateconf_client_get_string (client, key, NULL); - - if (!toplevel_id && panel_id && - (toplevel_id = g_hash_table_lookup (panel_id_hash, panel_id))) { - key = panel_mateconf_full_key (key_type, object_id, "attached_toplevel_id"); - mateconf_client_set_string (client, key, toplevel_id, NULL); - - toplevel_id = NULL; - } - - /* pixmap -> custom_icon */ - key = panel_mateconf_full_key (key_type, object_id, "custom_icon"); - custom_icon = mateconf_client_get_string (client, key, NULL); - - key = panel_mateconf_full_key (key_type, object_id, "pixmap"); - pixmap = mateconf_client_get_string (client, key, NULL); - - if (!custom_icon && pixmap) { - key = panel_mateconf_full_key (key_type, object_id, "custom_icon"); - mateconf_client_set_string (client, key, pixmap, NULL); - - key = panel_mateconf_full_key (key_type, object_id, "use_custom_icon"); - mateconf_client_set_bool (client, key, TRUE, NULL); - } - - g_free (toplevel_id); - g_free (panel_id); - g_free (custom_icon); - g_free (pixmap); -} - -static void -panel_compatibility_migrate_menu_button_settings (MateConfClient *client, - PanelMateConfKeyType key_type, - const char *object_id) -{ - const char *key; - gboolean use_custom_icon; - gboolean use_menu_path; - char *custom_icon; - char *menu_path; - - /* custom-icon -> use_custom_icon */ - key = panel_mateconf_full_key (key_type, object_id, "custom-icon"); - use_custom_icon = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_full_key (key_type, object_id, "use_custom_icon"); - mateconf_client_set_bool (client, key, use_custom_icon, NULL); - - /* custom-icon-file -> custom_icon */ - key = panel_mateconf_full_key (key_type, object_id, "custom-icon-file"); - custom_icon = mateconf_client_get_string (client, key, NULL); - - if (custom_icon) { - key = panel_mateconf_full_key (key_type, object_id, "custom_icon"); - mateconf_client_set_string (client, key, custom_icon, NULL); - } - - /* main_menu -> ! use_menu_path */ - key = panel_mateconf_full_key (key_type, object_id, "main-menu"); - use_menu_path = ! mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_full_key (key_type, object_id, "use_menu_path"); - mateconf_client_set_bool (client, key, use_menu_path, NULL); - - /* path -> menu_path */ - key = panel_mateconf_full_key (key_type, object_id, "path"); - menu_path = mateconf_client_get_string (client, key, NULL); - - if (menu_path) { - key = panel_mateconf_full_key (key_type, object_id, "menu_path"); - mateconf_client_set_string (client, key, menu_path, NULL); - } - - g_free (custom_icon); - g_free (menu_path); -} - -static void -panel_compatibility_migrate_objects (MateConfClient *client, - PanelMateConfKeyType key_type, - GHashTable *panel_id_hash) -{ - const char *key; - GSList *l, *objects; - - key = panel_mateconf_general_key (panel_mateconf_key_type_to_id_list (key_type)); - objects = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - - for (l = objects; l; l = l->next) { - const char *id = l->data; - PanelObjectType object_type; - char *object_type_str; - - if (!panel_compatibility_migrate_panel_id (client, key_type, id, panel_id_hash)) { - g_free (l->data); - continue; - } - - key = panel_mateconf_full_key (key_type, id, "object_type"); - object_type_str = mateconf_client_get_string (client, key, NULL); - - if (panel_profile_map_object_type_string (object_type_str, &object_type)) { - switch (object_type) { - case PANEL_OBJECT_DRAWER: - panel_compatibility_migrate_drawer_settings ( - client, key_type, id, panel_id_hash); - break; - case PANEL_OBJECT_MENU: - panel_compatibility_migrate_menu_button_settings ( - client, key_type, id); - break; - default: - break; - } - } - g_free (object_type_str); - g_free (l->data); - } - g_slist_free (objects); -} - -/* Major hack, but we now set toplevel_id_list in the defaults database, - * so we need to figure out if its actually set in the users database. - */ - -static MateConfEngine * -get_homedir_source (void) -{ - MateConfEngine *engine; - GError *error = NULL; - char *source; - - source = g_strdup_printf ("xml:readwrite:%s/.mateconf", g_get_home_dir ()); - - if (!(engine = mateconf_engine_get_for_address (source, &error))) { -#if 0 - g_warning ("Cannot get MateConf source '%s': %s\n", - source, error->message); -#endif - g_error_free (error); - g_free (source); - return NULL; - } - - g_free (source); - - return engine; -} - -static gboolean -is_general_key_set (MateConfEngine *engine, - const char *config_dir, - const char *general_key) -{ - MateConfEntry *entry; - const char *key; - gboolean retval; - - key = panel_mateconf_sprintf ("%s/general/%s", config_dir, general_key); - - if (!(entry = mateconf_engine_get_entry (engine, key, NULL, FALSE, NULL))) - return FALSE; - - retval = mateconf_entry_get_value (entry) != NULL || - mateconf_entry_get_schema_name (entry) != NULL; - - mateconf_entry_unref (entry); - - return retval; -} - -static gboolean -panel_compatibility_detect_needs_migration (void) -{ - MateConfEngine *engine; - gboolean needs_migration = FALSE; - - if (!(engine = get_homedir_source ())) - return FALSE; - - if (!is_general_key_set (engine, PANEL_CONFIG_DIR, "panel_id_list")) - goto no_migration; - - if (is_general_key_set (engine, PANEL_CONFIG_DIR, "toplevel_id_list")) - goto no_migration; - - needs_migration = TRUE; - - no_migration: - mateconf_engine_unref (engine); - - return needs_migration; -} - -/* If toplevel_id_list is unset, migrate all the panels in - * panel_id_list to toplevels - */ -void -panel_compatibility_migrate_panel_id_list (MateConfClient *client) -{ - GHashTable *panel_id_hash; - const char *key; - GSList *panel_id_list; - GSList *toplevel_id_list = NULL; - GSList *l; - - if (!panel_compatibility_detect_needs_migration ()) - return; - - panel_id_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - - key = panel_mateconf_general_key ("panel_id_list"); - panel_id_list = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - - for (l = panel_id_list; l; l = l->next) { - char *new_id; - gboolean is_drawer = FALSE; - - new_id = panel_compatibility_migrate_panel_settings (client, - toplevel_id_list, - l->data, - &is_drawer); - - /* Drawer toplevels don't belong on the toplevel list */ - if (!is_drawer) - toplevel_id_list = g_slist_prepend (toplevel_id_list, new_id); - - g_hash_table_insert (panel_id_hash, l->data, new_id); - } - - key = panel_mateconf_general_key ("toplevel_id_list"); - mateconf_client_set_list (client, key, MATECONF_VALUE_STRING, toplevel_id_list, NULL); - - g_slist_free (panel_id_list); - g_slist_free (toplevel_id_list); - - panel_compatibility_migrate_objects (client, PANEL_MATECONF_OBJECTS, panel_id_hash); - panel_compatibility_migrate_objects (client, PANEL_MATECONF_APPLETS, panel_id_hash); - - g_hash_table_destroy (panel_id_hash); -} - -static void -copy_mateconf_dir (MateConfClient *client, - const char *src_dir, - const char *dest_dir) -{ - GSList *list, *l; - - list = mateconf_client_all_entries (client, src_dir, NULL); - for (l = list; l; l = l->next) { - MateConfEntry *entry = l->data; - const char *key; - char *tmp; - - tmp = g_path_get_basename (mateconf_entry_get_key (entry)); - key = panel_mateconf_sprintf ("%s/%s", dest_dir, tmp); - g_free (tmp); - - if (mateconf_entry_get_schema_name (entry)) - mateconf_engine_associate_schema (client->engine, - key, - mateconf_entry_get_schema_name (entry), - NULL); - - if (entry->value) - mateconf_client_set (client, key, entry->value, NULL); - - mateconf_entry_unref (entry); - } - g_slist_free (list); - - list = mateconf_client_all_dirs (client, src_dir, NULL); - for (l = list; l; l = l->next) { - char *subdir = l->data; - char *src_subdir; - char *dest_subdir; - char *tmp; - - tmp = g_path_get_basename (subdir); - src_subdir = mateconf_concat_dir_and_key (src_dir, tmp); - dest_subdir = mateconf_concat_dir_and_key (dest_dir, tmp); - g_free (tmp); - - copy_mateconf_dir (client, src_subdir, dest_subdir); - - g_free (src_subdir); - g_free (dest_subdir); - g_free (subdir); - } - - g_slist_free (list); -} - -void -panel_compatibility_maybe_copy_old_config (MateConfClient *client) -{ - MateConfEngine *engine; - const char *key; - - key = panel_mateconf_general_key ("profiles_migrated"); - if (mateconf_client_get_bool (client, key, NULL)) - return; - - if (!(engine = get_homedir_source ())) - goto no_migration_needed;; - - if (!is_general_key_set (engine, PANEL_OLD_CONFIG_DIR, "panel_id_list") && - !is_general_key_set (engine, PANEL_OLD_CONFIG_DIR, "toplevel_id_list") && - !is_general_key_set (engine, PANEL_OLD_CONFIG_DIR, "applet_id_list") && - !is_general_key_set (engine, PANEL_OLD_CONFIG_DIR, "object_id_list")) - goto no_migration_needed; - - copy_mateconf_dir (client, PANEL_OLD_CONFIG_DIR, PANEL_CONFIG_DIR); - - key = panel_mateconf_general_key ("profiles_migrated"); - mateconf_client_set_bool (client, key, TRUE, NULL); - - no_migration_needed: - if (engine) - mateconf_engine_unref (engine); -} - -void -panel_compatibility_migrate_applications_scheme (MateConfClient *client, - const char *key) -{ - char *location; - - location = mateconf_client_get_string (client, key, NULL); - - if (!location) - return; - - if (!strncmp (location, "applications:", strlen ("applications:")) || - !strncmp (location, "applications-all-users:", strlen ("applications-all-users:")) || - !strncmp (location, "all-applications:", strlen ("all-applications:")) || - !strncmp (location, "preferences:", strlen ("preferences:")) || - !strncmp (location, "preferences-all-users:", strlen ("preferences-all-users:")) || - !strncmp (location, "all-preferences:", strlen ("all-preferences:")) || - !strncmp (location, "system-settings:", strlen ("system-settings:")) || - !strncmp (location, "server-settings:", strlen ("server-settings:"))) { - char *basename; - char *new_location; - - basename = g_path_get_basename (location); - new_location = panel_g_lookup_in_applications_dirs (basename); - g_free (basename); - - if (new_location != NULL) { - mateconf_client_set_string (client, key, - new_location, NULL); - g_free (new_location); - } - } - - g_free (location); -} - -void -panel_compatibility_migrate_screenshot_action (MateConfClient *client, - const char *id) -{ - const char *key; - - panel_profile_remove_from_list (PANEL_MATECONF_OBJECTS, id); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, - "launcher_location"); - mateconf_client_set_string (client, key, "mate-screenshot.desktop", NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, - "object_type"); - //FIXME: ideally, we would use panel_object_type_map, but it's private - //in panel-profile.c - mateconf_client_set_string (client, key, "launcher-object", NULL); - - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); -} - -gchar * -panel_compatibility_get_applet_iid (const gchar *id) -{ - MateConfClient *client = panel_mateconf_get_client (); - MatePanelAppletInfo *info; - const char *key; - gchar *applet_iid; - gboolean needs_migration; - const char *iid; - - /* - * There are two compatibility steps here: - * - * 1) we need to migrate from matecomponent_iid to applet_iid if there's no - * value in the applet_iid key. Always. - * - * 2) we need to try to migrate the iid to a new iid. We can't assume - * that the fact that the applet_iid key was used mean anything - * since the value there could well be a matecomponent iid. - * The reason we really have to try to migrate first is this case: - * if an applet was added with the matecomponent iid but gets ported later - * to dbus, then the reference to the matecomponent iid will only be valid - * as an old reference. - * And if migration fails, we just use the iid as it is. - */ - - needs_migration = FALSE; - - key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "applet_iid"); - applet_iid = mateconf_client_get_string (client, key, NULL); - - if (!applet_iid || !applet_iid[0]) { - needs_migration = TRUE; - - key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "matecomponent_iid"); - applet_iid = mateconf_client_get_string (client, key, NULL); - - if (!applet_iid || !applet_iid[0]) - return NULL; - } - - info = mate_panel_applets_manager_get_applet_info_from_old_id (applet_iid); - if (!info) - info = mate_panel_applets_manager_get_applet_info (applet_iid); - - if (!info) - return NULL; - - iid = mate_panel_applet_info_get_iid (info); - - /* migrate if the iid in the configuration is different than the real - * iid that will get used */ - if (!g_str_equal (iid, applet_iid)) - needs_migration = TRUE; - - g_free (applet_iid); - - if (needs_migration) { - key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "applet_iid"); - mateconf_client_set_string (client, key, iid, NULL); - } - - return g_strdup (iid); -} diff --git a/mate-panel/panel-compatibility.h b/mate-panel/panel-compatibility.h deleted file mode 100644 index 4413fb95..00000000 --- a/mate-panel/panel-compatibility.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * panel-compatibility.h: panel backwards compatibility support - * - * Copyright (C) 2003 Sun Microsystems, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifndef __PANEL_COMPATIBILITY_H__ -#define __PANEL_COMPATIBILITY_H__ - -#include <glib.h> -#include <mateconf/mateconf-client.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void panel_compatibility_migrate_panel_id_list (MateConfClient *client); -void panel_compatibility_maybe_copy_old_config (MateConfClient *client); -void panel_compatibility_migrate_applications_scheme (MateConfClient *client, - const char *key); -void panel_compatibility_migrate_screenshot_action (MateConfClient *client, - const char *id); - -gchar *panel_compatibility_get_applet_iid (const gchar *id); - -#ifdef __cplusplus -} -#endif - -#endif /* __PANEL_MENU_BAR_H__ */ diff --git a/mate-panel/panel-compatibility.schemas b/mate-panel/panel-compatibility.schemas deleted file mode 100644 index ea4a7a68..00000000 --- a/mate-panel/panel-compatibility.schemas +++ /dev/null @@ -1,546 +0,0 @@ -<?xml version="1.0"?> -<mateconfschemafile> - -<!-- - Schemas to maintain compatibility with the 2.0/2.2 configurations. - - The problem being addressed here is that because the 2.0/2.2 panel - applies schemas to keys at runtime, existing user configurations - will end up with dangling references to the old schemas unless we - install these old schemas. - - For example, a 2.0/2.2 panel will apply the medium/general/panel_id_list - schema to profiles/default/general/panel_id_list. This association - is in the user's configuration, not in the system MateConf database. - If the user never changes panel_id_list and logs into a machine without - this schema, then panel_id_list will be empty. - --> - - <schemalist> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/general/panel_id_list</key> - <owner>panel</owner> - <type>list</type> - <list_type>string</list_type> - <default>[00000001,00000002]</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/general/applet_id_list</key> - <owner>panel</owner> - <type>list</type> - <list_type>string</list_type> - <default>[00000001,00000002,00000003,00000004,show_desktop_button]</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/general/object_id_list</key> - <owner>panel</owner> - <type>list</type> - <list_type>string</list_type> - <default>[00000001,00000002]</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_type</key> - <owner>panel</owner> - <type>string</type> - <default>edge-panel</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_size</key> - <owner>panel</owner> - <type>string</type> - <default>panel-size-x-small</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_hide_mode</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_hide_state</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/screen</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/monitor</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/screen_edge</key> - <owner>panel</owner> - <type>string</type> - <default>panel-edge-bottom</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/hide_buttons_enabled</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/hide_button_pixmaps_enabled</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_background_type</key> - <owner>panel</owner> - <type>string</type> - <default>no-background</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_background_pixmap</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_background_pixmap_fit</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_background_pixmap_stretch</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_background_pixmap_rotate</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_background_color</key> - <owner>panel</owner> - <type>string</type> - <default>#ffffff</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000001/panel_background_color_alpha</key> - <owner>panel</owner> - <type>int</type> - <default>65535</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000001/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>launcher-object</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000001/launcher_location</key> - <owner>panel</owner> - <type>string</type> - <default>applications:///caja.desktop</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000001/panel_id</key> - <owner>panel</owner> - <type>string</type> - <default>00000002</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000001/position</key> - <owner>panel</owner> - <type>int</type> - <default>20</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000001/panel_right_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000002/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>launcher-object</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000002/launcher_location</key> - <owner>panel</owner> - <type>string</type> - <default>applications:///System/mate-terminal.desktop</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000002/panel_id</key> - <owner>panel</owner> - <type>string</type> - <default>00000002</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000002/position</key> - <owner>panel</owner> - <type>int</type> - <default>25</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/objects/00000002/panel_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/show_desktop_button/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>matecomponent-applet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/show_desktop_button/panel_id</key> - <owner>panel</owner> - <type>string</type> - <default>00000001</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/show_desktop_button/position</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/show_desktop_button/matecomponent_iid</key> - <owner>panel</owner> - <type>string</type> - <default>OAFIID:MATE_ShowDesktopApplet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/show_desktop_button/panel_right_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000001/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>matecomponent-applet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000001/panel_id</key> - <owner>panel</owner> - <type>string</type> - <default>00000001</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000001/position</key> - <owner>panel</owner> - <type>int</type> - <default>1</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000001/matecomponent_iid</key> - <owner>panel</owner> - <type>string</type> - <default>OAFIID:MATE_TasklistApplet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000001/panel_right_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000002/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>matecomponent-applet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000002/panel_id</key> - <owner>panel</owner> - <type>string</type> - <default>00000001</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000002/position</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000002/matecomponent_iid</key> - <owner>panel</owner> - <type>string</type> - <default>OAFIID:MATE_PagerApplet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000002/panel_right_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000003/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>matecomponent-applet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000003/panel_id</key> - <owner>panel</owner> - <type>string</type> - <default>00000002</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000003/position</key> - <owner>panel</owner> - <type>int</type> - <default>-1</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000003/matecomponent_iid</key> - <owner>panel</owner> - <type>string</type> - <default>OAFIID:MATE_MixerApplet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000003/panel_right_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000004/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>matecomponent-applet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000004/panel_id</key> - <owner>panel</owner> - <type>string</type> - <default>00000002</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000004/position</key> - <owner>panel</owner> - <type>int</type> - <default>-1</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000004/matecomponent_iid</key> - <owner>panel</owner> - <type>string</type> - <default>OAFIID:MATE_ClockApplet</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/applets/00000004/panel_right_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_type</key> - <owner>panel</owner> - <type>string</type> - <default>menu-panel</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_size</key> - <owner>panel</owner> - <type>string</type> - <default>panel-size-x-small</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/screen</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/monitor</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_background_type</key> - <owner>panel</owner> - <type>string</type> - <default>no-background</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_background_pixmap</key> - <owner>panel</owner> - <type>string</type> - <default> </default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_background_pixmap_fit</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_background_pixmap_stretch</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_background_pixmap_rotate</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/panel_background_color</key> - <owner>panel</owner> - <type>string</type> - <default>#000000</default> - <locale name="C"/> - </schema> - - <schema> - <key>/schemas/apps/panel/default_profiles/medium/panels/00000002/clock_format</key> - <owner>panel</owner> - <type>string</type> - <default>%I:%M %p</default> - <locale name="C"/> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/mate-panel/panel-config-global.c b/mate-panel/panel-config-global.c index 1ed3348a..32687748 100644 --- a/mate-panel/panel-config-global.c +++ b/mate-panel/panel-config-global.c @@ -21,6 +21,7 @@ * Authors: * Mark McLoughlin <[email protected]> * Glynn Foster <[email protected]> + * Stefano Karapetsas <[email protected]> */ #include <config.h> @@ -28,10 +29,9 @@ #include "panel-config-global.h" #include <string.h> -#include <mateconf/mateconf.h> +#include <gio/gio.h> #include "panel-globals.h" -#include "panel-mateconf.h" typedef struct { guint tooltips_enabled : 1; @@ -43,6 +43,7 @@ typedef struct { static GlobalConfig global_config = { 0, }; static gboolean global_config_initialised = FALSE; +static GSettings *panel_global_settings = NULL; gboolean panel_global_config_get_highlight_when_over (void) @@ -85,69 +86,56 @@ panel_global_config_get_confirm_panel_remove (void) } static void -panel_global_config_set_entry (MateConfEntry *entry) +panel_global_config_set_entry (GSettings *settings, gchar *key) { - MateConfValue *value; - const char *key; + g_return_if_fail (settings != NULL); + g_return_if_fail (key != NULL); - g_return_if_fail (entry != NULL); - - value = mateconf_entry_get_value (entry); - key = panel_mateconf_basename (mateconf_entry_get_key (entry)); - - if (!value || !key) - return; - - if (strcmp (key, "tooltips_enabled") == 0) + if (strcmp (key, "tooltips-enabled") == 0) global_config.tooltips_enabled = - mateconf_value_get_bool (value); + g_settings_get_boolean (settings, key); - else if (strcmp (key, "enable_animations") == 0) + else if (strcmp (key, "enable-animations") == 0) global_config.enable_animations = - mateconf_value_get_bool (value); + g_settings_get_boolean (settings, key); - else if (strcmp (key, "drawer_autoclose") == 0) + else if (strcmp (key, "drawer-autoclose") == 0) global_config.drawer_auto_close = - mateconf_value_get_bool (value); + g_settings_get_boolean (settings, key); - else if (strcmp (key, "confirm_panel_remove") == 0) + else if (strcmp (key, "confirm-panel-remove") == 0) global_config.confirm_panel_remove = - mateconf_value_get_bool (value); + g_settings_get_boolean (settings, key); - else if (strcmp (key, "highlight_launchers_on_mouseover") == 0) + else if (strcmp (key, "highlight-launchers-on-mouseover") == 0) global_config.highlight_when_over = - mateconf_value_get_bool (value); + g_settings_get_boolean (settings, key); } static void -panel_global_config_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +panel_global_config_notify (GSettings *settings, + gchar *key, + gpointer user_data) { - panel_global_config_set_entry (entry); + panel_global_config_set_entry (settings, key); } void panel_global_config_load (void) { - MateConfClient *client; - GSList *l, *entries; - const char *key = "/apps/panel/global"; - - client = panel_mateconf_get_client (); + gchar **keys; + gint i; - mateconf_client_add_dir (client, key, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); + panel_global_settings = g_settings_new ("org.mate.panel"); - entries = mateconf_client_all_entries (client, key, NULL); + keys = g_settings_list_keys (panel_global_settings); - for (l = entries; l; l = l->next) { - panel_global_config_set_entry (l->data); - mateconf_entry_unref (l->data); + for (i = 0; keys[i]; i++) { + panel_global_config_set_entry (panel_global_settings, keys[i]); } - g_slist_free (entries); + g_strfreev (keys); - mateconf_client_notify_add (client, key, panel_global_config_notify, NULL, NULL, NULL); + g_signal_connect (panel_global_settings, "changed", G_CALLBACK (panel_global_config_notify), NULL); global_config_initialised = TRUE; } diff --git a/mate-panel/panel-default-setup.entries b/mate-panel/panel-default-setup.entries deleted file mode 100644 index c232b4d8..00000000 --- a/mate-panel/panel-default-setup.entries +++ /dev/null @@ -1,657 +0,0 @@ -<mateconfentryfile> - - <entrylist base="/apps/panel/default_setup"> - - <!-- List of toplevels --> - - <entry> - <key>general/toplevel_id_list</key> - <schema_key>/schemas/apps/panel/general/toplevel_id_list</schema_key> - <value> - <list type="string"> - <value> - <string>top_panel</string> - </value> - <value> - <string>bottom_panel</string> - </value> - </list> - </value> - </entry> - - <!-- List of objects --> - - <entry> - <key>general/object_id_list</key> - <schema_key>/schemas/apps/panel/general/object_id_list</schema_key> - <value> - <list type="string"> - <value> - <string>menu_bar</string> - </value> - <value> - <string>browser_launcher</string> - </value> - <value> - <string>email_launcher</string> - </value> - </list> - </value> - </entry> - - <!-- List of applets --> - - <entry> - <key>general/applet_id_list</key> - <schema_key>/schemas/apps/panel/general/applet_id_list</schema_key> - <value> - <list type="string"> - <value> - <string>window_menu</string> - </value> - <value> - <string>clock</string> - </value> - <value> - <string>notification_area</string> - </value> - <value> - <string>show_desktop_button</string> - </value> - <value> - <string>window_list</string> - </value> - <value> - <string>workspace_switcher</string> - </value> - </list> - </value> - </entry> - - <!-- Top Panel --> - - <entry> - <key>toplevels/top_panel/expand</key> - <schema_key>/schemas/apps/panel/toplevels/expand</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>toplevels/top_panel/orientation</key> - <schema_key>/schemas/apps/panel/toplevels/orientation</schema_key> - <value> - <string>top</string> - </value> - </entry> - <entry> - <key>toplevels/top_panel/size</key> - <schema_key>/schemas/apps/panel/toplevels/size</schema_key> - <value> - <int>24</int> - </value> - </entry> - - <entry><key>toplevels/top_panel/name</key><schema_key>/schemas/apps/panel/toplevels/name</schema_key></entry> - <entry><key>toplevels/top_panel/screen</key><schema_key>/schemas/apps/panel/toplevels/screen</schema_key></entry> - <entry><key>toplevels/top_panel/monitor</key><schema_key>/schemas/apps/panel/toplevels/monitor</schema_key></entry> - <entry><key>toplevels/top_panel/x</key><schema_key>/schemas/apps/panel/toplevels/x</schema_key></entry> - <entry><key>toplevels/top_panel/y</key><schema_key>/schemas/apps/panel/toplevels/y</schema_key></entry> - <entry><key>toplevels/top_panel/x_right</key><schema_key>/schemas/apps/panel/toplevels/x_right</schema_key></entry> - <entry><key>toplevels/top_panel/y_bottom</key><schema_key>/schemas/apps/panel/toplevels/y_bottom</schema_key></entry> - <entry><key>toplevels/top_panel/x_centered</key><schema_key>/schemas/apps/panel/toplevels/x_centered</schema_key></entry> - <entry><key>toplevels/top_panel/y_centered</key><schema_key>/schemas/apps/panel/toplevels/y_centered</schema_key></entry> - <entry><key>toplevels/top_panel/auto_hide</key><schema_key>/schemas/apps/panel/toplevels/auto_hide</schema_key></entry> - <entry><key>toplevels/top_panel/enable_animations</key><schema_key>/schemas/apps/panel/toplevels/enable_animations</schema_key></entry> - <entry><key>toplevels/top_panel/enable_buttons</key><schema_key>/schemas/apps/panel/toplevels/enable_buttons</schema_key></entry> - <entry><key>toplevels/top_panel/enable_arrows</key><schema_key>/schemas/apps/panel/toplevels/enable_arrows</schema_key></entry> - <entry><key>toplevels/top_panel/hide_delay</key><schema_key>/schemas/apps/panel/toplevels/hide_delay</schema_key></entry> - <entry><key>toplevels/top_panel/unhide_delay</key><schema_key>/schemas/apps/panel/toplevels/unhide_delay</schema_key></entry> - <entry><key>toplevels/top_panel/auto_hide_size</key><schema_key>/schemas/apps/panel/toplevels/auto_hide_size</schema_key></entry> - <entry><key>toplevels/top_panel/animation_speed</key><schema_key>/schemas/apps/panel/toplevels/animation_speed</schema_key></entry> - <entry><key>toplevels/top_panel/background/type</key><schema_key>/schemas/apps/panel/toplevels/background/type</schema_key></entry> - <entry><key>toplevels/top_panel/background/color</key><schema_key>/schemas/apps/panel/toplevels/background/color</schema_key></entry> - <entry><key>toplevels/top_panel/background/opacity</key><schema_key>/schemas/apps/panel/toplevels/background/opacity</schema_key></entry> - <entry><key>toplevels/top_panel/background/image</key><schema_key>/schemas/apps/panel/toplevels/background/image</schema_key></entry> - <entry><key>toplevels/top_panel/background/fit</key><schema_key>/schemas/apps/panel/toplevels/background/fit</schema_key></entry> - <entry><key>toplevels/top_panel/background/stretch</key><schema_key>/schemas/apps/panel/toplevels/background/stretch</schema_key></entry> - <entry><key>toplevels/top_panel/background/rotate</key><schema_key>/schemas/apps/panel/toplevels/background/rotate</schema_key></entry> - - <!-- Bottom Panel --> - - <entry> - <key>toplevels/bottom_panel/expand</key> - <schema_key>/schemas/apps/panel/toplevels/expand</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>toplevels/bottom_panel/orientation</key> - <schema_key>/schemas/apps/panel/toplevels/orientation</schema_key> - <value> - <string>bottom</string> - </value> - </entry> - <entry> - <key>toplevels/bottom_panel/size</key> - <schema_key>/schemas/apps/panel/toplevels/size</schema_key> - <value> - <int>24</int> - </value> - </entry> - <entry> - <key>toplevels/bottom_panel/y_bottom</key> - <schema_key>/schemas/apps/panel/toplevels/y_bottom</schema_key> - <value> - <int>0</int> - </value> - </entry> - - <entry><key>toplevels/bottom_panel/name</key><schema_key>/schemas/apps/panel/toplevels/name</schema_key></entry> - <entry><key>toplevels/bottom_panel/screen</key><schema_key>/schemas/apps/panel/toplevels/screen</schema_key></entry> - <entry><key>toplevels/bottom_panel/monitor</key><schema_key>/schemas/apps/panel/toplevels/monitor</schema_key></entry> - <entry><key>toplevels/bottom_panel/x</key><schema_key>/schemas/apps/panel/toplevels/x</schema_key></entry> - <entry><key>toplevels/bottom_panel/y</key><schema_key>/schemas/apps/panel/toplevels/y</schema_key></entry> - <entry><key>toplevels/bottom_panel/x_right</key><schema_key>/schemas/apps/panel/toplevels/x_right</schema_key></entry> - <entry><key>toplevels/bottom_panel/x_centered</key><schema_key>/schemas/apps/panel/toplevels/x_centered</schema_key></entry> - <entry><key>toplevels/bottom_panel/y_centered</key><schema_key>/schemas/apps/panel/toplevels/y_centered</schema_key></entry> - <entry><key>toplevels/bottom_panel/auto_hide</key><schema_key>/schemas/apps/panel/toplevels/auto_hide</schema_key></entry> - <entry><key>toplevels/bottom_panel/enable_animations</key><schema_key>/schemas/apps/panel/toplevels/enable_animations</schema_key></entry> - <entry><key>toplevels/bottom_panel/enable_buttons</key><schema_key>/schemas/apps/panel/toplevels/enable_buttons</schema_key></entry> - <entry><key>toplevels/bottom_panel/enable_arrows</key><schema_key>/schemas/apps/panel/toplevels/enable_arrows</schema_key></entry> - <entry><key>toplevels/bottom_panel/hide_delay</key><schema_key>/schemas/apps/panel/toplevels/hide_delay</schema_key></entry> - <entry><key>toplevels/bottom_panel/unhide_delay</key><schema_key>/schemas/apps/panel/toplevels/unhide_delay</schema_key></entry> - <entry><key>toplevels/bottom_panel/auto_hide_size</key><schema_key>/schemas/apps/panel/toplevels/auto_hide_size</schema_key></entry> - <entry><key>toplevels/bottom_panel/animation_speed</key><schema_key>/schemas/apps/panel/toplevels/animation_speed</schema_key></entry> - <entry><key>toplevels/bottom_panel/background/type</key><schema_key>/schemas/apps/panel/toplevels/background/type</schema_key></entry> - <entry><key>toplevels/bottom_panel/background/color</key><schema_key>/schemas/apps/panel/toplevels/background/color</schema_key></entry> - <entry><key>toplevels/bottom_panel/background/opacity</key><schema_key>/schemas/apps/panel/toplevels/background/opacity</schema_key></entry> - <entry><key>toplevels/bottom_panel/background/image</key><schema_key>/schemas/apps/panel/toplevels/background/image</schema_key></entry> - <entry><key>toplevels/bottom_panel/background/fit</key><schema_key>/schemas/apps/panel/toplevels/background/fit</schema_key></entry> - <entry><key>toplevels/bottom_panel/background/stretch</key><schema_key>/schemas/apps/panel/toplevels/background/stretch</schema_key></entry> - <entry><key>toplevels/bottom_panel/background/rotate</key><schema_key>/schemas/apps/panel/toplevels/background/rotate</schema_key></entry> - - <!-- Menu Bar --> - - <entry> - <key>objects/menu_bar/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>menu-bar</string> - </value> - </entry> - <entry> - <key>objects/menu_bar/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>top_panel</string> - </value> - </entry> - <entry> - <key>objects/menu_bar/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>0</int> - </value> - </entry> - <entry> - <key>objects/menu_bar/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>false</bool> - </value> - </entry> - <entry> - <key>objects/menu_bar/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - - <entry><key>objects/menu_bar/applet_iid</key><schema_key>/schemas/apps/panel/objects/applet_iid</schema_key></entry> - <entry><key>objects/menu_bar/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>objects/menu_bar/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>objects/menu_bar/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>objects/menu_bar/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>objects/menu_bar/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>objects/menu_bar/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>objects/menu_bar/launcher_location</key><schema_key>/schemas/apps/panel/objects/launcher_location</schema_key></entry> - <entry><key>objects/menu_bar/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Browser Launcher --> - - <entry> - <key>objects/browser_launcher/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>launcher-object</string> - </value> - </entry> - <entry> - <key>objects/browser_launcher/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>top_panel</string> - </value> - </entry> - <entry> - <key>objects/browser_launcher/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>1</int> - </value> - </entry> - <entry> - <key>objects/browser_launcher/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>false</bool> - </value> - </entry> - <entry> - <key>objects/browser_launcher/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>objects/browser_launcher/launcher_location</key> - <schema_key>/schemas/apps/panel/objects/launcher_location</schema_key> - <value> - <string>firefox.desktop</string> - </value> - </entry> - - <entry><key>objects/browser_launcher/applet_iid</key><schema_key>/schemas/apps/panel/objects/applet_iid</schema_key></entry> - <entry><key>objects/browser_launcher/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>objects/browser_launcher/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>objects/browser_launcher/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>objects/browser_launcher/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>objects/browser_launcher/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>objects/browser_launcher/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>objects/browser_launcher/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Email Launcher --> - - <entry> - <key>objects/email_launcher/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>launcher-object</string> - </value> - </entry> - <entry> - <key>objects/email_launcher/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>top_panel</string> - </value> - </entry> - <entry> - <key>objects/email_launcher/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>2</int> - </value> - </entry> - <entry> - <key>objects/email_launcher/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>false</bool> - </value> - </entry> - <entry> - <key>objects/email_launcher/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>objects/email_launcher/launcher_location</key> - <schema_key>/schemas/apps/panel/objects/launcher_location</schema_key> - <value> - <string>thunderbird.desktop</string> - </value> - </entry> - - <entry><key>objects/email_launcher/applet_iid</key><schema_key>/schemas/apps/panel/objects/applet_iid</schema_key></entry> - <entry><key>objects/email_launcher/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>objects/email_launcher/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>objects/email_launcher/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>objects/email_launcher/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>objects/email_launcher/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>objects/email_launcher/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>objects/email_launcher/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Window Menu Applet --> - - <entry> - <key>applets/window_menu/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>external-applet</string> - </value> - </entry> - <entry> - <key>applets/window_menu/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>top_panel</string> - </value> - </entry> - <entry> - <key>applets/window_menu/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>0</int> - </value> - </entry> - <entry> - <key>applets/window_menu/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/window_menu/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/window_menu/applet_iid</key> - <schema_key>/schemas/apps/panel/objects/applet_iid</schema_key> - <value> - <string>WnckletFactory::WindowMenuApplet</string> - </value> - </entry> - - <entry><key>applets/window_menu/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>applets/window_menu/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>applets/window_menu/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>applets/window_menu/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>applets/window_menu/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>applets/window_menu/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>applets/window_menu/launcher_location</key><schema_key>/schemas/apps/panel/objects/launcher_location</schema_key></entry> - <entry><key>applets/window_menu/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Clock Applet --> - - <entry> - <key>applets/clock/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>external-applet</string> - </value> - </entry> - <entry> - <key>applets/clock/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>top_panel</string> - </value> - </entry> - <entry> - <key>applets/clock/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>2</int> - </value> - </entry> - <entry> - <key>applets/clock/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/clock/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/clock/applet_iid</key> - <schema_key>/schemas/apps/panel/objects/applet_iid</schema_key> - <value> - <string>ClockAppletFactory::ClockApplet</string> - </value> - </entry> - - <entry><key>applets/clock/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>applets/clock/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>applets/clock/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>applets/clock/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>applets/clock/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>applets/clock/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>applets/clock/launcher_location</key><schema_key>/schemas/apps/panel/objects/launcher_location</schema_key></entry> - <entry><key>applets/clock/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Notification Area Applet --> - - <entry> - <key>applets/notification_area/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>external-applet</string> - </value> - </entry> - <entry> - <key>applets/notification_area/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>top_panel</string> - </value> - </entry> - <entry> - <key>applets/notification_area/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>3</int> - </value> - </entry> - <entry> - <key>applets/notification_area/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/notification_area/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/notification_area/applet_iid</key> - <schema_key>/schemas/apps/panel/objects/applet_iid</schema_key> - <value> - <string>NotificationAreaAppletFactory::NotificationArea</string> - </value> - </entry> - - <entry><key>applets/notification_area/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>applets/notification_area/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>applets/notification_area/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>applets/notification_area/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>applets/notification_area/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>applets/notification_area/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>applets/notification_area/launcher_location</key><schema_key>/schemas/apps/panel/objects/launcher_location</schema_key></entry> - <entry><key>applets/notification_area/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Show Desktop Applet --> - - <entry> - <key>applets/show_desktop_button/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>external-applet</string> - </value> - </entry> - <entry> - <key>applets/show_desktop_button/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>bottom_panel</string> - </value> - </entry> - <entry> - <key>applets/show_desktop_button/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>0</int> - </value> - </entry> - <entry> - <key>applets/show_desktop_button/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>false</bool> - </value> - </entry> - <entry> - <key>applets/show_desktop_button/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/show_desktop_button/applet_iid</key> - <schema_key>/schemas/apps/panel/objects/applet_iid</schema_key> - <value> - <string>WnckletFactory::ShowDesktopApplet</string> - </value> - </entry> - - <entry><key>applets/show_desktop_button/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>applets/show_desktop_button/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>applets/show_desktop_button/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>applets/show_desktop_button/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>applets/show_desktop_button/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>applets/show_desktop_button/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>applets/show_desktop_button/launcher_location</key><schema_key>/schemas/apps/panel/objects/launcher_location</schema_key></entry> - <entry><key>applets/show_desktop_button/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Window List Applet --> - - <entry> - <key>applets/window_list/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>external-applet</string> - </value> - </entry> - <entry> - <key>applets/window_list/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>bottom_panel</string> - </value> - </entry> - <entry> - <key>applets/window_list/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>1</int> - </value> - </entry> - <entry> - <key>applets/window_list/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>false</bool> - </value> - </entry> - <entry> - <key>applets/window_list/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/window_list/applet_iid</key> - <schema_key>/schemas/apps/panel/objects/applet_iid</schema_key> - <value> - <string>WnckletFactory::WindowListApplet</string> - </value> - </entry> - - <entry><key>applets/window_list/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>applets/window_list/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>applets/window_list/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>applets/window_list/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>applets/window_list/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>applets/window_list/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>applets/window_list/launcher_location</key><schema_key>/schemas/apps/panel/objects/launcher_location</schema_key></entry> - <entry><key>applets/window_list/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - <!-- Workspace Switcher Applet --> - - <entry> - <key>applets/workspace_switcher/object_type</key> - <schema_key>/schemas/apps/panel/objects/object_type</schema_key> - <value> - <string>external-applet</string> - </value> - </entry> - <entry> - <key>applets/workspace_switcher/toplevel_id</key> - <schema_key>/schemas/apps/panel/objects/toplevel_id</schema_key> - <value> - <string>bottom_panel</string> - </value> - </entry> - <entry> - <key>applets/workspace_switcher/position</key> - <schema_key>/schemas/apps/panel/objects/position</schema_key> - <value> - <int>0</int> - </value> - </entry> - <entry> - <key>applets/workspace_switcher/panel_right_stick</key> - <schema_key>/schemas/apps/panel/objects/panel_right_stick</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/workspace_switcher/locked</key> - <schema_key>/schemas/apps/panel/objects/locked</schema_key> - <value> - <bool>true</bool> - </value> - </entry> - <entry> - <key>applets/workspace_switcher/applet_iid</key> - <schema_key>/schemas/apps/panel/objects/applet_iid</schema_key> - <value> - <string>WnckletFactory::WorkspaceSwitcherApplet</string> - </value> - </entry> - - <entry><key>applets/workspace_switcher/attached_toplevel_id</key><schema_key>/schemas/apps/panel/objects/attached_toplevel_id</schema_key> </entry> - <entry><key>applets/workspace_switcher/tooltip</key><schema_key>/schemas/apps/panel/objects/tooltip</schema_key></entry> - <entry><key>applets/workspace_switcher/use_custom_icon</key><schema_key>/schemas/apps/panel/objects/use_custom_icon</schema_key></entry> - <entry><key>applets/workspace_switcher/custom_icon</key><schema_key>/schemas/apps/panel/objects/custom_icon</schema_key></entry> - <entry><key>applets/workspace_switcher/use_menu_path</key><schema_key>/schemas/apps/panel/objects/use_menu_path</schema_key></entry> - <entry><key>applets/workspace_switcher/menu_path</key><schema_key>/schemas/apps/panel/objects/menu_path</schema_key></entry> - <entry><key>applets/workspace_switcher/launcher_location</key><schema_key>/schemas/apps/panel/objects/launcher_location</schema_key></entry> - <entry><key>applets/workspace_switcher/action_type</key><schema_key>/schemas/apps/panel/objects/action_type</schema_key></entry> - - </entrylist> - -</mateconfentryfile> diff --git a/mate-panel/panel-enums-gsettings.h b/mate-panel/panel-enums-gsettings.h new file mode 100644 index 00000000..70600c47 --- /dev/null +++ b/mate-panel/panel-enums-gsettings.h @@ -0,0 +1,79 @@ +/* + * panel-enums-gsettings.h: + * + * Copyright (C) 2003 Sun Microsystems, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + + * Authors: + * Mark McLoughlin <[email protected]> + * Stefano Karapetsas <[email protected]> + */ + +#ifndef __PANEL_ENUMS_GSETTINGS_H__ +#define __PANEL_ENUMS_GSETTINGS_H__ + +#include <glib.h> + +G_BEGIN_DECLS + +typedef enum { /*< flags=0 >*/ + PANEL_ORIENTATION_TOP = 1 << 0, + PANEL_ORIENTATION_RIGHT = 1 << 1, + PANEL_ORIENTATION_BOTTOM = 1 << 2, + PANEL_ORIENTATION_LEFT = 1 << 3 +} PanelOrientation; + +typedef enum { + PANEL_ANIMATION_SLOW = 0, + PANEL_ANIMATION_MEDIUM = 1, + PANEL_ANIMATION_FAST = 2 +} PanelAnimationSpeed; + +typedef enum { + PANEL_BACK_NONE = 0, + PANEL_BACK_COLOR = 1, + PANEL_BACK_IMAGE = 2 +} PanelBackgroundType; + +typedef enum { + PANEL_OBJECT_DRAWER, + PANEL_OBJECT_MENU, + PANEL_OBJECT_LAUNCHER, + PANEL_OBJECT_APPLET, + PANEL_OBJECT_ACTION, + PANEL_OBJECT_MENU_BAR, + PANEL_OBJECT_SEPARATOR, + /* The following two are for backwards compatibility with 2.0.x */ + PANEL_OBJECT_LOGOUT, + PANEL_OBJECT_LOCK +} PanelObjectType; + +typedef enum { + PANEL_ACTION_NONE = 0, + PANEL_ACTION_LOCK, + PANEL_ACTION_LOGOUT, + PANEL_ACTION_RUN, + PANEL_ACTION_SEARCH, + PANEL_ACTION_FORCE_QUIT, + PANEL_ACTION_CONNECT_SERVER, + PANEL_ACTION_SHUTDOWN, + PANEL_ACTION_LAST +} PanelActionButtonType; + +G_END_DECLS + +#endif /* __PANEL_ENUMS_GSETTINGS_H__ */ diff --git a/mate-panel/panel-enums.h b/mate-panel/panel-enums.h index b9418fbb..6a98ab97 100644 --- a/mate-panel/panel-enums.h +++ b/mate-panel/panel-enums.h @@ -26,17 +26,9 @@ #define __PANEL_ENUMS_H__ #include <glib.h> +#include "panel-enums-gsettings.h" -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - PANEL_ORIENTATION_TOP = 1 << 0, - PANEL_ORIENTATION_RIGHT = 1 << 1, - PANEL_ORIENTATION_BOTTOM = 1 << 2, - PANEL_ORIENTATION_LEFT = 1 << 3 -} PanelOrientation; +G_BEGIN_DECLS #define PANEL_HORIZONTAL_MASK (PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM) #define PANEL_VERTICAL_MASK (PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT) @@ -59,52 +51,10 @@ typedef enum { } PanelState; typedef enum { - PANEL_ANIMATION_SLOW = 0, - PANEL_ANIMATION_MEDIUM = 1, - PANEL_ANIMATION_FAST = 2 -} PanelAnimationSpeed; - -typedef enum { - PANEL_BACK_NONE = 0, - PANEL_BACK_COLOR = 1, - PANEL_BACK_IMAGE = 2 -} PanelBackgroundType; - -typedef enum { - PANEL_MATECONF_TOPLEVELS, - PANEL_MATECONF_OBJECTS, - PANEL_MATECONF_APPLETS -} PanelMateConfKeyType; - -typedef enum { - PANEL_OBJECT_DRAWER, - PANEL_OBJECT_MENU, - PANEL_OBJECT_LAUNCHER, - PANEL_OBJECT_APPLET, - PANEL_OBJECT_ACTION, - PANEL_OBJECT_MENU_BAR, - PANEL_OBJECT_SEPARATOR, - /* The following two are for backwards compatibility with 2.0.x */ - PANEL_OBJECT_LOGOUT, - PANEL_OBJECT_LOCK -} PanelObjectType; - -typedef enum { - PANEL_ACTION_NONE = 0, - PANEL_ACTION_LOCK, - PANEL_ACTION_LOGOUT, - PANEL_ACTION_RUN, - PANEL_ACTION_SEARCH, - PANEL_ACTION_FORCE_QUIT, - PANEL_ACTION_CONNECT_SERVER, - PANEL_ACTION_SHUTDOWN, - /* compatibility with MATE < 2.13.90 */ - PANEL_ACTION_SCREENSHOT, - PANEL_ACTION_LAST -} PanelActionButtonType; + PANEL_GSETTINGS_TOPLEVELS, + PANEL_GSETTINGS_OBJECTS +} PanelGSettingsKeyType; -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __PANEL_ENUMS_H__ */ diff --git a/mate-panel/panel-general.schemas.in b/mate-panel/panel-general.schemas.in deleted file mode 100644 index 1bfc2c7a..00000000 --- a/mate-panel/panel-general.schemas.in +++ /dev/null @@ -1,127 +0,0 @@ -<?xml version="1.0"?> -<mateconfschemafile> - - <schemalist> - - <schema> - <key>/schemas/apps/panel/general/enable_program_list</key> - <applyto>/apps/panel/general/enable_program_list</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Enable program list in "Run Application" dialog</short> - <long> - If true, the "Known Applications" listing in the "Run - Application" dialog is made available. Whether or not - the listing is expanded when the dialog is shown is - controlled by the show_program_list key. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/general/show_program_list</key> - <applyto>/apps/panel/general/show_program_list</applyto> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Expand program list in "Run Application" dialog</short> - <long> - If true, the "Known Applications" listing in the "Run - Application" dialog is expanded when the dialog is opened. - This key is only relevant if the enable_program_list key - is true. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/general/enable_autocompletion</key> - <applyto>/apps/panel/general/enable_autocompletion</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Enable autocompletion in "Run Application" dialog</short> - <long> - If true, autocompletion in the "Run Application" dialog is - made available. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/general/toplevel_id_list</key> - <applyto>/apps/panel/general/toplevel_id_list</applyto> - <owner>panel</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>Panel ID list</short> - <long> - A list of panel IDs. Each ID identifies an individual - toplevel panel. The settings for each of these panels are - stored in /apps/panel/toplevels/$(id). - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/general/applet_id_list</key> - <applyto>/apps/panel/general/applet_id_list</applyto> - <owner>panel</owner> - <list_type>string</list_type> - <type>list</type> - <default>[]</default> - <locale name="C"> - <short>Panel applet ID list</short> - <long> - A list of panel applet IDs. Each ID identifies an - individual panel applet. The settings for each of - these applets are stored in - /apps/panel/applets/$(id). - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/general/object_id_list</key> - <applyto>/apps/panel/general/object_id_list</applyto> - <owner>panel</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>Panel object ID list</short> - <long> - A list of panel object IDs. Each ID identifies an individual - panel object (e.g. a launcher, action button or menu - button/bar). The settings for each of these objects are - stored in - /apps/panel/objects/$(id). - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/general/profiles_migrated</key> - <applyto>/apps/panel/general/profiles_migrated</applyto> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Old profiles configuration migrated</short> - <long> - A boolean flag to indicate whether the user's previous - configuration in /apps/panel/profiles/default has been - copied to the new location in /apps/panel. - </long> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/mate-panel/panel-global.schemas.in b/mate-panel/panel-global.schemas.in deleted file mode 100644 index f99c5b28..00000000 --- a/mate-panel/panel-global.schemas.in +++ /dev/null @@ -1,276 +0,0 @@ -<?xml version="1.0"?> -<mateconfschemafile> - -<!-- -Panel Global Config Schema File - work in progress ---> - - <schemalist> - - <schema> - <key>/schemas/apps/panel/global/tooltips_enabled</key> - <applyto>/apps/panel/global/tooltips_enabled</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Enable tooltips</short> - <long>If true, tooltips are shown for objects in panels. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/keep_menus_in_memory</key> - <applyto>/apps/panel/global/keep_menus_in_memory</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/enable_animations</key> - <applyto>/apps/panel/global/enable_animations</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Enable animations</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/panel_minimized_size</key> - <applyto>/apps/panel/global/panel_minimized_size</applyto> - <owner>panel</owner> - <type>int</type> - <default>3</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/panel_show_delay</key> - <applyto>/apps/panel/global/panel_show_delay</applyto> - <owner>panel</owner> - <type>int</type> - <default>300</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/panel_animation_speed</key> - <applyto>/apps/panel/global/panel_animation_speed</applyto> - <owner>panel</owner> - <type>string</type> - <default>panel-speed-medium</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/panel_hide_delay</key> - <applyto>/apps/panel/global/panel_hide_delay</applyto> - <owner>panel</owner> - <type>int</type> - <default>500</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/enable_key_bindings</key> - <applyto>/apps/panel/global/enable_key_bindings</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/menu_key</key> - <applyto>/apps/panel/global/menu_key</applyto> - <owner>panel</owner> - <type>string</type> - <default><Alt>F1</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/run_key</key> - <applyto>/apps/panel/global/run_key</applyto> - <owner>panel</owner> - <type>string</type> - <default><Alt>F2</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/screenshot_key</key> - <applyto>/apps/panel/global/screenshot_key</applyto> - <owner>panel</owner> - <type>string</type> - <default>Print</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/window_screenshot_key</key> - <applyto>/apps/panel/global/window_screenshot_key</applyto> - <owner>panel</owner> - <type>string</type> - <default><Alt>Print</default> - <locale name="C"> - <short>Deprecated</short> - <long></long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/drawer_autoclose</key> - <applyto>/apps/panel/global/drawer_autoclose</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Autoclose drawer</short> - <long>If true, a drawer will automatically be closed - when the user clicks a launcher in it. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/confirm_panel_remove</key> - <applyto>/apps/panel/global/confirm_panel_remove</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Confirm panel removal</short> - <long>If true, a dialog is shown asking for confirmation - if the user wants to remove a panel. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/highlight_launchers_on_mouseover</key> - <applyto>/apps/panel/global/highlight_launchers_on_mouseover</applyto> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Highlight launchers on mouseover</short> - <long>If true, a launcher is highlighted when the user - moves the pointer over it. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/locked_down</key> - <applyto>/apps/panel/global/locked_down</applyto> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Complete panel lockdown</short> - <long>If true, the panel will not allow any changes to - the configuration of the panel. Individual applets - may need to be locked down separately however. - The panel must be restarted for this to take effect. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/disabled_applets</key> - <applyto>/apps/panel/global/disabled_applets</applyto> - <owner>panel</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>Applet IIDs to disable from loading</short> - <long>A list of applet IIDs that the panel will ignore. This way you - can disable certain applets from loading or showing up in the menu. - For example to disable the mini-commander applet add 'OAFIID:MATE_MiniCommanderApplet' - to this list. The panel must be restarted for this to take effect. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/disable_lock_screen</key> - <applyto>/apps/panel/global/disable_lock_screen</applyto> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Deprecated</short> - <long>This key is deprecated as it cannot be used to implement proper - lockdown. The /desktop/mate/lockdown/disable_lock_screen key - should be used instead. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/disable_log_out</key> - <applyto>/apps/panel/global/disable_log_out</applyto> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Disable Logging Out</short> - <long>If true, the panel will not allow a user to log out, - by removing access to the log out menu entries. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/global/disable_force_quit</key> - <applyto>/apps/panel/global/disable_force_quit</applyto> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Disable Force Quit</short> - <long>If true, the panel will not allow a user to force - an application to quit by removing access to the - force quit button. - </long> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/mate-panel/panel-gsettings.c b/mate-panel/panel-gsettings.c new file mode 100644 index 00000000..44ffe342 --- /dev/null +++ b/mate-panel/panel-gsettings.c @@ -0,0 +1,178 @@ +/* + * panel-gsettings.c: panel gsettings utility methods + * + * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. + * 2012 Stefano Karapetsas + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Authors: + * Mark McLoughlin <[email protected]> + * Glynn Foster <[email protected]> + * Stefano Karapetsas <[email protected]> + */ + +#include <config.h> + +#include "panel-gsettings.h" + +#include <string.h> +#include <glib.h> +#include <gio/gio.h> + +#include <libpanel-util/panel-cleanup.h> + +/* (copied from gnome-panel) + * Adapted from is_valid_keyname() in glib (gio/glib-compile-schemas.c) + * Differences: + * - gettext support removed (we don't need translations here) + * - remove support for allow_any_name + */ +gboolean +panel_gsettings_is_valid_keyname (const gchar *key, + GError **error) +{ + gint i; + + if (key[0] == '\0') + { + g_set_error_literal (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + "empty names are not permitted"); + return FALSE; + } + + if (!g_ascii_islower (key[0])) + { + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + "invalid name '%s': names must begin " + "with a lowercase letter", key); + return FALSE; + } + + for (i = 1; key[i]; i++) + { + if (key[i] != '-' && + !g_ascii_islower (key[i]) && + !g_ascii_isdigit (key[i])) + { + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + "invalid name '%s': invalid character '%c'; " + "only lowercase letters, numbers and dash ('-') " + "are permitted.", key, key[i]); + return FALSE; + } + + if (key[i] == '-' && key[i + 1] == '-') + { + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + "invalid name '%s': two successive dashes ('--') " + "are not permitted.", key); + return FALSE; + } + } + + if (key[i - 1] == '-') + { + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + "invalid name '%s': the last character may not be a " + "dash ('-').", key); + return FALSE; + } + + if (i > 32) + { + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + "invalid name '%s': maximum length is 32", key); + return FALSE; + } + + return TRUE; +} + +/* copied from gnome-panel */ +gboolean +panel_gsettings_append_strv (GSettings *settings, + const gchar *key, + const gchar *value) +{ + gchar **old; + gchar **new; + gint size; + gboolean retval; + + old = g_settings_get_strv (settings, key); + + for (size = 0; old[size] != NULL; size++); + + size += 1; /* appended value */ + size += 1; /* NULL */ + + new = g_realloc_n (old, size, sizeof (gchar *)); + + new[size - 2] = g_strdup (value); + new[size - 1] = NULL; + + retval = g_settings_set_strv (settings, key, + (const gchar **) new); + + g_strfreev (new); + + return retval; +} + +/* copied from gnome-panel */ +gboolean +panel_gsettings_remove_all_from_strv (GSettings *settings, + const gchar *key, + const gchar *value) +{ + GArray *array; + gchar **old; + gint i; + gboolean retval; + + old = g_settings_get_strv (settings, key); + array = g_array_new (TRUE, TRUE, sizeof (gchar *)); + + for (i = 0; old[i] != NULL; i++) { + if (g_strcmp0 (old[i], value) != 0) + array = g_array_append_val (array, old[i]); + } + + retval = g_settings_set_strv (settings, key, + (const gchar **) array->data); + + g_strfreev (old); + g_array_free (array, TRUE); + + return retval; +} + + + +/* convert a gchar ** to GList (taken from libmatekbd code) */ +GSList* +panel_gsettings_strv_to_gslist (gchar **array) +{ + GSList *list = NULL; + gint i; + if (array != NULL) { + for (i = 0; array[i]; i++) { + list = g_slist_append (list, g_strdup (array[i])); + } + } + return list; +} diff --git a/mate-panel/panel-gsettings.h b/mate-panel/panel-gsettings.h new file mode 100644 index 00000000..ac606207 --- /dev/null +++ b/mate-panel/panel-gsettings.h @@ -0,0 +1,53 @@ +/* + * panel-gsettings.h: panel gsettings utility methods + * + * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. + * 2012 Stefano Karapetsas + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Authors: + * Mark McLoughlin <[email protected]> + * Glynn Foster <[email protected]> + * Stefano Karapetsas <[email protected]> + */ + +#ifndef __PANEL_GSETTINGS_H__ +#define __PANEL_GSETTINGS_H__ + +#include <glib.h> +#include <gio/gio.h> + +#include "panel-enums.h" + +G_BEGIN_DECLS + +gboolean panel_gsettings_is_valid_keyname (const gchar *key, + GError **error); + +gboolean panel_gsettings_append_strv (GSettings *settings, + const gchar *key, + const gchar *value); + +gboolean panel_gsettings_remove_all_from_strv (GSettings *settings, + const gchar *key, + const gchar *value); + +GSList* panel_gsettings_strv_to_gslist (gchar **array); + +G_END_DECLS + +#endif /* __PANEL_GSETTINGS_H__ */ diff --git a/mate-panel/panel-layout.c b/mate-panel/panel-layout.c new file mode 100644 index 00000000..76e7747a --- /dev/null +++ b/mate-panel/panel-layout.c @@ -0,0 +1,353 @@ +/* + * panel-layout.c: methods to load default panels from file + * + * Copyright (C) 2011 Novell, Inc. + * 2012 Stefano Karapetsas + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Authors: + * Stefano Karapetsas <[email protected]> + */ + +#include <config.h> +#include <string.h> + +#include <glib.h> +#include <gio/gio.h> + +#include <libpanel-util/panel-dconf.h> + +#include "panel-layout.h" +#include "panel-profile.h" +#include "panel-gsettings.h" +#include "panel-schemas.h" +#include "panel-enums.h" + +#define PANEL_LAYOUT_MATE_FILE PANELDATADIR "/panel-default-layout.mate" +#define PANEL_LAYOUT_DIST_FILE PANELDATADIR "/panel-default-layout.dist" + +typedef struct { + const char *name; + GType type; +} PanelLayoutKeyDefinition; + +static PanelLayoutKeyDefinition panel_layout_toplevel_keys[] = { + { PANEL_TOPLEVEL_NAME_KEY, G_TYPE_STRING }, + { PANEL_TOPLEVEL_SCREEN_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_MONITOR_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_EXPAND_KEY, G_TYPE_BOOLEAN }, + { PANEL_TOPLEVEL_ORIENTATION_KEY, G_TYPE_STRING }, + { PANEL_TOPLEVEL_SIZE_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_X_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_Y_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_X_RIGHT_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_Y_BOTTOM_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_X_CENTERED_KEY, G_TYPE_BOOLEAN }, + { PANEL_TOPLEVEL_Y_CENTERED_KEY, G_TYPE_BOOLEAN }, + { PANEL_TOPLEVEL_AUTO_HIDE_KEY, G_TYPE_BOOLEAN }, + { PANEL_TOPLEVEL_ENABLE_ANIMATIONS_KEY, G_TYPE_BOOLEAN }, + { PANEL_TOPLEVEL_ENABLE_BUTTONS_KEY, G_TYPE_BOOLEAN }, + { PANEL_TOPLEVEL_ENABLE_ARROWS_KEY, G_TYPE_BOOLEAN }, + { PANEL_TOPLEVEL_HIDE_DELAY_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_UNHIDE_DELAY_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_AUTO_HIDE_SIZE_KEY, G_TYPE_INT }, + { PANEL_TOPLEVEL_ANIMATION_SPEED_KEY, G_TYPE_STRING } +}; + +static PanelLayoutKeyDefinition panel_layout_object_keys[] = { + { PANEL_OBJECT_TYPE_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_TOPLEVEL_ID_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_POSITION_KEY, G_TYPE_INT }, + { PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, G_TYPE_BOOLEAN }, + { PANEL_OBJECT_LOCKED_KEY, G_TYPE_BOOLEAN }, + { PANEL_OBJECT_APPLET_IID_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_ATTACHED_TOPLEVEL_ID_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_TOOLTIP_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_USE_CUSTOM_ICON_KEY, G_TYPE_BOOLEAN }, + { PANEL_OBJECT_CUSTOM_ICON_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_USE_MENU_PATH_KEY, G_TYPE_BOOLEAN }, + { PANEL_OBJECT_MENU_PATH_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_HAS_ARROW_KEY, G_TYPE_BOOLEAN }, + { PANEL_OBJECT_LAUNCHER_LOCATION_KEY, G_TYPE_STRING }, + { PANEL_OBJECT_ACTION_TYPE_KEY, G_TYPE_STRING } +}; + +/* + * return the default layout file path, making it overridable by + * distributions + */ +static gchar * +panel_layout_filename () { + + if (g_file_test (PANEL_LAYOUT_DIST_FILE, G_FILE_TEST_IS_REGULAR)) { + return g_strdup (PANEL_LAYOUT_DIST_FILE); + } + else if (g_file_test (PANEL_LAYOUT_MATE_FILE, G_FILE_TEST_IS_REGULAR)) { + return g_strdup (PANEL_LAYOUT_MATE_FILE); + } + else { + return NULL; + } +} + +static gboolean +panel_layout_append_group_helper (GKeyFile *keyfile, + const char *group, + int set_screen_to, + const char *group_prefix, + char *id_list_key, + const char *schema, + const char *path_prefix, + const char *default_prefix, + PanelLayoutKeyDefinition *key_definitions, + int key_definitions_len, + const char *type_for_error_message) +{ + gboolean retval = FALSE; + const char *id; + char *unique_id = NULL; + char *path = NULL; + GSettings *settings = NULL; + char **keyfile_keys = NULL; + char *value_str; + int value_int; + gboolean value_boolean; + int i, j; + GError *error = NULL; + gchar **existing_ids; + gboolean existing_id = FALSE; + gchar *dir = NULL; + gchar *dconf_path = NULL; + PanelGSettingsKeyType type; + + /* Try to extract an id from the group, by stripping the prefix, + * and create a unique id out of that */ + id = group + strlen (group_prefix); + while (g_ascii_isspace (*id)) + id++; + + if (!*id) + id = NULL; + + if (id && !panel_gsettings_is_valid_keyname (id, &error)) { + g_warning ("Invalid id name in layout '%s' (%s)", id, error->message); + g_error_free (error); + return FALSE; + } + + if (g_strcmp0 (id_list_key, PANEL_TOPLEVEL_ID_LIST_KEY) == 0) { + dir = "toplevels"; + type = PANEL_GSETTINGS_TOPLEVELS; + } + if (g_strcmp0 (id_list_key, PANEL_OBJECT_ID_LIST_KEY) == 0) { + dir = "objects"; + type = PANEL_GSETTINGS_OBJECTS; + } + + dconf_path = g_strdup_printf (PANEL_RESOURCE_PATH "/%s", dir); + existing_ids = panel_dconf_list_subdirs (dconf_path, TRUE); + + if (id) { + for (i = 0; existing_ids[i]; i) { + if (!strcmp (existing_ids[i], id)) { + existing_id = TRUE; + } + } + } + g_strfreev (existing_ids); + g_free (dconf_path); + + if (existing_id || !id) + unique_id = panel_profile_find_new_id (type); + else + unique_id = g_strdup (id); + + path = g_strdup_printf ("%s%s/", path_prefix, unique_id); + settings = g_settings_new_with_path (schema, path); + g_free (path); + + keyfile_keys = g_key_file_get_keys (keyfile, group, NULL, NULL); + + if (keyfile_keys) { + + /* validate/add keys from the keyfile */ + for (i = 0; keyfile_keys[i] != NULL; i++) { + gboolean found = FALSE; + + for (j = 0; j < key_definitions_len; j++) { + if (g_strcmp0 (keyfile_keys[i], + key_definitions[j].name) == 0) { + found = TRUE; + break; + } + } + + if (!found) { + g_warning ("Unknown key '%s' for %s", + keyfile_keys[i], + unique_id); + return FALSE; + } + + switch (key_definitions[j].type) { + case G_TYPE_STRING: + value_str = g_key_file_get_string (keyfile, + group, keyfile_keys[i], + NULL); + if (value_str) + g_settings_set_string (settings, + key_definitions[j].name, + value_str); + g_free (value_str); + break; + + case G_TYPE_INT: + value_int = g_key_file_get_integer (keyfile, + group, keyfile_keys[i], + NULL); + g_settings_set_int (settings, + key_definitions[j].name, + value_int); + break; + + case G_TYPE_BOOLEAN: + value_boolean = g_key_file_get_boolean (keyfile, + group, keyfile_keys[i], + NULL); + g_settings_set_boolean (settings, + key_definitions[j].name, + value_boolean); + break; + default: + g_assert_not_reached (); + break; + } + } + + if (set_screen_to != -1 && + g_strcmp0 (schema, PANEL_TOPLEVEL_SCHEMA) == 0) + g_settings_set_int (settings, + PANEL_TOPLEVEL_SCREEN_KEY, + set_screen_to); + + GSettings *panel_settings; + panel_settings = g_settings_new (PANEL_SCHEMA); + panel_gsettings_append_strv (panel_settings, + id_list_key, + unique_id); + g_object_unref (panel_settings); + + retval = TRUE; + } + + if (keyfile_keys) + g_strfreev (keyfile_keys); + + if (settings) + g_object_unref (settings); + + if (unique_id) + g_free (unique_id); + + return retval; +} + +void +panel_layout_apply_default_from_gkeyfile (GdkScreen *screen) +{ + int screen_n; + gchar *layout_file = NULL; + GKeyFile *keyfile = NULL; + gchar **groups = NULL; + GError *error = NULL; + int i; + + screen_n = gdk_screen_get_number (screen); + layout_file = panel_layout_filename(); + + if (layout_file) + { + keyfile = g_key_file_new (); + if (g_key_file_load_from_file (keyfile, + layout_file, + G_KEY_FILE_NONE, + &error)) + { + groups = g_key_file_get_groups (keyfile, NULL); + + for (i = 0; groups[i] != NULL; i++) { + + if (g_strcmp0 (groups[i], "Toplevel") == 0 || + g_str_has_prefix (groups[i], "Toplevel ")) + + panel_layout_append_group_helper ( + keyfile, groups[i], + screen_n, + "Toplevel", + PANEL_TOPLEVEL_ID_LIST_KEY, + PANEL_TOPLEVEL_SCHEMA, + PANEL_TOPLEVEL_PATH, + PANEL_TOPLEVEL_DEFAULT_PREFIX, + panel_layout_toplevel_keys, + G_N_ELEMENTS (panel_layout_toplevel_keys), + "toplevel"); + + else if (g_strcmp0 (groups[i], "Object") == 0 || + g_str_has_prefix (groups[i], "Object ")) + + panel_layout_append_group_helper ( + keyfile, groups[i], + -1, + "Object", + PANEL_OBJECT_ID_LIST_KEY, + PANEL_OBJECT_SCHEMA, + PANEL_OBJECT_PATH, + PANEL_OBJECT_DEFAULT_PREFIX, + panel_layout_object_keys, + G_N_ELEMENTS (panel_layout_object_keys), + "object"); + + else + + g_warning ("Unknown group in default layout: '%s'", + groups[i]); + + } + + } + else + { + g_warning ("Error while parsing default layout from '%s': %s\n", + layout_file, error->message); + g_error_free (error); + } + + } + else { + g_warning ("Cant find a default layout file!"); + /* FIXME implement a fallback panel */ + } + + if (groups) + g_strfreev (groups); + + if (keyfile) + g_key_file_free (keyfile); + + if (layout_file) + g_free (layout_file); +} diff --git a/matecomponent/panel-module/mate-panel-applets-matecomponent-module.c b/mate-panel/panel-layout.h index 5713ebc4..3d50e292 100644 --- a/matecomponent/panel-module/mate-panel-applets-matecomponent-module.c +++ b/mate-panel/panel-layout.h @@ -1,5 +1,7 @@ /* - * Copyright (C) 2010 Novell, Inc. + * panel-layout.h: methods to load default panels from file + * + * Copyright (C) 2012 Stefano Karapetsas * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,33 +18,21 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * - * Author: Vincent Untz <[email protected]> + * Authors: + * Stefano Karapetsas <[email protected]> */ -#include "config.h" +#ifndef __PANEL_LAYOUT_H__ +#define __PANEL_LAYOUT_H__ +#include <glib.h> #include <gio/gio.h> +#include <gdk/gdk.h> -#include <mate-panel-applets-manager.h> -#include "mate-panel-applets-manager-matecomponent.h" +G_BEGIN_DECLS -void -g_io_module_load (GIOModule *module) -{ - mate_panel_applets_manager_matecomponent_register (module); -} +void panel_layout_apply_default_from_gkeyfile (GdkScreen *screen); -void -g_io_module_unload (GIOModule *module) -{ -} +G_END_DECLS -char ** -g_io_module_query (void) -{ - char *eps[] = { - MATE_PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME, - NULL - }; - return g_strdupv (eps); -} +#endif /* __PANEL_LAYOUT_H__ */ diff --git a/mate-panel/panel-lockdown.c b/mate-panel/panel-lockdown.c index e484b016..953944c6 100644 --- a/mate-panel/panel-lockdown.c +++ b/mate-panel/panel-lockdown.c @@ -27,18 +27,8 @@ #include "panel-lockdown.h" #include <string.h> -#include "panel-mateconf.h" - -#define N_LISTENERS 6 - -#define PANEL_GLOBAL_LOCKDOWN_DIR "/apps/panel/global" -#define DESKTOP_MATE_LOCKDOWN_DIR "/desktop/mate/lockdown" -#define PANEL_GLOBAL_LOCKED_DOWN_KEY PANEL_GLOBAL_LOCKDOWN_DIR "/locked_down" -#define DISABLE_COMMAND_LINE_KEY DESKTOP_MATE_LOCKDOWN_DIR "/disable_command_line" -#define DISABLE_LOCK_SCREEN_KEY DESKTOP_MATE_LOCKDOWN_DIR "/disable_lock_screen" -#define DISABLE_LOG_OUT_KEY PANEL_GLOBAL_LOCKDOWN_DIR "/disable_log_out" -#define DISABLE_FORCE_QUIT_KEY PANEL_GLOBAL_LOCKDOWN_DIR "/disable_force_quit" -#define DISABLED_APPLETS_KEY PANEL_GLOBAL_LOCKDOWN_DIR "/disabled_applets" +#include <gio/gio.h> +#include "panel-schemas.h" typedef struct { guint initialized : 1; @@ -49,11 +39,12 @@ typedef struct { guint disable_log_out : 1; guint disable_force_quit : 1; - GSList *disabled_applets; - - guint listeners [N_LISTENERS]; + gchar **disabled_applets; GSList *closures; + + GSettings *panel_settings; + GSettings *lockdown_settings; } PanelLockdown; static PanelLockdown panel_lockdown = { 0, }; @@ -69,148 +60,95 @@ panel_lockdown_invoke_closures (PanelLockdown *lockdown) } static void -locked_down_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +locked_down_notify (GSettings *settings, + gchar *key, PanelLockdown *lockdown) { - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - lockdown->locked_down = mateconf_value_get_bool (entry->value); - + lockdown->locked_down = g_settings_get_boolean (settings, key); panel_lockdown_invoke_closures (lockdown); } static void -disable_command_line_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +disable_command_line_notify (GSettings *settings, + gchar *key, PanelLockdown *lockdown) { - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - lockdown->disable_command_line = mateconf_value_get_bool (entry->value); - + lockdown->disable_command_line = g_settings_get_boolean (settings, key); panel_lockdown_invoke_closures (lockdown); } static void -disable_lock_screen_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +disable_lock_screen_notify (GSettings *settings, + gchar *key, PanelLockdown *lockdown) { - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - lockdown->disable_lock_screen = mateconf_value_get_bool (entry->value); - + lockdown->disable_lock_screen = g_settings_get_boolean (settings, key); panel_lockdown_invoke_closures (lockdown); } static void -disable_log_out_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +disable_log_out_notify (GSettings *settings, + gchar *key, PanelLockdown *lockdown) { - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - lockdown->disable_log_out = mateconf_value_get_bool (entry->value); - + lockdown->disable_log_out = g_settings_get_boolean (settings, key); panel_lockdown_invoke_closures (lockdown); } static void -disable_force_quit_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +disable_force_quit_notify (GSettings *settings, + gchar *key, PanelLockdown *lockdown) { - if (!entry->value || entry->value->type != MATECONF_VALUE_BOOL) - return; - - lockdown->disable_force_quit = mateconf_value_get_bool (entry->value); - + lockdown->disable_force_quit = g_settings_get_boolean (settings, key); panel_lockdown_invoke_closures (lockdown); } static void -disabled_applets_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +disabled_applets_notify (GSettings *settings, + gchar *key, PanelLockdown *lockdown) { - GSList *l; - - if (!entry->value || entry->value->type != MATECONF_VALUE_LIST || - mateconf_value_get_list_type (entry->value) != MATECONF_VALUE_STRING) - return; - - for (l = lockdown->disabled_applets; l; l = l->next) - g_free (l->data); - g_slist_free (lockdown->disabled_applets); - lockdown->disabled_applets = NULL; - - for (l = mateconf_value_get_list (entry->value); l; l = l->next) { - const char *iid = mateconf_value_get_string (l->data); - - lockdown->disabled_applets = - g_slist_prepend (lockdown->disabled_applets, - g_strdup (iid)); - } - + lockdown->disabled_applets = g_settings_get_strv (settings, key); panel_lockdown_invoke_closures (lockdown); } static gboolean panel_lockdown_load_bool (PanelLockdown *lockdown, - MateConfClient *client, + GSettings *settings, const char *key, - MateConfClientNotifyFunc notify_func, - int listener) + GCallback notify_func) { - GError *error = NULL; gboolean retval; + gchar *signal_name; - retval = mateconf_client_get_bool (client, key, &error); - if (error) { - g_warning ("Error getting value of '%s': %s\n", - key, error->message); - retval = FALSE; - } + retval = g_settings_get_boolean (settings, key); + + signal_name = g_strdup_printf ("changed::%s", key); - lockdown->listeners [listener] = - mateconf_client_notify_add (client, - key, - notify_func, - lockdown, - NULL, NULL); + g_signal_connect (settings, + signal_name, + G_CALLBACK (notify_func), + lockdown); + + g_free (signal_name); return retval; } -static GSList * +static gchar ** panel_lockdown_load_disabled_applets (PanelLockdown *lockdown, - MateConfClient *client, - int listener) + GSettings *settings) { - GSList *retval; + gchar **retval; - retval = mateconf_client_get_list (client, - DISABLED_APPLETS_KEY, - MATECONF_VALUE_STRING, - NULL); + retval = g_settings_get_strv (settings, + PANEL_DISABLED_APPLETS_KEY); - lockdown->listeners [listener] = - mateconf_client_notify_add (client, - DISABLED_APPLETS_KEY, - (MateConfClientNotifyFunc) disabled_applets_notify, - lockdown, - NULL, NULL); + g_signal_connect (settings, + "changed::" PANEL_DISABLED_APPLETS_KEY, + G_CALLBACK (disabled_applets_notify), + lockdown); return retval; } @@ -218,62 +156,42 @@ panel_lockdown_load_disabled_applets (PanelLockdown *lockdown, void panel_lockdown_init (void) { - MateConfClient *client; - int i = 0; - - client = panel_mateconf_get_client (); - - mateconf_client_add_dir (client, - DESKTOP_MATE_LOCKDOWN_DIR, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - - mateconf_client_add_dir (client, - PANEL_GLOBAL_LOCKDOWN_DIR, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); + panel_lockdown.panel_settings = g_settings_new (PANEL_SCHEMA); + panel_lockdown.lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA); panel_lockdown.locked_down = panel_lockdown_load_bool (&panel_lockdown, - client, - PANEL_GLOBAL_LOCKED_DOWN_KEY, - (MateConfClientNotifyFunc) locked_down_notify, - i++); + panel_lockdown.panel_settings, + PANEL_LOCKED_DOWN_KEY, + G_CALLBACK (locked_down_notify)); panel_lockdown.disable_command_line = panel_lockdown_load_bool (&panel_lockdown, - client, - DISABLE_COMMAND_LINE_KEY, - (MateConfClientNotifyFunc) disable_command_line_notify, - i++); + panel_lockdown.lockdown_settings, + LOCKDOWN_DISABLE_COMMAND_LINE_KEY, + G_CALLBACK (disable_command_line_notify)); panel_lockdown.disable_lock_screen = panel_lockdown_load_bool (&panel_lockdown, - client, - DISABLE_LOCK_SCREEN_KEY, - (MateConfClientNotifyFunc) disable_lock_screen_notify, - i++); + panel_lockdown.lockdown_settings, + LOCKDOWN_DISABLE_LOCK_SCREEN_KEY, + G_CALLBACK (disable_lock_screen_notify)); panel_lockdown.disable_log_out = panel_lockdown_load_bool (&panel_lockdown, - client, - DISABLE_LOG_OUT_KEY, - (MateConfClientNotifyFunc) disable_log_out_notify, - i++); + panel_lockdown.panel_settings, + PANEL_DISABLE_LOG_OUT_KEY, + G_CALLBACK (disable_log_out_notify)); panel_lockdown.disable_force_quit = panel_lockdown_load_bool (&panel_lockdown, - client, - DISABLE_FORCE_QUIT_KEY, - (MateConfClientNotifyFunc) disable_force_quit_notify, - i++); + panel_lockdown.panel_settings, + PANEL_DISABLE_FORCE_QUIT_KEY, + G_CALLBACK (disable_force_quit_notify)); panel_lockdown.disabled_applets = panel_lockdown_load_disabled_applets (&panel_lockdown, - client, - i++); - - g_assert (i == N_LISTENERS); + panel_lockdown.panel_settings); panel_lockdown.initialized = TRUE; } @@ -281,33 +199,23 @@ panel_lockdown_init (void) void panel_lockdown_finalize (void) { - MateConfClient *client; - GSList *l; - int i; + GSList *l; g_assert (panel_lockdown.initialized != FALSE); - client = panel_mateconf_get_client (); - - for (l = panel_lockdown.disabled_applets; l; l = l->next) - g_free (l->data); - g_slist_free (panel_lockdown.disabled_applets); - panel_lockdown.disabled_applets = NULL; - - for (i = 0; i < N_LISTENERS; i++) { - if (panel_lockdown.listeners [i]) - mateconf_client_notify_remove (client, - panel_lockdown.listeners [i]); - panel_lockdown.listeners [i] = 0; + if (panel_lockdown.disabled_applets) { + g_strfreev (panel_lockdown.disabled_applets); + panel_lockdown.disabled_applets = NULL; } - mateconf_client_remove_dir (client, - PANEL_GLOBAL_LOCKDOWN_DIR, - NULL); - - mateconf_client_remove_dir (client, - DESKTOP_MATE_LOCKDOWN_DIR, - NULL); + if (panel_lockdown.panel_settings) { + g_object_unref (panel_lockdown.panel_settings); + panel_lockdown.panel_settings = NULL; + } + if (panel_lockdown.lockdown_settings) { + g_object_unref (panel_lockdown.lockdown_settings); + panel_lockdown.lockdown_settings = NULL; + } for (l = panel_lockdown.closures; l; l = l->next) g_closure_unref (l->data); @@ -360,13 +268,14 @@ panel_lockdown_get_disable_force_quit (void) gboolean panel_lockdown_is_applet_disabled (const char *iid) { - GSList *l; + gint i; g_assert (panel_lockdown.initialized != FALSE); - for (l = panel_lockdown.disabled_applets; l; l = l->next) - if (!strcmp (l->data, iid)) - return TRUE; + if (panel_lockdown.disabled_applets) + for (i = 0; panel_lockdown.disabled_applets[i]; i++) + if (!strcmp (panel_lockdown.disabled_applets[i], iid)) + return TRUE; return FALSE; } diff --git a/mate-panel/panel-mateconf.c b/mate-panel/panel-mateconf.c deleted file mode 100644 index 974ddb4b..00000000 --- a/mate-panel/panel-mateconf.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * panel-mateconf.c: panel mateconf utility methods - * - * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - * Glynn Foster <[email protected]> - */ - -#include <config.h> - -#include "panel-mateconf.h" - -#include <string.h> -#include <glib.h> -#include <mateconf/mateconf-client.h> - -#include <libpanel-util/panel-cleanup.h> - -#undef PANEL_MATECONF_DEBUG - -MateConfClient * -panel_mateconf_get_client (void) -{ - static MateConfClient *panel_mateconf_client = NULL; - - if (!panel_mateconf_client) { - panel_mateconf_client = mateconf_client_get_default (); - panel_cleanup_register (panel_cleanup_unref_and_nullify, - &panel_mateconf_client); - } - - return panel_mateconf_client; -} - -/* - * panel_mateconf_sprintf: - * @format: the format string. See sprintf() documentation. - * @...: the arguments to be inserted. - * - * This is a version of sprintf using a static buffer which is - * intended for use in generating the full mateconf key for all panel - * config keys. - * Note, you should not free the return value from this function and - * you should realize that the return value will get overwritten or - * freed by a subsequent call to this function. - * - * Return Value: a pointer to the static string buffer. - */ -const char * -panel_mateconf_sprintf (const char *format, - ...) -{ - static char *buffer = NULL; - static int buflen = 128; - va_list args; - int len; - - if (!buffer) - buffer = g_new (char, buflen); - - va_start (args, format); - len = g_vsnprintf (buffer, buflen, format, args); - - if (len >= buflen) { - int i; - - /* Round up length to the nearest power of 2 */ - for (i = 0; len != 1; i++, len >>= 1); - - buflen = len << (i + 1); - g_assert (buflen > 0); - - g_free (buffer); - buffer = g_new (char, buflen); - - va_start (args, format); - len = g_vsnprintf (buffer, buflen, format, args); - - g_assert (len < buflen); - } - - va_end (args); - - return buffer; -} - -const char * -panel_mateconf_key_type_to_id_list (PanelMateConfKeyType type) -{ - char *retval; - - switch (type) { - case PANEL_MATECONF_TOPLEVELS: - retval = "toplevel_id_list"; - break; - case PANEL_MATECONF_APPLETS: - retval = "applet_id_list"; - break; - case PANEL_MATECONF_OBJECTS: - retval = "object_id_list"; - break; - default: - retval = NULL; - g_assert_not_reached (); - break; - } - - return retval; -} - -const char * -panel_mateconf_global_key (const char *key) -{ - return panel_mateconf_sprintf ("/apps/panel/global/%s", key); -} - -const char * -panel_mateconf_general_key (const char *key) -{ - return panel_mateconf_sprintf (PANEL_CONFIG_DIR "/general/%s", key); -} - -const char * -panel_mateconf_full_key (PanelMateConfKeyType type, - const char *id, - const char *key) -{ - char *subdir = NULL; - - switch (type) { - case PANEL_MATECONF_TOPLEVELS: - subdir = "toplevels"; - break; - case PANEL_MATECONF_OBJECTS: - subdir = "objects"; - break; - case PANEL_MATECONF_APPLETS: - subdir = "applets"; - break; - default: - g_assert_not_reached (); - break; - } - - return panel_mateconf_sprintf (PANEL_CONFIG_DIR "/%s/%s/%s", - subdir, id, key); -} - -const char * -panel_mateconf_basename (const char *key) -{ - char *retval; - - g_return_val_if_fail (key != NULL, NULL); - - retval = strrchr (key, '/'); - - return retval ? retval + 1 : NULL; -} - -char * -panel_mateconf_dirname (const char *key) -{ - char *retval; - int len; - - g_return_val_if_fail (key != NULL, NULL); - - retval = strrchr (key, '/'); - g_assert (retval != NULL); - - len = retval - key; - g_assert (len > 0); - - retval = g_new0 (char, len + 1); - memcpy (retval, key, len); - - return retval; -} - -static void -panel_notify_object_dead (guint notify_id) -{ - MateConfClient *client; - - client = panel_mateconf_get_client (); - - mateconf_client_notify_remove (client, notify_id); -} - -guint -panel_mateconf_notify_add_while_alive (const char *key, - MateConfClientNotifyFunc notify_func, - GObject *alive_object) -{ - MateConfClient *client; - guint notify_id; - - g_return_val_if_fail (G_IS_OBJECT (alive_object), 0); - - client = panel_mateconf_get_client (); - - notify_id = mateconf_client_notify_add (client, key, notify_func, - alive_object, NULL, NULL); - - if (notify_id > 0) - g_object_weak_ref (alive_object, - (GWeakNotify) panel_notify_object_dead, - GUINT_TO_POINTER (notify_id)); - - return notify_id; -} - -void -panel_mateconf_copy_dir (MateConfClient *client, - const char *src_dir, - const char *dest_dir) -{ - GSList *list, *l; - - list = mateconf_client_all_entries (client, src_dir, NULL); - for (l = list; l; l = l->next) { - MateConfEntry *entry = l->data; - const char *key; - char *tmp; - - tmp = g_path_get_basename (mateconf_entry_get_key (entry)); - key = panel_mateconf_sprintf ("%s/%s", dest_dir, tmp); - g_free (tmp); - - mateconf_engine_associate_schema (client->engine, - key, - mateconf_entry_get_schema_name (entry), - NULL); - - if (!mateconf_entry_get_is_default (entry) && entry->value) - mateconf_client_set (client, key, entry->value, NULL); - - mateconf_entry_unref (entry); - } - g_slist_free (list); - - list = mateconf_client_all_dirs (client, src_dir, NULL); - for (l = list; l; l = l->next) { - char *subdir = l->data; - char *src_subdir; - char *dest_subdir; - char *tmp; - - tmp = g_path_get_basename (subdir); - src_subdir = mateconf_concat_dir_and_key (src_dir, tmp); - dest_subdir = mateconf_concat_dir_and_key (dest_dir, tmp); - g_free (tmp); - - panel_mateconf_copy_dir (client, src_subdir, dest_subdir); - - g_free (src_subdir); - g_free (dest_subdir); - g_free (subdir); - } - - g_slist_free (list); -} - -void -panel_mateconf_associate_schemas_in_dir (MateConfClient *client, - const char *profile_dir, - const char *schema_dir) -{ - GSList *list, *l; - -#ifdef PANEL_MATECONF_DEBUG - g_print ("associating schemas in %s to %s\n", schema_dir, profile_dir); -#endif - - list = mateconf_client_all_entries (client, schema_dir, NULL); - for (l = list; l; l = l->next) { - MateConfEntry *entry = l->data; - const char *key; - char *tmp; - - tmp = g_path_get_basename (mateconf_entry_get_key (entry)); - - key = panel_mateconf_sprintf ("%s/%s", profile_dir, tmp); - - g_free (tmp); - - mateconf_engine_associate_schema ( - client->engine, key, mateconf_entry_get_key (entry), NULL); - - mateconf_entry_unref (entry); - } - - g_slist_free (list); - - list = mateconf_client_all_dirs (client, schema_dir, NULL); - for (l = list; l; l = l->next) { - char *subdir = l->data; - char *prefs_subdir; - char *schema_subdir; - char *tmp; - - tmp = g_path_get_basename (subdir); - - prefs_subdir = g_strdup_printf ("%s/%s", profile_dir, tmp); - schema_subdir = g_strdup_printf ("%s/%s", schema_dir, tmp); - - panel_mateconf_associate_schemas_in_dir ( - client, prefs_subdir, schema_subdir); - - g_free (prefs_subdir); - g_free (schema_subdir); - g_free (subdir); - g_free (tmp); - } - - g_slist_free (list); -} - -gint -panel_mateconf_value_strcmp (gconstpointer a, - gconstpointer b) -{ - const char *str_a; - const char *str_b; - - if (a == b || !a || !b) - return 0; - - str_a = mateconf_value_get_string (a); - str_b = mateconf_value_get_string (b); - - return strcmp (str_a, str_b); -} diff --git a/mate-panel/panel-mateconf.h b/mate-panel/panel-mateconf.h deleted file mode 100644 index 80c49fa5..00000000 --- a/mate-panel/panel-mateconf.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * panel-mateconf.h: panel mateconf utility methods - * - * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - * Glynn Foster <[email protected]> - */ - -#ifndef __PANEL_MATECONF_H__ -#define __PANEL_MATECONF_H__ - -#include <mateconf/mateconf-client.h> - -#include "panel-enums.h" - -#define PANEL_CONFIG_DIR "/apps/panel" -#define PANEL_SCHEMAS_DIR "/schemas/apps/panel" -#define PANEL_DEFAULTS_DIR "/apps/panel/default_setup" -#define PANEL_OLD_CONFIG_DIR "/apps/panel/profiles/default" - -#ifdef __cplusplus -extern "C" { -#endif - -MateConfClient *panel_mateconf_get_client (void); - -const char *panel_mateconf_sprintf (const char *format, ...) G_GNUC_PRINTF (1, 2); -const char *panel_mateconf_basename (const char *key); -char *panel_mateconf_dirname (const char *key); -const char *panel_mateconf_global_key (const char *key); -const char *panel_mateconf_general_key (const char *key); -const char *panel_mateconf_full_key (PanelMateConfKeyType type, - const char *id, - const char *key); -const char *panel_mateconf_key_type_to_id_list (PanelMateConfKeyType type); - -guint panel_mateconf_notify_add (const char *key, - MateConfClientNotifyFunc notify_func, - gpointer user_data); -guint panel_mateconf_notify_add_while_alive (const char *key, - MateConfClientNotifyFunc notify_func, - GObject *alive_object); - -void panel_mateconf_copy_dir (MateConfClient *client, - const char *src_dir, - const char *dest_dir); - -void panel_mateconf_associate_schemas_in_dir (MateConfClient *client, - const char *profile_dir, - const char *schema_dir); - -gint panel_mateconf_value_strcmp (gconstpointer a, - gconstpointer b); - -#ifdef __cplusplus -} -#endif - -#endif /* __PANEL_MATECONF_H__ */ diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c index 1a2d3ac6..16a62d06 100644 --- a/mate-panel/panel-menu-bar.c +++ b/mate-panel/panel-menu-bar.c @@ -302,7 +302,7 @@ static void panel_menu_bar_load(PanelWidget* panel, gboolean locked, int positio panel_widget_set_applet_expandable(panel, GTK_WIDGET(menubar), FALSE, TRUE); } -void panel_menu_bar_load_from_mateconf(PanelWidget* panel, gboolean locked, int position, gboolean exactpos, const char* id) +void panel_menu_bar_load_from_gsettings (PanelWidget* panel, gboolean locked, int position, gboolean exactpos, const char* id) { panel_menu_bar_load(panel, locked, position, exactpos, id); } @@ -312,7 +312,7 @@ void panel_menu_bar_create(PanelToplevel* toplevel, int position) char* id; id = panel_profile_prepare_object(PANEL_OBJECT_MENU_BAR, toplevel, position, FALSE); - panel_profile_add_to_list(PANEL_MATECONF_OBJECTS, id); + panel_profile_add_to_list(PANEL_GSETTINGS_OBJECTS, id); g_free(id); } diff --git a/mate-panel/panel-menu-bar.h b/mate-panel/panel-menu-bar.h index 43672da9..6fe47d09 100644 --- a/mate-panel/panel-menu-bar.h +++ b/mate-panel/panel-menu-bar.h @@ -58,7 +58,7 @@ GType panel_menu_bar_get_type (void) G_GNUC_CONST; void panel_menu_bar_create (PanelToplevel *toplevel, int position); -void panel_menu_bar_load_from_mateconf (PanelWidget *panel, +void panel_menu_bar_load_from_gsettings (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, diff --git a/mate-panel/panel-menu-button.c b/mate-panel/panel-menu-button.c index 091c3993..b78d973b 100644 --- a/mate-panel/panel-menu-button.c +++ b/mate-panel/panel-menu-button.c @@ -28,6 +28,7 @@ #include <string.h> #include <glib/gi18n.h> +#include <gio/gio.h> #include <matemenu-tree.h> @@ -44,6 +45,7 @@ #include "panel-lockdown.h" #include "panel-a11y.h" #include "panel-icon-names.h" +#include "panel-schemas.h" G_DEFINE_TYPE (PanelMenuButton, panel_menu_button, BUTTON_TYPE_WIDGET) @@ -56,6 +58,7 @@ enum { PROP_TOOLTIP, PROP_USE_MENU_PATH, PROP_USE_CUSTOM_ICON, + PROP_HAS_ARROW, PROP_DND_ENABLED }; @@ -80,7 +83,7 @@ static MenuPathRootItem root_items[] = { struct _PanelMenuButtonPrivate { PanelToplevel *toplevel; - guint mateconf_notify; + GSettings *settings; char *applet_id; GtkWidget *menu; @@ -92,10 +95,11 @@ struct _PanelMenuButtonPrivate { MenuPathRoot path_root; guint use_menu_path : 1; guint use_custom_icon : 1; + guint has_arrow : 1; guint dnd_enabled : 1; }; -static void panel_menu_button_disconnect_from_mateconf (PanelMenuButton *button); +static void panel_menu_button_disconnect_from_gsettings (PanelMenuButton *button); static void panel_menu_button_recreate_menu (PanelMenuButton *button); static void panel_menu_button_set_icon (PanelMenuButton *button); @@ -172,15 +176,15 @@ panel_menu_button_init (PanelMenuButton *button) button->priv->applet_id = NULL; button->priv->toplevel = NULL; - button->priv->mateconf_notify = 0; button->priv->menu_path = NULL; button->priv->custom_icon = NULL; - button->priv->tooltip = NULL; + button->priv->tooltip = NULL; button->priv->path_root = LAST_MENU; button->priv->use_menu_path = FALSE; button->priv->use_custom_icon = FALSE; + button->priv->has_arrow = FALSE; } static void @@ -191,7 +195,7 @@ panel_menu_button_finalize (GObject *object) panel_lockdown_notify_remove (G_CALLBACK (panel_menu_button_recreate_menu), button); - panel_menu_button_disconnect_from_mateconf (button); + panel_menu_button_disconnect_from_gsettings (button); if (button->priv->menu) { /* detaching the menu will kill our reference */ @@ -242,6 +246,9 @@ panel_menu_button_get_property (GObject *object, case PROP_USE_CUSTOM_ICON: g_value_set_boolean (value, button->priv->use_custom_icon); break; + case PROP_HAS_ARROW: + g_value_set_boolean (value, button->priv->has_arrow); + break; case PROP_DND_ENABLED: g_value_set_boolean (value, button->priv->dnd_enabled); break; @@ -279,6 +286,9 @@ panel_menu_button_set_property (GObject *object, case PROP_USE_CUSTOM_ICON: panel_menu_button_set_use_custom_icon (button, g_value_get_boolean (value)); break; + case PROP_HAS_ARROW: + panel_menu_button_set_has_arrow (button, g_value_get_boolean (value)); + break; case PROP_DND_ENABLED: panel_menu_button_set_dnd_enabled (button, g_value_get_boolean (value)); break; @@ -543,6 +553,16 @@ panel_menu_button_class_init (PanelMenuButtonClass *klass) FALSE, G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_HAS_ARROW, + g_param_spec_boolean ("has-arrow", + "Has Arrow", + "Determine if an arrow is drawn over the menu button icon", + FALSE, + G_PARAM_READWRITE)); + g_object_class_install_property ( gobject_class, PROP_DND_ENABLED, @@ -554,76 +574,52 @@ panel_menu_button_class_init (PanelMenuButtonClass *klass) } static void -panel_menu_button_mateconf_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - PanelMenuButton *button) +panel_menu_button_gsettings_notify (GSettings *settings, + gchar *key, + PanelMenuButton *button) { - MateConfValue *value; - const char *key; - - key = panel_mateconf_basename (mateconf_entry_get_key (entry)); - - value = entry->value; - - if (!strcmp (key, "menu_path")) { - if (value && value->type == MATECONF_VALUE_STRING) - panel_menu_button_set_menu_path (button, - mateconf_value_get_string (value)); - } else if (!strcmp (key, "custom_icon")) { - if (value && value->type == MATECONF_VALUE_STRING) - panel_menu_button_set_custom_icon (button, - mateconf_value_get_string (value)); - } else if (!strcmp (key, "tooltip")) { - if (value && value->type == MATECONF_VALUE_STRING) - panel_menu_button_set_tooltip (button, - mateconf_value_get_string (value)); - } else if (!strcmp (key, "use_menu_path")) { - if (value && value->type == MATECONF_VALUE_BOOL) - panel_menu_button_set_use_menu_path (button, - mateconf_value_get_bool (value)); - } else if (!strcmp (key, "use_custom_icon")) { - if (value && value->type == MATECONF_VALUE_BOOL) - panel_menu_button_set_use_custom_icon (button, - mateconf_value_get_bool (value)); + if (!strcmp (key, PANEL_OBJECT_MENU_PATH_KEY)) { + panel_menu_button_set_menu_path (button, + g_settings_get_string (settings, key)); + } else if (!strcmp (key, PANEL_OBJECT_CUSTOM_ICON_KEY)) { + panel_menu_button_set_custom_icon (button, + g_settings_get_string (settings, key)); + } else if (!strcmp (key, PANEL_OBJECT_TOOLTIP_KEY)) { + panel_menu_button_set_tooltip (button, + g_settings_get_string (settings, key)); + } else if (!strcmp (key, PANEL_OBJECT_USE_MENU_PATH_KEY)) { + panel_menu_button_set_use_menu_path (button, + g_settings_get_boolean (settings, key)); + } else if (!strcmp (key, PANEL_OBJECT_USE_CUSTOM_ICON_KEY)) { + panel_menu_button_set_use_custom_icon (button, + g_settings_get_boolean (settings, key)); + } else if (!strcmp (key, PANEL_OBJECT_HAS_ARROW_KEY)) { + panel_menu_button_set_has_arrow (button, + g_settings_get_boolean (settings, key)); } } static void -panel_menu_button_connect_to_mateconf (PanelMenuButton *button) +panel_menu_button_connect_to_gsettings (PanelMenuButton *button) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/objects/%s", - button->priv->applet_id); - mateconf_client_add_dir (client, key, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); - button->priv->mateconf_notify = - mateconf_client_notify_add (client, key, - (MateConfClientNotifyFunc) panel_menu_button_mateconf_notify, - button, NULL, NULL); + gchar *path; + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", button->priv->applet_id); + button->priv->settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_signal_connect (button->priv->settings, + "changed", + G_CALLBACK (panel_menu_button_gsettings_notify), + button); + g_free (path); } static void -panel_menu_button_disconnect_from_mateconf (PanelMenuButton *button) +panel_menu_button_disconnect_from_gsettings (PanelMenuButton *button) { - MateConfClient *client; - const char *key; - - if (!button->priv->mateconf_notify) - return; - - client = panel_mateconf_get_client (); - - key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/objects/%s", - button->priv->applet_id); - - mateconf_client_notify_remove (client, button->priv->mateconf_notify); - button->priv->mateconf_notify = 0; - - mateconf_client_remove_dir (client, key, NULL); + if (button->priv->settings) + { + g_object_unref (button->priv->settings); + button->priv->settings = NULL; + } } static void @@ -674,7 +670,7 @@ panel_menu_button_load (const char *menu_path, panel_widget_set_applet_expandable (panel, GTK_WIDGET (button), FALSE, TRUE); panel_widget_set_applet_size_constrained (panel, GTK_WIDGET (button), TRUE); - panel_menu_button_connect_to_mateconf (button); + panel_menu_button_connect_to_gsettings (button); panel_lockdown_notify_add (G_CALLBACK (panel_menu_button_recreate_menu), button); @@ -866,14 +862,26 @@ panel_menu_button_set_use_custom_icon (PanelMenuButton *button, } void -panel_menu_button_load_from_mateconf (PanelWidget *panel, +panel_menu_button_set_has_arrow (PanelMenuButton *button, + gboolean has_arrow) +{ + g_return_if_fail (PANEL_IS_MENU_BUTTON (button)); + + button->priv->has_arrow = has_arrow != FALSE; + + button_widget_set_has_arrow (BUTTON_WIDGET (button), has_arrow); +} + + +void +panel_menu_button_load_from_gsettings (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, const char *id) { - MateConfClient *client; - const char *key; + GSettings *settings; + gchar *path; char *menu_path; char *custom_icon; char *tooltip; @@ -881,25 +889,15 @@ panel_menu_button_load_from_mateconf (PanelWidget *panel, gboolean use_custom_icon; gboolean has_arrow; - client = panel_mateconf_get_client (); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "menu_path"); - menu_path = mateconf_client_get_string (client, key, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "custom_icon"); - custom_icon = mateconf_client_get_string (client, key, NULL); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "tooltip"); - tooltip = mateconf_client_get_string (client, key, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_menu_path"); - use_menu_path = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_custom_icon"); - use_custom_icon = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "has_arrow"); - has_arrow = mateconf_client_get_bool (client, key, NULL); + menu_path = g_settings_get_string (settings, PANEL_OBJECT_MENU_PATH_KEY); + custom_icon = g_settings_get_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY); + tooltip = g_settings_get_string (settings, PANEL_OBJECT_TOOLTIP_KEY); + use_menu_path = g_settings_get_boolean (settings, PANEL_OBJECT_USE_MENU_PATH_KEY); + use_custom_icon = g_settings_get_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY); + has_arrow = g_settings_get_boolean (settings, PANEL_OBJECT_HAS_ARROW_KEY); panel_menu_button_load (menu_path, use_menu_path, @@ -916,6 +914,8 @@ panel_menu_button_load_from_mateconf (PanelWidget *panel, g_free (menu_path); g_free (custom_icon); g_free (tooltip); + g_free (path); + g_object_unref (settings); } gboolean @@ -926,44 +926,43 @@ panel_menu_button_create (PanelToplevel *toplevel, gboolean use_menu_path, const char *tooltip) { - MateConfClient *client; + GSettings *settings; + gchar *path; const char *scheme; - const char *key; char *id; - client = panel_mateconf_get_client (); - id = panel_profile_prepare_object (PANEL_OBJECT_MENU, toplevel, position, FALSE); - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_menu_path"); - mateconf_client_set_bool (client, key, use_menu_path, NULL); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + + g_settings_set_boolean (settings, PANEL_OBJECT_USE_MENU_PATH_KEY, use_menu_path); scheme = panel_menu_filename_to_scheme (filename); if (filename && !scheme) { g_warning ("Failed to find menu scheme for %s\n", filename); g_free (id); + g_free (path); + g_object_unref (settings); return FALSE; } if (use_menu_path && menu_path && menu_path [0] && scheme) { - char *menu_uri; - + char *menu_uri; menu_uri = g_strconcat (scheme, ":", menu_path, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "menu_path"); - mateconf_client_set_string (client, key, menu_uri, NULL); - + g_settings_set_string (settings, PANEL_OBJECT_MENU_PATH_KEY, menu_uri); g_free (menu_uri); } if (tooltip && tooltip [0]) { - key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "tooltip"); - mateconf_client_set_string (client, key, tooltip, NULL); + g_settings_set_string (settings, PANEL_OBJECT_TOOLTIP_KEY, tooltip); } - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); + panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (id); + g_free (path); + g_object_unref (settings); return TRUE; } diff --git a/mate-panel/panel-menu-button.h b/mate-panel/panel-menu-button.h index c6c9d564..66755079 100644 --- a/mate-panel/panel-menu-button.h +++ b/mate-panel/panel-menu-button.h @@ -74,8 +74,10 @@ void panel_menu_button_set_use_menu_path (PanelMenuButton *button, gboolean panel_menu_button_get_use_menu_path (PanelMenuButton *button); void panel_menu_button_set_use_custom_icon (PanelMenuButton *button, gboolean use_custom_icon); +void panel_menu_button_set_has_arrow (PanelMenuButton *button, + gboolean has_arrow); -void panel_menu_button_load_from_mateconf (PanelWidget *panel, +void panel_menu_button_load_from_gsettings (PanelWidget *panel, gboolean locked, int position, gboolean exactpos, diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c index bd234de9..46c9a6a3 100644 --- a/mate-panel/panel-menu-items.c +++ b/mate-panel/panel-menu-items.c @@ -54,13 +54,9 @@ #include "panel-recent.h" #include "panel-stock-icons.h" #include "panel-util.h" +#include "panel-schemas.h" #define BOOKMARKS_FILENAME ".gtk-bookmarks" -#define DESKTOP_IS_HOME_DIR_DIR "/apps/caja/preferences" -#define DESKTOP_IS_HOME_DIR_KEY "/apps/caja/preferences/desktop_is_home_dir" -#define NAMES_DIR "/apps/caja/desktop" -#define HOME_NAME_KEY "/apps/caja/desktop/home_icon_name" -#define COMPUTER_NAME_KEY "/apps/caja/desktop/computer_icon_name" #define MAX_ITEMS_OR_SUBMENU 8 #define MAX_BOOKMARK_ITEMS 100 @@ -76,6 +72,9 @@ struct _PanelPlaceMenuItemPrivate { GtkWidget *menu; PanelWidget *panel; + GSettings *caja_desktop_settings; + GSettings *caja_prefs_settings; + GtkRecentManager *recent_manager; GFileMonitor *bookmarks_monitor; @@ -1027,7 +1026,7 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item) { GtkWidget *places_menu; GtkWidget *item; - char *mateconf_name; + char *gsettings_name; char *name; char *uri; GFile *file; @@ -1048,9 +1047,8 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item) g_free (name); g_free (uri); - if (!mateconf_client_get_bool (panel_mateconf_get_client (), - DESKTOP_IS_HOME_DIR_KEY, - NULL)) { + if (!g_settings_get_boolean (place_item->priv->caja_prefs_settings, + CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY)) { file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)); uri = g_file_get_uri (file); g_object_unref (file); @@ -1072,15 +1070,14 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item) panel_place_menu_item_append_gtk_bookmarks (places_menu); add_menu_separator (places_menu); - mateconf_name = mateconf_client_get_string (panel_mateconf_get_client (), - COMPUTER_NAME_KEY, - NULL); + gsettings_name = g_settings_get_string (place_item->priv->caja_desktop_settings, + CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY); panel_menu_items_append_from_desktop (places_menu, "caja-computer.desktop", - mateconf_name, + gsettings_name, TRUE); - if (mateconf_name) - g_free (mateconf_name); + if (gsettings_name) + g_free (gsettings_name); panel_place_menu_item_append_local_gio (place_item, places_menu); add_menu_separator (places_menu); @@ -1130,9 +1127,8 @@ panel_place_menu_item_recreate_menu (GtkWidget *widget) } static void -panel_place_menu_item_key_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +panel_place_menu_item_key_changed (GSettings *settings, + gchar *key, GtkWidget *place_item) { panel_place_menu_item_recreate_menu (place_item); @@ -1195,7 +1191,12 @@ panel_desktop_menu_item_append_menu (GtkWidget *menu, if (add_separator) add_menu_separator (menu); + /* FIXME replace this with MATE documentation system, when it will be ready + * see: http://forums.mate-desktop.org/viewtopic.php?f=17&t=805 + panel_menu_items_append_from_desktop (menu, "yelp.desktop", NULL, FALSE); + */ + panel_menu_items_append_from_desktop (menu, "mate-about.desktop", NULL, FALSE); if (parent->priv->append_lock_logout) @@ -1238,12 +1239,14 @@ panel_place_menu_item_finalize (GObject *object) { PanelPlaceMenuItem *menuitem = (PanelPlaceMenuItem *) object; - mateconf_client_remove_dir (panel_mateconf_get_client (), - DESKTOP_IS_HOME_DIR_DIR, - NULL); - mateconf_client_remove_dir (panel_mateconf_get_client (), - NAMES_DIR, - NULL); + if (menuitem->priv->caja_desktop_settings) { + g_object_unref (menuitem->priv->caja_desktop_settings); + menuitem->priv->caja_desktop_settings = NULL; + } + if (menuitem->priv->caja_prefs_settings) { + g_object_unref (menuitem->priv->caja_prefs_settings); + menuitem->priv->caja_prefs_settings = NULL; + } if (menuitem->priv->bookmarks_monitor != NULL) { g_file_monitor_cancel (menuitem->priv->bookmarks_monitor); @@ -1323,24 +1326,21 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem) menuitem->priv = PANEL_PLACE_MENU_ITEM_GET_PRIVATE (menuitem); - mateconf_client_add_dir (panel_mateconf_get_client (), - DESKTOP_IS_HOME_DIR_DIR, - MATECONF_CLIENT_PRELOAD_NONE, - NULL); - mateconf_client_add_dir (panel_mateconf_get_client (), - NAMES_DIR, - MATECONF_CLIENT_PRELOAD_NONE, - NULL); - - panel_mateconf_notify_add_while_alive (HOME_NAME_KEY, - (MateConfClientNotifyFunc) panel_place_menu_item_key_changed, - G_OBJECT (menuitem)); - panel_mateconf_notify_add_while_alive (DESKTOP_IS_HOME_DIR_KEY, - (MateConfClientNotifyFunc) panel_place_menu_item_key_changed, - G_OBJECT (menuitem)); - panel_mateconf_notify_add_while_alive (COMPUTER_NAME_KEY, - (MateConfClientNotifyFunc) panel_place_menu_item_key_changed, - G_OBJECT (menuitem)); + menuitem->priv->caja_desktop_settings = g_settings_new (CAJA_DESKTOP_SCHEMA); + menuitem->priv->caja_prefs_settings = g_settings_new (CAJA_PREFS_SCHEMA); + + g_signal_connect (menuitem->priv->caja_desktop_settings, + "changed::" CAJA_DESKTOP_HOME_ICON_NAME_KEY, + G_CALLBACK (panel_place_menu_item_key_changed), + G_OBJECT (menuitem)); + g_signal_connect (menuitem->priv->caja_desktop_settings, + "changed::" CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY, + G_CALLBACK (panel_place_menu_item_key_changed), + G_OBJECT (menuitem)); + g_signal_connect (menuitem->priv->caja_prefs_settings, + "changed::" CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY, + G_CALLBACK (panel_place_menu_item_key_changed), + G_OBJECT (menuitem)); menuitem->priv->recent_manager = gtk_recent_manager_get_default (); diff --git a/mate-panel/panel-object.schemas.in b/mate-panel/panel-object.schemas.in deleted file mode 100644 index cf73c6cc..00000000 --- a/mate-panel/panel-object.schemas.in +++ /dev/null @@ -1,263 +0,0 @@ -<?xml version="1.0"?> -<mateconfschemafile> - - <schemalist> - - <!-- Applies to all object types --> - - <schema> - <key>/schemas/apps/panel/objects/object_type</key> - <owner>panel</owner> - <type>string</type> - <default>menu-object</default> - <locale name="C"> - <short>Panel object type</short> - <long> - The type of this panel object. Possible values are - "drawer-object", "menu-object", "launcher-object", - "external-applet", "action-applet", "menu-bar" and - "separator". - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/toplevel_id</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Toplevel panel containing object</short> - <long> - The identifier of the toplevel panel which contains this object. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/position</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>Object's position on the panel</short> - <long> - The position of this panel object. The position is specified - by the number of pixels from the left (or top if vertical) - panel edge. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/panel_right_stick</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Interpret position relative to bottom/right edge</short> - <long> - If true, the position of the object is interpreted relative - to the right (or bottom if vertical) edge of the panel. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/locked</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Lock the object to the panel</short> - <long> - If true, the user may not move the applet without first unlocking - the object using the "Unlock" menuitem. - </long> - </locale> - </schema> - - - <!-- Applies to applets --> - - <schema> - <key>/schemas/apps/panel/objects/matecomponent_iid</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Applet MateComponent IID</short> - <long> - This key is deprecated, following the migration to a new library for - applets. The MateComponent implementation ID of the applet - e.g. - "OAFIID:MATE_ClockApplet". This key is only relevant if the - object_type key is "matecomponent-applet". - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/applet_iid</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Applet IID</short> - <long> - The implementation ID of the applet - e.g. - "ClockAppletFactory::ClockApplet". This key is only - relevant if the object_type key is "external-applet" - (or the deprecated "matecomponent-applet"). - </long> - </locale> - </schema> - - <!-- Applies to drawers --> - - <schema> - <key>/schemas/apps/panel/objects/attached_toplevel_id</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Panel attached to drawer</short> - <long> - The identifier of the panel attached to this drawer. This - key is only relevant if the object_type key is "drawer-object". - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/tooltip</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Tooltip displayed for drawer or menu</short> - <long> - The text to display in a tooltip for this drawer or this menu. This - key is only relevant if the object_type key is "drawer-object" or - "menu-object". - </long> - </locale> - </schema> - - <!-- Applies to drawers and menu buttons --> - - <schema> - <key>/schemas/apps/panel/objects/use_custom_icon</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Use custom icon for object's button</short> - <long> - If true, the custom_icon key is used as a custom icon for - the button. If false, the custom_icon key is ignored. - This key is only relevant if the object_type key is - "menu-object" or "drawer-object". - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/custom_icon</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Icon used for object's button</short> - <long> - The location of the image file used as the icon for the - object's button. This key is only relevant if the - object_type key is "drawer-object" or "menu-object" and - the use_custom_icon key is true. - </long> - </locale> - </schema> - - <!-- Applies to menu buttons --> - - <schema> - <key>/schemas/apps/panel/objects/use_menu_path</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Use custom path for menu contents</short> - <long> - If true, the menu_path key is used as the path from which - the menu contents should be constructed. If false, the - menu_path key is ignored. This key is only relevant - if the object_type key is "menu-object". - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/menu_path</key> - <owner>panel</owner> - <type>string</type> - <default>applications:/</default> - <locale name="C"> - <short>Menu content path</short> - <long> - The path from which the menu contents is contructed. This - key is only relevant if the use_menu_path key is true and - the object_type key is "menu-object". - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/objects/has_arrow</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Draw arrow in menu button</short> - <long> - If true, an arrow is drawn over the menu button icon. If - false, menu button has only the icon. - </long> - </locale> - </schema> - - <!-- Applies to launchers --> - - <schema> - <key>/schemas/apps/panel/objects/launcher_location</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Launcher location</short> - <long> - The location of the .desktop file describing the launcher. - This key is only relevant if the object_type key is - "launcher-object". - </long> - </locale> - </schema> - - <!-- Applies to action buttons --> - - <schema> - <key>/schemas/apps/panel/objects/action_type</key> - <owner>panel</owner> - <type>string</type> - <default>lock</default> - <locale name="C"> - <short>Action button type</short> - <long> - The action type this button represents. Possible values are - "lock", "logout", "run", "search" and "screenshot". This - key is only relevant if the object_type key is "action-applet". - </long> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/mate-panel/panel-profile.c b/mate-panel/panel-profile.c index 4f2fb931..300ce64c 100644 --- a/mate-panel/panel-profile.c +++ b/mate-panel/panel-profile.c @@ -25,21 +25,24 @@ #include <config.h> #include "panel-profile.h" +#include "panel-layout.h" #include <string.h> #include <glib/gi18n.h> +#include <gio/gio.h> #include <libpanel-util/panel-list.h> +#include <libpanel-util/panel-dconf.h> #include "applet.h" -#include "panel-compatibility.h" -#include "panel-mateconf.h" #include "panel.h" #include "panel-widget.h" #include "panel-util.h" #include "panel-multiscreen.h" #include "panel-toplevel.h" #include "panel-lockdown.h" +#include "panel-gsettings.h" +#include "panel-schemas.h" typedef struct { GdkScreen *screen; @@ -67,145 +70,16 @@ typedef struct { typedef const char *(*PanelProfileGetIdFunc) (gpointer object); typedef gboolean (*PanelProfileOnLoadQueue) (const char *id); -typedef void (*PanelProfileLoadFunc) (MateConfClient *client, - const char *profile_dir, - PanelMateConfKeyType type, - const char *id); +typedef void (*PanelProfileLoadFunc) (const char *id); typedef void (*PanelProfileDestroyFunc) (const char *id); -static MateConfEnumStringPair panel_orientation_map [] = { - { PANEL_ORIENTATION_TOP, "top" }, - { PANEL_ORIENTATION_BOTTOM, "bottom" }, - { PANEL_ORIENTATION_LEFT, "left" }, - { PANEL_ORIENTATION_RIGHT, "right" }, - { 0, NULL } -}; - -static MateConfEnumStringPair panel_animation_speed_map [] = { - { PANEL_ANIMATION_SLOW, "slow" }, - { PANEL_ANIMATION_MEDIUM, "medium" }, - { PANEL_ANIMATION_FAST, "fast" }, - { 0, NULL } -}; - -static MateConfEnumStringPair panel_background_type_map [] = { - { PANEL_BACK_NONE, "gtk" }, - { PANEL_BACK_COLOR, "color" }, - { PANEL_BACK_IMAGE, "image" }, - { 0, NULL } -}; - -static MateConfEnumStringPair panel_object_type_map [] = { - { PANEL_OBJECT_DRAWER, "drawer-object" }, - { PANEL_OBJECT_MENU, "menu-object" }, - { PANEL_OBJECT_LAUNCHER, "launcher-object" }, - { PANEL_OBJECT_APPLET, "external-applet" }, - { PANEL_OBJECT_ACTION, "action-applet" }, - { PANEL_OBJECT_MENU_BAR, "menu-bar" }, - { PANEL_OBJECT_SEPARATOR, "separator" }, - /* The following is for backwards compatibility with 2.30.x and earlier */ - { PANEL_OBJECT_APPLET, "matecomponent-applet" }, - /* The following two are for backwards compatibility with 2.0.x */ - { PANEL_OBJECT_LOCK, "lock-object" }, - { PANEL_OBJECT_LOGOUT, "logout-object" }, - { 0, NULL } -}; +static GSettings *profile_settings = NULL; static GQuark toplevel_id_quark = 0; static GQuark queued_changes_quark = 0; static GQuark commit_timeout_quark = 0; -static void panel_profile_object_id_list_update (MateConfClient *client, - MateConfValue *value, - PanelMateConfKeyType type); - -gboolean -panel_profile_map_orientation_string (const char *str, - PanelOrientation *orientation) -{ - int mapped; - - g_return_val_if_fail (orientation != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_orientation_map, str, &mapped)) - return FALSE; - - *orientation = mapped; - - return TRUE; -} - -const char * -panel_profile_map_orientation (PanelOrientation orientation) -{ - return mateconf_enum_to_string (panel_orientation_map, orientation); -} - -gboolean -panel_profile_map_speed_string (const char *str, - PanelAnimationSpeed *speed) -{ - int mapped; - - g_return_val_if_fail (speed != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_animation_speed_map, str, &mapped)) - return FALSE; - - *speed = mapped; - - return TRUE; -} - -gboolean -panel_profile_map_background_type_string (const char *str, - PanelBackgroundType *background_type) -{ - int mapped; - - g_return_val_if_fail (background_type != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_background_type_map, str, &mapped)) - return FALSE; - - *background_type = mapped; - - return TRUE; -} - -const char * -panel_profile_map_background_type (PanelBackgroundType background_type) -{ - return mateconf_enum_to_string (panel_background_type_map, background_type); -} - -gboolean -panel_profile_map_object_type_string (const char *str, - PanelObjectType *object_type) -{ - int mapped; - - g_return_val_if_fail (object_type != NULL, FALSE); - - if (!str) - return FALSE; - - if (!mateconf_string_to_enum (panel_object_type_map, str, &mapped)) - return FALSE; - - *object_type = mapped; - - return TRUE; -} +static void panel_profile_object_id_list_update (gchar **objects); static void panel_profile_set_toplevel_id (PanelToplevel *toplevel, @@ -246,83 +120,52 @@ panel_profile_get_toplevel_by_id (const char *toplevel_id) } char * -panel_profile_find_new_id (PanelMateConfKeyType type) +panel_profile_find_new_id (PanelGSettingsKeyType type) { - MateConfClient *client; - GSList *l, *existing_ids; - const char *key; + gchar **existing_ids; char *retval = NULL; char *prefix; char *dir; int i; - - client = panel_mateconf_get_client (); + int j; switch (type) { - case PANEL_MATECONF_TOPLEVELS: - prefix = "panel"; - dir = "toplevels"; - break; - case PANEL_MATECONF_OBJECTS: - prefix = "object"; - dir = "objects"; - break; - case PANEL_MATECONF_APPLETS: - prefix = "applet"; - dir = "applets"; - break; - default: - prefix = dir = NULL; - g_assert_not_reached (); - break; + case PANEL_GSETTINGS_TOPLEVELS: + prefix = PANEL_TOPLEVEL_DEFAULT_PREFIX; + dir = PANEL_TOPLEVEL_PATH; + break; + case PANEL_GSETTINGS_OBJECTS: + prefix = PANEL_OBJECT_DEFAULT_PREFIX; + dir = PANEL_OBJECT_PATH; + break; + default: + prefix = dir = NULL; + g_assert_not_reached (); + break; } - key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/%s", dir); - existing_ids = mateconf_client_all_dirs (client, key, NULL); + existing_ids = panel_dconf_list_subdirs (dir, TRUE); for (i = 0; !retval; i++) { retval = g_strdup_printf ("%s_%d", prefix, i); - for (l = existing_ids; l; l = l->next) - if (!strcmp (panel_mateconf_basename (l->data), retval)) { + for (j = 0; existing_ids[j] != NULL; j++) { + if (g_strcmp0 (existing_ids[j], retval) == 0) { g_free (retval); retval = NULL; break; } + } } + if (existing_ids) + g_strfreev (existing_ids); g_assert (retval != NULL); - for (l = existing_ids; l; l = l->next) - g_free (l->data); - g_slist_free (existing_ids); - return retval; } static void -panel_profile_set_queued_changes (PanelToplevel *toplevel, - MateConfChangeSet *changes) -{ - if (!queued_changes_quark) - queued_changes_quark = g_quark_from_static_string ("panel-queued-changes"); - - g_object_set_qdata_full (G_OBJECT (toplevel), - queued_changes_quark, - changes, - (GDestroyNotify) mateconf_change_set_unref); -} - -static MateConfChangeSet * -panel_profile_get_queued_changes (GObject *object) -{ - if (!queued_changes_quark) - return NULL; - - return g_object_get_qdata (object, queued_changes_quark); -} - -static void panel_profile_remove_commit_timeout (guint timeout) { g_source_remove (timeout); @@ -357,67 +200,34 @@ panel_profile_get_commit_timeout (GObject *object) return GPOINTER_TO_UINT (g_object_get_qdata (object, commit_timeout_quark)); } -static const char * -panel_profile_get_toplevel_key (PanelToplevel *toplevel, - const char *key) -{ - const char *id; - - id = panel_profile_get_toplevel_id (toplevel); - - return panel_mateconf_full_key (PANEL_MATECONF_TOPLEVELS, id, key); +gboolean +panel_profile_key_is_writable (PanelToplevel *toplevel, gchar *key) { + return g_settings_is_writable (toplevel->settings, key); } -#define TOPLEVEL_IS_WRITABLE_FUNC(k, p, s) \ - gboolean \ - panel_profile_is_writable_##p##_##s (PanelToplevel *toplevel) \ - { \ - MateConfClient *client; \ - const char *key; \ - client = panel_mateconf_get_client (); \ - key = panel_profile_get_toplevel_key (toplevel, k); \ - return mateconf_client_key_is_writable (client, key, NULL); \ - } +gboolean +panel_profile_background_key_is_writable (PanelToplevel *toplevel, gchar *key) { + return g_settings_is_writable (toplevel->background_settings, key); +} void panel_profile_set_background_type (PanelToplevel *toplevel, PanelBackgroundType background_type) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "background/type"); - mateconf_client_set_string (client, - key, - panel_profile_map_background_type (background_type), - NULL); + g_settings_set_enum (toplevel->background_settings, + "type", + background_type); } PanelBackgroundType panel_profile_get_background_type (PanelToplevel *toplevel) { PanelBackgroundType background_type; - MateConfClient *client; - const char *key; - char *str; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "background/type"); - str = mateconf_client_get_string (client, key, NULL); - - if (!str || !panel_profile_map_background_type_string (str, &background_type)) - background_type = PANEL_BACK_NONE; - - g_free (str); - + g_settings_get_enum (toplevel->background_settings, + "type"); return background_type; } -TOPLEVEL_IS_WRITABLE_FUNC ("background/type", background, type) - void panel_profile_set_background_color (PanelToplevel *toplevel, PanelColor *color) @@ -434,25 +244,18 @@ panel_profile_get_background_color (PanelToplevel *toplevel, color->alpha = panel_profile_get_background_opacity (toplevel); } -TOPLEVEL_IS_WRITABLE_FUNC ("background/color", background, color) - void panel_profile_set_background_gdk_color (PanelToplevel *toplevel, GdkColor *gdk_color) { - MateConfClient *client; - const char *key; char *color_str; - client = panel_mateconf_get_client (); - color_str = g_strdup_printf ("#%02x%02x%02x", gdk_color->red / 256, gdk_color->green / 256, gdk_color->blue / 256); - key = panel_profile_get_toplevel_key (toplevel, "background/color"); - mateconf_client_set_string (client, key, color_str, NULL); + g_settings_set_string(toplevel->background_settings, "color", color_str); g_free (color_str); } @@ -461,14 +264,9 @@ void panel_profile_get_background_gdk_color (PanelToplevel *toplevel, GdkColor *gdk_color) { - MateConfClient *client; - const char *key; char *color_str; - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "background/color"); - color_str = mateconf_client_get_string (client, key, NULL); + color_str = g_settings_get_string (toplevel->background_settings, "color"); if (!color_str || !gdk_color_parse (color_str, gdk_color)) { gdk_color->red = 0; gdk_color->green = 0; @@ -482,177 +280,113 @@ void panel_profile_set_background_opacity (PanelToplevel *toplevel, guint16 opacity) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "background/opacity"); - mateconf_client_set_int (client, key, opacity, NULL); + g_settings_set_int (toplevel->background_settings, "opacity", opacity); } guint16 panel_profile_get_background_opacity (PanelToplevel *toplevel) { - MateConfClient *client; - const char *key; guint16 opacity; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "background/opacity"); - opacity = mateconf_client_get_int (client, key, NULL); - + opacity = g_settings_get_int (toplevel->background_settings, "opacity"); return opacity; } -TOPLEVEL_IS_WRITABLE_FUNC ("background/opacity", background, opacity) - void panel_profile_set_background_image (PanelToplevel *toplevel, const char *image) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "background/image"); - if (image && image [0]) - mateconf_client_set_string (client, key, image, NULL); + g_settings_set_string (toplevel->background_settings, "image", image); else - mateconf_client_unset (client, key, NULL); + g_settings_reset (toplevel->background_settings, "image"); } char * panel_profile_get_background_image (PanelToplevel *toplevel) { - MateConfClient *client; - const char *key; char *retval; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "background/image"); - retval = mateconf_client_get_string (client, key, NULL); - + retval = g_settings_get_string (toplevel->background_settings, "image"); return retval; } -TOPLEVEL_IS_WRITABLE_FUNC ("background/image", background, image) - void panel_profile_set_toplevel_name (PanelToplevel *toplevel, const char *name) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "name"); - if (name && name [0]) - mateconf_client_set_string (client, key, name, NULL); + g_settings_set_string (toplevel->settings, "name", name); else - mateconf_client_unset (client, key, NULL); + g_settings_reset (toplevel->settings, "name"); } char * panel_profile_get_toplevel_name (PanelToplevel *toplevel) { - MateConfClient *client; - const char *key; char *retval; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "name"); - retval = mateconf_client_get_string (client, key, NULL); - + retval = g_settings_get_string (toplevel->settings, "name"); return retval; } -TOPLEVEL_IS_WRITABLE_FUNC ("name", toplevel, name) - void panel_profile_set_toplevel_orientation (PanelToplevel *toplevel, PanelOrientation orientation) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "orientation"); - mateconf_client_set_string (client, - key, - panel_profile_map_orientation (orientation), - NULL); + g_settings_set_enum (toplevel->settings, "orientation", orientation); } PanelOrientation panel_profile_get_toplevel_orientation (PanelToplevel *toplevel) { PanelOrientation orientation; - MateConfClient *client; - const char *key; - char *str; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "orientation"); - str = mateconf_client_get_string (client, key, NULL); - - if (!panel_profile_map_orientation_string (str, &orientation)) - orientation = panel_toplevel_get_orientation (toplevel); - - g_free (str); - + orientation = g_settings_get_enum (toplevel->settings, "orientation"); return orientation; } -TOPLEVEL_IS_WRITABLE_FUNC ("orientation", toplevel, orientation) - -#define TOPLEVEL_GET_SET_FUNCS(k, p, t, s, a) \ +#define TOPLEVEL_GET_SET_FUNCS(k, p, t, s, a) \ void \ panel_profile_set_##p##_##s (PanelToplevel *toplevel, a s) \ { \ - MateConfClient *client; \ - const char *key; \ - client = panel_mateconf_get_client (); \ - key = panel_profile_get_toplevel_key (toplevel, k); \ - mateconf_client_set_##t (client, key, s, NULL); \ + g_settings_set_##t (toplevel->settings, k, s); \ } \ a \ panel_profile_get_##p##_##s (PanelToplevel *toplevel) \ { \ - MateConfClient *client; \ - const char *key; \ - a retval; \ - client = panel_mateconf_get_client (); \ - key = panel_profile_get_toplevel_key (toplevel, k); \ - retval = mateconf_client_get_##t (client, key, NULL); \ - return retval; \ + a retval; \ + retval = g_settings_get_##t (toplevel->settings, k); \ + return retval; \ + } + +TOPLEVEL_GET_SET_FUNCS ("size", toplevel, int, size, int) +TOPLEVEL_GET_SET_FUNCS ("expand", toplevel, boolean, expand, gboolean) +TOPLEVEL_GET_SET_FUNCS ("auto-hide", toplevel, boolean, auto_hide, gboolean) +TOPLEVEL_GET_SET_FUNCS ("enable-buttons", toplevel, boolean, enable_buttons, gboolean) +TOPLEVEL_GET_SET_FUNCS ("enable-arrows", toplevel, boolean, enable_arrows, gboolean) + +#define TOPLEVEL_GET_SET_BG_FUNCS(k, p, t, s, a) \ + void \ + panel_profile_set_##p##_##s (PanelToplevel *toplevel, a s) \ + { \ + g_settings_set_##t (toplevel->background_settings, k, s); \ } \ - TOPLEVEL_IS_WRITABLE_FUNC(k, p, s) + a \ + panel_profile_get_##p##_##s (PanelToplevel *toplevel) \ + { \ + a retval; \ + retval = g_settings_get_##t (toplevel->background_settings, k); \ + return retval; \ + } -TOPLEVEL_GET_SET_FUNCS ("size", toplevel, int, size, int) -TOPLEVEL_GET_SET_FUNCS ("expand", toplevel, bool, expand, gboolean) -TOPLEVEL_GET_SET_FUNCS ("auto_hide", toplevel, bool, auto_hide, gboolean) -TOPLEVEL_GET_SET_FUNCS ("enable_buttons", toplevel, bool, enable_buttons, gboolean) -TOPLEVEL_GET_SET_FUNCS ("enable_arrows", toplevel, bool, enable_arrows, gboolean) -TOPLEVEL_GET_SET_FUNCS ("background/fit", background, bool, fit, gboolean) -TOPLEVEL_GET_SET_FUNCS ("background/stretch", background, bool, stretch, gboolean) -TOPLEVEL_GET_SET_FUNCS ("background/rotate", background, bool, rotate, gboolean) +TOPLEVEL_GET_SET_BG_FUNCS ("fit", background, boolean, fit, gboolean) +TOPLEVEL_GET_SET_BG_FUNCS ("stretch", background, boolean, stretch, gboolean) +TOPLEVEL_GET_SET_BG_FUNCS ("rotate", background, boolean, rotate, gboolean) -static const char * -panel_profile_get_attached_object_key (PanelToplevel *toplevel, - const char *key) +GSettings* +panel_profile_get_attached_object_settings (PanelToplevel *toplevel) { GtkWidget *attach_widget; const char *id; + char *path; + GSettings *settings; attach_widget = panel_toplevel_get_attach_widget (toplevel); @@ -661,200 +395,134 @@ panel_profile_get_attached_object_key (PanelToplevel *toplevel, if (!id) return NULL; - return panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, key); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + g_free (path); + + return settings; } void panel_profile_set_attached_custom_icon (PanelToplevel *toplevel, const char *custom_icon) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); + GSettings *settings; + settings = panel_profile_get_attached_object_settings (toplevel); - key = panel_profile_get_attached_object_key (toplevel, "use_custom_icon"); - if (key) - mateconf_client_set_bool (client, key, custom_icon != NULL, NULL); + g_settings_set_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY, custom_icon != NULL); + g_settings_set_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY, sure_string (custom_icon)); - key = panel_profile_get_attached_object_key (toplevel, "custom_icon"); - if (key) - mateconf_client_set_string (client, key, sure_string (custom_icon), NULL); + g_object_unref (settings); } char * panel_profile_get_attached_custom_icon (PanelToplevel *toplevel) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); + gchar *custom_icon = NULL; + if (panel_toplevel_get_is_attached (toplevel)) + { + GSettings *settings; + settings = panel_profile_get_attached_object_settings (toplevel); - key = panel_profile_get_attached_object_key (toplevel, "use_custom_icon"); - if (!key || !mateconf_client_get_bool (client, key, NULL)) - return NULL; - - key = panel_profile_get_attached_object_key (toplevel, "custom_icon"); + if (!g_settings_get_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY)) + { + g_object_unref (settings); + return NULL; + } - return key ? mateconf_client_get_string (client, key, NULL) : NULL; + custom_icon = g_settings_get_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY); + g_object_unref (settings); + } + return custom_icon; } gboolean panel_profile_is_writable_attached_custom_icon (PanelToplevel *toplevel) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_attached_object_key (toplevel, "use_custom_icon"); - if (!key) - return TRUE; - - if (!mateconf_client_key_is_writable (client, key, NULL)) - return FALSE; + gboolean is_writable = FALSE; + if (panel_toplevel_get_is_attached (toplevel)) + { + GSettings *settings; + settings = panel_profile_get_attached_object_settings (toplevel); - key = panel_profile_get_attached_object_key (toplevel, "custom_icon"); + is_writable = g_settings_is_writable (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY) && + g_settings_is_writable (settings, PANEL_OBJECT_CUSTOM_ICON_KEY); - return key ? mateconf_client_key_is_writable (client, key, NULL) : TRUE; + g_object_unref (settings); + } + return is_writable; } void panel_profile_set_attached_tooltip (PanelToplevel *toplevel, const char *tooltip) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_attached_object_key (toplevel, "tooltip"); - if (key) - mateconf_client_set_string (client, key, tooltip, NULL); + GSettings *settings; + settings = panel_profile_get_attached_object_settings (toplevel); + g_settings_set_string (settings, PANEL_OBJECT_TOOLTIP_KEY, tooltip); + g_object_unref (settings); } char * panel_profile_get_attached_tooltip (PanelToplevel *toplevel) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_attached_object_key (toplevel, "tooltip"); - - return key ? mateconf_client_get_string (client, key, NULL) : NULL; + gchar *tooltip = NULL; + if (panel_toplevel_get_is_attached (toplevel)) + { + GSettings *settings; + settings = panel_profile_get_attached_object_settings (toplevel); + tooltip = g_settings_get_string (settings, PANEL_OBJECT_TOOLTIP_KEY); + g_object_unref (settings); + } + return tooltip; } gboolean panel_profile_is_writable_attached_tooltip (PanelToplevel *toplevel) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_profile_get_attached_object_key (toplevel, "tooltip"); - - return key ? mateconf_client_key_is_writable (client, key, NULL) : TRUE; -} - -static PanelBackgroundType -get_background_type (MateConfClient *client, - const char *toplevel_dir) -{ - PanelBackgroundType background_type; - GError *error = NULL; - const char *key; - char *type_str; - - key = panel_mateconf_sprintf ("%s/background/type", toplevel_dir); - type_str = mateconf_client_get_string (client, key, &error); - if (error) { - g_warning (_("Error reading MateConf string value '%s': %s"), - key, error->message); - g_error_free (error); - return PANEL_BACK_NONE; + gboolean is_writable = FALSE; + if (panel_toplevel_get_is_attached (toplevel)) + { + GSettings *settings; + settings = panel_profile_get_attached_object_settings (toplevel); + is_writable = g_settings_is_writable (settings, PANEL_OBJECT_TOOLTIP_KEY); + g_object_unref (settings); } - - if (!type_str || !panel_profile_map_background_type_string (type_str, &background_type)) - background_type = PANEL_BACK_NONE; - - g_free (type_str); - - return background_type; + return is_writable; } static void -get_background_color (MateConfClient *client, - const char *toplevel_dir, - PanelColor *color) +get_background_color (PanelToplevel *toplevel, + PanelColor *color) { - GError *error; - const char *key; char *color_str; - - error = NULL; - key = panel_mateconf_sprintf ("%s/background/color", toplevel_dir); - color_str = mateconf_client_get_string (client, key, &error); - if (error) { - g_warning (_("Error reading MateConf string value '%s': %s"), - key, error->message); - g_error_free (error); - } else if (!color_str || !gdk_color_parse (color_str, &(color->gdk))) { + color_str = g_settings_get_string (toplevel->background_settings, "color"); + if (!color_str || !gdk_color_parse (color_str, &(color->gdk))) { color->gdk.red = 0; color->gdk.green = 0; color->gdk.blue = 0; } - g_free (color_str); - error = NULL; - key = panel_mateconf_sprintf ("%s/background/opacity", toplevel_dir); - color->alpha = mateconf_client_get_int (client, key, &error); - if (error) { - g_warning (_("Error reading MateConf integer value '%s': %s"), - key, error->message); - g_error_free (error); - color->alpha = 65535; /* fallback to fully opaque */ - } + color->alpha = g_settings_get_int (toplevel->background_settings, "opacity"); } static char * -get_background_image (MateConfClient *client, - const char *toplevel_dir, +get_background_image (PanelToplevel *toplevel, gboolean *fit, gboolean *stretch, gboolean *rotate) { - const char *key; - GError *error = NULL; char *image; - - key = panel_mateconf_sprintf ("%s/background/image", toplevel_dir); - image = mateconf_client_get_string (client, key, &error); - if (error) { - g_warning (_("Error reading MateConf string value '%s': %s"), - key, error->message); - g_error_free (error); - } - - key = panel_mateconf_sprintf ("%s/background/fit", toplevel_dir); - *fit = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/background/stretch", toplevel_dir); - *stretch = mateconf_client_get_bool (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/background/rotate", toplevel_dir); - *rotate = mateconf_client_get_bool (client, key, NULL); - + image = g_settings_get_string (toplevel->background_settings, "image"); + *fit = g_settings_get_boolean (toplevel->background_settings, "fit"); + *stretch = g_settings_get_boolean (toplevel->background_settings, "stretch"); + *rotate = g_settings_get_boolean (toplevel->background_settings, "rotate"); return image; } static void -panel_profile_load_background (PanelToplevel *toplevel, - MateConfClient *client, - const char *toplevel_dir) +panel_profile_load_background (PanelToplevel *toplevel) { PanelWidget *panel_widget; PanelBackground *background; @@ -868,11 +536,11 @@ panel_profile_load_background (PanelToplevel *toplevel, panel_widget = panel_toplevel_get_panel_widget (toplevel); background = &panel_widget->background; - background_type = get_background_type (client, toplevel_dir); + background_type = panel_profile_get_background_type (toplevel); - get_background_color (client, toplevel_dir, &color); + get_background_color (toplevel, &color); - image = get_background_image (client, toplevel_dir, &fit, &stretch, &rotate); + image = get_background_image (toplevel, &fit, &stretch, &rotate); panel_background_set (background, background_type, @@ -888,15 +556,9 @@ panel_profile_load_background (PanelToplevel *toplevel, static gboolean panel_profile_commit_toplevel_changes (PanelToplevel *toplevel) { - MateConfChangeSet *queued_changes; - - queued_changes = panel_profile_get_queued_changes (G_OBJECT (toplevel)); - if (queued_changes) - mateconf_client_commit_change_set ( - panel_mateconf_get_client (), - queued_changes, FALSE, NULL); + if (g_settings_get_has_unapplied (toplevel->queued_settings)) + g_settings_apply (toplevel->queued_settings); - panel_profile_set_queued_changes (toplevel, NULL); panel_profile_set_commit_timeout (toplevel, 0); return FALSE; @@ -906,75 +568,60 @@ static void panel_profile_queue_toplevel_location_change (PanelToplevel *toplevel, ToplevelLocationChange *change) { - MateConfChangeSet *queued_changes; guint commit_timeout; - queued_changes = panel_profile_get_queued_changes (G_OBJECT (toplevel)); - if (!queued_changes) { - queued_changes = mateconf_change_set_new (); - panel_profile_set_queued_changes (toplevel, queued_changes); - } + g_settings_delay (toplevel->queued_settings); if (change->screen_changed) - mateconf_change_set_set_int ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "screen"), - gdk_screen_get_number (change->screen)); + g_settings_set_int (toplevel->queued_settings, + "screen", + gdk_screen_get_number (change->screen)); if (change->monitor_changed) - mateconf_change_set_set_int ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "monitor"), - change->monitor); + g_settings_set_int (toplevel->queued_settings, + "monitor", + change->monitor); if (change->size_changed) - mateconf_change_set_set_int ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "size"), - change->size); + g_settings_set_int (toplevel->queued_settings, + "size", + change->size); if (change->orientation_changed) - mateconf_change_set_set_string ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "orientation"), - mateconf_enum_to_string (panel_orientation_map, change->orientation)); + g_settings_set_enum (toplevel->queued_settings, + "orientation", + change->orientation); if (!panel_toplevel_get_expand (toplevel)) { if (change->x_changed) - mateconf_change_set_set_int ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "x"), - change->x); + g_settings_set_int (toplevel->queued_settings, + "x", + change->x); if (change->x_right_changed) - mateconf_change_set_set_int ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "x_right"), - change->x_right); + g_settings_set_int (toplevel->queued_settings, + "x-right", + change->x_right); if (change->x_centered_changed) - mateconf_change_set_set_bool ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "x_centered"), - change->x_centered); + g_settings_set_boolean (toplevel->queued_settings, + "x-centered", + change->x_centered); if (change->y_changed) - mateconf_change_set_set_int ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "y"), - change->y); + g_settings_set_int (toplevel->queued_settings, + "y", + change->y); if (change->y_bottom_changed) - mateconf_change_set_set_int ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "y_bottom"), - change->y_bottom); + g_settings_set_int (toplevel->queued_settings, + "y-bottom", + change->y_bottom); if (change->y_centered_changed) - mateconf_change_set_set_bool ( - queued_changes, - panel_profile_get_toplevel_key (toplevel, "y_centered"), - change->y_centered); + g_settings_set_boolean (toplevel->queued_settings, + "y-centered", + change->y_centered); } commit_timeout = panel_profile_get_commit_timeout (G_OBJECT (toplevel)); @@ -1059,380 +706,202 @@ panel_profile_connect_to_toplevel (PanelToplevel *toplevel) } static void -set_name_from_string (PanelToplevel *toplevel, - const char *str) -{ - if (!str) - return; - - panel_toplevel_set_name (toplevel, str); -} - -static void -set_orientation_from_string (PanelToplevel *toplevel, - const char *str) +panel_profile_toplevel_change_notify (GSettings *settings, + gchar *key, + PanelToplevel *toplevel) { - PanelOrientation orientation; - - if (!str || !panel_profile_map_orientation_string (str, &orientation)) - return; - panel_toplevel_set_orientation (toplevel, orientation); -} - -static void -set_animation_speed_from_string (PanelToplevel *toplevel, - const char *str) -{ - PanelAnimationSpeed animation_speed; - - if (!str || !panel_profile_map_speed_string (str, &animation_speed)) - return; - - panel_toplevel_set_animation_speed (toplevel, animation_speed); -} - -static void -panel_profile_toplevel_change_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - PanelToplevel *toplevel) -{ - MateConfValue *value; - const char *key; - - key = panel_mateconf_basename (mateconf_entry_get_key (entry)); - - if (!(value = mateconf_entry_get_value (entry))) - return; - -#define UPDATE_STRING(k, n) \ +#define UPDATE_STRING(k, n) \ if (!strcmp (key, k)) { \ - if (value->type == MATECONF_VALUE_STRING) \ - set_##n##_from_string (toplevel, \ - mateconf_value_get_string (value)); \ + panel_toplevel_set_##n (toplevel, \ + g_settings_get_string (settings, key)); \ } -#define UPDATE_INT(k, n) \ +#define UPDATE_ENUM(k, n) \ if (!strcmp (key, k)) { \ - if (value->type == MATECONF_VALUE_INT) \ - panel_toplevel_set_##n (toplevel, \ - mateconf_value_get_int (value)); \ + panel_toplevel_set_##n (toplevel, \ + g_settings_get_enum (settings, key)); \ } -#define UPDATE_BOOL(k, n) \ +#define UPDATE_INT(k, n) \ if (!strcmp (key, k)) { \ - if (value->type == MATECONF_VALUE_BOOL) \ - panel_toplevel_set_##n (toplevel, \ - mateconf_value_get_bool (value)); \ + panel_toplevel_set_##n (toplevel, \ + g_settings_get_int (settings, key)); \ } -#define UPDATE_POS(k, n, n2) \ +#define UPDATE_BOOL(k, n) \ if (!strcmp (key, k)) { \ - if (value->type == MATECONF_VALUE_INT) { \ - int x, x_right, y, y_bottom; \ - panel_toplevel_get_position (toplevel, &x, &x_right, \ - &y, &y_bottom); \ - panel_toplevel_set_##n ( \ - toplevel, \ - mateconf_value_get_int (value), \ - n2, \ - panel_toplevel_get_##n##_centered (toplevel)); \ - } \ + panel_toplevel_set_##n (toplevel, \ + g_settings_get_boolean (settings, key)); \ } -#define UPDATE_POS2(k, n, n2) \ +#define UPDATE_POS(k, n, n2) \ if (!strcmp (key, k)) { \ - if (value->type == MATECONF_VALUE_INT) { \ - int x, x_right, y, y_bottom; \ - panel_toplevel_get_position (toplevel, &x, &x_right, \ - &y, &y_bottom); \ - panel_toplevel_set_##n ( \ - toplevel, \ - n, \ - mateconf_value_get_int (value), \ - panel_toplevel_get_##n##_centered (toplevel)); \ - } \ + int x, x_right, y, y_bottom; \ + panel_toplevel_get_position (toplevel, &x, &x_right, \ + &y, &y_bottom); \ + panel_toplevel_set_##n ( \ + toplevel, \ + g_settings_get_int (settings, key), \ + n2, \ + panel_toplevel_get_##n##_centered (toplevel)); \ } -#define UPDATE_CENTERED(k, n, n2) \ - if (!strcmp (key, k)) { \ - if (value->type == MATECONF_VALUE_BOOL) { \ - int x, x_right, y, y_bottom; \ - panel_toplevel_get_position (toplevel, &x, &x_right, \ - &y, &y_bottom); \ - panel_toplevel_set_##n ( \ - toplevel, n, n2, mateconf_value_get_bool (value)); \ - } \ +#define UPDATE_POS2(k, n, n2) \ + if (!strcmp (key, k)) { \ + int x, x_right, y, y_bottom; \ + panel_toplevel_get_position (toplevel, &x, &x_right, \ + &y, &y_bottom); \ + panel_toplevel_set_##n ( \ + toplevel, \ + n, \ + g_settings_get_int (settings, key), \ + panel_toplevel_get_##n##_centered (toplevel)); \ } - if (!strcmp (key, "screen")) { - if (value->type == MATECONF_VALUE_INT) { - GdkScreen *screen; - - screen = gdk_display_get_screen ( - gdk_display_get_default (), - mateconf_value_get_int (value)); - if (screen) - gtk_window_set_screen (GTK_WINDOW (toplevel), screen); - else - /* Make sure to set the key back to an actual - * available screen so it will get loaded on - * next startup. - */ - panel_profile_toplevel_screen_changed (toplevel); +#define UPDATE_CENTERED(k, n, n2) \ + if (!strcmp (key, k)) { \ + int x, x_right, y, y_bottom; \ + panel_toplevel_get_position (toplevel, &x, &x_right, \ + &y, &y_bottom); \ + panel_toplevel_set_##n ( \ + toplevel, n, n2, \ + g_settings_get_boolean (settings, key)); \ } - + + if (!strcmp (key, "screen")) { + GdkScreen *screen; + screen = gdk_display_get_screen ( + gdk_display_get_default (), + g_settings_get_int (settings, key)); + if (screen) + gtk_window_set_screen (GTK_WINDOW (toplevel), screen); + else + /* Make sure to set the key back to an actual + * available screen so it will get loaded on + * next startup. + */ + panel_profile_toplevel_screen_changed (toplevel); } else UPDATE_INT ("monitor", monitor) else UPDATE_STRING ("name", name) else UPDATE_BOOL ("expand", expand) - else UPDATE_STRING ("orientation", orientation) + else UPDATE_ENUM ("orientation", orientation) else UPDATE_INT ("size", size) else UPDATE_POS ("x", x, x_right) else UPDATE_POS ("y", y, y_bottom) - else UPDATE_POS2 ("x_right", x, x_right) - else UPDATE_POS2 ("y_bottom", y, y_bottom) - else UPDATE_CENTERED ("x_centered", x, x_right) - else UPDATE_CENTERED ("y_centered", y, y_bottom) - else UPDATE_BOOL ("auto_hide", auto_hide) - else UPDATE_BOOL ("enable_animations", animate) - else UPDATE_BOOL ("enable_buttons", enable_buttons) - else UPDATE_BOOL ("enable_arrows", enable_arrows) - else UPDATE_INT ("hide_delay", hide_delay) - else UPDATE_INT ("unhide_delay", unhide_delay) - else UPDATE_INT ("auto_hide_size", auto_hide_size) - else UPDATE_STRING ("animation_speed", animation_speed) + else UPDATE_POS2 ("x-right", x, x_right) + else UPDATE_POS2 ("y-bottom", y, y_bottom) + else UPDATE_CENTERED ("x-centered", x, x_right) + else UPDATE_CENTERED ("y-centered", y, y_bottom) + else UPDATE_BOOL ("auto-hide", auto_hide) + else UPDATE_BOOL ("enable-animations", animate) + else UPDATE_BOOL ("enable-buttons", enable_buttons) + else UPDATE_BOOL ("enable-arrows", enable_arrows) + else UPDATE_INT ("hide-delay", hide_delay) + else UPDATE_INT ("unhide-delay", unhide_delay) + else UPDATE_INT ("auto-hide-size", auto_hide_size) + else UPDATE_ENUM ("animation-speed", animation_speed) } static void -panel_profile_background_change_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - PanelToplevel *toplevel) +panel_profile_background_change_notify (GSettings *settings, + gchar *key, + PanelToplevel *toplevel) { PanelWidget *panel_widget; PanelBackground *background; - MateConfValue *value; - const char *key; - - key = panel_mateconf_basename (mateconf_entry_get_key (entry)); - - if (!(value = mateconf_entry_get_value (entry))) - return; panel_widget = panel_toplevel_get_panel_widget (toplevel); background = &panel_widget->background; if (!strcmp (key, "type")) { - if (value->type == MATECONF_VALUE_STRING) { - PanelBackgroundType background_type; - - if (panel_profile_map_background_type_string ( - mateconf_value_get_string (value), - &background_type)) { - panel_background_set_type (background, background_type); - panel_toplevel_update_edges (toplevel); - } - } + PanelBackgroundType background_type; + background_type = g_settings_get_enum (settings, key); + panel_background_set_type (background, background_type); + panel_toplevel_update_edges (toplevel); } else if (!strcmp (key, "color")) { - if (value->type == MATECONF_VALUE_STRING) { - GdkColor gdk_color; - const char *str; - - str = mateconf_value_get_string (value); - - if (gdk_color_parse (str, &gdk_color)) - panel_background_set_gdk_color (background, &gdk_color); - } + GdkColor gdk_color; + const char *str; + str = g_settings_get_string (settings, key); + if (gdk_color_parse (str, &gdk_color)) + panel_background_set_gdk_color (background, &gdk_color); } else if (!strcmp (key, "opacity")) { - if (value->type == MATECONF_VALUE_INT) - panel_background_set_opacity (background, - mateconf_value_get_int (value)); + panel_background_set_opacity (background, + g_settings_get_int (settings, key)); } else if (!strcmp (key, "image")) { - if (value->type == MATECONF_VALUE_STRING) - panel_background_set_image (background, - mateconf_value_get_string (value)); + panel_background_set_image (background, + g_settings_get_string (settings, key)); } else if (!strcmp (key, "fit")) { - if (value->type == MATECONF_VALUE_BOOL) - panel_background_set_fit (background, - mateconf_value_get_bool (value)); + panel_background_set_fit (background, + g_settings_get_boolean (settings, key)); } else if (!strcmp (key, "stretch")) { - if (value->type == MATECONF_VALUE_BOOL) - panel_background_set_stretch (background, - mateconf_value_get_bool (value)); + panel_background_set_stretch (background, + g_settings_get_boolean (settings, key)); } else if (!strcmp (key, "rotate")) { - if (value->type == MATECONF_VALUE_BOOL) - panel_background_set_rotate (background, - mateconf_value_get_bool (value)); - } -} - -static void -panel_profile_disconnect_toplevel (PanelToplevel *toplevel, - gpointer data) -{ - MateConfClient *client; - guint notify_id = GPOINTER_TO_UINT (data); - - client = panel_mateconf_get_client (); - - mateconf_client_notify_remove (client, notify_id); -} - -guint -panel_profile_toplevel_notify_add (PanelToplevel *toplevel, - const char *key, - MateConfClientNotifyFunc func, - gpointer data) -{ - MateConfClient *client; - const char *tmp; - guint retval; - - client = panel_mateconf_get_client (); - - if (!key) - tmp = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/toplevels/%s", - panel_profile_get_toplevel_id (toplevel)); - else - tmp = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/toplevels/%s/%s", - panel_profile_get_toplevel_id (toplevel), - key); - - retval = mateconf_client_notify_add (client, tmp, func, data, NULL, NULL); - - return retval; -} - -static void -panel_profile_save_id_list (PanelMateConfKeyType type, - GSList *list, - gboolean resave) -{ - MateConfClient *client; - const char *key; - const char *id_list; - - g_assert (!(resave && list != NULL)); - - client = panel_mateconf_get_client (); - - id_list = panel_mateconf_key_type_to_id_list (type); - - key = panel_mateconf_general_key (id_list); - if (resave) - list = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - else { - /* Make sure the elements in the list appear only once. We only - * do it when we save a list with new elements. */ - list = panel_g_slist_make_unique (list, - (GCompareFunc) strcmp, - TRUE); + panel_background_set_rotate (background, + g_settings_get_boolean (settings, key)); } - - mateconf_client_set_list (client, key, MATECONF_VALUE_STRING, list, NULL); - - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); -} - -static inline void -panel_profile_save_other_id_lists (PanelMateConfKeyType type) -{ - if (type != PANEL_MATECONF_TOPLEVELS) - panel_profile_save_id_list (PANEL_MATECONF_TOPLEVELS, NULL, TRUE); - - if (type != PANEL_MATECONF_OBJECTS) - panel_profile_save_id_list (PANEL_MATECONF_OBJECTS, NULL, TRUE); - - if (type != PANEL_MATECONF_APPLETS) - panel_profile_save_id_list (PANEL_MATECONF_APPLETS, NULL, TRUE); } void -panel_profile_add_to_list (PanelMateConfKeyType type, - const char *id) +panel_profile_add_to_list (PanelGSettingsKeyType type, + const char *id) { - MateConfClient *client; - GSList *list; - const char *key; - const char *id_list; - char *new_id; - - client = panel_mateconf_get_client (); - - id_list = panel_mateconf_key_type_to_id_list (type); - - key = panel_mateconf_general_key (id_list); - list = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); + char *key; + char *new_id; new_id = id ? g_strdup (id) : panel_profile_find_new_id (type); - list = g_slist_append (list, new_id); + if (type == PANEL_GSETTINGS_TOPLEVELS) + key = g_strdup (PANEL_TOPLEVEL_ID_LIST_KEY); + else if (type == PANEL_GSETTINGS_OBJECTS) + key = g_strdup (PANEL_OBJECT_ID_LIST_KEY); - panel_profile_save_id_list (type, list, FALSE); - panel_profile_save_other_id_lists (type); + panel_gsettings_append_strv (profile_settings, + key, + new_id); + + g_free (key); + g_free (new_id); } void -panel_profile_remove_from_list (PanelMateConfKeyType type, - const char *id) -{ - MateConfClient *client; - GSList *list, *l; - const char *key; - const char *id_list; - - client = panel_mateconf_get_client (); - - id_list = panel_mateconf_key_type_to_id_list (type); - - key = panel_mateconf_general_key (id_list); - list = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - - /* Remove all occurrence of id and not just the first. We're more solid - * this way (see bug #137308 for example). */ - l = list; - while (l) { - GSList *next; - - next = l->next; - - if (!strcmp (id, l->data)) { - g_free (l->data); - list = g_slist_delete_link (list, l); - } - - l = next; - } - - panel_profile_save_id_list (type, list, FALSE); - panel_profile_save_other_id_lists (type); +panel_profile_remove_from_list (PanelGSettingsKeyType type, + const char *id) +{ + gchar *key; + if (type == PANEL_GSETTINGS_TOPLEVELS) + key = g_strdup (PANEL_TOPLEVEL_ID_LIST_KEY); + else if (type == PANEL_GSETTINGS_OBJECTS) + key = g_strdup (PANEL_OBJECT_ID_LIST_KEY); + + panel_gsettings_remove_all_from_strv (profile_settings, + key, + id); + g_free (key); } static gboolean -panel_profile_id_list_is_writable (PanelMateConfKeyType type) +panel_profile_id_list_is_writable (PanelGSettingsKeyType type) { - MateConfClient *client; - const char *key; - const char *id_list; - - client = panel_mateconf_get_client (); - - id_list = panel_mateconf_key_type_to_id_list (type); - - key = panel_mateconf_general_key (id_list); - return mateconf_client_key_is_writable (client, key, NULL); + gboolean is_writable; + gchar *key; + if (type == PANEL_GSETTINGS_TOPLEVELS) + key = g_strdup (PANEL_TOPLEVEL_ID_LIST_KEY); + else if (type == PANEL_GSETTINGS_OBJECTS) + key = g_strdup (PANEL_OBJECT_ID_LIST_KEY); + is_writable = g_settings_is_writable (profile_settings, key); + g_free (key); + return is_writable; } gboolean panel_profile_id_lists_are_writable (void) { return - panel_profile_id_list_is_writable (PANEL_MATECONF_TOPLEVELS) && - panel_profile_id_list_is_writable (PANEL_MATECONF_APPLETS) && - panel_profile_id_list_is_writable (PANEL_MATECONF_OBJECTS); + panel_profile_id_list_is_writable (PANEL_GSETTINGS_TOPLEVELS) && + panel_profile_id_list_is_writable (PANEL_GSETTINGS_OBJECTS); } static gboolean @@ -1497,77 +966,68 @@ panel_profile_find_empty_spot (GdkScreen *screen, void panel_profile_create_toplevel (GdkScreen *screen) { - MateConfClient *client; - const char *key; char *id; - char *dir; + char *path; PanelOrientation orientation; int monitor; - + GSettings *settings; + g_return_if_fail (screen != NULL); - client = panel_mateconf_get_client (); + id = panel_profile_find_new_id (PANEL_GSETTINGS_TOPLEVELS); - id = panel_profile_find_new_id (PANEL_MATECONF_TOPLEVELS); + path = g_strdup_printf (PANEL_TOPLEVEL_PATH "%s/", id); - dir = g_strdup_printf (PANEL_CONFIG_DIR "/toplevels/%s", id); - panel_mateconf_associate_schemas_in_dir (client, dir, PANEL_SCHEMAS_DIR "/toplevels"); - g_free (dir); + settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, path); + g_free (path); - key = panel_mateconf_full_key (PANEL_MATECONF_TOPLEVELS, id, "screen"); - mateconf_client_set_int (client, key, gdk_screen_get_number (screen), NULL); + g_settings_set_int (settings, PANEL_TOPLEVEL_SCREEN_KEY, gdk_screen_get_number (screen)); if (panel_profile_find_empty_spot (screen, &orientation, &monitor)) { - key = panel_mateconf_full_key (PANEL_MATECONF_TOPLEVELS, id, "monitor"); - mateconf_client_set_int (client, key, monitor, NULL); - - key = panel_mateconf_full_key (PANEL_MATECONF_TOPLEVELS, id, "orientation"); - mateconf_client_set_string (client, key, panel_profile_map_orientation (orientation), NULL); + g_settings_set_int (settings, PANEL_TOPLEVEL_MONITOR_KEY, monitor); + g_settings_set_enum (settings, PANEL_TOPLEVEL_ORIENTATION_KEY, orientation); } - panel_profile_add_to_list (PANEL_MATECONF_TOPLEVELS, id); + panel_profile_add_to_list (PANEL_GSETTINGS_TOPLEVELS, id); + g_object_unref (settings); g_free (id); } static void -panel_profile_delete_toplevel_objects (const char *toplevel_id, - PanelMateConfKeyType key_type) +panel_profile_delete_toplevel_objects (const char *toplevel_id) { - MateConfClient *client; - const char *key; - GSList *new_list = NULL,*list, *l; + gchar **list; + GArray *newlist; + int i; - client = panel_mateconf_get_client (); + list = g_settings_get_strv (profile_settings, PANEL_OBJECT_ID_LIST_KEY); + newlist = g_array_new (TRUE, TRUE, sizeof (gchar *)); - key = panel_mateconf_general_key (panel_mateconf_key_type_to_id_list (key_type)); - list = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - - for (l = list; l; l = l->next) { - char *id = l->data; + for (i = 0; list[i]; i++) { + char *path; char *parent_toplevel_id; + GSettings *settings; - key = panel_mateconf_full_key (key_type, id, "toplevel_id"); - parent_toplevel_id = mateconf_client_get_string (client, key, NULL); + path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", list[i]); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path); + parent_toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY); + g_free (path); + g_object_unref (settings); if (parent_toplevel_id && !strcmp (toplevel_id, parent_toplevel_id)) { - g_free (id); g_free (parent_toplevel_id); continue; } - new_list = g_slist_prepend (new_list, id); + newlist = g_array_append_val (newlist, list[i]); g_free (parent_toplevel_id); } - g_slist_free (list); - - key = panel_mateconf_general_key (panel_mateconf_key_type_to_id_list (key_type)); - mateconf_client_set_list (client, key, MATECONF_VALUE_STRING, new_list, NULL); - for (l = new_list; l; l = l->next) - g_free (l->data); - g_slist_free (new_list); + g_settings_set_strv (profile_settings, PANEL_OBJECT_ID_LIST_KEY, (const gchar **) newlist->data); + g_array_free (newlist, TRUE); + g_strfreev (list); } void @@ -1577,29 +1037,22 @@ panel_profile_delete_toplevel (PanelToplevel *toplevel) toplevel_id = panel_profile_get_toplevel_id (toplevel); - panel_profile_delete_toplevel_objects (toplevel_id, PANEL_MATECONF_OBJECTS); - panel_profile_delete_toplevel_objects (toplevel_id, PANEL_MATECONF_APPLETS); + panel_profile_delete_toplevel_objects (toplevel_id); - panel_profile_remove_from_list (PANEL_MATECONF_TOPLEVELS, toplevel_id); + panel_profile_remove_from_list (PANEL_GSETTINGS_TOPLEVELS, toplevel_id); } static GdkScreen * -get_toplevel_screen (MateConfClient *client, - const char *toplevel_dir) +get_toplevel_screen (char *toplevel_path) { - GError *error = NULL; + GdkDisplay *display; - const char *key; + GSettings *settings; int screen_n; - key = panel_mateconf_sprintf ("%s/screen", toplevel_dir); - screen_n = mateconf_client_get_int (client, key, &error); - if (error) { - g_warning (_("Error reading MateConf integer value '%s': %s"), - key, error->message); - g_error_free (error); - return gdk_screen_get_default (); - } + settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, toplevel_path); + screen_n = g_settings_get_int (settings, "screen"); + g_object_unref (settings); display = gdk_display_get_default (); @@ -1616,42 +1069,20 @@ get_toplevel_screen (MateConfClient *client, } PanelToplevel * -panel_profile_load_toplevel (MateConfClient *client, - const char *profile_dir, - PanelMateConfKeyType type, - const char *toplevel_id) +panel_profile_load_toplevel (char *toplevel_id) { PanelToplevel *toplevel; GdkScreen *screen; - GError *error; - const char *key; - char *toplevel_dir; - guint notify_id; + char *toplevel_path; + char *toplevel_background_path; if (!toplevel_id || !toplevel_id [0]) return NULL; - toplevel_dir = g_strdup_printf ("%s/toplevels/%s", profile_dir, toplevel_id); + toplevel_path = g_strdup_printf ("%s%s/", PANEL_TOPLEVEL_PATH, toplevel_id); - if (!mateconf_client_dir_exists (client, toplevel_dir, NULL)) - panel_mateconf_associate_schemas_in_dir ( - client, toplevel_dir, PANEL_SCHEMAS_DIR "/toplevels"); - - mateconf_client_add_dir (client, - toplevel_dir, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - - key = panel_mateconf_sprintf ("%s/background", toplevel_dir); - mateconf_client_add_dir (client, - key, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - - if (!(screen = get_toplevel_screen (client, toplevel_dir))) { - mateconf_client_remove_dir (client, key, NULL); - mateconf_client_remove_dir (client, toplevel_dir, NULL); - g_free (toplevel_dir); + if (!(screen = get_toplevel_screen (toplevel_path))) { + g_free (toplevel_path); return NULL; } @@ -1659,131 +1090,86 @@ panel_profile_load_toplevel (MateConfClient *client, "screen", screen, NULL); -#define GET_INT(k, fn) \ - { \ - int val; \ - error = NULL; \ - key = panel_mateconf_sprintf ("%s/" k, toplevel_dir); \ - val = mateconf_client_get_int (client, key, &error); \ - if (!error) \ - panel_toplevel_set_##fn (toplevel, val); \ - else { \ - g_warning (_("Error reading MateConf integer value '%s': %s"), \ - key, error->message); \ - g_error_free (error); \ - } \ + panel_toplevel_set_settings_path (toplevel, toplevel_path); + toplevel->settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, toplevel_path); + toplevel->queued_settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, toplevel_path); + + toplevel_background_path = g_strdup_printf ("%sbackground/", toplevel_path); + toplevel->background_settings = g_settings_new_with_path (PANEL_TOPLEVEL_BACKGROUND_SCHEMA, toplevel_background_path); + +#define GET_INT(k, fn) \ + { \ + int val; \ + val = g_settings_get_int (toplevel->settings, k); \ + panel_toplevel_set_##fn (toplevel, val); \ + } + +#define GET_BOOL(k, fn) \ + { \ + gboolean val; \ + val = g_settings_get_boolean (toplevel->settings, k); \ + panel_toplevel_set_##fn (toplevel, val); \ } -#define GET_BOOL(k, fn) \ - { \ - gboolean val; \ - error = NULL; \ - key = panel_mateconf_sprintf ("%s/" k, toplevel_dir); \ - val = mateconf_client_get_bool (client, key, &error); \ - if (!error) \ - panel_toplevel_set_##fn (toplevel, val); \ - else { \ - g_warning (_("Error reading MateConf boolean value '%s': %s"), \ - key, error->message); \ - g_error_free (error); \ - } \ +#define GET_STRING(k, fn) \ + { \ + char *val; \ + val = g_settings_get_string (toplevel->settings, k); \ + panel_toplevel_set_##fn (toplevel, val); \ + g_free (val); \ } -#define GET_STRING(k, fn) \ - { \ - char *val; \ - error = NULL; \ - key = panel_mateconf_sprintf ("%s/" k, toplevel_dir); \ - val = mateconf_client_get_string (client, key, &error); \ - if (!error && val) { \ - set_##fn##_from_string (toplevel, val); \ - g_free (val); \ - } else if (error) { \ - g_warning (_("Error reading MateConf string value '%s': %s"), \ - key, error->message); \ - g_error_free (error); \ - } \ +#define GET_ENUM(k, fn) \ + { \ + int val; \ + val = g_settings_get_enum (toplevel->settings, k); \ + panel_toplevel_set_##fn (toplevel, val); \ } GET_STRING ("name", name); GET_INT ("monitor", monitor); GET_BOOL ("expand", expand); - GET_STRING ("orientation", orientation); + GET_ENUM ("orientation", orientation); GET_INT ("size", size); - GET_BOOL ("auto_hide", auto_hide); - GET_BOOL ("enable_animations", animate); - GET_BOOL ("enable_buttons", enable_buttons); - GET_BOOL ("enable_arrows", enable_arrows); - GET_INT ("hide_delay", hide_delay); - GET_INT ("unhide_delay", unhide_delay); - GET_INT ("auto_hide_size", auto_hide_size); - GET_STRING ("animation_speed", animation_speed); - -#define GET_POSITION(a, b, c, fn) \ - { \ - gboolean centered; \ - int position; \ - int position2; \ - key = panel_mateconf_sprintf ("%s/" c, toplevel_dir); \ - centered = mateconf_client_get_bool (client, key, &error); \ - if (!error) { \ - key = panel_mateconf_sprintf ("%s/" a, toplevel_dir); \ - position = mateconf_client_get_int (client, key, &error); \ - } \ - if (!error) { \ - MateConfValue *value; \ - key = panel_mateconf_sprintf ("%s/" b, toplevel_dir); \ - /* we need to do this since the key was added in 2.19 and \ - * the default value returned when the key is not set \ - * (for people coming from older versions) is 0, which \ - * is not what we want. */ \ - value = mateconf_client_get_without_default (client, key, &error);\ - if (value && value->type == MATECONF_VALUE_INT) \ - position2 = mateconf_value_get_int (value); \ - else \ - position2 = -1; \ - \ - if (value) \ - mateconf_value_free (value); \ - } \ - if (!error) \ - panel_toplevel_set_##fn (toplevel, position, position2, \ - centered); \ - else { \ - g_warning (_("Error reading MateConf integer value '%s': %s"), \ - key, error->message); \ - g_error_free (error); \ - } \ + GET_BOOL ("auto-hide", auto_hide); + GET_BOOL ("enable-animations", animate); + GET_BOOL ("enable-buttons", enable_buttons); + GET_BOOL ("enable-arrows", enable_arrows); + GET_INT ("hide-delay", hide_delay); + GET_INT ("unhide-delay", unhide_delay); + GET_INT ("auto-hide-size", auto_hide_size); + GET_ENUM ("animation-speed", animation_speed); + +#define GET_POSITION(a, b, c, fn) \ + { \ + gboolean centered; \ + int position; \ + int position2; \ + centered = g_settings_get_boolean (toplevel->settings, c); \ + position = g_settings_get_int (toplevel->settings, a); \ + position2 = g_settings_get_int (toplevel->settings, b); \ + panel_toplevel_set_##fn (toplevel, position, position2, centered); \ } - GET_POSITION ("x", "x_right", "x_centered", x); - GET_POSITION ("y", "y_bottom", "y_centered", y); + GET_POSITION ("x", "x-right", "x-centered", x); + GET_POSITION ("y", "y-bottom", "y-centered", y); - panel_profile_load_background (toplevel, client, toplevel_dir); + panel_profile_load_background (toplevel); panel_profile_set_toplevel_id (toplevel, toplevel_id); panel_profile_connect_to_toplevel (toplevel); - notify_id = panel_profile_toplevel_notify_add ( - toplevel, - NULL, - (MateConfClientNotifyFunc) panel_profile_toplevel_change_notify, - toplevel); - g_signal_connect (toplevel, "destroy", - G_CALLBACK (panel_profile_disconnect_toplevel), - GUINT_TO_POINTER (notify_id)); - - notify_id = panel_profile_toplevel_notify_add ( - toplevel, - "background", - (MateConfClientNotifyFunc) panel_profile_background_change_notify, - toplevel); - g_signal_connect (toplevel, "destroy", - G_CALLBACK (panel_profile_disconnect_toplevel), - GUINT_TO_POINTER (notify_id)); - - g_free (toplevel_dir); + g_signal_connect (toplevel->settings, + "changed", + G_CALLBACK (panel_profile_toplevel_change_notify), + toplevel); + g_signal_connect (toplevel->background_settings, + "changed", + G_CALLBACK (panel_profile_background_change_notify), + toplevel); + + g_free (toplevel_background_path); panel_setup (toplevel); @@ -1791,18 +1177,13 @@ panel_profile_load_toplevel (MateConfClient *client, } static void -panel_profile_load_and_show_toplevel (MateConfClient *client, - const char *profile_dir, - PanelMateConfKeyType type, - const char *toplevel_id) +panel_profile_load_and_show_toplevel (char *toplevel_id) { - PanelToplevel *toplevel; - const char *id_list; - const char *key; - MateConfValue *value; - gboolean loading_queued_applets; + PanelToplevel *toplevel; + gchar **objects; + gboolean loading_queued_applets; - toplevel = panel_profile_load_toplevel (client, profile_dir, type, toplevel_id); + toplevel = panel_profile_load_toplevel (toplevel_id); if (!toplevel) return; @@ -1812,39 +1193,27 @@ panel_profile_load_and_show_toplevel (MateConfClient *client, /* reload list of objects to get those that might be on the new * toplevel */ - id_list = panel_mateconf_key_type_to_id_list (PANEL_MATECONF_OBJECTS); - key = panel_mateconf_sprintf ("%s/general/%s", profile_dir, id_list); - value = mateconf_client_get (client, key, NULL); - if (value) { - panel_profile_object_id_list_update (client, value, - PANEL_MATECONF_OBJECTS); - loading_queued_applets = TRUE; - mateconf_value_free (value); - } - - id_list = panel_mateconf_key_type_to_id_list (PANEL_MATECONF_APPLETS); - key = panel_mateconf_sprintf ("%s/general/%s", profile_dir, id_list); - value = mateconf_client_get (client, key, NULL); - if (value) { - panel_profile_object_id_list_update (client, value, - PANEL_MATECONF_APPLETS); + GSettings *panel_settings; + panel_settings = g_settings_new (PANEL_SCHEMA); + objects = g_settings_get_strv (panel_settings, PANEL_OBJECT_ID_LIST_KEY); + + if (objects) { + panel_profile_object_id_list_update (objects); loading_queued_applets = TRUE; - mateconf_value_free (value); } if (!loading_queued_applets) mate_panel_applet_load_queued_applets (FALSE); + + g_strfreev (objects); + g_object_unref (panel_settings); } static void -panel_profile_load_and_show_toplevel_startup (MateConfClient *client, - const char *profile_dir, - PanelMateConfKeyType type, - const char *toplevel_id) +panel_profile_load_and_show_toplevel_startup (const char *toplevel_id) { PanelToplevel *toplevel; - - toplevel = panel_profile_load_toplevel (client, profile_dir, type, toplevel_id); + toplevel = panel_profile_load_toplevel (toplevel_id); if (toplevel) gtk_widget_show (GTK_WIDGET (toplevel)); } @@ -1866,39 +1235,26 @@ panel_profile_prepare_object_with_id (PanelObjectType object_type, int position, gboolean right_stick) { - PanelMateConfKeyType key_type; - MateConfClient *client; + PanelGSettingsKeyType key_type; const char *key; char *id; - char *dir; - - key_type = (object_type == PANEL_OBJECT_APPLET) ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS; - - client = panel_mateconf_get_client (); + char *settings_path; + GSettings *settings; + key_type = PANEL_GSETTINGS_OBJECTS; id = panel_profile_find_new_id (key_type); - dir = g_strdup_printf (PANEL_CONFIG_DIR "/%s/%s", - (key_type == PANEL_MATECONF_APPLETS) ? "applets" : "objects", - id); - panel_mateconf_associate_schemas_in_dir (client, dir, PANEL_SCHEMAS_DIR "/objects"); - - key = panel_mateconf_full_key (key_type, id, "object_type"); - mateconf_client_set_string (client, - key, - mateconf_enum_to_string (panel_object_type_map, object_type), - NULL); + settings_path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); - key = panel_mateconf_full_key (key_type, id, "toplevel_id"); - mateconf_client_set_string (client, key, toplevel_id, NULL); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, settings_path); - key = panel_mateconf_full_key (key_type, id, "position"); - mateconf_client_set_int (client, key, position, NULL); + g_settings_set_enum (settings, PANEL_OBJECT_TYPE_KEY, object_type); + g_settings_set_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY, toplevel_id); + g_settings_set_int (settings, PANEL_OBJECT_POSITION_KEY, position); + g_settings_set_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, right_stick); - key = panel_mateconf_full_key (key_type, id, "panel_right_stick"); - mateconf_client_set_bool (client, key, right_stick, NULL); - - g_free (dir); + g_free (settings_path); + g_object_unref (settings); return id; } @@ -1918,59 +1274,34 @@ panel_profile_prepare_object (PanelObjectType object_type, void panel_profile_delete_object (AppletInfo *applet_info) { - PanelMateConfKeyType type; + PanelGSettingsKeyType type; const char *id; - type = (applet_info->type) == PANEL_OBJECT_APPLET ? PANEL_MATECONF_APPLETS : - PANEL_MATECONF_OBJECTS; + type = PANEL_GSETTINGS_OBJECTS; id = mate_panel_applet_get_id (applet_info); panel_profile_remove_from_list (type, id); } static void -panel_profile_load_object (MateConfClient *client, - const char *profile_dir, - PanelMateConfKeyType type, - const char *id) +panel_profile_load_object (char *id) { PanelObjectType object_type; - char *object_dir; - const char *key; - char *type_string; + char *object_path; char *toplevel_id; int position; gboolean right_stick; gboolean locked; + GSettings *settings; - object_dir = g_strdup_printf ("%s/%s/%s", - profile_dir, - type == PANEL_MATECONF_OBJECTS ? "objects" : "applets", - id); - - mateconf_client_add_dir (client, object_dir, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); - - key = panel_mateconf_sprintf ("%s/object_type", object_dir); - type_string = mateconf_client_get_string (client, key, NULL); - - if (!panel_profile_map_object_type_string (type_string, &object_type)) { - g_free (type_string); - mateconf_client_remove_dir (client, object_dir, NULL); - g_free (object_dir); - return; - } - - key = panel_mateconf_sprintf ("%s/position", object_dir); - position = mateconf_client_get_int (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/toplevel_id", object_dir); - toplevel_id = mateconf_client_get_string (client, key, NULL); - - key = panel_mateconf_sprintf ("%s/panel_right_stick", object_dir); - right_stick = mateconf_client_get_bool (client, key, NULL); + object_path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, object_path); - key = panel_mateconf_sprintf ("%s/locked", object_dir); - locked = mateconf_client_get_bool (client, key, NULL); + object_type = g_settings_get_enum (settings, PANEL_OBJECT_TYPE_KEY); + position = g_settings_get_int (settings, PANEL_OBJECT_POSITION_KEY); + toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY); + right_stick = g_settings_get_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY); + locked = g_settings_get_boolean (settings, PANEL_OBJECT_LOCKED_KEY); mate_panel_applet_queue_applet_to_load (id, object_type, @@ -1980,8 +1311,8 @@ panel_profile_load_object (MateConfClient *client, locked); g_free (toplevel_id); - g_free (type_string); - g_free (object_dir); + g_free (object_path); + g_object_unref (settings); } static void @@ -1995,43 +1326,36 @@ panel_profile_destroy_object (const char *id) } static void -panel_profile_delete_dir (MateConfClient *client, - PanelMateConfKeyType type, - const char *id) +panel_profile_delete_dir (PanelGSettingsKeyType type, + const char *id) { - const char *key; - char *type_str; + gchar *dir; switch (type) { - case PANEL_MATECONF_TOPLEVELS: - type_str = "toplevels"; - break; - case PANEL_MATECONF_OBJECTS: - type_str = "objects"; - break; - case PANEL_MATECONF_APPLETS: - type_str = "applets"; - break; - default: - type_str = NULL; - g_assert_not_reached (); - break; + case PANEL_GSETTINGS_TOPLEVELS: + dir = g_strdup_printf (PANEL_TOPLEVEL_PATH "%s/", id); + break; + case PANEL_GSETTINGS_OBJECTS: + dir = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id); + break; } - if (type == PANEL_MATECONF_TOPLEVELS) { - key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/%s/%s/background", - type_str, id); - mateconf_client_remove_dir (client, key, NULL); + if (type == PANEL_GSETTINGS_TOPLEVELS) { + gchar *subdir; + subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH "%s/background/", id); + panel_dconf_recursive_reset (subdir, NULL); + g_free (subdir); + } + else if (type == PANEL_GSETTINGS_OBJECTS) { + gchar *subdir; + subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH "%s/prefs/", id); + panel_dconf_recursive_reset (subdir, NULL); + g_free (subdir); } - key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/%s/%s", - type_str, id); - mateconf_client_remove_dir (client, key, NULL); + panel_dconf_recursive_reset (dir, NULL); - mateconf_client_recursive_unset (client, - key, - MATECONF_UNSET_INCLUDING_SCHEMA_NAMES, - NULL); + g_free (dir); } static gboolean @@ -2067,7 +1391,7 @@ panel_profile_id_exists (GSList *id_list, return FALSE; for (l = id_list; l; l = l->next) { - const char *check_id = mateconf_value_get_string (l->data); + const char *check_id = l->data; if (!strcmp (id, check_id)) return TRUE; @@ -2077,19 +1401,17 @@ panel_profile_id_exists (GSList *id_list, } static void -panel_profile_load_added_ids (MateConfClient *client, - PanelMateConfKeyType type, - GSList *list, - GSList *id_list, - PanelProfileGetIdFunc get_id_func, - PanelProfileLoadFunc load_handler, - PanelProfileOnLoadQueue on_load_queue) +panel_profile_load_added_ids (GSList *list, + GSList *id_list, + PanelProfileGetIdFunc get_id_func, + PanelProfileLoadFunc load_handler, + PanelProfileOnLoadQueue on_load_queue) { GSList *added_ids = NULL; GSList *l; for (l = id_list; l; l = l->next) { - const char *id = mateconf_value_get_string (l->data); + const char *id = l->data; if (!panel_profile_object_exists (list, id, get_id_func) && (on_load_queue == NULL || !on_load_queue (id))) @@ -2101,7 +1423,7 @@ panel_profile_load_added_ids (MateConfClient *client, id = (char *) l->data; if (id && id[0]) - load_handler (client, PANEL_CONFIG_DIR, type, id); + load_handler (id); g_free (l->data); l->data = NULL; @@ -2111,12 +1433,11 @@ panel_profile_load_added_ids (MateConfClient *client, } static void -panel_profile_delete_removed_ids (MateConfClient *client, - PanelMateConfKeyType type, - GSList *list, - GSList *id_list, - PanelProfileGetIdFunc get_id_func, - PanelProfileDestroyFunc destroy_handler) +panel_profile_delete_removed_ids (PanelGSettingsKeyType type, + GSList *list, + GSList *id_list, + PanelProfileGetIdFunc get_id_func, + PanelProfileDestroyFunc destroy_handler) { GSList *removed_ids = NULL; GSList *l; @@ -2133,7 +1454,7 @@ panel_profile_delete_removed_ids (MateConfClient *client, for (l = removed_ids; l; l = l->next) { const char *id = l->data; - panel_profile_delete_dir (client, type, id); + panel_profile_delete_dir (type, id); destroy_handler (id); g_free (l->data); @@ -2143,27 +1464,21 @@ panel_profile_delete_removed_ids (MateConfClient *client, } static void -panel_profile_toplevel_id_list_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry) +panel_profile_toplevel_id_list_notify (GSettings *settings, + gchar *key, + gpointer user_data) { - MateConfValue *value; GSList *l, *existing_toplevels; GSList *toplevel_ids; + gchar **toplevel_ids_strv; - if (!(value = mateconf_entry_get_value (entry))) - return; + toplevel_ids_strv = g_settings_get_strv (settings, key); - if (value->type != MATECONF_VALUE_LIST || - mateconf_value_get_list_type (value) != MATECONF_VALUE_STRING) { - mateconf_value_free (value); - return; - } - - toplevel_ids = g_slist_copy (mateconf_value_get_list (value)); + toplevel_ids = panel_gsettings_strv_to_gslist (toplevel_ids_strv); toplevel_ids = panel_g_slist_make_unique (toplevel_ids, - panel_mateconf_value_strcmp, + g_strcmp0, FALSE); + g_strfreev (toplevel_ids_strv); existing_toplevels = NULL; for (l = panel_toplevel_list_toplevels (); l; l = l->next) { @@ -2176,69 +1491,52 @@ panel_profile_toplevel_id_list_notify (MateConfClient *client, existing_toplevels = g_slist_prepend (existing_toplevels, toplevel); } - panel_profile_load_added_ids (client, - PANEL_MATECONF_TOPLEVELS, - existing_toplevels, - toplevel_ids, - (PanelProfileGetIdFunc) panel_profile_get_toplevel_id, - (PanelProfileLoadFunc) panel_profile_load_and_show_toplevel, - (PanelProfileOnLoadQueue) NULL); - - panel_profile_delete_removed_ids (client, - PANEL_MATECONF_TOPLEVELS, - existing_toplevels, - toplevel_ids, - (PanelProfileGetIdFunc) panel_profile_get_toplevel_id, - (PanelProfileDestroyFunc) panel_profile_destroy_toplevel); + panel_profile_load_added_ids (existing_toplevels, + toplevel_ids, + (PanelProfileGetIdFunc) panel_profile_get_toplevel_id, + (PanelProfileLoadFunc) panel_profile_load_and_show_toplevel, + (PanelProfileOnLoadQueue) NULL); + + panel_profile_delete_removed_ids (PANEL_GSETTINGS_TOPLEVELS, + existing_toplevels, + toplevel_ids, + (PanelProfileGetIdFunc) panel_profile_get_toplevel_id, + (PanelProfileDestroyFunc) panel_profile_destroy_toplevel); g_slist_free (existing_toplevels); g_slist_free (toplevel_ids); } static void -panel_profile_object_id_list_update (MateConfClient *client, - MateConfValue *value, - PanelMateConfKeyType type) +panel_profile_object_id_list_update (gchar **objects) { GSList *existing_applets; GSList *sublist = NULL, *l; GSList *object_ids; - if (value->type != MATECONF_VALUE_LIST || - mateconf_value_get_list_type (value) != MATECONF_VALUE_STRING) { - mateconf_value_free (value); - return; - } - - object_ids = g_slist_copy (mateconf_value_get_list (value)); + object_ids = panel_gsettings_strv_to_gslist (objects); object_ids = panel_g_slist_make_unique (object_ids, - panel_mateconf_value_strcmp, + g_strcmp0, FALSE); existing_applets = mate_panel_applet_list_applets (); for (l = existing_applets; l; l = l->next) { AppletInfo *info = l->data; - - if ((type == PANEL_MATECONF_APPLETS && info->type == PANEL_OBJECT_APPLET) || - (type == PANEL_MATECONF_OBJECTS && info->type != PANEL_OBJECT_APPLET)) - sublist = g_slist_prepend (sublist, info); + sublist = g_slist_prepend (sublist, info); } - panel_profile_load_added_ids (client, - type, - sublist, - object_ids, - (PanelProfileGetIdFunc) mate_panel_applet_get_id, - (PanelProfileLoadFunc) panel_profile_load_object, - (PanelProfileOnLoadQueue) mate_panel_applet_on_load_queue); - - panel_profile_delete_removed_ids (client, - type, - sublist, - object_ids, - (PanelProfileGetIdFunc) mate_panel_applet_get_id, - (PanelProfileDestroyFunc) panel_profile_destroy_object); + panel_profile_load_added_ids (sublist, + object_ids, + (PanelProfileGetIdFunc) mate_panel_applet_get_id, + (PanelProfileLoadFunc) panel_profile_load_object, + (PanelProfileOnLoadQueue) mate_panel_applet_on_load_queue); + + panel_profile_delete_removed_ids (PANEL_GSETTINGS_OBJECTS, + sublist, + object_ids, + (PanelProfileGetIdFunc) mate_panel_applet_get_id, + (PanelProfileDestroyFunc) panel_profile_destroy_object); g_slist_free (sublist); g_slist_free (object_ids); @@ -2247,237 +1545,50 @@ panel_profile_object_id_list_update (MateConfClient *client, } static void -panel_profile_object_id_list_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) -{ - MateConfValue *value; - PanelMateConfKeyType type = GPOINTER_TO_INT (data); - - if (!(value = mateconf_entry_get_value (entry))) - return; - - panel_profile_object_id_list_update (client, value, type); -} - -static void -panel_profile_load_list (MateConfClient *client, - const char *profile_dir, - PanelMateConfKeyType type, - PanelProfileLoadFunc load_handler, - MateConfClientNotifyFunc notify_handler) -{ - - const char *key; - GSList *list; - GSList *l; - const char *id_list; - - id_list = panel_mateconf_key_type_to_id_list (type); - - key = panel_mateconf_sprintf ("%s/general/%s", profile_dir, id_list); - - mateconf_client_notify_add (client, key, notify_handler, - GINT_TO_POINTER (type), - NULL, NULL); - - list = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - list = panel_g_slist_make_unique (list, - (GCompareFunc) strcmp, - TRUE); - - for (l = list; l; l = l->next) { - char *id; - id = (char *) l->data; - - if (id && id[0]) - load_handler (client, profile_dir, type, id); - - g_free (l->data); - l->data = NULL; - } - g_slist_free (list); -} - -static GSList * -panel_profile_copy_defaults_for_screen (MateConfClient *client, - const char *profile_dir, - int screen_n, - PanelMateConfKeyType type) -{ - GSList *default_ids, *l; - GSList *new_ids = NULL; - const char *key; - const char *id_list, *type_str; - - id_list = panel_mateconf_key_type_to_id_list (type); - - switch (type) { - case PANEL_MATECONF_TOPLEVELS: - type_str = "toplevels"; - break; - case PANEL_MATECONF_OBJECTS: - type_str = "objects"; - break; - case PANEL_MATECONF_APPLETS: - type_str = "applets"; - break; - default: - type_str = NULL; - g_assert_not_reached (); - break; - } - - key = panel_mateconf_sprintf (PANEL_DEFAULTS_DIR "/general/%s", id_list); - default_ids = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - - for (l = default_ids; l; l = l->next) { - char *default_id = l->data; - char *new_id; - char *src_dir; - char *dest_dir; - - new_id = g_strdup_printf ("%s_screen%d", default_id, screen_n); - - src_dir = g_strdup_printf (PANEL_DEFAULTS_DIR "/%s/%s", type_str, default_id); - dest_dir = g_strdup_printf ("%s/%s/%s", profile_dir, type_str, new_id); - - panel_mateconf_copy_dir (client, src_dir, dest_dir); - - new_ids = g_slist_prepend (new_ids, new_id); - - g_free (src_dir); - g_free (dest_dir); - g_free (l->data); - } - g_slist_free (default_ids); - - return new_ids; -} - -static void -panel_profile_append_new_ids (MateConfClient *client, - PanelMateConfKeyType type, - GSList *new_ids) +panel_profile_object_id_list_notify (GSettings *settings, + gchar *key, + gpointer data) { - GSList *list, *l; - const char *key; - const char *id_list; - - id_list = panel_mateconf_key_type_to_id_list (type); - - key = panel_mateconf_general_key (id_list); - list = mateconf_client_get_list (client, key, MATECONF_VALUE_STRING, NULL); - - for (l = new_ids; l; l = l->next) - list = g_slist_append (list, l->data); - - g_slist_free (new_ids); - - mateconf_client_set_list (client, key, MATECONF_VALUE_STRING, list, NULL); - - for (l = list; l; l = l->next) - g_free (l->data); - g_slist_free (list); + gchar **objects; + objects = g_settings_get_strv (settings, key); + panel_profile_object_id_list_update (objects); + g_strfreev (objects); } static void -panel_profile_copy_default_objects_for_screen (MateConfClient *client, - const char *profile_dir, - int screen_n, - PanelMateConfKeyType type) -{ - GSList *new_objects, *l, *next; - - new_objects = panel_profile_copy_defaults_for_screen (client, profile_dir, screen_n, type); - - for (l = new_objects; l; l = next) { - char *object_id = l->data; - const char *key; - char *toplevel_id; - char *new_toplevel_id; - - next = l->next; - - key = panel_mateconf_full_key (type, object_id, "toplevel_id"); - toplevel_id = mateconf_client_get_string (client, key, NULL); - if (!toplevel_id) { - new_objects = g_slist_remove_link (new_objects, l); - g_free (l->data); - g_slist_free_1 (l); - continue; - } - - new_toplevel_id = g_strdup_printf ("%s_screen%d", toplevel_id, screen_n); - mateconf_client_set_string (client, key, new_toplevel_id, NULL); - - g_free (toplevel_id); - g_free (new_toplevel_id); - } - - panel_profile_append_new_ids (client, type, new_objects); -} - -/* FIXME: - * We might want to do something more sophisticated like hardcode - * the default panel setup as the fallback panels. - */ -static GSList * -panel_profile_create_fallback_toplevel_list (MateConfClient *client, - const char *profile_dir) +panel_profile_load_list (GSettings *settings, + PanelGSettingsKeyType type, + PanelProfileLoadFunc load_handler, + GCallback notify_handler) { - char *id; - char *dir; - id = panel_profile_find_new_id (PANEL_MATECONF_TOPLEVELS); + gchar *key; + gchar *changed_signal; + gchar **list; + gint i; - dir = g_strdup_printf ("%s/toplevels/%s", profile_dir, id); - panel_mateconf_associate_schemas_in_dir (client, dir, PANEL_SCHEMAS_DIR "/toplevels"); - g_free (dir); + if (type == PANEL_GSETTINGS_TOPLEVELS) + key = g_strdup (PANEL_TOPLEVEL_ID_LIST_KEY); + else if (type == PANEL_GSETTINGS_OBJECTS) + key = g_strdup (PANEL_OBJECT_ID_LIST_KEY); - return g_slist_prepend (NULL, id); -} + changed_signal = g_strdup_printf ("changed::%s", key); -static void -panel_profile_load_defaults_on_screen (MateConfClient *client, - const char *profile_dir, - GdkScreen *screen) -{ - GSList *new_toplevels, *l; - int screen_n; + g_signal_connect (settings, changed_signal, G_CALLBACK (notify_handler), NULL); - screen_n = gdk_screen_get_number (screen); + list = g_settings_get_strv (settings, key); - new_toplevels = panel_profile_copy_defaults_for_screen ( - client, profile_dir, screen_n, PANEL_MATECONF_TOPLEVELS); - if (!new_toplevels) { - g_warning ("Failed to load default panel configuration. panel-default-setup.entries " - "hasn't been installed using mateconftool-2 --load ?\n"); - new_toplevels = panel_profile_create_fallback_toplevel_list (client, profile_dir); + for (i = 0; list[i]; i++) { + load_handler (list[i]); } - - for (l = new_toplevels; l; l = l->next) { - char *toplevel_id = l->data; - const char *key; - - key = panel_mateconf_full_key (PANEL_MATECONF_TOPLEVELS, - toplevel_id, - "screen"); - mateconf_client_set_int (client, key, screen_n, NULL); - } - - panel_profile_append_new_ids (client, PANEL_MATECONF_TOPLEVELS, new_toplevels); - - panel_profile_copy_default_objects_for_screen ( - client, profile_dir, screen_n, PANEL_MATECONF_OBJECTS); - panel_profile_copy_default_objects_for_screen ( - client, profile_dir, screen_n, PANEL_MATECONF_APPLETS); + if (list) + g_strfreev (list); + g_free (changed_signal); + g_free (key); } static void -panel_profile_ensure_toplevel_per_screen (MateConfClient *client, - const char *profile_dir) +panel_profile_ensure_toplevel_per_screen () { GSList *toplevels; GSList *empty_screens = NULL; @@ -2504,7 +1615,7 @@ panel_profile_ensure_toplevel_per_screen (MateConfClient *client, } for (l = empty_screens; l; l = l->next) - panel_profile_load_defaults_on_screen (client, profile_dir, l->data); + panel_layout_apply_default_from_gkeyfile (l->data); g_slist_free (empty_screens); } @@ -2512,112 +1623,71 @@ panel_profile_ensure_toplevel_per_screen (MateConfClient *client, void panel_profile_load (void) { - MateConfClient *client; - - client = panel_mateconf_get_client (); - - mateconf_client_add_dir (client, PANEL_CONFIG_DIR "/general", MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); + profile_settings = g_settings_new ("org.mate.panel"); - panel_compatibility_maybe_copy_old_config (client); - - panel_compatibility_migrate_panel_id_list (client); - - panel_profile_load_list (client, - PANEL_CONFIG_DIR, - PANEL_MATECONF_TOPLEVELS, + panel_profile_load_list (profile_settings, + PANEL_GSETTINGS_TOPLEVELS, panel_profile_load_and_show_toplevel_startup, - (MateConfClientNotifyFunc) panel_profile_toplevel_id_list_notify); - panel_profile_load_list (client, - PANEL_CONFIG_DIR, - PANEL_MATECONF_OBJECTS, - panel_profile_load_object, - (MateConfClientNotifyFunc) panel_profile_object_id_list_notify); - panel_profile_load_list (client, - PANEL_CONFIG_DIR, - PANEL_MATECONF_APPLETS, + G_CALLBACK (panel_profile_toplevel_id_list_notify)); + panel_profile_load_list (profile_settings, + PANEL_GSETTINGS_OBJECTS, panel_profile_load_object, - (MateConfClientNotifyFunc) panel_profile_object_id_list_notify); + G_CALLBACK (panel_profile_object_id_list_notify)); - panel_profile_ensure_toplevel_per_screen (client, PANEL_CONFIG_DIR); + panel_profile_ensure_toplevel_per_screen (); mate_panel_applet_load_queued_applets (TRUE); } static gboolean -get_program_listing_setting (const char *setting) +get_program_listing_setting (const char *key) { - MateConfClient *client; - const char *key; - gboolean retval; - - client = panel_mateconf_get_client (); - - key = panel_mateconf_general_key (setting); - retval = mateconf_client_get_bool (client, key, NULL); - + gboolean retval; + retval = g_settings_get_boolean (profile_settings, key); return retval; } gboolean panel_profile_get_show_program_list (void) { - return get_program_listing_setting ("show_program_list"); + return get_program_listing_setting ("show-program-list"); } gboolean panel_profile_get_enable_program_list (void) { - return get_program_listing_setting ("enable_program_list"); + return get_program_listing_setting ("enable-program-list"); } gboolean panel_profile_get_enable_autocompletion (void) { - return get_program_listing_setting ("enable_autocompletion"); + return get_program_listing_setting ("enable-autocompletion"); } void panel_profile_set_show_program_list (gboolean show_program_list) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_mateconf_general_key ("show_program_list"); - mateconf_client_set_bool (client, key, show_program_list, NULL); + g_settings_set_boolean (profile_settings, "show-program-list", show_program_list); } gboolean panel_profile_is_writable_show_program_list (void) { - MateConfClient *client; - const char *key; - - client = panel_mateconf_get_client (); - - key = panel_mateconf_general_key ("show_program_list"); - return mateconf_client_key_is_writable (client, key, NULL); + return g_settings_is_writable (profile_settings, "show-program-list"); } gboolean panel_profile_can_be_moved_freely (PanelToplevel *toplevel) { - const char *key; - MateConfClient *client; - if (panel_lockdown_get_locked_down () || - !panel_profile_is_writable_toplevel_orientation (toplevel)) + !g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_ORIENTATION_KEY)) return FALSE; - client = panel_mateconf_get_client (); - - key = panel_profile_get_toplevel_key (toplevel, "screen"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_SCREEN_KEY)) return FALSE; - key = panel_profile_get_toplevel_key (toplevel, "monitor"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_MONITOR_KEY)) return FALSE; /* For expanded panels we don't really have to check @@ -2625,24 +1695,18 @@ panel_profile_can_be_moved_freely (PanelToplevel *toplevel) if (panel_toplevel_get_expand (toplevel)) return TRUE; - key = panel_profile_get_toplevel_key (toplevel, "x"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_KEY)) return FALSE; - key = panel_profile_get_toplevel_key (toplevel, "x_right"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_RIGHT_KEY)) return FALSE; - key = panel_profile_get_toplevel_key (toplevel, "x_centered"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_CENTERED_KEY)) return FALSE; - key = panel_profile_get_toplevel_key (toplevel, "y"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_KEY)) return FALSE; - key = panel_profile_get_toplevel_key (toplevel, "y_bottom"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_BOTTOM_KEY)) return FALSE; - key = panel_profile_get_toplevel_key (toplevel, "y_centered"); - if (!mateconf_client_key_is_writable (client, key, NULL)) + if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_CENTERED_KEY)) return FALSE; return TRUE; diff --git a/mate-panel/panel-profile.h b/mate-panel/panel-profile.h index 4191ef67..bd16f615 100644 --- a/mate-panel/panel-profile.h +++ b/mate-panel/panel-profile.h @@ -27,22 +27,20 @@ #include <glib.h> #include <gdk/gdk.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include "panel-toplevel.h" #include "panel-enums.h" #include "panel-types.h" #include "applet.h" -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS void panel_profile_load (void); const char *panel_profile_get_toplevel_id (PanelToplevel *toplevel); PanelToplevel *panel_profile_get_toplevel_by_id (const char *toplevel_id); -char *panel_profile_find_new_id (PanelMateConfKeyType type); +char *panel_profile_find_new_id (PanelGSettingsKeyType type); gboolean panel_profile_get_show_program_list (void); @@ -52,16 +50,13 @@ gboolean panel_profile_get_enable_program_list (void); gboolean panel_profile_get_enable_autocompletion (void); -void panel_profile_add_to_list (PanelMateConfKeyType type, +void panel_profile_add_to_list (PanelGSettingsKeyType type, const char *id); -void panel_profile_remove_from_list (PanelMateConfKeyType type, +void panel_profile_remove_from_list (PanelGSettingsKeyType type, const char *id); gboolean panel_profile_id_lists_are_writable (void); void panel_profile_create_toplevel (GdkScreen *screen); -PanelToplevel *panel_profile_load_toplevel (MateConfClient *client, - const char *profile_dir, - PanelMateConfKeyType type, - const char *toplevel_id); +PanelToplevel *panel_profile_load_toplevel (char *toplevel_id); void panel_profile_delete_toplevel (PanelToplevel *toplevel); char *panel_profile_prepare_object (PanelObjectType object_type, PanelToplevel *toplevel, @@ -73,55 +68,50 @@ char *panel_profile_prepare_object_with_id (PanelObjectType object_t gboolean right_stick); void panel_profile_delete_object (AppletInfo *applet_info); +gboolean panel_profile_key_is_writable (PanelToplevel *toplevel, + gchar *key); +gboolean panel_profile_background_key_is_writable (PanelToplevel *toplevel, + gchar *key); void panel_profile_set_toplevel_name (PanelToplevel *toplevel, const char *name); char *panel_profile_get_toplevel_name (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_toplevel_name (PanelToplevel *toplevel); void panel_profile_set_toplevel_orientation (PanelToplevel *toplevel, PanelOrientation orientation); PanelOrientation panel_profile_get_toplevel_orientation (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_toplevel_orientation (PanelToplevel *toplevel); void panel_profile_set_toplevel_size (PanelToplevel *toplevel, int size); int panel_profile_get_toplevel_size (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_toplevel_size (PanelToplevel *toplevel); void panel_profile_set_toplevel_expand (PanelToplevel *toplevel, gboolean expand); gboolean panel_profile_get_toplevel_expand (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_toplevel_expand (PanelToplevel *toplevel); void panel_profile_set_toplevel_auto_hide (PanelToplevel *toplevel, gboolean auto_hide); gboolean panel_profile_get_toplevel_auto_hide (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_toplevel_auto_hide (PanelToplevel *toplevel); void panel_profile_set_toplevel_enable_buttons (PanelToplevel *toplevel, gboolean enable_buttons); gboolean panel_profile_get_toplevel_enable_buttons (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_toplevel_enable_buttons (PanelToplevel *toplevel); void panel_profile_set_toplevel_enable_arrows (PanelToplevel *toplevel, gboolean enable_arrows); gboolean panel_profile_get_toplevel_enable_arrows (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_toplevel_enable_arrows (PanelToplevel *toplevel); /* We don't set this in the panel, so there is no set accessor */ void panel_profile_set_background_type (PanelToplevel *toplevel, PanelBackgroundType background_type); PanelBackgroundType panel_profile_get_background_type (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_background_type (PanelToplevel *toplevel); void panel_profile_set_background_color (PanelToplevel *toplevel, PanelColor *color); void panel_profile_get_background_color (PanelToplevel *toplevel, PanelColor *color); -gboolean panel_profile_is_writable_background_color (PanelToplevel *toplevel); void panel_profile_set_background_gdk_color (PanelToplevel *toplevel, GdkColor *gdk_color); @@ -131,58 +121,38 @@ void panel_profile_get_background_gdk_color (PanelToplevel *topl void panel_profile_set_background_opacity (PanelToplevel *toplevel, guint16 opacity); guint16 panel_profile_get_background_opacity (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_background_opacity (PanelToplevel *toplevel); void panel_profile_set_background_image (PanelToplevel *toplevel, const char *image); char *panel_profile_get_background_image (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_background_image (PanelToplevel *toplevel); void panel_profile_set_background_fit (PanelToplevel *toplevel, gboolean fit); gboolean panel_profile_get_background_fit (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_background_fit (PanelToplevel *toplevel); void panel_profile_set_background_stretch (PanelToplevel *toplevel, gboolean stretch); gboolean panel_profile_get_background_stretch (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_background_stretch (PanelToplevel *toplevel); void panel_profile_set_background_rotate (PanelToplevel *toplevel, gboolean rotate); gboolean panel_profile_get_background_rotate (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_background_rotate (PanelToplevel *toplevel); void panel_profile_set_attached_custom_icon (PanelToplevel *toplevel, const char *custom_icon); char *panel_profile_get_attached_custom_icon (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_attached_custom_icon (PanelToplevel *toplevel); +gboolean panel_profile_is_writable_attached_custom_icon (PanelToplevel *toplevel); + void panel_profile_set_attached_tooltip (PanelToplevel *toplevel, const char *custom_icon); char *panel_profile_get_attached_tooltip (PanelToplevel *toplevel); -gboolean panel_profile_is_writable_attached_tooltip (PanelToplevel *toplevel); - -guint panel_profile_toplevel_notify_add (PanelToplevel *toplevel, - const char *key, - MateConfClientNotifyFunc func, - gpointer data); - -const char *panel_profile_map_orientation (PanelOrientation orientation); -const char *panel_profile_map_background_type (PanelBackgroundType background_type); -gboolean panel_profile_map_orientation_string (const char *str, - PanelOrientation *orientation); -gboolean panel_profile_map_speed_string (const char *str, - PanelAnimationSpeed *speed); -gboolean panel_profile_map_background_type_string (const char *str, - PanelBackgroundType *background_type); -gboolean panel_profile_map_object_type_string (const char *str, - PanelObjectType *object_type); +gboolean panel_profile_is_writable_attached_tooltip (PanelToplevel *toplevel); /* all keys relevant to moving are writable */ gboolean panel_profile_can_be_moved_freely (PanelToplevel *toplevel); -#ifdef __cplusplus -} -#endif +GSettings* panel_profile_get_attached_object_settings (PanelToplevel *toplevel); + +G_END_DECLS #endif /* __PANEL_PROFILE_H__ */ diff --git a/mate-panel/panel-properties-dialog.c b/mate-panel/panel-properties-dialog.c index 0a5df0a1..8247f04a 100644 --- a/mate-panel/panel-properties-dialog.c +++ b/mate-panel/panel-properties-dialog.c @@ -28,6 +28,7 @@ #include <string.h> #include <glib/gi18n.h> +#include <gio/gio.h> #include <libpanel-util/panel-error.h> #include <libpanel-util/panel-glib.h> @@ -37,13 +38,15 @@ #include "nothing.h" #include "panel-profile.h" -#include "panel-mateconf.h" +#include "panel-schemas.h" #include "panel-util.h" #include "panel-globals.h" #include "panel-icon-names.h" typedef struct { PanelToplevel *toplevel; + GSettings *settings; + GSettings *background_settings; GtkWidget *properties_dialog; @@ -77,9 +80,6 @@ typedef struct { GtkWidget *writability_warn_general; GtkWidget *writability_warn_background; - guint toplevel_notify; - guint background_notify; - /* FIXME: This is a workaround for GTK+ bug #327243 */ int selection_emitted; } PanelPropertiesDialog; @@ -89,17 +89,13 @@ static GQuark panel_properties_dialog_quark = 0; static void panel_properties_dialog_free (PanelPropertiesDialog *dialog) { - MateConfClient *client; - - client = panel_mateconf_get_client (); - - if (dialog->toplevel_notify) - mateconf_client_notify_remove (client, dialog->toplevel_notify); - dialog->toplevel_notify = 0; + if (dialog->settings) + g_object_unref (dialog->settings); + dialog->settings = NULL; - if (dialog->background_notify) - mateconf_client_notify_remove (client, dialog->background_notify); - dialog->background_notify = 0; + if (dialog->background_settings) + g_object_unref (dialog->background_settings); + dialog->background_settings = NULL; if (dialog->properties_dialog) gtk_widget_destroy (dialog->properties_dialog); @@ -193,7 +189,7 @@ panel_properties_dialog_setup_orientation_combo (PanelPropertiesDialog *dialog, G_CALLBACK (panel_properties_dialog_orientation_changed), dialog); - if (! panel_profile_is_writable_toplevel_orientation (dialog->toplevel)) { + if (! panel_profile_key_is_writable (dialog->toplevel, PANEL_TOPLEVEL_ORIENTATION_KEY)) { gtk_widget_set_sensitive (dialog->orientation_combo, FALSE); gtk_widget_set_sensitive (dialog->orientation_label, FALSE); gtk_widget_show (dialog->writability_warn_general); @@ -232,7 +228,7 @@ panel_properties_dialog_setup_size_spin (PanelPropertiesDialog *dialog, G_CALLBACK (panel_properties_dialog_size_changed), dialog); - if ( ! panel_profile_is_writable_toplevel_size (dialog->toplevel)) { + if ( ! panel_profile_key_is_writable (dialog->toplevel, PANEL_TOPLEVEL_SIZE_KEY)) { gtk_widget_set_sensitive (dialog->size_spin, FALSE); gtk_widget_set_sensitive (dialog->size_label, FALSE); gtk_widget_set_sensitive (dialog->size_label_pixels, FALSE); @@ -278,13 +274,14 @@ panel_properties_dialog_setup_icon_chooser (PanelPropertiesDialog *dialog, if (!panel_profile_is_writable_attached_custom_icon (dialog->toplevel)) { gtk_widget_set_sensitive (dialog->icon_chooser, FALSE); gtk_widget_set_sensitive (dialog->icon_label, FALSE); - gtk_widget_show (dialog->writability_warn_general); + if (panel_toplevel_get_is_attached (dialog->toplevel)) + gtk_widget_show (dialog->writability_warn_general); } } /* Note: this is only for toggle buttons on the general page, if needed for togglebuttons elsewhere you must make this respect the writability warning thing for the right page */ -#define SETUP_TOGGLE_BUTTON(wid, n, p) \ +#define SETUP_TOGGLE_BUTTON(wid, n, p, key) \ static void \ panel_properties_dialog_##n (PanelPropertiesDialog *dialog, \ GtkToggleButton *n) \ @@ -301,16 +298,16 @@ panel_properties_dialog_setup_icon_chooser (PanelPropertiesDialog *dialog, panel_profile_get_toplevel_##p (dialog->toplevel)); \ g_signal_connect_swapped (dialog->n, "toggled", \ G_CALLBACK (panel_properties_dialog_##n), dialog); \ - if ( ! panel_profile_is_writable_toplevel_##p (dialog->toplevel)) { \ + if ( ! panel_profile_key_is_writable (dialog->toplevel, key)) { \ gtk_widget_set_sensitive (dialog->n, FALSE); \ gtk_widget_show (dialog->writability_warn_general); \ } \ } -SETUP_TOGGLE_BUTTON ("expand_toggle", expand_toggle, expand) -SETUP_TOGGLE_BUTTON ("autohide_toggle", autohide_toggle, auto_hide) -SETUP_TOGGLE_BUTTON ("hidebuttons_toggle", hidebuttons_toggle, enable_buttons) -SETUP_TOGGLE_BUTTON ("arrows_toggle", arrows_toggle, enable_arrows) +SETUP_TOGGLE_BUTTON ("expand_toggle", expand_toggle, expand, PANEL_TOPLEVEL_EXPAND_KEY) +SETUP_TOGGLE_BUTTON ("autohide_toggle", autohide_toggle, auto_hide, PANEL_TOPLEVEL_AUTO_HIDE_KEY) +SETUP_TOGGLE_BUTTON ("hidebuttons_toggle", hidebuttons_toggle, enable_buttons, PANEL_TOPLEVEL_ENABLE_BUTTONS_KEY) +SETUP_TOGGLE_BUTTON ("arrows_toggle", arrows_toggle, enable_arrows, PANEL_TOPLEVEL_ENABLE_ARROWS_KEY) static void panel_properties_dialog_color_changed (PanelPropertiesDialog *dialog, @@ -344,7 +341,7 @@ panel_properties_dialog_setup_color_button (PanelPropertiesDialog *dialog, G_CALLBACK (panel_properties_dialog_color_changed), dialog); - if ( ! panel_profile_is_writable_background_color (dialog->toplevel)) { + if ( ! panel_profile_background_key_is_writable (dialog->toplevel, "color")) { gtk_widget_set_sensitive (dialog->color_button, FALSE); gtk_widget_set_sensitive (dialog->color_label, FALSE); gtk_widget_show (dialog->writability_warn_background); @@ -394,7 +391,7 @@ panel_properties_dialog_setup_image_chooser (PanelPropertiesDialog *dialog, G_CALLBACK (panel_properties_dialog_image_changed), dialog); - if ( ! panel_profile_is_writable_background_image (dialog->toplevel)) { + if ( ! panel_profile_background_key_is_writable (dialog->toplevel, "image")) { gtk_widget_set_sensitive (dialog->image_chooser, FALSE); gtk_widget_show (dialog->writability_warn_background); } @@ -442,7 +439,7 @@ panel_properties_dialog_setup_opacity_scale (PanelPropertiesDialog *dialog, G_CALLBACK (panel_properties_dialog_opacity_changed), dialog); - if ( ! panel_profile_is_writable_background_opacity (dialog->toplevel)) { + if ( ! panel_profile_background_key_is_writable (dialog->toplevel, "opacity")) { gtk_widget_set_sensitive (dialog->opacity_scale, FALSE); gtk_widget_set_sensitive (dialog->opacity_label, FALSE); gtk_widget_set_sensitive (dialog->opacity_legend, FALSE); @@ -526,7 +523,7 @@ panel_properties_dialog_setup_background_radios (PanelPropertiesDialog *dialog, G_CALLBACK (panel_properties_dialog_background_toggled), dialog); - if ( ! panel_profile_is_writable_background_type (dialog->toplevel)) { + if ( ! panel_profile_background_key_is_writable (dialog->toplevel, "type")) { gtk_widget_set_sensitive (dialog->default_radio, FALSE); gtk_widget_set_sensitive (dialog->color_radio, FALSE); gtk_widget_set_sensitive (dialog->image_radio, FALSE); @@ -540,7 +537,7 @@ panel_properties_update_arrows_toggle_visible (PanelPropertiesDialog *dialog, { if (gtk_toggle_button_get_active (toggle)) gtk_widget_set_sensitive (dialog->arrows_toggle, - panel_profile_is_writable_toplevel_enable_arrows (dialog->toplevel)); + panel_profile_key_is_writable (dialog->toplevel, PANEL_TOPLEVEL_ENABLE_ARROWS_KEY)); else gtk_widget_set_sensitive (dialog->arrows_toggle, FALSE); } @@ -581,9 +578,8 @@ panel_properties_dialog_destroy (PanelPropertiesDialog *dialog) static void panel_properties_dialog_update_orientation (PanelPropertiesDialog *dialog, - MateConfValue *value) + PanelOrientation orientation) { - PanelOrientation orientation; GtkTreeModel *model; GtkTreeIter iter; OrientationComboItem *item; @@ -591,12 +587,6 @@ panel_properties_dialog_update_orientation (PanelPropertiesDialog *dialog, int spin_size; int profile_size; - if (!value || value->type != MATECONF_VALUE_STRING) - return; - - if (!panel_profile_map_orientation_string (mateconf_value_get_string (value), &orientation)) - return; - /* change the maximum size of the panel */ //TODO: we should also do this when the monitor size changes max_size = panel_toplevel_get_maximum_size (dialog->toplevel); @@ -632,63 +622,40 @@ panel_properties_dialog_update_orientation (PanelPropertiesDialog *dialog, static void panel_properties_dialog_update_size (PanelPropertiesDialog *dialog, - MateConfValue *value) + int size) { - if (!value || value->type != MATECONF_VALUE_INT) - return; - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->size_spin), - mateconf_value_get_int (value)); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->size_spin), size); } static void -panel_properties_dialog_toplevel_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +panel_properties_dialog_toplevel_notify (GSettings *settings, + gchar *key, PanelPropertiesDialog *dialog) { - MateConfValue *value; - const char *key; - - key = panel_mateconf_basename (mateconf_entry_get_key (entry)); - if (!key) - return; - - value = mateconf_entry_get_value (entry); -#define UPDATE_TOGGLE(p, n) \ - if (!strcmp (key, p)) { \ - if (value && value->type == MATECONF_VALUE_BOOL) { \ - gboolean val = mateconf_value_get_bool (value); \ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->n)) != val) \ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->n), val); \ - } \ +#define UPDATE_TOGGLE(p, n) \ + if (!strcmp (key, p)) { \ + gboolean val = g_settings_get_boolean (settings, key); \ + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->n)) != val) \ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->n), val); \ } if (!strcmp (key, "orientation")) - panel_properties_dialog_update_orientation (dialog, value); + panel_properties_dialog_update_orientation (dialog, g_settings_get_enum (settings, key)); else if (!strcmp (key, "size")) - panel_properties_dialog_update_size (dialog, value); + panel_properties_dialog_update_size (dialog, g_settings_get_int (settings, key)); else UPDATE_TOGGLE ("expand", expand_toggle) - else UPDATE_TOGGLE ("auto_hide", autohide_toggle) - else UPDATE_TOGGLE ("enable_buttons", hidebuttons_toggle) - else UPDATE_TOGGLE ("enable_arrows", arrows_toggle) + else UPDATE_TOGGLE ("auto-hide", autohide_toggle) + else UPDATE_TOGGLE ("enable-buttons", hidebuttons_toggle) + else UPDATE_TOGGLE ("enable-arrows", arrows_toggle) } static void panel_properties_dialog_update_background_type (PanelPropertiesDialog *dialog, - MateConfValue *value) + PanelBackgroundType background_type) { - PanelBackgroundType background_type; GtkWidget *active_radio; - if (!value || value->type != MATECONF_VALUE_STRING) - return; - - if (!panel_profile_map_background_type_string (mateconf_value_get_string (value), - &background_type)) - return; - switch (background_type) { case PANEL_BACK_NONE: active_radio = dialog->default_radio; @@ -710,15 +677,12 @@ panel_properties_dialog_update_background_type (PanelPropertiesDialog *dialog, static void panel_properties_dialog_update_background_color (PanelPropertiesDialog *dialog, - MateConfValue *value) + gchar *str_color) { GdkColor new_color = { 0, }; GdkColor old_color; - if (!value || value->type != MATECONF_VALUE_STRING) - return; - - if (!gdk_color_parse (mateconf_value_get_string (value), &new_color)) + if (!gdk_color_parse (str_color, &new_color)) return; gtk_color_button_get_color (GTK_COLOR_BUTTON (dialog->color_button), @@ -733,14 +697,11 @@ panel_properties_dialog_update_background_color (PanelPropertiesDialog *dialog, static void panel_properties_dialog_update_background_opacity (PanelPropertiesDialog *dialog, - MateConfValue *value) + gint opacity) { gdouble percentage; - if (!value || value->type != MATECONF_VALUE_INT) - return; - - percentage = ((gdouble) (mateconf_value_get_int (value) * 100)) / 65535; + percentage = ((gdouble) (opacity * 100)) / 65535; if ((int) gtk_range_get_value (GTK_RANGE (dialog->opacity_scale)) != (int) percentage) gtk_range_set_value (GTK_RANGE (dialog->opacity_scale), percentage); @@ -748,15 +709,10 @@ panel_properties_dialog_update_background_opacity (PanelPropertiesDialog *dialog static void panel_properties_dialog_update_background_image (PanelPropertiesDialog *dialog, - MateConfValue *value) + gchar *text) { - const char *text; char *old_text; - if (!value || value->type != MATECONF_VALUE_STRING) - return; - - text = mateconf_value_get_string (value); old_text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog->image_chooser)); if (PANEL_GLIB_STR_EMPTY (text) && old_text) @@ -771,28 +727,32 @@ panel_properties_dialog_update_background_image (PanelPropertiesDialog *dialog, } static void -panel_properties_dialog_background_notify (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +panel_properties_dialog_background_notify (GSettings *settings, + gchar *key, PanelPropertiesDialog *dialog) { - MateConfValue *value; - const char *key; - - key = panel_mateconf_basename (mateconf_entry_get_key (entry)); - if (!key) - return; - - value = mateconf_entry_get_value (entry); - if (!strcmp (key, "type")) - panel_properties_dialog_update_background_type (dialog, value); + { + PanelBackgroundType type = g_settings_get_enum (settings, key); + panel_properties_dialog_update_background_type (dialog, type); + } else if (!strcmp (key, "color")) - panel_properties_dialog_update_background_color (dialog, value); + { + char *color = g_settings_get_string (settings, key); + panel_properties_dialog_update_background_color (dialog, color); + g_free (color); + } else if (!strcmp (key, "opacity")) - panel_properties_dialog_update_background_opacity (dialog, value); + { + gint opacity = g_settings_get_int (settings, key); + panel_properties_dialog_update_background_opacity (dialog, opacity); + } else if (!strcmp (key, "image")) - panel_properties_dialog_update_background_image (dialog, value); + { + char *image = g_settings_get_string (settings, key); + panel_properties_dialog_update_background_image (dialog, image); + g_free (image); + } } static void @@ -874,6 +834,7 @@ panel_properties_dialog_new (PanelToplevel *toplevel, GtkBuilder *gui) { PanelPropertiesDialog *dialog; + char *toplevel_settings_path; dialog = g_new0 (PanelPropertiesDialog, 1); @@ -913,24 +874,29 @@ panel_properties_dialog_new (PanelToplevel *toplevel, G_CALLBACK (panel_properties_update_arrows_toggle_visible), dialog); - dialog->toplevel_notify = - panel_profile_toplevel_notify_add ( - dialog->toplevel, - NULL, - (MateConfClientNotifyFunc) panel_properties_dialog_toplevel_notify, - dialog); + g_object_get (toplevel, "settings-path", &toplevel_settings_path, NULL); + dialog->settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, + toplevel_settings_path); + gchar *toplevel_background_path; + toplevel_background_path = g_strdup_printf ("%sbackground/", toplevel_settings_path); + dialog->background_settings = g_settings_new_with_path (PANEL_TOPLEVEL_BACKGROUND_SCHEMA, + toplevel_background_path); + g_free (toplevel_background_path); + + g_signal_connect (dialog->settings, + "changed", + G_CALLBACK (panel_properties_dialog_toplevel_notify), + dialog); panel_properties_dialog_setup_color_button (dialog, gui); panel_properties_dialog_setup_image_chooser (dialog, gui); panel_properties_dialog_setup_opacity_scale (dialog, gui); panel_properties_dialog_setup_background_radios (dialog, gui); - dialog->background_notify = - panel_profile_toplevel_notify_add ( - dialog->toplevel, - "background", - (MateConfClientNotifyFunc) panel_properties_dialog_background_notify, - dialog); + g_signal_connect (dialog->background_settings, + "changed", + G_CALLBACK (panel_properties_dialog_background_notify), + dialog); panel_properties_dialog_update_for_attached (dialog, panel_toplevel_get_is_attached (dialog->toplevel)); diff --git a/mate-panel/panel-reset.c b/mate-panel/panel-reset.c index 9c53c458..22532da4 100644 --- a/mate-panel/panel-reset.c +++ b/mate-panel/panel-reset.c @@ -17,27 +17,26 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. + * + * Authors: + * Perberos <[email protected]> + * Stefano Karapetsas <[email protected]> */ #ifndef __PANEL_RESET_C__ #define __PANEL_RESET_C__ #include <stdlib.h> +#include <glib.h> #include "panel-reset.h" +#include "panel-schemas.h" +#include <libpanel-util/panel-dconf.h> void panel_reset() { - /* En teoria, al hacer `mate-panel --reset` se podria correr este comando - * para que se reestablesca la configuracion por defecto del panel. O se - * borre para que pueda elegir una nueva. Esto ultimo solo si se desarrolla - * el dialogo de seleccion de configuracion inicial. - * - * La configuracion no se borra a travez de los archivos, por que hacer esto - * no hace que el demonio de configuracion se actualice. Obligando que se - * deba cerrar sesion antes de volver a abrir el panel. - * Es por eso que se eliminan las entradas a travez de mate-conf. - */ - system("mateconftool-2 --recursive-unset /apps/panel"); // unix like + panel_dconf_recursive_reset (PANEL_GENERAL_PATH, NULL); + panel_dconf_recursive_reset (PANEL_TOPLEVEL_PATH, NULL); + panel_dconf_recursive_reset (PANEL_OBJECT_PATH, NULL); /* TODO: send a dbus message to mate-panel, if active, to reload the panel * configuration */ diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c index 866751da..23da2a7b 100644 --- a/mate-panel/panel-run-dialog.c +++ b/mate-panel/panel-run-dialog.c @@ -40,7 +40,6 @@ #include <glib/gi18n.h> #include <gio/gio.h> #include <gdk/gdkkeysyms.h> -#include <mateconf/mateconf-client.h> #include <matemenu-tree.h> #define MATE_DESKTOP_USE_UNSTABLE_API @@ -53,7 +52,6 @@ #include <libpanel-util/panel-show.h> #include "nothing.h" -#include "panel-mateconf.h" #include "panel-util.h" #include "panel-globals.h" #include "panel-enums.h" @@ -93,13 +91,14 @@ typedef struct { int add_icons_idle_id; int add_items_idle_id; int find_command_idle_id; - int content_notify_id; gboolean use_program_list; gboolean completion_started; char *icon_path; char *desktop_path; char *item_name; + + GSettings *settings; } PanelRunDialog; enum { @@ -117,72 +116,67 @@ static PanelRunDialog *static_dialog = NULL; static void panel_run_dialog_disconnect_pixmap (PanelRunDialog *dialog); -#define PANEL_RUN_HISTORY_KEY "/apps/mate-settings/mate-panel/history-mate-run" +#define PANEL_RUN_SCHEMA "org.mate.panel" +#define PANEL_RUN_HISTORY_KEY "history-mate-run" +#define PANEL_RUN_SHOW_PROGRAM_LIST_KEY "show-program-list" #define PANEL_RUN_MAX_HISTORY 10 static GtkTreeModel * -_panel_run_get_recent_programs_list (void) +_panel_run_get_recent_programs_list (PanelRunDialog *dialog) { GtkListStore *list; - GSList *mateconf_items; - GSList *command; + gchar **items; int i = 0; list = gtk_list_store_new (1, G_TYPE_STRING); - mateconf_items = mateconf_client_get_list (panel_mateconf_get_client (), - PANEL_RUN_HISTORY_KEY, - MATECONF_VALUE_STRING, NULL); + items = g_settings_get_strv (dialog->settings, PANEL_RUN_HISTORY_KEY); - for (command = mateconf_items; - command && i < PANEL_RUN_MAX_HISTORY; - command = command->next) { + for (i = 0; + items[i] && i < PANEL_RUN_MAX_HISTORY; + i++) { GtkTreeIter iter; gtk_list_store_prepend (list, &iter); - gtk_list_store_set (list, &iter, 0, command->data, -1); - i++; + gtk_list_store_set (list, &iter, 0, items[i], -1); } - g_slist_free (mateconf_items); + g_strfreev (items); return GTK_TREE_MODEL (list); } static void -_panel_run_save_recent_programs_list (GtkComboBoxEntry *entry, +_panel_run_save_recent_programs_list (PanelRunDialog *dialog, + GtkComboBoxEntry *entry, char *lastcommand) { GtkTreeModel *model; GtkTreeIter iter; - GSList *mateconf_items = NULL; - int i = 0; + GArray *items; + gint i = 0; - mateconf_items = g_slist_prepend (mateconf_items, lastcommand); + items = g_array_new (TRUE, TRUE, sizeof (gchar *)); + g_array_append_val (items, lastcommand); i++; model = gtk_combo_box_get_model (GTK_COMBO_BOX (entry)); if (gtk_tree_model_get_iter_first (model, &iter)) { char *command; - do { gtk_tree_model_get (model, &iter, 0, &command, -1); - - if (strcmp (command, lastcommand) == 0) + if (g_strcmp0 (command, lastcommand) == 0) continue; - - mateconf_items = g_slist_prepend (mateconf_items, command); + g_array_append_val (items, command); i++; } while (gtk_tree_model_iter_next (model, &iter) && i < PANEL_RUN_MAX_HISTORY); } - mateconf_client_set_list (panel_mateconf_get_client (), - PANEL_RUN_HISTORY_KEY, - MATECONF_VALUE_STRING, mateconf_items, - NULL); + g_settings_set_strv (dialog->settings, PANEL_RUN_HISTORY_KEY, + (const gchar **) items->data); - g_slist_free (mateconf_items); + g_array_free (items, TRUE); } static void @@ -217,10 +211,9 @@ panel_run_dialog_destroy (PanelRunDialog *dialog) g_source_remove (dialog->find_command_idle_id); dialog->find_command_idle_id = 0; - if (dialog->content_notify_id) - mateconf_client_notify_remove (panel_mateconf_get_client (), - dialog->content_notify_id); - dialog->content_notify_id = 0; + if (dialog->settings != NULL) + g_object_unref (dialog->settings); + dialog->settings = NULL; if (dialog->dir_hash) g_hash_table_destroy (dialog->dir_hash); @@ -479,7 +472,7 @@ panel_run_dialog_execute (PanelRunDialog *dialog) if (result) { /* only save working commands in history */ _panel_run_save_recent_programs_list - (GTK_COMBO_BOX_ENTRY (dialog->combobox), command); + (dialog, GTK_COMBO_BOX_ENTRY (dialog->combobox), command); /* only close the dialog if we successfully showed or launched * something */ @@ -1181,12 +1174,11 @@ panel_run_dialog_update_content (PanelRunDialog *dialog, } static void -panel_run_dialog_content_notify (MateConfClient *client, - int notify_id, - MateConfEntry *entry, +panel_run_dialog_content_notify (GSettings *settings, + gchar *key, PanelRunDialog *dialog) { - panel_run_dialog_update_content (dialog, mateconf_value_get_bool (entry->value)); + panel_run_dialog_update_content (dialog, g_settings_get_boolean (settings, key)); } static void @@ -1201,9 +1193,6 @@ static void panel_run_dialog_setup_list_expander (PanelRunDialog *dialog, GtkBuilder *gui) { - MateConfClient *client; - const char *key; - dialog->list_expander = PANEL_GTK_BUILDER_GET (gui, "list_expander"); if (panel_profile_get_enable_program_list ()) { @@ -1217,16 +1206,10 @@ panel_run_dialog_setup_list_expander (PanelRunDialog *dialog, G_CALLBACK (list_expander_toggled), dialog); - client = panel_mateconf_get_client (); - key = panel_mateconf_general_key ("show_program_list"); - - dialog->content_notify_id = - mateconf_client_notify_add (client, key, - (MateConfClientNotifyFunc) panel_run_dialog_content_notify, - dialog, NULL, NULL); - - if (!dialog->content_notify_id) - g_warning ("error setting up content change notification"); + g_signal_connect (dialog->settings, + "changed::" PANEL_RUN_SHOW_PROGRAM_LIST_KEY, + G_CALLBACK (panel_run_dialog_content_notify), + dialog); } } @@ -1748,7 +1731,7 @@ panel_run_dialog_setup_entry (PanelRunDialog *dialog, gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox), - _panel_run_get_recent_programs_list ()); + _panel_run_get_recent_programs_list (dialog)); gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (dialog->combobox), 0); @@ -1944,6 +1927,8 @@ panel_run_dialog_new (GdkScreen *screen, dialog->run_button = PANEL_GTK_BUILDER_GET (gui, "run_button"); dialog->terminal_checkbox = PANEL_GTK_BUILDER_GET (gui, "terminal_checkbox"); + dialog->settings = g_settings_new (PANEL_RUN_SCHEMA); + panel_run_dialog_setup_pixmap (dialog, gui); panel_run_dialog_setup_entry (dialog, gui); panel_run_dialog_setup_file_button (dialog, gui); diff --git a/mate-panel/panel-schemas.h b/mate-panel/panel-schemas.h new file mode 100644 index 00000000..b57a4063 --- /dev/null +++ b/mate-panel/panel-schemas.h @@ -0,0 +1,90 @@ +#ifndef __PANEL_SCHEMAS_H__ +#define __PANEL_SCHEMAS_H__ + +#define PANEL_RESOURCE_PATH "/org/mate/panel/" +#define PANEL_GENERAL_PATH "/org/mate/panel/general/" + +#define PANEL_TOPLEVEL_PATH "/org/mate/panel/toplevels/" +#define PANEL_TOPLEVEL_DEFAULT_PREFIX "toplevel" +#define PANEL_OBJECT_PATH "/org/mate/panel/objects/" +#define PANEL_OBJECT_DEFAULT_PREFIX "object" + +#define PANEL_SCHEMA "org.mate.panel" +#define PANEL_TOPLEVEL_ID_LIST_KEY "toplevel-id-list" +#define PANEL_OBJECT_ID_LIST_KEY "object-id-list" +#define PANEL_LOCKED_DOWN_KEY "locked-down" +#define PANEL_DISABLE_LOG_OUT_KEY "disable-log-out" +#define PANEL_DISABLE_FORCE_QUIT_KEY "disable-force-quit" +#define PANEL_DISABLED_APPLETS_KEY "disabled-applets" + +#define PANEL_TOPLEVEL_SCHEMA "org.mate.panel.toplevel" +#define PANEL_TOPLEVEL_NAME_KEY "name" +#define PANEL_TOPLEVEL_SCREEN_KEY "screen" +#define PANEL_TOPLEVEL_MONITOR_KEY "monitor" +#define PANEL_TOPLEVEL_EXPAND_KEY "expand" +#define PANEL_TOPLEVEL_ORIENTATION_KEY "orientation" +#define PANEL_TOPLEVEL_SIZE_KEY "size" +#define PANEL_TOPLEVEL_X_KEY "x" +#define PANEL_TOPLEVEL_Y_KEY "y" +#define PANEL_TOPLEVEL_X_RIGHT_KEY "x-right" +#define PANEL_TOPLEVEL_Y_BOTTOM_KEY "y-bottom" +#define PANEL_TOPLEVEL_X_CENTERED_KEY "x-centered" +#define PANEL_TOPLEVEL_Y_CENTERED_KEY "y-centered" +#define PANEL_TOPLEVEL_AUTO_HIDE_KEY "auto-hide" +#define PANEL_TOPLEVEL_ENABLE_ANIMATIONS_KEY "enable-animations" +#define PANEL_TOPLEVEL_ENABLE_BUTTONS_KEY "enable-buttons" +#define PANEL_TOPLEVEL_ENABLE_ARROWS_KEY "enable-arrows" +#define PANEL_TOPLEVEL_HIDE_DELAY_KEY "hide-delay" +#define PANEL_TOPLEVEL_UNHIDE_DELAY_KEY "unhide-delay" +#define PANEL_TOPLEVEL_AUTO_HIDE_SIZE_KEY "auto-hide-size" +#define PANEL_TOPLEVEL_ANIMATION_SPEED_KEY "animation-speed" + +#define PANEL_TOPLEVEL_BACKGROUND_SCHEMA "org.mate.panel.toplevel.background" +#define PANEL_TOPLEVEL_BACKGROUND_SCHEMA_CHILD "background" + +#define PANEL_OBJECT_SCHEMA "org.mate.panel.object" +#define PANEL_OBJECT_TYPE_KEY "object-type" +#define PANEL_OBJECT_TOPLEVEL_ID_KEY "toplevel-id" +#define PANEL_OBJECT_POSITION_KEY "position" +#define PANEL_OBJECT_PANEL_RIGHT_STICK_KEY "panel-right-stick" +#define PANEL_OBJECT_LOCKED_KEY "locked" +#define PANEL_OBJECT_APPLET_IID_KEY "applet-iid" +#define PANEL_OBJECT_ATTACHED_TOPLEVEL_ID_KEY "attached-toplevel-id" +#define PANEL_OBJECT_TOOLTIP_KEY "tooltip" +#define PANEL_OBJECT_USE_CUSTOM_ICON_KEY "use-custom-icon" +#define PANEL_OBJECT_CUSTOM_ICON_KEY "custom-icon" +#define PANEL_OBJECT_USE_MENU_PATH_KEY "use-menu-path" +#define PANEL_OBJECT_MENU_PATH_KEY "menu-path" +#define PANEL_OBJECT_HAS_ARROW_KEY "has-arrow" +#define PANEL_OBJECT_LAUNCHER_LOCATION_KEY "launcher-location" +#define PANEL_OBJECT_ACTION_TYPE_KEY "action-type" + +/* external schemas */ + +#define CAJA_DESKTOP_SCHEMA "org.mate.caja.desktop" +#define CAJA_DESKTOP_HOME_ICON_NAME_KEY "home-icon-name" +#define CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY "computer-icon-name" + +#define CAJA_PREFS_SCHEMA "org.mate.caja.preferences" +#define CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY "desktop-is-home-dir" + +#define MATE_SESSION_SCHEMA "org.mate.session" +#define MATE_SESSION_LOGOUT_PROMPT_KEY "logout-prompt" + +#define LOCKDOWN_SCHEMA "org.mate.lockdown" +#define LOCKDOWN_DISABLE_COMMAND_LINE_KEY "disable-command-line" +#define LOCKDOWN_DISABLE_LOCK_SCREEN_KEY "disable-lock-screen" + +#define MARCO_SCHEMA "org.mate.Marco.general" +#define MARCO_MOUSE_BUTTON_MODIFIER_KEY "mouse-button-modifier" + +#define MARCO_KEYBINDINGS_SCHEMA "org.mate.Marco.window-keybindings" +#define MARCO_ACTIVATE_WINDOW_MENU_KEY "activate-window-menu" +#define MARCO_TOGGLE_MAXIMIZED_KEY "toggle-maximized" +#define MARCO_MAXIMIZE_KEY "maximize" +#define MARCO_UNMAXIMIZE_KEY "unmaximize" +#define MARCO_TOGGLE_SHADED_KEY "toggle-shaded" +#define MARCO_BEGIN_MOVE_KEY "begin-move" +#define MARCO_BEGIN_RESIZE_KEY "begin-resize" + +#endif /* __PANEL_SCHEMAS_H__ */ diff --git a/mate-panel/panel-separator.c b/mate-panel/panel-separator.c index 9a8e7186..b7122c15 100644 --- a/mate-panel/panel-separator.c +++ b/mate-panel/panel-separator.c @@ -203,7 +203,7 @@ panel_separator_set_orientation (PanelSeparator *separator, } void -panel_separator_load_from_mateconf (PanelWidget *panel, +panel_separator_load_from_gsettings (PanelWidget *panel, gboolean locked, int position, const char *id) @@ -238,7 +238,7 @@ panel_separator_create (PanelToplevel *toplevel, id = panel_profile_prepare_object (PANEL_OBJECT_SEPARATOR, toplevel, position, FALSE); - panel_profile_add_to_list (PANEL_MATECONF_OBJECTS, id); + panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id); g_free (id); } diff --git a/mate-panel/panel-separator.h b/mate-panel/panel-separator.h index a7c699b8..8dcd5980 100644 --- a/mate-panel/panel-separator.h +++ b/mate-panel/panel-separator.h @@ -56,7 +56,7 @@ struct _PanelSeparatorClass { GType panel_separator_get_type (void) G_GNUC_CONST; void panel_separator_create (PanelToplevel *toplevel, int position); -void panel_separator_load_from_mateconf (PanelWidget *panel_widget, +void panel_separator_load_from_gsettings (PanelWidget *panel_widget, gboolean locked, gint position, const char *id); diff --git a/mate-panel/panel-test-applets.c b/mate-panel/panel-test-applets.c index f17ad8d1..96d0554d 100644 --- a/mate-panel/panel-test-applets.c +++ b/mate-panel/panel-test-applets.c @@ -3,16 +3,19 @@ * * Authors: * Mark McLoughlin <[email protected]> + * Stefano Karapetsas <[email protected]> * * Copyright 2002 Sun Microsystems, Inc. + * 2012 Stefano Karapetsas */ #include <config.h> #include <glib/gi18n.h> #include <gtk/gtk.h> -#include <mateconf/mateconf.h> +#include <gio/gio.h> #include <libpanel-util/panel-cleanup.h> +#include <libpanel-util/panel-dconf.h> #include <libmate-panel-applet-private/mate-panel-applet-container.h> #include <libmate-panel-applet-private/mate-panel-applets-manager-dbus.h> @@ -23,18 +26,18 @@ G_GNUC_UNUSED void on_execute_button_clicked (GtkButton *button, gpointer dummy) static GtkWidget *win = NULL; static GtkWidget *applet_combo = NULL; -static GtkWidget *prefs_dir_entry = NULL; +static GtkWidget *prefs_path_entry = NULL; static GtkWidget *orient_combo = NULL; static GtkWidget *size_combo = NULL; static char *cli_iid = NULL; -static char *cli_prefs_dir = NULL; +static char *cli_prefs_path = NULL; static char *cli_size = NULL; static char *cli_orient = NULL; static const GOptionEntry options [] = { { "iid", 0, 0, G_OPTION_ARG_STRING, &cli_iid, N_("Specify an applet IID to load"), NULL}, - { "prefs-dir", 0, 0, G_OPTION_ARG_STRING, &cli_prefs_dir, N_("Specify a mateconf location in which the applet preferences should be stored"), NULL}, + { "prefs-path", 0, 0, G_OPTION_ARG_STRING, &cli_prefs_path, N_("Specify a gsettings path in which the applet preferences should be stored"), NULL}, { "size", 0, 0, G_OPTION_ARG_STRING, &cli_size, N_("Specify the initial size of the applet (xx-small, medium, large etc.)"), NULL}, { "orient", 0, 0, G_OPTION_ARG_STRING, &cli_orient, N_("Specify the initial orientation of the applet (top, bottom, left or right)"), NULL}, { NULL} @@ -136,7 +139,7 @@ applet_activated_cb (GObject *source_object, static void load_applet_into_window (const char *title, - const char *prefs_key, + const char *prefs_path, guint size, guint orientation) { @@ -158,7 +161,7 @@ load_applet_into_window (const char *title, g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_add (&builder, "{sv}", - "prefs-key", g_variant_new_string (prefs_key)); + "prefs-path", g_variant_new_string (prefs_path)); g_variant_builder_add (&builder, "{sv}", "size", g_variant_new_uint32 (size)); g_variant_builder_add (&builder, "{sv}", @@ -201,7 +204,7 @@ load_applet_from_command_line (void) g_print ("Loading %s\n", cli_iid); - load_applet_into_window (cli_iid, cli_prefs_dir, size, orient); + load_applet_into_window (cli_iid, cli_prefs_path, size, orient); } G_GNUC_UNUSED void @@ -213,7 +216,7 @@ on_execute_button_clicked (GtkButton *button, title = get_combo_applet_id (applet_combo); load_applet_into_window (title, - gtk_entry_get_text (GTK_ENTRY (prefs_dir_entry)), + gtk_entry_get_text (GTK_ENTRY (prefs_path_entry)), get_combo_value (size_combo), get_combo_value (orient_combo)); g_free (title); @@ -261,8 +264,11 @@ setup_options (void) MatePanelAppletsManager *manager; GList *applet_list, *l; int i; - char *prefs_dir; - char *unique_key; + int j; + char *prefs_path = NULL; + char *unique_key = NULL; + gboolean *unique_key_found = FALSE; + gchar **dconf_paths; GtkListStore *model; GtkTreeIter iter; GtkCellRenderer *renderer; @@ -301,11 +307,27 @@ setup_options (void) setup_combo (orient_combo, orient_items, "Orientation", G_N_ELEMENTS (orient_items)); - unique_key = mateconf_unique_key (); - prefs_dir = g_strdup_printf ("/tmp/%s", unique_key); - g_free (unique_key); - gtk_entry_set_text (GTK_ENTRY (prefs_dir_entry), prefs_dir); - g_free (prefs_dir); + for (i = 0; !unique_key_found; i++) + { + unique_key = g_strdup_printf ("mate-panel-test-applet-%d", i); + unique_key_found = TRUE; + dconf_paths = panel_dconf_list_subdirs ("/tmp/", TRUE); + for (j = 0; dconf_paths[j] != NULL; j++) + { + if (g_strcmp0(unique_key, dconf_paths[j]) == 0) { + unique_key_found = FALSE; + break; + } + } + if (dconf_paths) + g_strfreev (dconf_paths); + } + + prefs_path = g_strdup_printf ("/tmp/%s/", unique_key); + if (unique_key) + g_free (unique_key); + gtk_entry_set_text (GTK_ENTRY (prefs_path_entry), prefs_path); + g_free (prefs_path); } int @@ -369,8 +391,8 @@ main (int argc, char **argv) "toplevel")); applet_combo = GTK_WIDGET (gtk_builder_get_object (builder, "applet-combo")); - prefs_dir_entry = GTK_WIDGET (gtk_builder_get_object (builder, - "prefs-dir-entry")); + prefs_path_entry = GTK_WIDGET (gtk_builder_get_object (builder, + "prefs-path-entry")); orient_combo = GTK_WIDGET (gtk_builder_get_object (builder, "orient-combo")); size_combo = GTK_WIDGET (gtk_builder_get_object (builder, diff --git a/mate-panel/panel-test-applets.ui b/mate-panel/panel-test-applets.ui index 05916cf5..a5a092c8 100644 --- a/mate-panel/panel-test-applets.ui +++ b/mate-panel/panel-test-applets.ui @@ -72,10 +72,10 @@ <object class="GtkLabel" id="prefs-label"> <property name="visible">True</property> <property name="xalign">1</property> - <property name="label" translatable="yes">_Prefs Dir:</property> + <property name="label" translatable="yes">_Prefs Path:</property> <property name="use_underline">True</property> <property name="justify">center</property> - <property name="mnemonic_widget">prefs-dir-entry</property> + <property name="mnemonic_widget">prefs-path-entry</property> </object> <packing> <property name="top_attach">2</property> @@ -85,7 +85,7 @@ </packing> </child> <child> - <object class="GtkEntry" id="prefs-dir-entry"> + <object class="GtkEntry" id="prefs-path-entry"> <property name="visible">True</property> <property name="can_focus">True</property> </object> diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c index 043e2e26..ed396980 100644 --- a/mate-panel/panel-toplevel.c +++ b/mate-panel/panel-toplevel.c @@ -47,6 +47,7 @@ #include "panel-struts.h" #include "panel-config-global.h" #include "panel-lockdown.h" +#include "panel-schemas.h" G_DEFINE_TYPE (PanelToplevel, panel_toplevel, GTK_TYPE_WINDOW) @@ -76,6 +77,8 @@ typedef enum { } PanelGrabOpType; struct _PanelToplevelPrivate { + gchar *settings_path; + gboolean expand; PanelOrientation orientation; int size; @@ -212,6 +215,7 @@ enum { enum { PROP_0, PROP_NAME, + PROP_SETTINGS_PATH, PROP_EXPAND, PROP_ORIENTATION, PROP_SIZE, @@ -454,7 +458,7 @@ static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpTyp op_type == PANEL_GRAB_OP_RESIZE_DOWN || op_type == PANEL_GRAB_OP_RESIZE_LEFT || op_type == PANEL_GRAB_OP_RESIZE_RIGHT) && - ! panel_profile_is_writable_toplevel_size (toplevel)) + ! panel_profile_key_is_writable (toplevel, PANEL_TOPLEVEL_SIZE_KEY)) return; if (toplevel->priv->attached && op_type == PANEL_GRAB_OP_MOVE) { @@ -3819,6 +3823,9 @@ panel_toplevel_set_property (GObject *object, case PROP_NAME: panel_toplevel_set_name (toplevel, g_value_get_string (value)); break; + case PROP_SETTINGS_PATH: + panel_toplevel_set_settings_path (toplevel, g_value_get_string (value)); + break; case PROP_EXPAND: panel_toplevel_set_expand (toplevel, g_value_get_boolean (value)); break; @@ -3913,6 +3920,9 @@ panel_toplevel_get_property (GObject *object, case PROP_NAME: g_value_set_string (value, panel_toplevel_get_name (toplevel)); break; + case PROP_SETTINGS_PATH: + g_value_set_string (value, toplevel->priv->settings_path); + break; case PROP_EXPAND: g_value_set_boolean (value, toplevel->priv->expand); break; @@ -3982,6 +3992,21 @@ panel_toplevel_finalize (GObject *object) toplevel_list = g_slist_remove (toplevel_list, toplevel); + if (toplevel->priv->settings_path) { + g_free (toplevel->priv->settings_path); + toplevel->priv->settings_path = NULL; + } + + if (toplevel->settings) { + g_object_unref (toplevel->settings); + toplevel->settings = NULL; + } + + if (toplevel->background_settings) { + g_object_unref (toplevel->background_settings); + toplevel->background_settings = NULL; + } + if (toplevel->priv->gtk_settings) { g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings, G_CALLBACK (panel_toplevel_drag_threshold_changed), @@ -4068,6 +4093,16 @@ panel_toplevel_class_init (PanelToplevelClass *klass) g_object_class_install_property ( gobject_class, + PROP_SETTINGS_PATH, + g_param_spec_string ( + "settings-path", + "GSettings path", + "The GSettings path used for this panel", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property ( + gobject_class, PROP_EXPAND, g_param_spec_boolean ( "expand", @@ -4598,6 +4633,13 @@ panel_toplevel_set_name (PanelToplevel *toplevel, g_object_notify (G_OBJECT (toplevel), "name"); } +void +panel_toplevel_set_settings_path (PanelToplevel *toplevel, + const char *settings_path) +{ + toplevel->priv->settings_path = g_strdup (settings_path); +} + const char* panel_toplevel_get_name(PanelToplevel* toplevel) { g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL); diff --git a/mate-panel/panel-toplevel.h b/mate-panel/panel-toplevel.h index 2c08a4aa..78be8393 100644 --- a/mate-panel/panel-toplevel.h +++ b/mate-panel/panel-toplevel.h @@ -53,6 +53,9 @@ typedef struct _PanelToplevelPrivate PanelToplevelPrivate; struct _PanelToplevel { GtkWindow window_instance; + GSettings *settings; + GSettings *queued_settings; + GSettings *background_settings; PanelToplevelPrivate *priv; }; @@ -81,6 +84,8 @@ PanelWidget *panel_toplevel_get_panel_widget (PanelToplevel void panel_toplevel_set_name (PanelToplevel *toplevel, const char *name); const char* panel_toplevel_get_name(PanelToplevel* toplevel); +void panel_toplevel_set_settings_path (PanelToplevel *toplevel, + const char *settings_path); const char* panel_toplevel_get_description(PanelToplevel* toplevel); void panel_toplevel_set_expand (PanelToplevel *toplevel, gboolean expand); diff --git a/mate-panel/panel-toplevel.schemas.in b/mate-panel/panel-toplevel.schemas.in deleted file mode 100644 index 90d3ca3f..00000000 --- a/mate-panel/panel-toplevel.schemas.in +++ /dev/null @@ -1,434 +0,0 @@ -<?xml version="1.0"?> -<mateconfschemafile> - - <schemalist> - - <schema> - <key>/schemas/apps/panel/toplevels/name</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Name to identify panel</short> - <long> - This is a human readable name which you can use to identify - a panel. Its main purpose is to serve as the panel's window - title which is useful when navigating between panels. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/screen</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>X screen where the panel is displayed</short> - <long> - With a multi-screen setup, you may have panels on each - individual screen. This key identifies the current screen - the panel is displayed on. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/monitor</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>Xinerama monitor where the panel is displayed</short> - <long> - In a Xinerama setup, you may have panels on each individual - monitor. This key identifies the current monitor the panel - is displayed on. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/expand</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Expand to occupy entire screen width</short> - <long> - If true, the panel will occupy the entire screen width - (height if this is a vertical panel). In this mode the panel - can only be placed at a screen edge. If false, the panel - will only be large enough to accommodate the applets, - launchers and buttons on the panel. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/orientation</key> - <owner>panel</owner> - <type>string</type> - <default>top</default> - <locale name="C"> - <short>Panel orientation</short> - <long> - The orientation of the panel. Possible values are "top", - "bottom", "left", "right". In expanded mode the key - specifies which screen edge the panel is on. In un-expanded - mode the difference between "top" and "bottom" is less - important - both indicate that this is a horizontal panel - - but still give a useful hint as to how some panel objects - should behave. For example, on a "top" panel a menu button - will pop up its menu below the panel, whereas on a "bottom" - panel the menu will be popped up above the panel. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/size</key> - <owner>panel</owner> - <type>int</type> - <default>24</default> - <locale name="C"> - <short>Panel size</short> - <long> - The height (width for a vertical panel) of the panel. The - panel will determine at runtime a minimum size based on - the font size and other indicators. The maximum size is - fixed at one quarter of the screen height (or width). - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/x</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>X co-ordinate of panel</short> - <long> - The location of the panel along the x-axis. This key is - only relevant in un-expanded mode. In expanded mode this - key is ignored and the panel is placed at the screen edge - specified by the orientation key. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/y</key> - <owner>panel</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>Y co-ordinate of panel</short> - <long> - The location of the panel along the y-axis. This key is - only relevant in un-expanded mode. In expanded mode this - key is ignored and the panel is placed at the screen edge - specified by the orientation key. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/x_right</key> - <owner>panel</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>X co-ordinate of panel, starting from the right of the screen</short> - <long> - The location of the panel along the x-axis, starting from the right of - the screen. If set to -1, the value is ignored and the value of the x - key is used. If the value is greater than 0, then the value of the x - key is ignored. - This key is only relevant in un-expanded mode. In expanded mode this - key is ignored and the panel is placed at the screen edge - specified by the orientation key. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/y_bottom</key> - <owner>panel</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>Y co-ordinate of panel, starting from the bottom of the screen</short> - <long> - The location of the panel along the y-axis, starting from the bottom of - the screen. If set to -1, the value is ignored and the value of the y - key is used. If the value is greater than 0, then the value of the y - key is ignored. - This key is only relevant in un-expanded mode. In expanded mode this - key is ignored and the panel is placed at the screen edge - specified by the orientation key. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/x_centered</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Center panel on x-axis</short> - <long> - If true, the x and x_right keys are ignored and the panel is placed at - the center of the x-axis of the screen. If the panel is - resized it will remain at that position - i.e. the panel - will grow on both sides. If false, the x and x_right keys specify - the location of the panel. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/y_centered</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Center panel on y-axis</short> - <long> - If true, the y and y_bottom keys are ignored and the panel is placed at - the center of the y-axis of the screen. If the panel is - resized it will remain at that position - i.e. the panel - will grow on both sides. If false, the y and y_bottom keys specify - the location of the panel. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/auto_hide</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Automatically hide panel into corner</short> - <long> - If true, the panel is automatically hidden into a corner - of the screen when the pointer leaves the panel area. Moving the - pointer to that corner again will cause the panel to re-appear. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/enable_animations</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Enable animations</short> - <long> - If true, hiding and un-hiding of this panel will be animated - rather than happening instantly. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/enable_buttons</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Enable hide buttons</short> - <long> - If true, buttons will be placed on each side of the panel - which may be used to move the panel to edge of the screen, - leaving only a button showing. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/enable_arrows</key> - <owner>panel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Enable arrows on hide buttons</short> - <long> - If true, arrows will be placed on the hide buttons. This - key is only relevant if the enable_buttons key is true. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/hide_delay</key> - <owner>panel</owner> - <type>int</type> - <default>300</default> - <locale name="C"> - <short>Panel autohide delay</short> - <long> - Specifies the number of milliseconds delay after the pointer - leaves the panel area before the panel is automatically hidden. - This key is only relevant if the auto_hide key is true. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/unhide_delay</key> - <owner>panel</owner> - <type>int</type> - <default>100</default> - <locale name="C"> - <short>Panel autounhide delay</short> - <long> - Specifies the number of milliseconds delay after the pointer - enters the panel area before the panel is automatically - re-shown. This key is only relevant if the auto_hide key is - true. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/auto_hide_size</key> - <owner>panel</owner> - <type>int</type> - <default>1</default> - <locale name="C"> - <short>Visible pixels when hidden</short> - <long> - Specifies the number of pixels visible when the panel is - automatically hidden into a corner. This key is only - relevant if the auto_hide key is true. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/animation_speed</key> - <owner>panel</owner> - <type>string</type> - <default>fast</default> - <locale name="C"> - <short>Animation speed</short> - <long> - The speed in which panel animations should occur. Possible - values are "slow", "medium" and "fast". This key is only - relevant if the enable_animations key is true. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/background/type</key> - <owner>panel</owner> - <type>string</type> - <default>gtk</default> - <locale name="C"> - <short>Background type</short> - <long> - Which type of background should be used for this panel. - Possible values are "gtk" - the default GTK+ widget - background will be used, "color" - the color key will - be used as background color or "image" - the image - specified by the image key will be used as background. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/background/color</key> - <owner>panel</owner> - <type>string</type> - <default>#ffffff</default> - <locale name="C"> - <short>Background color</short> - <long> - Specifies the background color for the panel in #RGB - format. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/background/opacity</key> - <owner>panel</owner> - <type>int</type> - <default>6000</default> - <locale name="C"> - <short>Background color opacity</short> - <long> - Specifies the opacity of the background color format. If the - color is not completely opaque (a value of less than 65535), - the color will be composited onto the desktop background - image. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/background/image</key> - <owner>panel</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Background image</short> - <long> - Specifies the file to be used for the background image. If - the image contains an alpha channel it will be composited - onto the desktop background image. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/background/fit</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Fit image to panel</short> - <long> - If true, the image will be scaled (retaining the aspect - ratio of the image) to the panel height (if horizontal). - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/background/stretch</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Stretch image to panel</short> - <long> - If true, the image will be scaled to the panel dimensions. - The aspect ratio of the image will not be maintained. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/panel/toplevels/background/rotate</key> - <owner>panel</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Rotate image on vertical panels</short> - <long> - If true, the background image will be rotated when the panel - is oriented vertically. - </long> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/mate-panel/panel-util.c b/mate-panel/panel-util.c index f8713611..4f081a4b 100644 --- a/mate-panel/panel-util.c +++ b/mate-panel/panel-util.c @@ -38,7 +38,7 @@ #include "nothing.h" #include "xstuff.h" #include "panel-config-global.h" -#include "panel-mateconf.h" +#include "panel-schemas.h" #include "panel-globals.h" #include "launcher.h" #include "panel-icon-names.h" @@ -822,7 +822,6 @@ panel_util_get_file_display_name_if_mount (GFile *file) return ret; } -#define HOME_NAME_KEY "/apps/caja/desktop/home_icon_name" static char * panel_util_get_file_display_for_common_files (GFile *file) { @@ -830,18 +829,20 @@ panel_util_get_file_display_for_common_files (GFile *file) compare = g_file_new_for_path (g_get_home_dir ()); if (g_file_equal (file, compare)) { - char *mateconf_name; + GSettings *caja_desktop_settings; + char *caja_home_icon_name; g_object_unref (compare); - mateconf_name = mateconf_client_get_string (panel_mateconf_get_client (), - HOME_NAME_KEY, - NULL); - if (PANEL_GLIB_STR_EMPTY (mateconf_name)) { - g_free (mateconf_name); + caja_desktop_settings = g_settings_new (CAJA_DESKTOP_SCHEMA); + caja_home_icon_name = g_settings_get_string (caja_desktop_settings, + CAJA_DESKTOP_HOME_ICON_NAME_KEY); + g_object_unref (caja_desktop_settings); + if (PANEL_GLIB_STR_EMPTY (caja_home_icon_name)) { + g_free (caja_home_icon_name); return g_strdup (_("Home Folder")); } else { - return mateconf_name; + return caja_home_icon_name; } } g_object_unref (compare); diff --git a/mate-panel/panel.c b/mate-panel/panel.c index 5f2a9666..c3a5a8ab 100644 --- a/mate-panel/panel.c +++ b/mate-panel/panel.c @@ -30,13 +30,11 @@ #include "panel-context-menu.h" #include "panel-util.h" #include "panel-config-global.h" -#include "panel-mateconf.h" #include "panel-profile.h" #include "mate-panel-applet-frame.h" #include "panel-action-button.h" #include "panel-menu-bar.h" #include "panel-separator.h" -#include "panel-compatibility.h" #include "panel-multiscreen.h" #include "panel-toplevel.h" #include "panel-menu-button.h" @@ -407,8 +405,8 @@ set_background_image_from_uri (PanelToplevel *toplevel, { char *image; - if ( ! panel_profile_is_writable_background_type (toplevel) || - ! panel_profile_is_writable_background_image (toplevel)) + if ( ! panel_profile_background_key_is_writable (toplevel, "type") || + ! panel_profile_background_key_is_writable (toplevel, "image")) return FALSE; if (!(image = g_filename_from_uri (uri, NULL, NULL))) @@ -431,8 +429,8 @@ set_background_color (PanelToplevel *toplevel, if (!dropped) return FALSE; - if ( ! panel_profile_is_writable_background_type (toplevel) || - ! panel_profile_is_writable_background_color (toplevel)) + if ( ! panel_profile_background_key_is_writable (toplevel, "color") || + ! panel_profile_background_key_is_writable (toplevel, "type")) return FALSE; color.gdk.red = dropped [0]; @@ -1086,7 +1084,7 @@ panel_receive_dnd_data (PanelWidget *panel, success = set_background_image_from_uri (panel->toplevel, (char *) data); break; case TARGET_BACKGROUND_RESET: - if (panel_profile_is_writable_background_type (panel->toplevel)) { + if (panel_profile_background_key_is_writable (panel->toplevel, "type")) { panel_profile_set_background_type (panel->toplevel, PANEL_BACK_NONE); success = TRUE; } else { diff --git a/matecomponent/Makefile.am b/matecomponent/Makefile.am deleted file mode 100644 index 831b4c8e..00000000 --- a/matecomponent/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = idl libmate-panel-applet panel-module - --include $(top_srcdir)/git.mk diff --git a/matecomponent/idl/MATE_Panel.idl b/matecomponent/idl/MATE_Panel.idl deleted file mode 100644 index 472b9ff5..00000000 --- a/matecomponent/idl/MATE_Panel.idl +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef MATE_PANEL_IDL -#define MATE_PANEL_IDL - -#include <MateComponent_Unknown.idl> - -module MATE { - module Vertigo { - - /* - * The panel's orientation. - */ - typedef unsigned short PanelOrient; - - const PanelOrient PANEL_ORIENT_UP = 0; - const PanelOrient PANEL_ORIENT_DOWN = 1; - const PanelOrient PANEL_ORIENT_LEFT = 2; - const PanelOrient PANEL_ORIENT_RIGHT = 3; - - /* - * The panel's width or height, depending - * on its orientation. - */ - typedef unsigned short PanelSize; - - const PanelSize PANEL_XX_SMALL = 12; - const PanelSize PANEL_X_SMALL = 24; - const PanelSize PANEL_SMALL = 36; - const PanelSize PANEL_MEDIUM = 48; - const PanelSize PANEL_LARGE = 64; - const PanelSize PANEL_X_LARGE = 80; - const PanelSize PANEL_XX_LARGE = 128; - - /* Used for the size hints list */ - typedef sequence<long> SizeHintList; - - /* - * MATE::PanelBackground Format: - * o "none:" - no background. - * o "colour:xxxxxx' - rgb colour value. - * o "pixmap:XID,x,y" - the pixmap XID, and the applets offsets into - * that pixmap. - */ - typedef string PanelBackground; - - interface MatePanelAppletShell : MateComponent::Unknown { - oneway void popup_menu (in long button, in long time); - }; - }; -}; - -#endif /* MATE_PANEL_IDL */ diff --git a/matecomponent/idl/Makefile.am b/matecomponent/idl/Makefile.am deleted file mode 100644 index a3141042..00000000 --- a/matecomponent/idl/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -idldir = $(datadir)/idl/mate-panel-2.0 -idl_DATA = MATE_Panel.idl - -EXTRA_DIST = $(idl_DATA) - --include $(top_srcdir)/git.mk diff --git a/matecomponent/libmate-panel-applet/MATE_Panel_TestApplet.server.in b/matecomponent/libmate-panel-applet/MATE_Panel_TestApplet.server.in deleted file mode 100644 index 18f2629f..00000000 --- a/matecomponent/libmate-panel-applet/MATE_Panel_TestApplet.server.in +++ /dev/null @@ -1,31 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:MATE_Panel_TestMateComponentApplet_Factory" - type="exe" - location="test-matecomponent-applet"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:MateComponent/GenericFactory:1.0"/> - <item value="IDL:MateComponent/Unknown:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Test MateComponent Applet Factory"/> - <oaf_attribute name="description" type="string" _value="Test MateComponent Applet Factory"/> - -</oaf_server> - -<oaf_server iid="OAFIID:MATE_Panel_TestMateComponentApplet" - type="factory" - location="OAFIID:MATE_Panel_TestMateComponentApplet_Factory"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:MATE/Vertigo/MatePanelAppletShell:1.0"/> - <item value="IDL:MateComponent/Control:1.0"/> - <item value="IDL:MateComponent/Unknown:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Test MateComponent Applet"/> - <oaf_attribute name="description" type="string" _value="A simple applet for testing the MATE-2.0 panel"/> - <oaf_attribute name="panel:icon" type="string" value="mate-gegl.png"/> - -</oaf_server> - -</oaf_info> diff --git a/matecomponent/libmate-panel-applet/Makefile.am b/matecomponent/libmate-panel-applet/Makefile.am deleted file mode 100644 index 1cd38d9f..00000000 --- a/matecomponent/libmate-panel-applet/Makefile.am +++ /dev/null @@ -1,129 +0,0 @@ -lib_LTLIBRARIES = libmate-panel-applet-2.la -bin_PROGRAMS = panel-test-applets-matecomponent -noinst_PROGRAMS = test-matecomponent-applet - -AM_CPPFLAGS = \ - $(LIBMATE_PANEL_APPLET_MATECOMPONENT_CFLAGS) \ - -I$(top_builddir)/matecomponent/libmate-panel-applet \ - -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ - -DMATE_PANEL_APPLET_DATADIR=\""$(datadir)"\" \ - -DMATE_PANEL_APPLET_BUILDERDIR=\""$(uidir)"\" \ - $(DISABLE_DEPRECATED_CFLAGS) - -AM_CFLAGS = $(WARN_CFLAGS) - -libmate_panel_appletincludedir = $(includedir)/panel-2.0 -libmate_panel_appletinclude_HEADERS = \ - mate-panel-applet.h \ - mate-panel-applet-mateconf.h \ - mate-panel-applet-enums.h \ - MATE_Panel.h - -libmate_panel_applet_2_la_SOURCES = \ - mate-panel-applet.h \ - mate-panel-applet.c \ - mate-panel-applet-mateconf.c \ - mate-panel-applet-mateconf.h \ - mate-panel-applet-shell.c \ - mate-panel-applet-shell.h \ - mate-panel-applet-private.h \ - mate-panel-applet-marshal.c \ - mate-panel-applet-marshal.h \ - mate-panel-applet-enums.c \ - mate-panel-applet-enums.h \ - $(CORBA_SRCLIST) - -libmate_panel_applet_2_la_LDFLAGS = \ - -version-info $(LIB_MATE_PANEL_APPLET_MATECOMPONENT_LT_VERSION) \ - -no-undefined -libmate_panel_applet_2_la_LIBADD = \ - $(LIBMATE_PANEL_APPLET_MATECOMPONENT_LIBS) \ - $(X_LIBS) - -panel_test_applets_matecomponent_LDADD = \ - $(LIBMATE_PANEL_APPLET_MATECOMPONENT_LIBS) - -test_matecomponent_applet_LDADD = \ - $(LIBMATE_PANEL_APPLET_MATECOMPONENT_LIBS) \ - libmate-panel-applet-2.la - -$(libmate_panel_applet_2_la_OBJECTS) $(test_matecomponent_applet_matecomponent_OBJECTS): $(BUILT_SOURCES) - -CORBA_SRCLIST = \ - MATE_Panel-stubs.c \ - MATE_Panel-skels.c \ - MATE_Panel-common.c \ - MATE_Panel.h - -$(CORBA_SRCLIST): $(top_srcdir)/matecomponent/idl/MATE_Panel.idl $(MATECORBA_IDL) - $(AM_V_GEN)$(MATECORBA_IDL) -I $(MATECOMPONENT_IDLDIR) -I $(MATECOMPONENT_ACT_IDLDIR) $(top_srcdir)/matecomponent/idl/MATE_Panel.idl - -mate-panel-applet-marshal.h: mate-panel-applet-marshal.list $(GLIB_GENMARSHAL) - $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=mate_panel_applet_marshal > $@ - -mate-panel-applet-marshal.c: mate-panel-applet-marshal.list $(GLIB_GENMARSHAL) - $(AM_V_GEN)echo "#include \"mate-panel-applet-marshal.h\"" > $@ && \ - $(GLIB_GENMARSHAL) $< --body --prefix=mate_panel_applet_marshal >> $@ - -mate_panel_applet_enum_headers = $(top_srcdir)/libmate-panel-applet/mate-panel-applet.h - -mate-panel-applet-enums.c: @REBUILD@ $(mate_panel_applet_enum_headers) - $(AM_V_GEN)glib-mkenums \ - --fhead "#include <glib-object.h>\n" \ - --fhead "#include \"mate-panel-applet-enums.h\"\n\n" \ - --fprod "\n/* enumerations from \"@filename@\" */" \ - --fprod "\n#include \"@filename@\"\n" \ - --vhead "static const G@Type@Value _@enum_name@_values[] = {" \ - --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ - --vtail " { 0, NULL, NULL }\n};\n\n" \ - --vtail "GType\n@enum_name@_get_type (void)\n{\n" \ - --vtail " static GType type = 0;\n\n" \ - --vtail " if (!type)\n" \ - --vtail " type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n\n" \ - --vtail " return type;\n}\n\n" \ - $(mate_panel_applet_enum_headers) > $@ - -mate-panel-applet-enums.h: @REBUILD@ $(mate_panel_applet_enum_headers) - $(AM_V_GEN)glib-mkenums \ - --fhead "#ifndef __MATE_PANEL_APPLET_ENUMS_H__\n" \ - --fhead "#define __MATE_PANEL_APPLET_ENUMS_H__\n\n" \ - --fhead "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n" \ - --ftail "#ifdef __cplusplus\n}\n#endif\n\n" \ - --ftail "#endif /* __MATE_PANEL_APPLET_ENUMS_H__ */\n" \ - --fprod "\n/* --- @filename@ --- */" \ - --eprod "#define PANEL_TYPE_@ENUMNAME@ @enum_name@_get_type()\n" \ - --eprod "GType @enum_name@_get_type (void);\n" \ - $(mate_panel_applet_enum_headers) > $@ - -BUILT_SOURCES = \ - $(CORBA_SRCLIST) \ - mate-panel-applet-enums.c \ - mate-panel-applet-enums.h \ - mate-panel-applet-marshal.c \ - mate-panel-applet-marshal.h - -uidir = $(datadir)/mate-panel/ui -ui_DATA = panel-test-applets-matecomponent.ui - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libmatepanelapplet-2.0.pc - -serverdir = $(libdir)/matecomponent/servers -server_in_files = MATE_Panel_TestApplet.server.in -noinst_DATA = $(server_in_files:.server.in=.server) - -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST = \ - MATE_Panel_TestApplet.server.in \ - mate-panel-applet-marshal.list \ - libmatepanelapplet-2.0.pc.in \ - libmatepanelapplet-2.0-uninstalled.pc.in \ - panel-test-applets-matecomponent.ui - -CLEANFILES = $(BUILT_SOURCES) $(noinst_DATA) - -dist-hook: - cd $(distdir) ; rm -f $(CLEANFILES) - --include $(top_srcdir)/git.mk diff --git a/matecomponent/libmate-panel-applet/TODO b/matecomponent/libmate-panel-applet/TODO deleted file mode 100644 index e0384730..00000000 --- a/matecomponent/libmate-panel-applet/TODO +++ /dev/null @@ -1,14 +0,0 @@ -libmate-panel-applet todo list -========================= - - Things that need to be finished before this library can be considered -anyway complete. - - * Size negotiation. Basically make sure this works. It should be no - different than the usual GtkWidget size request/allocation. The - applets shouldn't be allowed to be any bigger than the panel. The - other issue is with applets that want to expand to fill the available - space on the panel. At the moment this is solved with getExpandFlags, - but this ends up with some freaky stuff going on when you're moving - applets. Maybe we should consider having a re-sizable flag which would - make the applets have grabs for re-sizing. diff --git a/matecomponent/libmate-panel-applet/libmatepanelapplet-2.0-uninstalled.pc.in b/matecomponent/libmate-panel-applet/libmatepanelapplet-2.0-uninstalled.pc.in deleted file mode 100644 index 4b9b6c49..00000000 --- a/matecomponent/libmate-panel-applet/libmatepanelapplet-2.0-uninstalled.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libmate-panel-applet-2 -Description: libmate-panel-applet-2 -Requires: mateconf-2.0 gtk+-2.0 libmatecomponentui-2.0 -Version: @VERSION@ -Libs: ${pc_top_builddir}/${pcfiledir}/libmate-panel-applet-2.la -Cflags: -I${pc_top_builddir}/${pcfiledir} diff --git a/matecomponent/libmate-panel-applet/libmatepanelapplet-2.0.pc.in b/matecomponent/libmate-panel-applet/libmatepanelapplet-2.0.pc.in deleted file mode 100644 index a790b2c8..00000000 --- a/matecomponent/libmate-panel-applet/libmatepanelapplet-2.0.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libmate-panel-applet-2 -Description: libmate-panel-applet-2 -Requires: mateconf-2.0 gtk+-2.0 libmatecomponentui-2.0 -Version: @VERSION@ -Libs: -L${libdir} -lmate-panel-applet-2 -Cflags: -I${includedir}/panel-2.0 diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet-marshal.list b/matecomponent/libmate-panel-applet/mate-panel-applet-marshal.list deleted file mode 100644 index 1693a57d..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet-marshal.list +++ /dev/null @@ -1,5 +0,0 @@ -VOID:ENUM,BOXED,OBJECT -VOID:INT -VOID:UINT -VOID:ENUM -BOOLEAN:STRING diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet-mateconf.c b/matecomponent/libmate-panel-applet/mate-panel-applet-mateconf.c deleted file mode 100644 index 588df9ef..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet-mateconf.c +++ /dev/null @@ -1,458 +0,0 @@ -/* - * mate-panel-applet-mateconf.c: panel applet preferences handling. - * - * Copyright (C) 2001-2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#include <mateconf/mateconf-client.h> - -#include "mate-panel-applet-mateconf.h" -#include "mate-panel-applet-private.h" - -static MateConfClient * -mate_panel_applet_mateconf_get_client (void) -{ - static MateConfClient *client = NULL; - - if (!client) - client = mateconf_client_get_default (); - - return client; -} - -gchar * -mate_panel_applet_mateconf_get_full_key (MatePanelApplet *applet, - const gchar *key) -{ - gchar *prefs_key; - gchar *full_key; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (!key) - return NULL; - - prefs_key = mate_panel_applet_get_preferences_key (applet); - - full_key = g_strdup_printf ("%s/%s", prefs_key, key); - - g_free (prefs_key); - - return full_key; -} - -void -mate_panel_applet_mateconf_set_bool (MatePanelApplet *applet, - const gchar *key, - gboolean the_bool, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_bool (client, full_key, the_bool, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_int (MatePanelApplet *applet, - const gchar *key, - gint the_int, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_int (client, full_key, the_int, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_string (MatePanelApplet *applet, - const gchar *key, - const gchar *the_string, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_string (client, full_key, the_string, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_float (MatePanelApplet *applet, - const gchar *key, - gdouble the_float, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_float (client, full_key, the_float, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GSList *list, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_list (client, full_key, list_type, list, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_value (MatePanelApplet *applet, - const gchar *key, - MateConfValue *value, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set (client, full_key, value, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -gboolean -mate_panel_applet_mateconf_get_bool (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gboolean retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_bool (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gint -mate_panel_applet_mateconf_get_int (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gint retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), -1); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_int (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gchar * -mate_panel_applet_mateconf_get_string (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gchar *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_string (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gdouble -mate_panel_applet_mateconf_get_float (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gdouble retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), 0.0); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_float (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -MateConfValue * -mate_panel_applet_mateconf_get_value (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - MateConfValue *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -GSList * -mate_panel_applet_mateconf_get_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GSList *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_list (client, full_key, list_type, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet-mateconf.h b/matecomponent/libmate-panel-applet/mate-panel-applet-mateconf.h deleted file mode 100644 index 2eb523a4..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet-mateconf.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * mate-panel-applet-mateconf.h: panel applet preferences handling. - * - * Copyright (C) 2001-2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifndef __MATE_PANEL_APPLET_MATECONF_H__ -#define __MATE_PANEL_APPLET_MATECONF_H__ - -#include <glib.h> -#include <mateconf/mateconf-value.h> - -#include <mate-panel-applet.h> - -#ifdef __cplusplus -extern "C" { -#endif - -gchar *mate_panel_applet_mateconf_get_full_key (MatePanelApplet *applet, - const gchar *key); - -void mate_panel_applet_mateconf_set_bool (MatePanelApplet *applet, - const gchar *key, - gboolean the_bool, - GError **opt_error); -void mate_panel_applet_mateconf_set_int (MatePanelApplet *applet, - const gchar *key, - gint the_int, - GError **opt_error); -void mate_panel_applet_mateconf_set_string (MatePanelApplet *applet, - const gchar *key, - const gchar *the_string, - GError **opt_error); -void mate_panel_applet_mateconf_set_float (MatePanelApplet *applet, - const gchar *key, - gdouble the_float, - GError **opt_error); -void mate_panel_applet_mateconf_set_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GSList *list, - GError **opt_error); -void mate_panel_applet_mateconf_set_value (MatePanelApplet *applet, - const gchar *key, - MateConfValue *value, - GError **opt_error); - -gboolean mate_panel_applet_mateconf_get_bool (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gint mate_panel_applet_mateconf_get_int (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gchar *mate_panel_applet_mateconf_get_string (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gdouble mate_panel_applet_mateconf_get_float (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -GSList *mate_panel_applet_mateconf_get_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GError **opt_error); -MateConfValue *mate_panel_applet_mateconf_get_value (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); - -#ifdef __cplusplus -} -#endif - -#endif /* __MATE_PANEL_APPLET_MATECONF_H__ */ diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet-private.h b/matecomponent/libmate-panel-applet/mate-panel-applet-private.h deleted file mode 100644 index 6cc36abd..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet-private.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * mate-panel-applet-private.h: - * - * Copyright (C) 2001 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifndef __MATE_PANEL_APPLET_PRIVATE_H__ -#define __MATE_PANEL_APPLET_PRIVATE_H__ - -#include "mate-panel-applet.h" - -#ifdef __cplusplus -extern "C" { -#endif - -gboolean _mate_panel_applet_popup_menu (MatePanelApplet *applet, guint button, guint32 time); - -#ifdef __cplusplus -} -#endif - -#endif /* __MATE_PANEL_APPLET_PRIVATE_H__ */ diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet-shell.c b/matecomponent/libmate-panel-applet/mate-panel-applet-shell.c deleted file mode 100644 index a9b56489..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet-shell.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * mate-panel-applet-shell.c: the panel's interface to the applet. - * - * Copyright (C) 2001 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#include <config.h> - -#include "mate-panel-applet-shell.h" -#include "mate-panel-applet.h" -#include "mate-panel-applet-private.h" - -struct _MatePanelAppletShellPrivate { - MatePanelApplet *applet; -}; - -static GObjectClass *parent_class = NULL; - -static void -impl_MatePanelAppletShell_popup_menu (PortableServer_Servant servant, - CORBA_long button, - CORBA_long time, - CORBA_Environment *ev) -{ - MatePanelAppletShell *applet_shell; - - applet_shell = MATE_PANEL_APPLET_SHELL (matecomponent_object (servant)); - - _mate_panel_applet_popup_menu (applet_shell->priv->applet, button, time); -} - -static void -mate_panel_applet_shell_finalize (GObject *object) -{ - MatePanelAppletShell *shell = MATE_PANEL_APPLET_SHELL (object); - - if (shell->priv) { - g_free (shell->priv); - shell->priv = NULL; - } - - parent_class->finalize (object); -} - -static void -mate_panel_applet_shell_class_init (MatePanelAppletShellClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - klass->epv.popup_menu = impl_MatePanelAppletShell_popup_menu; - - object_class->finalize = mate_panel_applet_shell_finalize; - - parent_class = g_type_class_peek_parent (klass); -} - -static void -mate_panel_applet_shell_init (MatePanelAppletShell *shell) -{ - shell->priv = g_new0 (MatePanelAppletShellPrivate, 1); - - shell->priv->applet = NULL; -} - -MATECOMPONENT_TYPE_FUNC_FULL (MatePanelAppletShell, - MATE_Vertigo_MatePanelAppletShell, - MATECOMPONENT_OBJECT_TYPE, - mate_panel_applet_shell) - -void -mate_panel_applet_shell_construct (MatePanelAppletShell *shell, - MatePanelApplet *applet) -{ - shell->priv->applet = applet; -} - -MatePanelAppletShell * -mate_panel_applet_shell_new (MatePanelApplet *applet) -{ - MatePanelAppletShell *shell; - - shell = g_object_new (MATE_PANEL_APPLET_SHELL_TYPE, NULL); - - mate_panel_applet_shell_construct (shell, applet); - - return shell; -} diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet-shell.h b/matecomponent/libmate-panel-applet/mate-panel-applet-shell.h deleted file mode 100644 index b4c7d548..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet-shell.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * mate-panel-applet-shell.h: the panel's interface to the applet. - * - * Copyright (C) 2001 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifndef __MATE_PANEL_APPLET_SHELL_H__ -#define __MATE_PANEL_APPLET_SHELL_H__ - -#include <matecomponent/matecomponent-object.h> - -#include <mate-panel-applet.h> -#include <MATE_Panel.h> - -#define MATE_PANEL_APPLET_SHELL_TYPE (mate_panel_applet_shell_get_type ()) -#define MATE_PANEL_APPLET_SHELL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_PANEL_APPLET_SHELL_TYPE, MatePanelAppletShell)) -#define MATE_PANEL_APPLET_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MATE_PANEL_APPLET_SHELL_TYPE, MatePanelAppletShellClass)) -#define PANEL_IS_APPLET_SHELL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_PANEL_APPLET_SHELL_TYPE)) -#define PANEL_IS_APPLET_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MATE_PANEL_APPLET_SHELL_TYPE)) - -typedef struct _MatePanelAppletShellPrivate MatePanelAppletShellPrivate; - -typedef struct { - MateComponentObject base; - - MatePanelAppletShellPrivate *priv; -} MatePanelAppletShell; - -typedef struct { - MateComponentObjectClass base_class; - - POA_MATE_Vertigo_MatePanelAppletShell__epv epv; -} MatePanelAppletShellClass; - - -GType mate_panel_applet_shell_get_type (void) G_GNUC_CONST; - -void mate_panel_applet_shell_construct (MatePanelAppletShell *shell, - MatePanelApplet *applet); - -MatePanelAppletShell *mate_panel_applet_shell_new (MatePanelApplet *applet); - - -#endif /* MATE_PANEL_APPLET_SHELL_H */ diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet.c b/matecomponent/libmate-panel-applet/mate-panel-applet.c deleted file mode 100644 index d8ad2a0a..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet.c +++ /dev/null @@ -1,1830 +0,0 @@ -/* - * mate-panel-applet.c: panel applet writing library. - * - * Copyright (C) 2001 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <unistd.h> -#include <stdlib.h> -#include <string.h> - -#include <cairo.h> -#include <gdk/gdk.h> -#include <gdk/gdkx.h> -#include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> -#include <matecomponent/matecomponent-ui-util.h> -#include <matecomponent/matecomponent-main.h> -#include <matecomponent/matecomponent-types.h> -#include <matecomponent/matecomponent-property-bag.h> -#include <matecomponent/matecomponent-item-handler.h> -#include <matecomponent/matecomponent-property-bag-client.h> -#include <mateconf/mateconf.h> -#include <mateconf/mateconf-client.h> -#include <X11/Xatom.h> - -#include "mate-panel-applet.h" -#include "mate-panel-applet-private.h" -#include "mate-panel-applet-shell.h" -#include "mate-panel-applet-marshal.h" -#include "mate-panel-applet-enums.h" - -#define MATE_PANEL_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET, MatePanelAppletPrivate)) - -struct _MatePanelAppletPrivate { - MatePanelAppletShell *shell; - MateComponentControl *control; - MateComponentPropertyBag *prop_sack; - MateComponentItemHandler *item_handler; - MateConfClient *client; - - char *iid; - GClosure *closure; - gboolean bound; - char *prefs_key; - - MatePanelAppletFlags flags; - MatePanelAppletOrient orient; - guint size; - char *background; - GtkWidget *background_widget; - - int previous_width; - int previous_height; - - int *size_hints; - int size_hints_len; - - gboolean moving_focus_out; - - gboolean locked_down; -}; - -enum { - CHANGE_ORIENT, - CHANGE_SIZE, - CHANGE_BACKGROUND, - MOVE_FOCUS_OUT_OF_APPLET, - SAVE_YOURSELF, - LAST_SIGNAL -}; - -static guint mate_panel_applet_signals [LAST_SIGNAL]; - -#define PROPERTY_ORIENT "mate-panel-applet-orient" -#define PROPERTY_SIZE "mate-panel-applet-size" -#define PROPERTY_BACKGROUND "mate-panel-applet-background" -#define PROPERTY_FLAGS "mate-panel-applet-flags" -#define PROPERTY_SIZE_HINTS "mate-panel-applet-size-hints" -#define PROPERTY_LOCKED_DOWN "mate-panel-applet-locked-down" - -enum { - PROPERTY_ORIENT_IDX, - PROPERTY_SIZE_IDX, - PROPERTY_BACKGROUND_IDX, - PROPERTY_FLAGS_IDX, - PROPERTY_SIZE_HINTS_IDX, - PROPERTY_LOCKED_DOWN_IDX -}; - -G_DEFINE_TYPE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX) - -static void mate_panel_applet_handle_background (MatePanelApplet *applet); -static void mate_panel_applet_setup (MatePanelApplet *applet); - -static void -mate_panel_applet_associate_schemas_in_dir (MateConfClient *client, - const gchar *prefs_key, - const gchar *schema_dir, - GError **error) -{ - GSList *list, *l; - - list = mateconf_client_all_entries (client, schema_dir, error); - - if (*error != NULL) - return; - - for (l = list; l; l = l->next) { - MateConfEntry *entry = l->data; - const gchar *schema_key; - MateConfEntry *applet_entry; - const gchar *applet_schema_key; - gchar *key; - gchar *tmp; - - schema_key = mateconf_entry_get_key (entry); - tmp = g_path_get_basename (schema_key); - - if (strchr (tmp, '-')) - g_warning ("Applet key '%s' contains a hyphen. Please " - "use underscores in mateconf keys\n", tmp); - - key = g_strdup_printf ("%s/%s", prefs_key, tmp); - g_free (tmp); - - /* Associating a schema is potentially expensive, so let's try - * to avoid this by doing it only when needed. So we check if - * the key is already correctly associated. */ - - applet_entry = mateconf_client_get_entry (client, key, - NULL, TRUE, NULL); - if (applet_entry) - applet_schema_key = mateconf_entry_get_schema_name (applet_entry); - else - applet_schema_key = NULL; - - if (g_strcmp0 (schema_key, applet_schema_key) != 0) { - mateconf_engine_associate_schema (client->engine, - key, schema_key, error); - - if (applet_entry == NULL || - mateconf_entry_get_value (applet_entry) == NULL || - mateconf_entry_get_is_default (applet_entry)) { - /* unset the key: mateconf_client_get_entry() - * brought an invalid entry in the client - * cache, and we want to fix this */ - mateconf_client_unset (client, key, NULL); - } - } - - g_free (key); - - if (applet_entry) - mateconf_entry_unref (applet_entry); - mateconf_entry_unref (entry); - - if (*error) { - g_slist_free (list); - return; - } - } - - g_slist_free (list); - - list = mateconf_client_all_dirs (client, schema_dir, error); - - for (l = list; l; l = l->next) { - gchar *subdir = l->data; - gchar *prefs_subdir; - gchar *schema_subdir; - gchar *tmp; - - tmp = g_path_get_basename (subdir); - - prefs_subdir = g_strdup_printf ("%s/%s", prefs_key, tmp); - schema_subdir = g_strdup_printf ("%s/%s", schema_dir, tmp); - - mate_panel_applet_associate_schemas_in_dir (client, - prefs_subdir, - schema_subdir, - error); - - g_free (prefs_subdir); - g_free (schema_subdir); - g_free (subdir); - g_free (tmp); - - if (*error) { - g_slist_free (list); - return; - } - } - - g_slist_free (list); -} - -void -mate_panel_applet_add_preferences (MatePanelApplet *applet, - const gchar *schema_dir, - GError **opt_error) -{ - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (schema_dir != NULL); - - if (!applet->priv->prefs_key) - return; - - if (opt_error) - error = opt_error; - else - error = &our_error; - - mate_panel_applet_associate_schemas_in_dir (applet->priv->client, - applet->priv->prefs_key, - schema_dir, - error); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": failed to add preferences from '%s' : '%s'", - schema_dir, our_error->message); - g_error_free (our_error); - } -} - -char * -mate_panel_applet_get_preferences_key (MatePanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (!applet->priv->prefs_key) - return NULL; - - return g_strdup (applet->priv->prefs_key); -} - -static void -mate_panel_applet_set_preferences_key (MatePanelApplet *applet, - const char *prefs_key) -{ - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (applet->priv->prefs_key) { - mateconf_client_remove_dir (applet->priv->client, - applet->priv->prefs_key, - NULL); - - g_free (applet->priv->prefs_key); - applet->priv->prefs_key = NULL; - } - - if (prefs_key) { - applet->priv->prefs_key = g_strdup (prefs_key); - - mateconf_client_add_dir (applet->priv->client, - applet->priv->prefs_key, - MATECONF_CLIENT_PRELOAD_RECURSIVE, - NULL); - } -} - -MatePanelAppletFlags -mate_panel_applet_get_flags (MatePanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE); - - return applet->priv->flags; -} - -void -mate_panel_applet_set_flags (MatePanelApplet *applet, - MatePanelAppletFlags flags) -{ - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (applet->priv->prop_sack != NULL) - matecomponent_pbclient_set_short (MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_FLAGS, flags, NULL); - else - applet->priv->flags = flags; -} - -void -mate_panel_applet_set_size_hints (MatePanelApplet *applet, - const int *size_hints, - int n_elements, - int base_size) -{ - CORBA_sequence_CORBA_long *seq; - CORBA_Environment env; - CORBA_any any; - int i; - - CORBA_exception_init (&env); - - seq = CORBA_sequence_CORBA_long__alloc (); - seq->_length = seq->_maximum = n_elements; - seq->_release = CORBA_TRUE; - seq->_buffer = CORBA_sequence_CORBA_long_allocbuf (seq->_length); - - for (i = 0; i < n_elements; i++) - seq->_buffer [i] = size_hints [i] + base_size; - - any._type = TC_CORBA_sequence_CORBA_long; - any._release = CORBA_FALSE; - any._value = seq; - - MateComponent_PropertyBag_setValue (MATECOMPONENT_OBJREF (applet->priv->prop_sack), - PROPERTY_SIZE_HINTS, - &any, - &env); - - CORBA_free (seq); - - CORBA_exception_free (&env); -} - -guint -mate_panel_applet_get_size (MatePanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), 0); - - return applet->priv->size; -} - -MatePanelAppletOrient -mate_panel_applet_get_orient (MatePanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), 0); - - return applet->priv->orient; -} - -gboolean -mate_panel_applet_get_locked_down (MatePanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE); - - return applet->priv->locked_down; -} - -static Atom _net_wm_window_type = None; -static Atom _net_wm_window_type_dock = None; -static Atom _net_active_window = None; - -static void -mate_panel_applet_init_atoms (Display *xdisplay) -{ - if (_net_wm_window_type == None) - _net_wm_window_type = XInternAtom (xdisplay, - "_NET_WM_WINDOW_TYPE", - False); - - if (_net_wm_window_type_dock == None) - _net_wm_window_type_dock = XInternAtom (xdisplay, - "_NET_WM_WINDOW_TYPE_DOCK", - False); - - if (_net_active_window == None) - _net_active_window = XInternAtom (xdisplay, - "_NET_ACTIVE_WINDOW", - False); -} - -static Window -mate_panel_applet_find_toplevel_dock_window (MatePanelApplet *applet, - Display *xdisplay) -{ - GtkWidget *toplevel; - Window xwin; - Window root, parent, *child; - int num_children; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)); - if (!gtk_widget_get_realized (toplevel)) - return None; - - xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel)); - - child = NULL; - parent = root = None; - do { - Atom type_return; - Atom window_type; - int format_return; - gulong number_return, bytes_after_return; - guchar *data_return; - - XGetWindowProperty (xdisplay, - xwin, - _net_wm_window_type, - 0, 1, False, - XA_ATOM, - &type_return, &format_return, - &number_return, - &bytes_after_return, - &data_return); - - if (type_return == XA_ATOM) { - window_type = *(Atom *) data_return; - - XFree (data_return); - data_return = NULL; - - if (window_type == _net_wm_window_type_dock) - return xwin; - } - - if (!XQueryTree (xdisplay, - xwin, - &root, &parent, &child, - (guint *) &num_children)) { - return None; - } - - if (child && num_children > 0) - XFree (child); - - xwin = parent; - - } while (xwin != None && xwin != root); - - return None; -} - -/* This function - * 1) Gets the window id of the panel that contains the applet - * using XQueryTree and XGetWindowProperty to find an ancestor - * window with the _NET_WM_WINDOW_TYPE_DOCK window type. - * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused - */ -void -mate_panel_applet_request_focus (MatePanelApplet *applet, - guint32 timestamp) -{ - GdkScreen *screen; - GdkWindow *root; - GdkDisplay *display; - Display *xdisplay; - Window dock_xwindow; - Window xroot; - XEvent xev; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - screen = gtk_widget_get_screen (GTK_WIDGET (applet)); - root = gdk_screen_get_root_window (screen); - display = gdk_screen_get_display (screen); - - xdisplay = GDK_DISPLAY_XDISPLAY (display); - xroot = GDK_WINDOW_XWINDOW (root); - - mate_panel_applet_init_atoms (xdisplay); - - dock_xwindow = mate_panel_applet_find_toplevel_dock_window (applet, xdisplay); - if (dock_xwindow == None) - return; - - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = dock_xwindow; - xev.xclient.message_type = _net_active_window; - xev.xclient.format = 32; - xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */ - xev.xclient.data.l[1] = timestamp; - xev.xclient.data.l[2] = None; /* "currently active window", supposedly */ - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; - - XSendEvent (xdisplay, - xroot, False, - SubstructureRedirectMask | SubstructureNotifyMask, - &xev); -} - -void -mate_panel_applet_setup_menu (MatePanelApplet *applet, - const gchar *xml, - const MateComponentUIVerb *verb_list, - gpointer user_data) -{ - MateComponentUIComponent *popup_component; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (xml != NULL && verb_list != NULL); - - popup_component = mate_panel_applet_get_popup_component (applet); - - matecomponent_ui_component_set (popup_component, "/", "<popups/>", NULL); - - matecomponent_ui_component_set_translate (popup_component, "/popups", xml, NULL); - - matecomponent_ui_component_add_verb_list_with_data (popup_component, verb_list, user_data); -} - -void -mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet, - const gchar *opt_datadir, - const gchar *file, - const gchar *opt_app_name, - const MateComponentUIVerb *verb_list, - gpointer user_data) -{ - MateComponentUIComponent *popup_component; - gchar *app_name = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (file != NULL && verb_list != NULL); - - if (!opt_datadir) - opt_datadir = MATE_PANEL_APPLET_DATADIR; - - if (!opt_app_name) - opt_app_name = app_name = g_strdup_printf ("%lu", - (unsigned long) getpid ()); - - popup_component = mate_panel_applet_get_popup_component (applet); - - matecomponent_ui_util_set_ui (popup_component, opt_datadir, file, opt_app_name, NULL); - - matecomponent_ui_component_add_verb_list_with_data (popup_component, verb_list, user_data); - - if (app_name) - g_free (app_name); -} - -MateComponentControl * -mate_panel_applet_get_control (MatePanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - return applet->priv->control; -} - -MateComponentUIComponent * -mate_panel_applet_get_popup_component (MatePanelApplet *applet) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - return matecomponent_control_get_popup_ui_component (applet->priv->control); -} - -static void -mate_panel_applet_finalize (GObject *object) -{ - MatePanelApplet *applet = MATE_PANEL_APPLET (object); - - mate_panel_applet_set_preferences_key (applet, NULL); - - if (applet->priv->client) - g_object_unref (applet->priv->client); - applet->priv->client = NULL; - - if (applet->priv->prop_sack) - matecomponent_object_unref ( - MATECOMPONENT_OBJECT (applet->priv->prop_sack)); - applet->priv->prop_sack = NULL; - - g_free (applet->priv->size_hints); - g_free (applet->priv->prefs_key); - g_free (applet->priv->background); - g_free (applet->priv->iid); - - if (applet->priv->closure) - g_closure_unref (applet->priv->closure); - applet->priv->closure = NULL; - - G_OBJECT_CLASS (mate_panel_applet_parent_class)->finalize (object); -} - -static gboolean -container_has_focusable_child (GtkContainer *container) -{ - GtkWidget *child; - GList *list; - GList *t; - gboolean retval = FALSE; - - list = gtk_container_get_children (container); - - for (t = list; t; t = t->next) { - child = GTK_WIDGET (t->data); - if (gtk_widget_get_can_focus (child)) { - retval = TRUE; - break; - } else if (GTK_IS_CONTAINER (child)) { - retval = container_has_focusable_child (GTK_CONTAINER (child)); - if (retval) - break; - } - } - g_list_free (list); - return retval; -} - -static void -mate_panel_applet_position_menu (GtkMenu *menu, - int *x, - int *y, - gboolean *push_in, - GtkWidget *widget) -{ - MatePanelApplet *applet; - GtkAllocation allocation; - GtkRequisition requisition; - GdkScreen *screen; - int menu_x = 0; - int menu_y = 0; - int pointer_x; - int pointer_y; - - g_return_if_fail (PANEL_IS_APPLET (widget)); - - applet = MATE_PANEL_APPLET (widget); - - screen = gtk_widget_get_screen (widget); - - gtk_widget_size_request (GTK_WIDGET (menu), &requisition); - - gdk_window_get_origin (gtk_widget_get_window (widget), - &menu_x, &menu_y); - gtk_widget_get_pointer (widget, &pointer_x, &pointer_y); - - gtk_widget_get_allocation (widget, &allocation); - - menu_x += allocation.x; - menu_y += allocation.y; - - if (applet->priv->orient == MATE_PANEL_APPLET_ORIENT_UP || - applet->priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN) { - if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) { - if (pointer_x < allocation.width && - requisition.width < pointer_x) - menu_x += MIN (pointer_x, - allocation.width - requisition.width); - } else { - menu_x += allocation.width - requisition.width; - if (pointer_x > 0 && pointer_x < allocation.width && - pointer_x < allocation.width - requisition.width) { - menu_x -= MIN (allocation.width - pointer_x, - allocation.width - requisition.width); - } - } - menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width); - - if (menu_y > gdk_screen_get_height (screen) / 2) - menu_y -= requisition.height; - else - menu_y += allocation.height; - } else { - if (pointer_y < allocation.height && - requisition.height < pointer_y) - menu_y += MIN (pointer_y, allocation.height - requisition.height); - menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height); - - if (menu_x > gdk_screen_get_width (screen) / 2) - menu_x -= requisition.width; - else - menu_x += allocation.width; - - } - - *x = menu_x; - *y = menu_y; - *push_in = TRUE; -} - -static gboolean -mate_panel_applet_can_focus (GtkWidget *widget) -{ - /* - * A MatePanelApplet widget can focus if it has a tooltip or it does - * not have any focusable children. - */ - if (gtk_widget_get_has_tooltip (widget)) - return TRUE; - - if (!PANEL_IS_APPLET (widget)) - return FALSE; - - return !container_has_focusable_child (GTK_CONTAINER (widget)); -} - -static gboolean -mate_panel_applet_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - MatePanelApplet *applet = MATE_PANEL_APPLET (widget); - - if (!container_has_focusable_child (GTK_CONTAINER (applet))) { - if (!gtk_widget_has_focus (widget)) { - gtk_widget_set_can_focus (widget, TRUE); - gtk_widget_grab_focus (widget); - } - } - - if (event->button == 1) - return TRUE; - else if (event->button == 3) { - matecomponent_control_do_popup_full ( - applet->priv->control, - NULL, NULL, - (GtkMenuPositionFunc) mate_panel_applet_position_menu, - applet, - event->button, - event->time); - return TRUE; - } - - return FALSE; -} - -gboolean -_mate_panel_applet_popup_menu (MatePanelApplet *applet, - guint button, - guint32 time) -{ - matecomponent_control_do_popup_full (applet->priv->control, NULL, NULL, - (GtkMenuPositionFunc) mate_panel_applet_position_menu, - applet, button, time); - return TRUE; -} - -static gboolean -mate_panel_applet_popup_menu (MatePanelApplet *applet) -{ - return _mate_panel_applet_popup_menu (applet, 3, GDK_CURRENT_TIME); -} - -static void -mate_panel_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - int focus_width = 0; - - GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->size_request (widget, - requisition); - - if (!mate_panel_applet_can_focus (widget)) - return; - - /* - * We are deliberately ignoring focus-padding here to - * save valuable panel real estate. - */ - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - NULL); - - requisition->width += 2 * focus_width; - requisition->height += 2 * focus_width; -} - -static void -mate_panel_applet_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkAllocation child_allocation; - GtkBin *bin; - GtkWidget *child; - int border_width; - int focus_width = 0; - MatePanelApplet *applet; - - if (!mate_panel_applet_can_focus (widget)) { - GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->size_allocate (widget, allocation); - } else { - /* - * We are deliberately ignoring focus-padding here to - * save valuable panel real estate. - */ - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - NULL); - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - gtk_widget_set_allocation (widget, allocation); - bin = GTK_BIN (widget); - - child_allocation.x = focus_width; - child_allocation.y = focus_width; - - child_allocation.width = MAX (allocation->width - border_width * 2, 0); - child_allocation.height = MAX (allocation->height - border_width * 2, 0); - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x + border_width, - allocation->y + border_width, - child_allocation.width, - child_allocation.height); - - child_allocation.width = MAX (child_allocation.width - 2 * focus_width, 0); - child_allocation.height = MAX (child_allocation.height - 2 * focus_width, 0); - - child = gtk_bin_get_child (bin); - if (child) - gtk_widget_size_allocate (child, &child_allocation); - } - - applet = MATE_PANEL_APPLET (widget); - - if (applet->priv->previous_height != allocation->height || - applet->priv->previous_width != allocation->width) { - applet->priv->previous_height = allocation->height; - applet->priv->previous_width = allocation->width; - - mate_panel_applet_handle_background (applet); - } -} - -static gboolean -mate_panel_applet_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GtkAllocation allocation; - int border_width; - int focus_width = 0; - int x, y, width, height; - - g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->expose_event (widget, event); - - if (!gtk_widget_has_focus (widget)) - return FALSE; - - gtk_widget_get_allocation (widget, &allocation); - - /* - * We are deliberately ignoring focus-padding here to - * save valuable panel real estate. - */ - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - NULL); - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - x = allocation.x; - y = allocation.y; - - width = allocation.width - 2 * border_width; - height = allocation.height - 2 * border_width; - - gtk_paint_focus (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - &event->area, widget, "mate_panel_applet", - x, y, width, height); - - return FALSE; -} - -static gboolean -mate_panel_applet_focus (GtkWidget *widget, - GtkDirectionType dir) -{ - gboolean ret; - GtkWidget *previous_focus_child; - MatePanelApplet *applet; - - g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE); - - applet = MATE_PANEL_APPLET (widget); - if (applet->priv->moving_focus_out) { - /* - * Applet will retain focus if there is nothing else on the - * panel to get focus - */ - applet->priv->moving_focus_out = FALSE; - return FALSE; - } - - previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)); - if (!previous_focus_child && !gtk_widget_has_focus (widget)) { - if (gtk_widget_get_has_tooltip (widget)) { - gtk_widget_set_can_focus (widget, TRUE); - gtk_widget_grab_focus (widget); - gtk_widget_set_can_focus (widget, FALSE); - return TRUE; - } - } - ret = GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->focus (widget, dir); - - if (!ret && !previous_focus_child) { - if (!gtk_widget_has_focus (widget)) { - /* - * Applet does not have a widget which can focus so set - * the focus on the applet unless it already had focus - * because it had a tooltip. - */ - gtk_widget_set_can_focus (widget, TRUE); - gtk_widget_grab_focus (widget); - gtk_widget_set_can_focus (widget, FALSE); - ret = TRUE; - } - } - - return ret; -} - -static gboolean -mate_panel_applet_parse_color (const gchar *color_str, - GdkColor *color) -{ - int r, g, b; - - g_assert (color_str && color); - - if (sscanf (color_str, "%4x%4x%4x", &r, &g, &b) != 3) - return FALSE; - - color->red = r; - color->green = g; - color->blue = b; - - return TRUE; -} - -static gboolean -mate_panel_applet_parse_pixmap_str (const char *str, - GdkNativeWindow *xid, - int *x, - int *y) -{ - char **elements; - char *tmp; - - g_return_val_if_fail (str != NULL, FALSE); - g_return_val_if_fail (xid != NULL, FALSE); - g_return_val_if_fail (x != NULL, FALSE); - g_return_val_if_fail (y != NULL, FALSE); - - elements = g_strsplit (str, ",", -1); - - if (!elements) - return FALSE; - - if (!elements [0] || !*elements [0] || - !elements [1] || !*elements [1] || - !elements [2] || !*elements [2]) - goto ERROR_AND_FREE; - - *xid = strtol (elements [0], &tmp, 10); - if (tmp == elements [0]) - goto ERROR_AND_FREE; - - *x = strtol (elements [1], &tmp, 10); - if (tmp == elements [1]) - goto ERROR_AND_FREE; - - *y = strtol (elements [2], &tmp, 10); - if (tmp == elements [2]) - goto ERROR_AND_FREE; - - g_strfreev (elements); - return TRUE; - - ERROR_AND_FREE: - g_strfreev (elements); - return FALSE; -} - -static GdkPixmap * -mate_panel_applet_get_pixmap (MatePanelApplet *applet, - GdkNativeWindow xid, - int x, - int y) -{ - gboolean display_grabbed; - GdkPixmap *pixmap; - GdkDisplay *display; - GdkPixmap *retval; - GdkWindow *window; - int width; - int height; - cairo_t *cr; - cairo_pattern_t *pattern; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (!gtk_widget_get_realized (GTK_WIDGET (applet))) - return NULL; - - display = gdk_display_get_default (); - display_grabbed = FALSE; - - window = gtk_widget_get_window (GTK_WIDGET (applet)); - - pixmap = gdk_pixmap_lookup_for_display (display, xid); - if (pixmap) - g_object_ref (pixmap); - else { - display_grabbed = TRUE; - gdk_x11_display_grab (display); - pixmap = gdk_pixmap_foreign_new_for_display (display, xid); - } - - /* This can happen if the user changes the background very fast. - * We'll get the next update, so it's not a big deal. */ - if (pixmap == NULL) { - if (display_grabbed) - gdk_x11_display_ungrab (display); - return NULL; - } - - #if GTK_CHECK_VERSION(3, 0, 0) - width = gdk_window_get_width(window); - height = gdk_window_get_height(window); - #else - gdk_drawable_get_size(GDK_DRAWABLE(window), &width, &height); - #endif - - retval = gdk_pixmap_new (window, - width, height, -1); - - /* the pixmap has no colormap, and we need one */ - gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), - gdk_drawable_get_colormap (window)); - - cr = gdk_cairo_create (GDK_DRAWABLE (retval)); - gdk_cairo_set_source_pixmap (cr, pixmap, -x, -y); - pattern = cairo_get_source (cr); - cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); - - cairo_rectangle (cr, 0, 0, width, height); - cairo_fill (cr); - - cairo_destroy (cr); - - g_object_unref (pixmap); - - if (display_grabbed) - gdk_x11_display_ungrab (display); - - return retval; -} - -static MatePanelAppletBackgroundType -mate_panel_applet_handle_background_string (MatePanelApplet *applet, - GdkColor *color, - GdkPixmap **pixmap) -{ - MatePanelAppletBackgroundType retval; - char **elements; - - retval = PANEL_NO_BACKGROUND; - - if (!gtk_widget_get_realized (GTK_WIDGET (applet)) || !applet->priv->background) - return retval; - - elements = g_strsplit (applet->priv->background, ":", -1); - - if (elements [0] && !strcmp (elements [0], "none" )) { - retval = PANEL_NO_BACKGROUND; - - } else if (elements [0] && !strcmp (elements [0], "color")) { - g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND); - - if (!elements [1] || !mate_panel_applet_parse_color (elements [1], color)) { - - g_warning ("Incomplete '%s' background type received", elements [0]); - g_strfreev (elements); - return PANEL_NO_BACKGROUND; - } - - retval = PANEL_COLOR_BACKGROUND; - - } else if (elements [0] && !strcmp (elements [0], "pixmap")) { - GdkNativeWindow pixmap_id; - int x, y; - - g_return_val_if_fail (pixmap != NULL, PANEL_NO_BACKGROUND); - - if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) { - g_warning ("Incomplete '%s' background type received: %s", - elements [0], elements [1]); - - g_strfreev (elements); - return PANEL_NO_BACKGROUND; - } - - *pixmap = mate_panel_applet_get_pixmap (applet, pixmap_id, x, y); - if (!*pixmap) { - g_warning ("Failed to get pixmap %s", elements [1]); - g_strfreev (elements); - return PANEL_NO_BACKGROUND; - } - - retval = PANEL_PIXMAP_BACKGROUND; - } else - g_warning ("Unknown background type received"); - - g_strfreev (elements); - - return retval; -} - -MatePanelAppletBackgroundType -mate_panel_applet_get_background (MatePanelApplet *applet, - GdkColor *color, - GdkPixmap **pixmap) -{ - g_return_val_if_fail (PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND); - - /* initial sanity */ - if (pixmap != NULL) - *pixmap = NULL; - if (color != NULL) - memset (color, 0, sizeof (GdkColor)); - - return mate_panel_applet_handle_background_string (applet, color, pixmap); -} - -static void -mate_panel_applet_get_prop (MateComponentPropertyBag *sack, - MateComponentArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - MatePanelApplet *applet = MATE_PANEL_APPLET (user_data); - - switch (arg_id) { - case PROPERTY_ORIENT_IDX: - MATECOMPONENT_ARG_SET_SHORT (arg, applet->priv->orient); - break; - case PROPERTY_SIZE_IDX: - MATECOMPONENT_ARG_SET_SHORT (arg, applet->priv->size); - break; - case PROPERTY_BACKGROUND_IDX: - MATECOMPONENT_ARG_SET_STRING (arg, applet->priv->background); - break; - case PROPERTY_FLAGS_IDX: - MATECOMPONENT_ARG_SET_SHORT (arg, applet->priv->flags); - break; - case PROPERTY_SIZE_HINTS_IDX: { - CORBA_sequence_CORBA_long *seq; - int i; - - seq = arg->_value; - - seq->_length = seq->_maximum = applet->priv->size_hints_len; - seq->_buffer = CORBA_sequence_CORBA_long_allocbuf (seq->_length); - seq->_release = CORBA_TRUE; - - for (i = 0; i < applet->priv->size_hints_len; i++) - seq->_buffer [i] = applet->priv->size_hints [i]; - } - break; - case PROPERTY_LOCKED_DOWN_IDX: - MATECOMPONENT_ARG_SET_BOOLEAN (arg, applet->priv->locked_down); - break; - default: - g_assert_not_reached (); - break; - } -} - -static void -mate_panel_applet_update_background_for_widget (GtkWidget *widget, - MatePanelAppletBackgroundType type, - GdkColor *color, - GdkPixmap *pixmap) -{ - GtkRcStyle *rc_style; - GtkStyle *style; - - /* reset style */ - gtk_widget_set_style (widget, NULL); - rc_style = gtk_rc_style_new (); - gtk_widget_modify_style (widget, rc_style); - g_object_unref (rc_style); - - switch (type) { - case PANEL_NO_BACKGROUND: - break; - case PANEL_COLOR_BACKGROUND: - gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color); - break; - case PANEL_PIXMAP_BACKGROUND: - style = gtk_style_copy (gtk_widget_get_style (widget)); - if (style->bg_pixmap[GTK_STATE_NORMAL]) - g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]); - style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap); - gtk_widget_set_style (widget, style); - g_object_unref (style); - break; - default: - g_assert_not_reached (); - break; - } -} - -static void -mate_panel_applet_handle_background (MatePanelApplet *applet) -{ - MatePanelAppletBackgroundType type; - GdkColor color; - GdkPixmap *pixmap; - - type = mate_panel_applet_get_background (applet, &color, &pixmap); - - if (applet->priv->background_widget) - mate_panel_applet_update_background_for_widget (applet->priv->background_widget, - type, &color, pixmap); - - switch (type) { - case PANEL_NO_BACKGROUND: - g_signal_emit (G_OBJECT (applet), - mate_panel_applet_signals [CHANGE_BACKGROUND], - 0, PANEL_NO_BACKGROUND, NULL, NULL); - break; - case PANEL_COLOR_BACKGROUND: - g_signal_emit (G_OBJECT (applet), - mate_panel_applet_signals [CHANGE_BACKGROUND], - 0, PANEL_COLOR_BACKGROUND, &color, NULL); - break; - case PANEL_PIXMAP_BACKGROUND: - g_signal_emit (G_OBJECT (applet), - mate_panel_applet_signals [CHANGE_BACKGROUND], - 0, PANEL_PIXMAP_BACKGROUND, NULL, pixmap); - - g_object_unref (pixmap); - break; - default: - g_assert_not_reached (); - break; - } -} - -static void -mate_panel_applet_set_prop (MateComponentPropertyBag *sack, - const MateComponentArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - MatePanelApplet *applet = MATE_PANEL_APPLET (user_data); - - switch (arg_id) { - case PROPERTY_ORIENT_IDX: { - MatePanelAppletOrient orient; - - orient = MATECOMPONENT_ARG_GET_SHORT (arg); - - if (applet->priv->orient != orient) { - applet->priv->orient = orient; - - g_signal_emit (G_OBJECT (applet), - mate_panel_applet_signals [CHANGE_ORIENT], - 0, orient); - } - } - break; - case PROPERTY_SIZE_IDX: { - guint size; - - size = MATECOMPONENT_ARG_GET_SHORT (arg); - - if (applet->priv->size != size) { - applet->priv->size = size; - - g_signal_emit (G_OBJECT (applet), - mate_panel_applet_signals [CHANGE_SIZE], - 0, size); - } - } - break; - case PROPERTY_BACKGROUND_IDX: - if (applet->priv->background) - g_free (applet->priv->background); - - applet->priv->background = g_strdup (MATECOMPONENT_ARG_GET_STRING (arg)); - - mate_panel_applet_handle_background (applet); - break; - case PROPERTY_FLAGS_IDX: - applet->priv->flags = MATECOMPONENT_ARG_GET_SHORT (arg); - break; - case PROPERTY_SIZE_HINTS_IDX: { - CORBA_sequence_CORBA_long *seq = arg->_value; - int i; - - applet->priv->size_hints = g_realloc (applet->priv->size_hints, - seq->_length * sizeof (int)); - for (i = 0; i < seq->_length; i++) - applet->priv->size_hints [i] = seq->_buffer [i]; - - applet->priv->size_hints_len = seq->_length;; - } - break; - case PROPERTY_LOCKED_DOWN_IDX: - applet->priv->locked_down = MATECOMPONENT_ARG_GET_BOOLEAN (arg); - break; - default: - g_assert_not_reached (); - break; - } -} - -static MateComponentPropertyBag * -mate_panel_applet_property_bag (MatePanelApplet *applet) -{ - MateComponentPropertyBag *sack; - - sack = matecomponent_property_bag_new (mate_panel_applet_get_prop, - mate_panel_applet_set_prop, - applet); - - matecomponent_property_bag_add (sack, - PROPERTY_ORIENT, - PROPERTY_ORIENT_IDX, - MATECOMPONENT_ARG_SHORT, - NULL, - "The Applet's containing Panel's orientation", - MateComponent_PROPERTY_READABLE | MateComponent_PROPERTY_WRITEABLE); - - matecomponent_property_bag_add (sack, - PROPERTY_SIZE, - PROPERTY_SIZE_IDX, - MATECOMPONENT_ARG_SHORT, - NULL, - "The Applet's containing Panel's size in pixels", - MateComponent_PROPERTY_READABLE | MateComponent_PROPERTY_WRITEABLE); - - matecomponent_property_bag_add (sack, - PROPERTY_BACKGROUND, - PROPERTY_BACKGROUND_IDX, - MATECOMPONENT_ARG_STRING, - NULL, - "The Applet's containing Panel's background color or pixmap", - MateComponent_PROPERTY_READABLE | MateComponent_PROPERTY_WRITEABLE); - - matecomponent_property_bag_add (sack, - PROPERTY_FLAGS, - PROPERTY_FLAGS_IDX, - MATECOMPONENT_ARG_SHORT, - NULL, - "The Applet's flags", - MateComponent_PROPERTY_READABLE); - - matecomponent_property_bag_add (sack, - PROPERTY_SIZE_HINTS, - PROPERTY_SIZE_HINTS_IDX, - TC_CORBA_sequence_CORBA_long, - NULL, - "Ranges that hint what sizes are acceptable for the applet", - MateComponent_PROPERTY_READABLE); - - matecomponent_property_bag_add (sack, - PROPERTY_LOCKED_DOWN, - PROPERTY_LOCKED_DOWN_IDX, - MATECOMPONENT_ARG_BOOLEAN, - NULL, - "The Applet's containing Panel is locked down", - MateComponent_PROPERTY_READABLE | MateComponent_PROPERTY_WRITEABLE); - - return sack; -} - -static void -mate_panel_applet_realize (GtkWidget *widget) -{ - GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->realize (widget); - - if (MATE_PANEL_APPLET (widget)->priv->background) - mate_panel_applet_handle_background (MATE_PANEL_APPLET (widget)); -} - -static void -mate_panel_applet_control_bound (MateComponentControl *control, - MatePanelApplet *applet) -{ - gboolean ret; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (applet->priv->iid != NULL && - applet->priv->closure != NULL); - - if (applet->priv->bound) - return; - - matecomponent_closure_invoke (applet->priv->closure, - G_TYPE_BOOLEAN, &ret, - PANEL_TYPE_APPLET, applet, - G_TYPE_STRING, applet->priv->iid, - NULL); - - - if (!ret) { /* FIXME */ - g_warning ("need to free the control here"); - - return; - } - - applet->priv->bound = TRUE; -} - -static MateComponent_Unknown -mate_panel_applet_item_handler_get_object (MateComponentItemHandler *handler, - const char *item_name, - gboolean only_if_exists, - gpointer user_data, - CORBA_Environment *ev) -{ - MatePanelApplet *applet = user_data; - GSList *options; - GSList *l; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), CORBA_OBJECT_NIL); - - options = matecomponent_item_option_parse (item_name); - - for (l = options; l; l = l->next) { - MateComponentItemOption *option = l->data; - - if (!option->value || !option->value [0]) - continue; - - if (!strcmp (option->key, "prefs_key") && !applet->priv->prefs_key) - mate_panel_applet_set_preferences_key (applet, option->value); - - else if (!strcmp (option->key, "background")) - matecomponent_pbclient_set_string (MATECOMPONENT_OBJREF (applet->priv->prop_sack), - PROPERTY_BACKGROUND, option->value, NULL); - - else if (!strcmp (option->key, "orient")) { - if (!strcmp (option->value, "up")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - MATE_PANEL_APPLET_ORIENT_UP, NULL); - - else if (!strcmp (option->value, "down")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - MATE_PANEL_APPLET_ORIENT_DOWN, NULL); - - else if (!strcmp (option->value, "left")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - MATE_PANEL_APPLET_ORIENT_LEFT, NULL); - - else if (!strcmp (option->value, "right")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT, - MATE_PANEL_APPLET_ORIENT_RIGHT, NULL); - - } else if (!strcmp (option->key, "size")) { - if (!strcmp (option->value, "xx-small")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - MATE_Vertigo_PANEL_XX_SMALL, NULL); - - else if (!strcmp (option->value, "x-small")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - MATE_Vertigo_PANEL_X_SMALL, NULL); - - else if (!strcmp (option->value, "small")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - MATE_Vertigo_PANEL_SMALL, NULL); - - else if (!strcmp (option->value, "medium")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - MATE_Vertigo_PANEL_MEDIUM, NULL); - - else if (!strcmp (option->value, "large")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - MATE_Vertigo_PANEL_LARGE, NULL); - - else if (!strcmp (option->value, "x-large")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - MATE_Vertigo_PANEL_X_LARGE, NULL); - - else if (!strcmp (option->value, "xx-large")) - matecomponent_pbclient_set_short ( - MATECOMPONENT_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE, - MATE_Vertigo_PANEL_XX_LARGE, NULL); - } else if (!strcmp (option->key, "locked_down")) { - gboolean val = FALSE; - if (option->value[0] == 'T' || - option->value[0] == 't' || - option->value[0] == 'Y' || - option->value[0] == 'y' || - atoi (option->value) != 0) - val = TRUE; - matecomponent_pbclient_set_boolean (MATECOMPONENT_OBJREF (applet->priv->prop_sack), - PROPERTY_LOCKED_DOWN, val, NULL); - } - } - - matecomponent_item_options_free (options); - - return matecomponent_object_dup_ref (MATECOMPONENT_OBJREF (applet->priv->control), ev); -} - -static void -mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet, - GtkDirectionType dir) -{ - GtkWidget *toplevel; - - applet->priv->moving_focus_out = TRUE; - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)); - g_return_if_fail (toplevel); - - gtk_widget_child_focus (toplevel, dir); - applet->priv->moving_focus_out = FALSE; -} - -static void -add_tab_bindings (GtkBindingSet *binding_set, - GdkModifierType modifiers, - GtkDirectionType direction) -{ - gtk_binding_entry_add_signal (binding_set, GDK_Tab, modifiers, - "move_focus_out_of_applet", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, modifiers, - "move_focus_out_of_applet", 1, - GTK_TYPE_DIRECTION_TYPE, direction); -} - -static GObject* mate_panel_applet_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) -{ - GObject* obj = G_OBJECT_CLASS(mate_panel_applet_parent_class)->constructor(type, n_construct_properties, construct_properties); - - MatePanelApplet* applet = MATE_PANEL_APPLET(obj); - - /* Voy a renombrar la clase para que se pueda tener compatibilidad con todos - * los estilos visuales de GTK2 - * - * Issue #27 - */ - gtk_widget_set_name(GTK_WIDGET(applet), "PanelApplet"); - - mate_panel_applet_setup(applet); - - return obj; -} - -static void -mate_panel_applet_class_init (MatePanelAppletClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GtkObjectClass *object_class = (GtkObjectClass *) klass; - GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; - GtkBindingSet *binding_set; - - gobject_class->constructor = mate_panel_applet_constructor; - klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet; - - widget_class->button_press_event = mate_panel_applet_button_press; - widget_class->size_request = mate_panel_applet_size_request; - widget_class->size_allocate = mate_panel_applet_size_allocate; - widget_class->expose_event = mate_panel_applet_expose; - widget_class->focus = mate_panel_applet_focus; - widget_class->realize = mate_panel_applet_realize; - - gobject_class->finalize = mate_panel_applet_finalize; - - g_type_class_add_private (klass, sizeof (MatePanelAppletPrivate)); - - mate_panel_applet_signals [CHANGE_ORIENT] = - g_signal_new ("change_orient", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (MatePanelAppletClass, change_orient), - NULL, - NULL, - mate_panel_applet_marshal_VOID__UINT, - G_TYPE_NONE, - 1, - G_TYPE_UINT); - - mate_panel_applet_signals [CHANGE_SIZE] = - g_signal_new ("change_size", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (MatePanelAppletClass, change_size), - NULL, - NULL, - mate_panel_applet_marshal_VOID__INT, - G_TYPE_NONE, - 1, - G_TYPE_INT); - - mate_panel_applet_signals [CHANGE_BACKGROUND] = - g_signal_new ("change_background", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (MatePanelAppletClass, change_background), - NULL, - NULL, - mate_panel_applet_marshal_VOID__ENUM_BOXED_OBJECT, - G_TYPE_NONE, - 3, - PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPE, - GDK_TYPE_COLOR, - GDK_TYPE_PIXMAP); - - mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] = - g_signal_new ("move_focus_out_of_applet", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (MatePanelAppletClass, move_focus_out_of_applet), - NULL, - NULL, - mate_panel_applet_marshal_VOID__ENUM, - G_TYPE_NONE, - 1, - GTK_TYPE_DIRECTION_TYPE); - - binding_set = gtk_binding_set_by_class (object_class); - add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); - add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); - add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); -} - -static void -mate_panel_applet_init (MatePanelApplet *applet) -{ - applet->priv = MATE_PANEL_APPLET_GET_PRIVATE (applet); - - applet->priv->client = mateconf_client_get_default (); - - applet->priv->bound = FALSE; - applet->priv->flags = MATE_PANEL_APPLET_FLAGS_NONE; - applet->priv->orient = MATE_PANEL_APPLET_ORIENT_UP; - applet->priv->size = MATE_Vertigo_PANEL_MEDIUM; - - applet->priv->moving_focus_out = FALSE; - - gtk_widget_set_events (GTK_WIDGET (applet), - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); -} - -static void -mate_panel_applet_setup (MatePanelApplet *applet) -{ - MatePanelAppletPrivate *priv; - - priv = applet->priv; - - priv->control = matecomponent_control_new (GTK_WIDGET (applet)); - - g_signal_connect (priv->control, "set_frame", - G_CALLBACK (mate_panel_applet_control_bound), - applet); - - priv->prop_sack = mate_panel_applet_property_bag (applet); - - matecomponent_control_set_properties ( - priv->control, MATECOMPONENT_OBJREF (priv->prop_sack), NULL); - - priv->shell = mate_panel_applet_shell_new (applet); - - matecomponent_object_add_interface (MATECOMPONENT_OBJECT (priv->control), - MATECOMPONENT_OBJECT (priv->shell)); - - priv->item_handler = - matecomponent_item_handler_new ( - NULL, mate_panel_applet_item_handler_get_object, applet); - - matecomponent_object_add_interface (MATECOMPONENT_OBJECT (priv->control), - MATECOMPONENT_OBJECT (priv->item_handler)); - - g_signal_connect (applet, "popup_menu", - G_CALLBACK (mate_panel_applet_popup_menu), NULL); -} - -GtkWidget* mate_panel_applet_new(void) -{ - MatePanelApplet* applet = g_object_new(PANEL_TYPE_APPLET, NULL); - - return GTK_WIDGET (applet); -} - -typedef struct { - GType applet_type; - GClosure *closure; -} MatePanelAppletCallBackData; - -static MatePanelAppletCallBackData * -mate_panel_applet_callback_data_new (GType applet_type, - GClosure *closure) -{ - MatePanelAppletCallBackData *retval; - - retval = g_new0 (MatePanelAppletCallBackData, 1); - - retval->applet_type = applet_type; - retval->closure = closure; - - return retval; -} - -static void -mate_panel_applet_callback_data_free (MatePanelAppletCallBackData *data) -{ - g_closure_unref (data->closure); - g_free (data); -} - -static MateComponentObject * -mate_panel_applet_factory_callback (MateComponentGenericFactory *factory, - const char *iid, - MatePanelAppletCallBackData *data) -{ - MatePanelApplet *applet; - - applet = g_object_new (data->applet_type, NULL); - - applet->priv->iid = g_strdup (iid); - applet->priv->closure = g_closure_ref (data->closure); - - matecomponent_control_life_instrument (applet->priv->control); - - return MATECOMPONENT_OBJECT (applet->priv->control); -} - -static void -mate_panel_applet_all_controls_dead (void) -{ - if (!matecomponent_control_life_get_count()) - matecomponent_main_quit (); -} - -int -mate_panel_applet_factory_main_closure (const gchar *iid, - GType applet_type, - GClosure *closure) -{ - int retval; - char *display_iid; - MatePanelAppletCallBackData *data; - - g_return_val_if_fail (iid != NULL, 1); - g_return_val_if_fail (closure != NULL, 1); - - g_assert (g_type_is_a (applet_type, PANEL_TYPE_APPLET)); - - bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - - matecomponent_control_life_set_callback (mate_panel_applet_all_controls_dead); - - closure = matecomponent_closure_store (closure, mate_panel_applet_marshal_BOOLEAN__STRING); - - data = mate_panel_applet_callback_data_new (applet_type, closure); - - display_iid = matecomponent_activation_make_registration_id ( - iid, DisplayString (gdk_display_get_default ())); - retval = matecomponent_generic_factory_main ( - display_iid, - (MateComponentFactoryCallback) mate_panel_applet_factory_callback, - data); - g_free (display_iid); - - mate_panel_applet_callback_data_free (data); - - return retval; -} - -int -mate_panel_applet_factory_main (const gchar *iid, - GType applet_type, - MatePanelAppletFactoryCallback callback, - gpointer data) -{ - GClosure *closure; - - g_return_val_if_fail (iid != NULL, 1); - g_return_val_if_fail (callback != NULL, 1); - - closure = g_cclosure_new (G_CALLBACK (callback), data, NULL); - - return mate_panel_applet_factory_main_closure (iid, applet_type, closure); -} - -void -mate_panel_applet_set_background_widget (MatePanelApplet *applet, - GtkWidget *widget) -{ - applet->priv->background_widget = widget; - - if (widget) { - MatePanelAppletBackgroundType type; - GdkColor color; - GdkPixmap *pixmap; - - type = mate_panel_applet_get_background (applet, &color, &pixmap); - mate_panel_applet_update_background_for_widget (widget, type, - &color, pixmap); - if (type == PANEL_PIXMAP_BACKGROUND) - g_object_unref (pixmap); - } -} diff --git a/matecomponent/libmate-panel-applet/mate-panel-applet.h b/matecomponent/libmate-panel-applet/mate-panel-applet.h deleted file mode 100644 index 3310fa32..00000000 --- a/matecomponent/libmate-panel-applet/mate-panel-applet.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * mate-panel-applet.h: panel applet writing API. - * - * Copyright (C) 2001 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifndef __MATE_PANEL_APPLET_H__ -#define __MATE_PANEL_APPLET_H__ - -#include <glib.h> -#include <gtk/gtk.h> -#include <matecomponent/matecomponent-control.h> -#include <matecomponent/matecomponent-main.h> -#include <matecomponent/matecomponent-ui-component.h> -#include <matecomponent/matecomponent-generic-factory.h> - -#include <MATE_Panel.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef MATE_Vertigo_PanelOrient MatePanelAppletOrient; - -#define MATE_PANEL_APPLET_ORIENT_UP MATE_Vertigo_PANEL_ORIENT_UP -#define MATE_PANEL_APPLET_ORIENT_DOWN MATE_Vertigo_PANEL_ORIENT_DOWN -#define MATE_PANEL_APPLET_ORIENT_LEFT MATE_Vertigo_PANEL_ORIENT_LEFT -#define MATE_PANEL_APPLET_ORIENT_RIGHT MATE_Vertigo_PANEL_ORIENT_RIGHT - - -#define PANEL_TYPE_APPLET (mate_panel_applet_get_type ()) -#define MATE_PANEL_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET, MatePanelApplet)) -#define MATE_PANEL_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_APPLET, MatePanelAppletClass)) -#define PANEL_IS_APPLET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_APPLET)) -#define PANEL_IS_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_APPLET)) -#define MATE_PANEL_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_APPLET, MatePanelAppletClass)) - -typedef enum { - PANEL_NO_BACKGROUND, - PANEL_COLOR_BACKGROUND, - PANEL_PIXMAP_BACKGROUND -} MatePanelAppletBackgroundType; - -typedef enum { - MATE_PANEL_APPLET_FLAGS_NONE = 0, - MATE_PANEL_APPLET_EXPAND_MAJOR = 1 << 0, - MATE_PANEL_APPLET_EXPAND_MINOR = 1 << 1, - MATE_PANEL_APPLET_HAS_HANDLE = 1 << 2 -} MatePanelAppletFlags; - -typedef struct _MatePanelApplet MatePanelApplet; -typedef struct _MatePanelAppletClass MatePanelAppletClass; -typedef struct _MatePanelAppletPrivate MatePanelAppletPrivate; - -typedef gboolean (*MatePanelAppletFactoryCallback) (MatePanelApplet *applet, - const gchar *iid, - gpointer user_data); - -struct _MatePanelApplet { - GtkEventBox event_box; - - MatePanelAppletPrivate *priv; -}; - -struct _MatePanelAppletClass { - GtkEventBoxClass event_box_class; - - void (*change_orient) (MatePanelApplet *applet, - MatePanelAppletOrient orient); - - void (*change_size) (MatePanelApplet *applet, - guint size); - - void (*change_background) (MatePanelApplet *applet, - MatePanelAppletBackgroundType type, - GdkColor *color, - GdkPixmap *pixmap); - void (*move_focus_out_of_applet) (MatePanelApplet *frame, - GtkDirectionType direction); -}; - -GType mate_panel_applet_get_type (void) G_GNUC_CONST; - -GtkWidget* mate_panel_applet_new(void); - -MatePanelAppletOrient mate_panel_applet_get_orient (MatePanelApplet *applet); - -guint mate_panel_applet_get_size (MatePanelApplet *applet); - -MatePanelAppletBackgroundType - mate_panel_applet_get_background (MatePanelApplet *applet, - /* return values */ - GdkColor *color, - GdkPixmap **pixmap); - -void mate_panel_applet_set_background_widget (MatePanelApplet *applet, - GtkWidget *widget); - -gchar *mate_panel_applet_get_preferences_key (MatePanelApplet *applet); - -void mate_panel_applet_add_preferences (MatePanelApplet *applet, - const gchar *schema_dir, - GError **opt_error); - -MatePanelAppletFlags mate_panel_applet_get_flags (MatePanelApplet *applet); -void mate_panel_applet_set_flags (MatePanelApplet *applet, - MatePanelAppletFlags flags); - -void mate_panel_applet_set_size_hints (MatePanelApplet *applet, - const int *size_hints, - int n_elements, - int base_size); - -gboolean mate_panel_applet_get_locked_down (MatePanelApplet *applet); - -void mate_panel_applet_request_focus (MatePanelApplet *applet, - guint32 timestamp); - -MateComponentControl *mate_panel_applet_get_control (MatePanelApplet *applet); -MateComponentUIComponent *mate_panel_applet_get_popup_component (MatePanelApplet *applet); - -void mate_panel_applet_setup_menu (MatePanelApplet *applet, - const gchar *xml, - const MateComponentUIVerb *verb_list, - gpointer user_data); - -void mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet, - const gchar *opt_datadir, - const gchar *file, - const gchar *opt_app_name, - const MateComponentUIVerb *verb_list, - gpointer user_data); - - -int mate_panel_applet_factory_main (const gchar *iid, - GType applet_type, - MatePanelAppletFactoryCallback callback, - gpointer data); - -int mate_panel_applet_factory_main_closure (const gchar *iid, - GType applet_type, - GClosure *closure); - -/* - * These macros are getting a bit unwieldy. - * - * Things to define for these: - * + required if Native Language Support is enabled (ENABLE_NLS): - * GETTEXT_PACKAGE and MATELOCALEDIR - */ - -#if !defined(ENABLE_NLS) -#define _MATE_PANEL_APPLET_SETUP_GETTEXT(call_textdomain) \ - do { } while (0) -#else /* defined(ENABLE_NLS) */ -#include <libintl.h> -#define _MATE_PANEL_APPLET_SETUP_GETTEXT(call_textdomain) \ - do { \ - bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); \ - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); \ - if (call_textdomain) \ - textdomain (GETTEXT_PACKAGE); \ - } while (0) -#endif /* !defined(ENABLE_NLS) */ - -#define MATE_PANEL_APPLET_MATECOMPONENT_FACTORY(iid, type, name, version, callback, data) \ -int main (int argc, char *argv []) \ -{ \ - GOptionContext *context; \ - GError *error; \ - int retval; \ - \ - _MATE_PANEL_APPLET_SETUP_GETTEXT (TRUE); \ - \ - context = g_option_context_new (""); \ - g_option_context_add_group (context, gtk_get_option_group (TRUE)); \ - g_option_context_add_group (context, \ - matecomponent_activation_get_goption_group ()); \ - \ - error = NULL; \ - if (!g_option_context_parse (context, &argc, &argv, &error)) { \ - if (error) { \ - g_printerr ("Cannot parse arguments: %s.\n", \ - error->message); \ - g_error_free (error); \ - } else \ - g_printerr ("Cannot parse arguments.\n"); \ - g_option_context_free (context); \ - return 1; \ - } \ - \ - gtk_init (&argc, &argv); \ - if (!matecomponent_init (&argc, argv)) { \ - g_printerr ("Cannot initialize matecomponent.\n"); \ - return 1; \ - } \ - \ - retval = mate_panel_applet_factory_main (iid, type, callback, data); \ - g_option_context_free (context); \ - \ - return retval; \ -} - -#ifdef __cplusplus -} -#endif - -#endif /* __MATE_PANEL_APPLET_H__ */ diff --git a/matecomponent/libmate-panel-applet/panel-test-applets-matecomponent.c b/matecomponent/libmate-panel-applet/panel-test-applets-matecomponent.c deleted file mode 100644 index 7c0da952..00000000 --- a/matecomponent/libmate-panel-applet/panel-test-applets-matecomponent.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * panel-test-applets.c: - * - * Authors: - * Mark McLoughlin <[email protected]> - * - * Copyright 2002 Sun Microsystems, Inc. - */ - -#include <config.h> -#include <glib/gi18n.h> -#include <gtk/gtk.h> -#include <matecomponent/matecomponent-exception.h> -#include <matecomponent/matecomponent-main.h> -#include <matecomponent/matecomponent-widget.h> -#include <mateconf/mateconf.h> - -#include "mate-panel-applet.h" - -G_GNUC_UNUSED void on_execute_button_clicked (GtkButton *button, gpointer dummy); - -static GtkWidget *win = NULL; -static GtkWidget *applet_combo = NULL; -static GtkWidget *prefs_dir_entry = NULL; -static GtkWidget *orient_combo = NULL; -static GtkWidget *size_combo = NULL; - -static char *cli_iid = NULL; -static char *cli_prefs_dir = NULL; -static char *cli_size = NULL; -static char *cli_orient = NULL; - -static const GOptionEntry options [] = { - { "iid", 0, 0, G_OPTION_ARG_STRING, &cli_iid, N_("Specify an applet IID to load"), NULL}, - { "prefs-dir", 0, 0, G_OPTION_ARG_STRING, &cli_prefs_dir, N_("Specify a mateconf location in which the applet preferences should be stored"), NULL}, - { "size", 0, 0, G_OPTION_ARG_STRING, &cli_size, N_("Specify the initial size of the applet (xx-small, medium, large etc.)"), NULL}, - { "orient", 0, 0, G_OPTION_ARG_STRING, &cli_orient, N_("Specify the initial orientation of the applet (top, bottom, left or right)"), NULL}, - { NULL} -}; - -enum { - COLUMN_TEXT, - COLUMN_ITEM, - NUMBER_COLUMNS -}; - -typedef struct { - const char *name; - const char *value; -} ComboItem; - -static ComboItem orient_items [] = { - { NC_("Orientation", "Top"), "top" }, - { NC_("Orientation", "Bottom"), "bottom" }, - { NC_("Orientation", "Left"), "left" }, - { NC_("Orientation", "Right"), "right" } -}; - - -static ComboItem size_items [] = { - { NC_("Size", "XX Small"), "xx-small" }, - { NC_("Size", "X Small"), "x-small" }, - { NC_("Size", "Small"), "small" }, - { NC_("Size", "Medium"), "medium" }, - { NC_("Size", "Large"), "large" }, - { NC_("Size", "X Large"), "x-large" }, - { NC_("Size", "XX Large"), "xx-large" } -}; - -static char * -get_combo_value (GtkWidget *combo_box) -{ - GtkTreeIter iter; - GtkTreeModel *model; - char *value; - - if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter)) - return NULL; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)); - gtk_tree_model_get (model, &iter, COLUMN_ITEM, &value, -1); - - return value; -} - -static char * -construct_moniker (void) -{ - const char *prefs_key; - char *iid; - char *size; - char *orient; - char *ret_value; - - iid = get_combo_value (applet_combo); - g_assert (iid != NULL); - size = get_combo_value (size_combo); - g_assert (size != NULL); - orient = get_combo_value (orient_combo); - g_assert (orient != NULL); - - prefs_key = gtk_entry_get_text (GTK_ENTRY (prefs_dir_entry)); - - ret_value= g_strdup_printf ("%s!prefs_key=%s;size=%s;orient=%s", - iid, prefs_key, size, orient); - g_free (iid); - g_free (size); - g_free (orient); - - return ret_value; -} - -static void -load_applet_into_window (const char *moniker, - const char *title) -{ - GtkWidget *applet_window; - GtkWidget *applet; - - applet = matecomponent_widget_new_control (moniker, NULL); - - if (!applet) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (win ? GTK_WINDOW (win) : NULL, - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Failed to load applet %s"), - title); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - return; - } - - applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_widget_show (applet); - - gtk_container_add (GTK_CONTAINER (applet_window), applet); - - //FIXME: we could set the window icon with the applet icon - gtk_window_set_title (GTK_WINDOW (applet_window), title); - gtk_widget_show (applet_window); -} - -static void -load_applet_from_command_line (void) -{ - GString *str; - - g_assert (cli_iid != NULL); - - str = g_string_new (cli_iid); - - if (cli_prefs_dir || cli_size || cli_orient) { - g_string_append_c (str, '!'); - - if (cli_prefs_dir) - g_string_append_printf (str, "prefs_key=%s", cli_prefs_dir); - - g_string_append_c (str, ';'); - - if (cli_size) - g_string_append_printf (str, "size=%s", cli_size); - - g_string_append_c (str, ';'); - - if (cli_orient) - g_string_append_printf (str, "orient=%s", cli_orient); - } - - g_print ("Loading %s\n", str->str); - - load_applet_into_window (str->str, cli_iid); - - g_string_free (str, TRUE); -} - -G_GNUC_UNUSED void -on_execute_button_clicked (GtkButton *button, - gpointer dummy) -{ - char *moniker; - char *title; - - moniker = construct_moniker (); - title = get_combo_value (applet_combo); - load_applet_into_window (moniker, title); - g_free (moniker); - g_free (title); -} - -static void -setup_combo (GtkWidget *combo_box, - ComboItem *items, - const char *context, - int nb_items, - gboolean dynamic) -{ - GtkListStore *model; - GtkTreeIter iter; - GtkCellRenderer *renderer; - int i; - - model = gtk_list_store_new (NUMBER_COLUMNS, - G_TYPE_STRING, - G_TYPE_STRING); - - gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), - GTK_TREE_MODEL (model)); - - - for (i = 0; i < nb_items; i++) { - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, - COLUMN_TEXT, dynamic ? g_strdup (items [i].name) : g_dpgettext2 (NULL, context, items [i].name), - COLUMN_ITEM, dynamic ? g_strdup (items [i].value) : items [i].value, - -1); - } - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), - renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), - renderer, "text", COLUMN_TEXT, NULL); - - gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0); -} - -static void -setup_options (void) -{ - MateComponent_ServerInfoList *applets; - CORBA_Environment env; - int i; - char *prefs_dir; - char *unique_key; - ComboItem *applet_items; - int applet_nb; - - CORBA_exception_init (&env); - - applets = matecomponent_activation_query ( - "has (repo_ids, 'IDL:MATE/Vertigo/MatePanelAppletShell:1.0')", - NULL, &env); - - if (MATECOMPONENT_EX (&env)) - g_error (_("query returned exception %s\n"), MATECOMPONENT_EX_REPOID (&env)); - - CORBA_exception_free (&env); - - applet_nb = applets->_length; - applet_items = g_new0 (ComboItem, applet_nb); - - for (i = 0; i < applet_nb; i++) { - MateComponent_ServerInfo *info; - - info = &applets->_buffer [i]; - - applet_items[i].name = info->iid; - applet_items[i].value = info->iid; - } - - setup_combo (applet_combo, applet_items, NULL, applet_nb, TRUE); - g_free (applet_items); - CORBA_free (applets); - - setup_combo (size_combo, size_items, "Size", - G_N_ELEMENTS (size_items), FALSE); - setup_combo (orient_combo, orient_items, "Orientation", - G_N_ELEMENTS (orient_items), FALSE); - - unique_key = mateconf_unique_key (); - prefs_dir = g_strdup_printf ("/tmp/%s", unique_key); - g_free (unique_key); - gtk_entry_set_text (GTK_ENTRY (prefs_dir_entry), prefs_dir); - g_free (prefs_dir); -} - -int -main (int argc, char **argv) -{ - GtkBuilder *builder; - char *uifile; - GError *error; - - bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - error = NULL; - if (!gtk_init_with_args (&argc, &argv, - "", (GOptionEntry *) options, GETTEXT_PACKAGE, - &error)) { - if (error) { - g_printerr ("%s\n", error->message); - g_error_free (error); - } else - g_printerr ("Cannot initiliaze GTK+.\n"); - - return 1; - } - - if (!matecomponent_init (&argc, argv)) { - g_printerr ("Cannot initialize matecomponent.\n"); - return 1; - } - - if (cli_iid) { - load_applet_from_command_line (); - gtk_main (); - return 0; - } - - builder = gtk_builder_new (); - gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); - - uifile = MATE_PANEL_APPLET_BUILDERDIR "/panel-test-applets.ui"; - gtk_builder_add_from_file (builder, uifile, &error); - - if (error) { - g_warning ("Error loading \"%s\": %s", uifile, error->message); - g_error_free (error); - return 1; - } - - gtk_builder_connect_signals (builder, NULL); - - win = GTK_WIDGET (gtk_builder_get_object (builder, - "toplevel")); - applet_combo = GTK_WIDGET (gtk_builder_get_object (builder, - "applet-combo")); - prefs_dir_entry = GTK_WIDGET (gtk_builder_get_object (builder, - "prefs-dir-entry")); - orient_combo = GTK_WIDGET (gtk_builder_get_object (builder, - "orient-combo")); - size_combo = GTK_WIDGET (gtk_builder_get_object (builder, - "size-combo")); - g_object_unref (builder); - - setup_options (); - - gtk_widget_show (win); - - gtk_main (); - - return 0; -} diff --git a/matecomponent/libmate-panel-applet/panel-test-applets-matecomponent.ui b/matecomponent/libmate-panel-applet/panel-test-applets-matecomponent.ui deleted file mode 100644 index 05916cf5..00000000 --- a/matecomponent/libmate-panel-applet/panel-test-applets-matecomponent.ui +++ /dev/null @@ -1,203 +0,0 @@ -<?xml version="1.0"?> -<interface> - <!-- interface-requires gtk+ 2.6 --> - <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkDialog" id="toplevel"> - <property name="visible">True</property> - <property name="title" translatable="yes" comments="This is an utility to easily test various applets">Test applet utility</property> - <property name="resizable">False</property> - <property name="type_hint">dialog</property> - <property name="has_separator">False</property> - <signal name="destroy" handler="gtk_main_quit"/> - <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">8</property> - <child> - <object class="GtkTable" id="table2"> - <property name="visible">True</property> - <property name="border_width">2</property> - <property name="n_rows">5</property> - <property name="n_columns">2</property> - <property name="column_spacing">4</property> - <property name="row_spacing">4</property> - <child> - <object class="GtkLabel" id="size-label"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Size:</property> - <property name="use_underline">True</property> - <property name="justify">center</property> - <property name="mnemonic_widget">size-combo</property> - </object> - <packing> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <object class="GtkLabel" id="applet-label"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Applet:</property> - <property name="use_underline">True</property> - <property name="justify">center</property> - <property name="mnemonic_widget">applet-combo</property> - </object> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <object class="GtkLabel" id="orient-label"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Orientation:</property> - <property name="use_underline">True</property> - <property name="justify">center</property> - <property name="mnemonic_widget">orient-combo</property> - </object> - <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <object class="GtkLabel" id="prefs-label"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Prefs Dir:</property> - <property name="use_underline">True</property> - <property name="justify">center</property> - <property name="mnemonic_widget">prefs-dir-entry</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <object class="GtkEntry" id="prefs-dir-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="applet-combo"> - <property name="visible">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="orient-combo"> - <property name="visible">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="size-combo"> - <property name="visible">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <object class="GtkHSeparator" id="hseparator2"> - <property name="visible">True</property> - </object> - <packing> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="ok-button"> - <property name="label">gtk-execute</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_stock">True</property> - <signal name="clicked" handler="on_execute_button_clicked"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button1"> - <property name="label">gtk-close</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_stock">True</property> - <signal name="clicked" handler="gtk_main_quit"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - </object> - </child> - <action-widgets> - <action-widget response="0">ok-button</action-widget> - <action-widget response="-7">button1</action-widget> - </action-widgets> - </object> -</interface> diff --git a/matecomponent/libmate-panel-applet/test-matecomponent-applet.c b/matecomponent/libmate-panel-applet/test-matecomponent-applet.c deleted file mode 100644 index d57e7f96..00000000 --- a/matecomponent/libmate-panel-applet/test-matecomponent-applet.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * test-matecomponent-applet.c: - * - * Authors: - * Mark McLoughlin <[email protected]> - * - * Copyright 2001 Sun Microsystems, Inc. - */ - -#include <config.h> -#include <string.h> - -#include <libmatecomponentui.h> - -#include "mate-panel-applet.h" - -static void -test_applet_on_do (MateComponentUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - g_message ("%s called\n", verbname); -} - -static const MateComponentUIVerb test_applet_menu_verbs [] = { - MATECOMPONENT_UI_VERB ("TestAppletDo1", test_applet_on_do), - MATECOMPONENT_UI_VERB ("TestAppletDo2", test_applet_on_do), - MATECOMPONENT_UI_VERB ("TestAppletDo3", test_applet_on_do), - - MATECOMPONENT_UI_VERB_END -}; - -static const char test_applet_menu_xml [] = - "<popup name=\"button3\">\n" - " <menuitem name=\"Test Item 1\" verb=\"TestAppletDo1\" _label=\"Test This One\"/>\n" - " <menuitem name=\"Test Item 2\" verb=\"TestAppletDo2\" _label=\"Test This Two\"/>\n" - " <menuitem name=\"Test Item 3\" verb=\"TestAppletDo3\" _label=\"Test This Three\"/>\n" - "</popup>\n"; - -typedef struct { - MatePanelApplet base; - GtkWidget *label; -} TestApplet; - -static GType -test_applet_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (MatePanelAppletClass), - NULL, NULL, NULL, NULL, NULL, - sizeof (TestApplet), - 0, NULL, NULL - }; - - type = g_type_register_static ( - PANEL_TYPE_APPLET, "TestApplet", &info, 0); - } - - return type; -} - -static void -test_applet_handle_orient_change (TestApplet *applet, - MatePanelAppletOrient orient, - gpointer dummy) -{ - gchar *text; - - text = g_strdup (gtk_label_get_text (GTK_LABEL (applet->label))); - - g_strreverse (text); - - gtk_label_set_text (GTK_LABEL (applet->label), text); - - g_free (text); -} - -static void -test_applet_handle_size_change (TestApplet *applet, - gint size, - gpointer dummy) -{ - switch (size) { - case MATE_Vertigo_PANEL_XX_SMALL: - gtk_label_set_markup ( - GTK_LABEL (applet->label), "<span size=\"xx-small\">Hello</span>"); - break; - case MATE_Vertigo_PANEL_X_SMALL: - gtk_label_set_markup ( - GTK_LABEL (applet->label), "<span size=\"x-small\">Hello</span>"); - break; - case MATE_Vertigo_PANEL_SMALL: - gtk_label_set_markup ( - GTK_LABEL (applet->label), "<span size=\"small\">Hello</span>"); - break; - case MATE_Vertigo_PANEL_MEDIUM: - gtk_label_set_markup ( - GTK_LABEL (applet->label), "<span size=\"medium\">Hello</span>"); - break; - case MATE_Vertigo_PANEL_LARGE: - gtk_label_set_markup ( - GTK_LABEL (applet->label), "<span size=\"large\">Hello</span>"); - break; - case MATE_Vertigo_PANEL_X_LARGE: - gtk_label_set_markup ( - GTK_LABEL (applet->label), "<span size=\"x-large\">Hello</span>"); - break; - case MATE_Vertigo_PANEL_XX_LARGE: - gtk_label_set_markup ( - GTK_LABEL (applet->label), "<span size=\"xx-large\">Hello</span>"); - break; - default: - g_assert_not_reached (); - break; - } -} - -static void -test_applet_handle_background_change (TestApplet *applet, - MatePanelAppletBackgroundType type, - GdkColor *color, - GdkPixmap *pixmap, - gpointer dummy) -{ - GdkWindow *window = gtk_widget_get_window (applet->label); - - switch (type) { - case PANEL_NO_BACKGROUND: - g_message ("Setting background to default"); - gdk_window_set_back_pixmap (window, NULL, FALSE); - break; - case PANEL_COLOR_BACKGROUND: - g_message ("Setting background to #%2x%2x%2x", - color->red, color->green, color->blue); - gdk_window_set_back_pixmap (window, NULL, FALSE); - break; - case PANEL_PIXMAP_BACKGROUND: - g_message ("Setting background to '%p'", pixmap); - gdk_window_set_back_pixmap (window, pixmap, FALSE); - break; - default: - g_assert_not_reached (); - break; - } -} - -static gboolean -test_applet_fill (TestApplet *applet) -{ - applet->label = gtk_label_new (NULL); - - gtk_container_add (GTK_CONTAINER (applet), applet->label); - - gtk_widget_show_all (GTK_WIDGET (applet)); - - test_applet_handle_size_change (applet, MATE_Vertigo_PANEL_MEDIUM, NULL); - - mate_panel_applet_setup_menu ( - MATE_PANEL_APPLET (applet), test_applet_menu_xml, test_applet_menu_verbs, NULL); - - gtk_widget_set_tooltip_text (GTK_WIDGET (applet), "Hello Tip"); - - mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_HAS_HANDLE); - - g_signal_connect (G_OBJECT (applet), - "change_orient", - G_CALLBACK (test_applet_handle_orient_change), - NULL); - - g_signal_connect (G_OBJECT (applet), - "change_size", - G_CALLBACK (test_applet_handle_size_change), - NULL); - - g_signal_connect (G_OBJECT (applet), - "change_background", - G_CALLBACK (test_applet_handle_background_change), - NULL); - - return TRUE; -} - -static gboolean -test_applet_factory (TestApplet *applet, - const gchar *iid, - gpointer data) -{ - gboolean retval = FALSE; - - if (!strcmp (iid, "OAFIID:MATE_Panel_TestMateComponentApplet")) - retval = test_applet_fill (applet); - - return retval; -} - -MATE_PANEL_APPLET_MATECOMPONENT_FACTORY ("OAFIID:MATE_Panel_TestMateComponentApplet_Factory", - test_applet_get_type (), - "A Test Applet for the MATE-2.0 Panel", - "0", - (MatePanelAppletFactoryCallback) test_applet_factory, - NULL) diff --git a/matecomponent/panel-module/MATE_Panel_Popup.xml b/matecomponent/panel-module/MATE_Panel_Popup.xml deleted file mode 100644 index 9956f2e6..00000000 --- a/matecomponent/panel-module/MATE_Panel_Popup.xml +++ /dev/null @@ -1,20 +0,0 @@ -<Root> - <popups> - <popup name="button3"> - - <placeholder delimit="top"> - - <menuitem name="remove" verb="RemoveAppletFromPanel" _label="_Remove From Panel" - pixtype="stock" pixname="gtk-remove"/> - - <menuitem name="move" verb="MoveApplet" _label="_Move"/> - - <separator verb="LockSeparator"/> - - <menuitem name="lock" verb="LockAppletToPanel" _label="Loc_k To Panel" - type="toggle"/> - - </placeholder> - </popup> - </popups> -</Root> diff --git a/matecomponent/panel-module/Makefile.am b/matecomponent/panel-module/Makefile.am deleted file mode 100644 index 8c353127..00000000 --- a/matecomponent/panel-module/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -panelmodule_LTLIBRARIES = libmate-panel-applets-matecomponent.la -panelmoduledir = $(modulesdir) - -libmate_panel_applets_matecomponent_la_SOURCES = \ - $(CORBA_SRCLIST) \ - mate-panel-applets-matecomponent-module.c \ - mate-panel-applets-manager-matecomponent.c \ - mate-panel-applets-manager-matecomponent.h \ - mate-panel-applet-frame-matecomponent.c \ - mate-panel-applet-frame-matecomponent.h - -libmate_panel_applets_matecomponent_la_CPPFLAGS = \ - $(MATECOMPONENT_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/mate-panel \ - -I$(top_builddir) \ - -DDATADIR=\""$(datadir)"\" - -libmate_panel_applets_matecomponent_la_LDFLAGS = \ - -export_dynamic -avoid-version -module -no-undefined \ - -export-symbols-regex '^g_io_module_(load|unload|query)' - -libmate_panel_applets_matecomponent_la_LIBADD = \ - $(MATECOMPONENT_LIBS) - -CORBA_SRCLIST = \ - MATE_Panel-stubs.c \ - MATE_Panel-skels.c \ - MATE_Panel-common.c \ - MATE_Panel.h - -$(CORBA_SRCLIST): $(top_srcdir)/matecomponent/idl/MATE_Panel.idl $(MATECORBA_IDL) - $(AM_V_GEN)$(MATECORBA_IDL) -I $(MATECOMPONENT_IDLDIR) -I $(MATECOMPONENT_ACT_IDLDIR) $(top_srcdir)/matecomponent/idl/MATE_Panel.idl - -xmluidir = $(datadir)/mate-2.0/ui -xmlui_DATA = MATE_Panel_Popup.xml - -install-data-hook: - if test -z "$(DESTDIR)" -a "$(GIO_QUERYMODULES)" != "no" ; then \ - $(GIO_QUERYMODULES) $(modulesdir) ; \ - fi -uninstall-local: - if test "$(GIO_QUERYMODULES)" != "no" ; then \ - $(GIO_QUERYMODULES) $(modulesdir) ; \ - fi - -EXTRA_DIST = $(xmlui_DATA) - -CLEANFILES = $(CORBA_SRCLIST) - --include $(top_srcdir)/git.mk diff --git a/matecomponent/panel-module/mate-panel-applet-frame-matecomponent.c b/matecomponent/panel-module/mate-panel-applet-frame-matecomponent.c deleted file mode 100644 index e62a13a7..00000000 --- a/matecomponent/panel-module/mate-panel-applet-frame-matecomponent.c +++ /dev/null @@ -1,759 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * mate-panel-applet-frame-matecomponent.c: panel side container for applets - * - * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. - * Copyright (C) 2010 Vincent Untz <[email protected]> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#include <config.h> - -#include <string.h> - -#include <libmatecomponentui.h> - -#include <mate-panel-applet-frame.h> -#include <mate-panel-applets-manager.h> - -#include "MATE_Panel.h" - -#include "mate-panel-applet-frame-matecomponent.h" - -G_DEFINE_TYPE (MatePanelAppletFrameMateComponent, - mate_panel_applet_frame_matecomponent, - PANEL_TYPE_APPLET_FRAME) - -struct _MatePanelAppletFrameMateComponentPrivate -{ - MATE_Vertigo_MatePanelAppletShell applet_shell; - CORBA_Object control; - MateComponent_PropertyBag property_bag; - MateComponentUIComponent *ui_component; -}; - -#define PROPERTY_ORIENT "mate-panel-applet-orient" -#define PROPERTY_SIZE "mate-panel-applet-size" -#define PROPERTY_BACKGROUND "mate-panel-applet-background" -#define PROPERTY_FLAGS "mate-panel-applet-flags" -#define PROPERTY_SIZE_HINTS "mate-panel-applet-size-hints" -#define PROPERTY_LOCKED_DOWN "mate-panel-applet-locked-down" - -typedef enum { - PANEL_SIZE_XX_SMALL = MATE_Vertigo_PANEL_XX_SMALL, - PANEL_SIZE_X_SMALL = MATE_Vertigo_PANEL_X_SMALL, - PANEL_SIZE_SMALL = MATE_Vertigo_PANEL_SMALL, - PANEL_SIZE_MEDIUM = MATE_Vertigo_PANEL_MEDIUM, - PANEL_SIZE_LARGE = MATE_Vertigo_PANEL_LARGE, - PANEL_SIZE_X_LARGE = MATE_Vertigo_PANEL_X_LARGE, - PANEL_SIZE_XX_LARGE = MATE_Vertigo_PANEL_XX_LARGE -} PanelSize; - -/* Keep in sync with mate-panel-applet.h. Uggh. */ -typedef enum { - APPLET_FLAGS_NONE = 0, - APPLET_EXPAND_MAJOR = 1 << 0, - APPLET_EXPAND_MINOR = 1 << 1, - APPLET_HAS_HANDLE = 1 << 2 -} MatePanelAppletFlags; - -GQuark -mate_panel_applet_frame_matecomponent_error_quark (void) -{ - static GQuark ret = 0; - - if (ret == 0) { - ret = g_quark_from_static_string ("mate_panel_applet_frame_matecomponent_error"); - } - - return ret; -} - -static guint -get_mate_panel_applet_orient (PanelOrientation orientation) -{ - /* For some reason libmate-panel-applet and panel use a different logic for - * orientation, so we need to convert it. We should fix this. */ - switch (orientation) { - case PANEL_ORIENTATION_TOP: - return 1; - case PANEL_ORIENTATION_BOTTOM: - return 0; - case PANEL_ORIENTATION_LEFT: - return 3; - case PANEL_ORIENTATION_RIGHT: - return 2; - default: - g_assert_not_reached (); - break; - } -} - -static void -mate_panel_applet_frame_matecomponent_update_flags (MatePanelAppletFrame *frame, - const CORBA_any *any) -{ - int flags; - gboolean major; - gboolean minor; - gboolean has_handle; - - flags = MATECOMPONENT_ARG_GET_SHORT (any); - - major = (flags & APPLET_EXPAND_MAJOR) != 0; - minor = (flags & APPLET_EXPAND_MINOR) != 0; - has_handle = (flags & APPLET_HAS_HANDLE) != 0; - - _mate_panel_applet_frame_update_flags (frame, major, minor, has_handle); -} - -static void -mate_panel_applet_frame_matecomponent_update_size_hints (MatePanelAppletFrame *frame, - const CORBA_any *any) -{ - CORBA_sequence_CORBA_long *seq; - - seq = any->_value; - - _mate_panel_applet_frame_update_size_hints (frame, seq->_buffer, seq->_length); -} - -static void -mate_panel_applet_frame_matecomponent_init_properties (MatePanelAppletFrame *frame) -{ - MatePanelAppletFrameMateComponent *matecomponent_frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (frame); - CORBA_any *any; - - any = matecomponent_pbclient_get_value (matecomponent_frame->priv->property_bag, - PROPERTY_FLAGS, - MATECOMPONENT_ARG_SHORT, - NULL); - if (any) { - mate_panel_applet_frame_matecomponent_update_flags (frame, any); - CORBA_free (any); - } - - any = matecomponent_pbclient_get_value (matecomponent_frame->priv->property_bag, - PROPERTY_SIZE_HINTS, - TC_CORBA_sequence_CORBA_long, - NULL); - if (any) { - mate_panel_applet_frame_matecomponent_update_size_hints (frame, any); - CORBA_free (any); - } -} - -static void -mate_panel_applet_frame_matecomponent_sync_menu_state (MatePanelAppletFrame *frame, - gboolean movable, - gboolean removable, - gboolean lockable, - gboolean locked, - gboolean locked_down) -{ - MatePanelAppletFrameMateComponent *matecomponent_frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (frame); - - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/LockAppletToPanel", - "state", - locked ? "1" : "0", - NULL); - - /* First sensitivity */ - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/LockAppletToPanel", - "sensitive", - lockable ? "1" : "0", - NULL); - - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/RemoveAppletFromPanel", - "sensitive", - (locked && !lockable) ? "0" : (removable ? "1" : "0"), - NULL); - - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/MoveApplet", - "sensitive", - locked ? "0" : (movable ? "1" : "0"), - NULL); - - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/LockAppletToPanel", - "hidden", - locked_down ? "1" : "0", - NULL); - - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/LockSeparator", - "hidden", - locked_down ? "1" : "0", - NULL); - - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/RemoveAppletFromPanel", - "hidden", - locked_down ? "1" : "0", - NULL); - - matecomponent_ui_component_set_prop (matecomponent_frame->priv->ui_component, - "/commands/MoveApplet", - "hidden", - locked_down ? "1" : "0", - NULL); -} - -static void -mate_panel_applet_frame_matecomponent_popup_menu (MatePanelAppletFrame *frame, - guint button, - guint32 timestamp) -{ - MatePanelAppletFrameMateComponent *matecomponent_frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (frame); - CORBA_Environment env; - - CORBA_exception_init (&env); - - MATE_Vertigo_MatePanelAppletShell_popup_menu (matecomponent_frame->priv->applet_shell, - button, timestamp, &env); - if (MATECOMPONENT_EX (&env)) - g_warning ("Exception from popup_menu '%s'\n", env._id); - - CORBA_exception_free (&env); -} - -static void -mate_panel_applet_frame_matecomponent_change_orientation (MatePanelAppletFrame *frame, - PanelOrientation orientation) -{ - MatePanelAppletFrameMateComponent *matecomponent_frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (frame); - CORBA_unsigned_short orient = 0; - - switch (orientation) { - case PANEL_ORIENTATION_TOP: - orient = MATE_Vertigo_PANEL_ORIENT_DOWN; - break; - case PANEL_ORIENTATION_BOTTOM: - orient = MATE_Vertigo_PANEL_ORIENT_UP; - break; - case PANEL_ORIENTATION_LEFT: - orient = MATE_Vertigo_PANEL_ORIENT_RIGHT; - break; - case PANEL_ORIENTATION_RIGHT: - orient = MATE_Vertigo_PANEL_ORIENT_LEFT; - break; - default: - g_assert_not_reached (); - break; - } - - matecomponent_pbclient_set_short (matecomponent_frame->priv->property_bag, - PROPERTY_ORIENT, - orient, - NULL); - - gtk_widget_queue_resize (GTK_WIDGET (frame)); -} - -static void -mate_panel_applet_frame_matecomponent_change_size (MatePanelAppletFrame *frame, - guint size) -{ - MatePanelAppletFrameMateComponent *matecomponent_frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (frame); - - /* Normalise the size to the constants defined in the IDL. */ - size = size <= PANEL_SIZE_XX_SMALL ? PANEL_SIZE_XX_SMALL : - size <= PANEL_SIZE_X_SMALL ? PANEL_SIZE_X_SMALL : - size <= PANEL_SIZE_SMALL ? PANEL_SIZE_SMALL : - size <= PANEL_SIZE_MEDIUM ? PANEL_SIZE_MEDIUM : - size <= PANEL_SIZE_LARGE ? PANEL_SIZE_LARGE : - size <= PANEL_SIZE_X_LARGE ? PANEL_SIZE_X_LARGE : PANEL_SIZE_XX_LARGE; - - matecomponent_pbclient_set_short (matecomponent_frame->priv->property_bag, - PROPERTY_SIZE, - size, - NULL); -} - -static void -mate_panel_applet_frame_matecomponent_change_background (MatePanelAppletFrame *frame, - PanelBackgroundType type) -{ - MatePanelAppletFrameMateComponent *matecomponent_frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (frame); - char *bg_str; - - bg_str = _mate_panel_applet_frame_get_background_string ( - frame, PANEL_WIDGET (GTK_WIDGET (frame)->parent), type); - - if (bg_str != NULL) { - matecomponent_pbclient_set_string (matecomponent_frame->priv->property_bag, - PROPERTY_BACKGROUND, - bg_str, NULL); - - g_free (bg_str); - } -} - -static void -mate_panel_applet_frame_matecomponent_applet_broken (MateCORBAConnection *cnx, - MatePanelAppletFrame *frame) -{ - _mate_panel_applet_frame_applet_broken (frame); -} - -static void -popup_handle_remove (MateComponentUIComponent *uic, - MatePanelAppletFrame *frame, - const gchar *verbname) -{ - _mate_panel_applet_frame_applet_remove (frame); -} - -static void -popup_handle_move (MateComponentUIComponent *uic, - MatePanelAppletFrame *frame, - const gchar *verbname) -{ - _mate_panel_applet_frame_applet_move (frame); -} - -static void -listener_popup_handle_lock (MateComponentUIComponent *uic, - const char *path, - MateComponent_UIComponent_EventType type, - const char *state, - gpointer data) -{ - MatePanelAppletFrame *frame; - gboolean locked; - - g_assert (!strcmp (path, "LockAppletToPanel")); - - if (type != MateComponent_UIComponent_STATE_CHANGED) - return; - - if (!state) - return; - - frame = (MatePanelAppletFrame *) data; - locked = (strcmp (state, "1") == 0); - - _mate_panel_applet_frame_applet_lock (frame, locked); - - mate_panel_applet_frame_sync_menu_state (frame); -} - -static MateComponentUIVerb popup_verbs [] = { - MATECOMPONENT_UI_UNSAFE_VERB ("RemoveAppletFromPanel", popup_handle_remove), - MATECOMPONENT_UI_UNSAFE_VERB ("MoveApplet", popup_handle_move), - - MATECOMPONENT_UI_VERB_END -}; - - -static void -mate_panel_applet_frame_matecomponent_finalize (GObject *object) -{ - MatePanelAppletFrameMateComponent *frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (object); - - if (frame->priv->control) { - /* do this before unref'ing every matecomponent stuff since it looks - * like we can receive some events when unref'ing them */ - MateCORBA_small_unlisten_for_broken (frame->priv->control, - G_CALLBACK (mate_panel_applet_frame_matecomponent_applet_broken)); - matecomponent_object_release_unref (frame->priv->control, NULL); - frame->priv->control = CORBA_OBJECT_NIL; - } - - if (frame->priv->property_bag) - matecomponent_object_release_unref ( - frame->priv->property_bag, NULL); - - if (frame->priv->applet_shell) - matecomponent_object_release_unref ( - frame->priv->applet_shell, NULL); - - if (frame->priv->ui_component) - matecomponent_object_unref ( - MATECOMPONENT_OBJECT (frame->priv->ui_component)); - - G_OBJECT_CLASS (mate_panel_applet_frame_matecomponent_parent_class)->finalize (object); -} - -static void -mate_panel_applet_frame_matecomponent_init (MatePanelAppletFrameMateComponent *frame) -{ - GtkWidget *container; - - frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame, - PANEL_TYPE_APPLET_FRAME_MATECOMPONENT, - MatePanelAppletFrameMateComponentPrivate); - - frame->priv->applet_shell = CORBA_OBJECT_NIL; - frame->priv->control = CORBA_OBJECT_NIL; - frame->priv->property_bag = CORBA_OBJECT_NIL; - frame->priv->ui_component = NULL; -} - -static void -mate_panel_applet_frame_matecomponent_class_init (MatePanelAppletFrameMateComponentClass *class) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (class); - MatePanelAppletFrameClass *frame_class = MATE_PANEL_APPLET_FRAME_CLASS (class); - - gobject_class->finalize = mate_panel_applet_frame_matecomponent_finalize; - - frame_class->init_properties = mate_panel_applet_frame_matecomponent_init_properties; - frame_class->sync_menu_state = mate_panel_applet_frame_matecomponent_sync_menu_state; - frame_class->popup_menu = mate_panel_applet_frame_matecomponent_popup_menu; - frame_class->change_orientation = mate_panel_applet_frame_matecomponent_change_orientation; - frame_class->change_size = mate_panel_applet_frame_matecomponent_change_size; - frame_class->change_background = mate_panel_applet_frame_matecomponent_change_background; - - g_type_class_add_private (class, sizeof (MatePanelAppletFrameMateComponentPrivate)); -} - -static MATE_Vertigo_MatePanelAppletShell -mate_panel_applet_frame_get_applet_shell (MateComponent_Control control) -{ - CORBA_Environment env; - MATE_Vertigo_MatePanelAppletShell retval; - - CORBA_exception_init (&env); - - retval = MateComponent_Unknown_queryInterface (control, - "IDL:MATE/Vertigo/MatePanelAppletShell:1.0", - &env); - if (MATECOMPONENT_EX (&env)) { - g_warning ("Unable to obtain AppletShell interface from control\n"); - - retval = CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&env); - - return retval; -} - -static const char* mate_panel_applet_frame_get_orient_string(MatePanelAppletFrame* frame, MatePanelAppletFrameActivating* frame_act) -{ - PanelOrientation orientation; - const char* retval = NULL; - - orientation = mate_panel_applet_frame_activating_get_orientation(frame_act); - - switch (orientation) - { - case PANEL_ORIENTATION_TOP: - retval = "down"; - break; - case PANEL_ORIENTATION_BOTTOM: - retval = "up"; - break; - case PANEL_ORIENTATION_LEFT: - retval = "right"; - break; - case PANEL_ORIENTATION_RIGHT: - retval = "left"; - break; - default: - g_assert_not_reached(); - break; - } - - return retval; -} - -static const char* mate_panel_applet_frame_get_size_string (MatePanelAppletFrame* frame, MatePanelAppletFrameActivating* frame_act) -{ - const char* retval = NULL; - guint32 size; - - size = mate_panel_applet_frame_activating_get_size(frame_act); - - if (size <= PANEL_SIZE_XX_SMALL) - { - retval = "xx-small"; - } - else if (size <= PANEL_SIZE_X_SMALL) - { - retval = "x-small"; - } - else if (size <= PANEL_SIZE_SMALL) - { - retval = "small"; - } - else if (size <= PANEL_SIZE_MEDIUM) - { - retval = "medium"; - } - else if (size <= PANEL_SIZE_LARGE) - { - retval = "large"; - } - else if (size <= PANEL_SIZE_X_LARGE) - { - retval = "x-large"; - } - else - { - retval = "xx-large"; - } - - return retval; -} - -static char * -mate_panel_applet_frame_construct_item (MatePanelAppletFrame *frame, - MatePanelAppletFrameActivating *frame_act) -{ - char *retval; - char *conf_path = NULL; - char *bg_str = NULL; - gboolean locked_down; - - conf_path = mate_panel_applet_frame_activating_get_conf_path (frame_act); - //FIXME vuntz -#if 0 - bg_str = _mate_panel_applet_frame_get_background_string ( - frame, panel, panel->background.type); -#endif - - if (bg_str == NULL) - bg_str = g_strdup (""); - - locked_down = mate_panel_applet_frame_activating_get_locked_down (frame_act); - - retval = g_strdup_printf ( - "prefs_key=%s;" - "background=%s;orient=%s;size=%s;locked_down=%s", - conf_path, bg_str, - mate_panel_applet_frame_get_orient_string (frame, frame_act), - mate_panel_applet_frame_get_size_string (frame, frame_act), - locked_down ? "true" : "false"); - - g_free (conf_path); - g_free (bg_str); - - return retval; -} - -static void -mate_panel_applet_frame_event_listener (MateComponentListener *listener, - const char *event, - const CORBA_any *any, - CORBA_Environment *ev, - MatePanelAppletFrame *frame) -{ - if (!strcmp (event, "MateComponent/Property:change:" PROPERTY_FLAGS)) - mate_panel_applet_frame_matecomponent_update_flags (frame, any); - - else if (!strcmp (event, "MateComponent/Property:change:" PROPERTY_SIZE_HINTS)) - mate_panel_applet_frame_matecomponent_update_size_hints (frame, any); -} - -static void -mate_panel_applet_frame_matecomponent_activated (CORBA_Object object, - const char *error_reason, - gpointer data) -{ - MatePanelAppletFrameActivating *frame_act; - MatePanelAppletFrameMateComponent *matecomponent_frame; - MatePanelAppletFrame *frame; - GtkWidget *widget; - MateComponentControlFrame *control_frame; - MateComponent_Control control; - MateComponent_ItemContainer container; - CORBA_Environment corba_ev; - AppletInfo *info; - char *error; - char *item_name; - GError *gerror = NULL; - - widget = NULL; - matecomponent_frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (data); - frame = MATE_PANEL_APPLET_FRAME (data); - frame_act = g_object_get_data (G_OBJECT (frame), "mate-panel-applet-frame-activating"); - g_object_set_data (G_OBJECT (frame), "mate-panel-applet-frame-activating", NULL); - - /* according to the source of matecomponent control == NULL && no - exception can happen, so handle it */ - if (error_reason != NULL || object == CORBA_OBJECT_NIL) { - gerror = g_error_new_literal (mate_panel_applet_frame_matecomponent_error_quark (), 0, error_reason); - goto error_out; - } - - CORBA_exception_init (&corba_ev); - - item_name = mate_panel_applet_frame_construct_item (frame, - frame_act); - - matecomponent_frame->priv->control = CORBA_OBJECT_NIL; - container = MateComponent_Unknown_queryInterface (object, - "IDL:MateComponent/ItemContainer:1.0", - &corba_ev); - if (!MATECOMPONENT_EX (&corba_ev) && container != CORBA_OBJECT_NIL) { - MateComponent_Unknown containee; - - containee = MateComponent_ItemContainer_getObjectByName (container, - item_name, - TRUE, - &corba_ev); - matecomponent_object_release_unref (container, NULL); - - if (!MATECOMPONENT_EX (&corba_ev) && containee != CORBA_OBJECT_NIL) { - matecomponent_frame->priv->control = - MateComponent_Unknown_queryInterface (containee, - "IDL:MateComponent/Control:1.0", - &corba_ev); - - matecomponent_object_release_unref (containee, NULL); - } - } - g_free (item_name); - - if (matecomponent_frame->priv->control == CORBA_OBJECT_NIL) { - error = matecomponent_exception_get_text (&corba_ev); - gerror = g_error_new (mate_panel_applet_frame_matecomponent_error_quark (), 0, "failed to get MateComponent/Control interface:\n", error); - CORBA_exception_free (&corba_ev); - matecomponent_object_release_unref (object, NULL); - g_free (error); - goto error_out; - } - - widget = matecomponent_widget_new_control_from_objref (matecomponent_frame->priv->control, - CORBA_OBJECT_NIL); - - CORBA_exception_free (&corba_ev); - matecomponent_object_release_unref (object, NULL); - - if (!widget) { - gerror = g_error_new_literal (mate_panel_applet_frame_matecomponent_error_quark (), 0, "no widget created"); - goto error_out; - } - - control_frame = matecomponent_widget_get_control_frame (MATECOMPONENT_WIDGET (widget)); - if (control_frame == NULL) { - gerror = g_error_new_literal (mate_panel_applet_frame_matecomponent_error_quark (), 0, "cannot get control frame"); - goto error_out; - } - - matecomponent_frame->priv->property_bag = - matecomponent_control_frame_get_control_property_bag (control_frame, - &corba_ev); - if (matecomponent_frame->priv->property_bag == NULL || MATECOMPONENT_EX (&corba_ev)) { - error = matecomponent_exception_get_text (&corba_ev); - CORBA_exception_free (&corba_ev); - gerror = g_error_new (mate_panel_applet_frame_matecomponent_error_quark (), 0, "cannot get property bag frame:\n%s", error); - g_free (error); - goto error_out; - } - - matecomponent_event_source_client_add_listener (matecomponent_frame->priv->property_bag, - (MateComponentListenerCallbackFn) mate_panel_applet_frame_event_listener, - "MateComponent/Property:change:mate-panel-applet", - NULL, - frame); - - matecomponent_frame->priv->ui_component = - matecomponent_control_frame_get_popup_component (control_frame, - &corba_ev); - if (matecomponent_frame->priv->ui_component == NULL || MATECOMPONENT_EX (&corba_ev)) { - error = matecomponent_exception_get_text (&corba_ev); - CORBA_exception_free (&corba_ev); - gerror = g_error_new (mate_panel_applet_frame_matecomponent_error_quark (), 0, "cannot get popup component:\n%s", error); - g_free (error); - goto error_out; - } - - matecomponent_ui_util_set_ui (matecomponent_frame->priv->ui_component, DATADIR, - "MATE_Panel_Popup.xml", "panel", NULL); - - matecomponent_ui_component_add_listener (matecomponent_frame->priv->ui_component, - "LockAppletToPanel", - listener_popup_handle_lock, - frame); - - matecomponent_ui_component_add_verb_list_with_data ( - matecomponent_frame->priv->ui_component, popup_verbs, frame); - - control = matecomponent_control_frame_get_control (control_frame); - if (!control) { - CORBA_exception_free (&corba_ev); - gerror = g_error_new_literal (mate_panel_applet_frame_matecomponent_error_quark (), 0, "cannot get control"); - goto error_out; - } - - matecomponent_frame->priv->applet_shell = mate_panel_applet_frame_get_applet_shell (control); - if (matecomponent_frame->priv->applet_shell == CORBA_OBJECT_NIL) { - CORBA_exception_free (&corba_ev); - gerror = g_error_new_literal (mate_panel_applet_frame_matecomponent_error_quark (), 0, "cannot get applet shell"); - goto error_out; - } - - CORBA_exception_free (&corba_ev); - - MateCORBA_small_listen_for_broken (object, - G_CALLBACK (mate_panel_applet_frame_matecomponent_applet_broken), - frame); - - gtk_container_add (GTK_CONTAINER (frame), widget); - - goto out; - -error_out: - if (widget) - g_object_unref (widget); - if (!gerror) - gerror = g_error_new_literal (mate_panel_applet_frame_matecomponent_error_quark (), 0, "unknown error"); - -out: - _mate_panel_applet_frame_activated (frame, frame_act, gerror); -} - -gboolean -mate_panel_applet_frame_matecomponent_load (const gchar *iid, - MatePanelAppletFrameActivating *frame_act) -{ - MatePanelAppletFrameMateComponent *matecomponent_frame; - MatePanelAppletFrame *frame; - CORBA_Environment ev; - - g_return_val_if_fail (iid != NULL, FALSE); - g_return_val_if_fail (frame_act != NULL, FALSE); - - if (!mate_panel_applets_manager_factory_activate (iid)) - return FALSE; - - matecomponent_frame = g_object_new (PANEL_TYPE_APPLET_FRAME_MATECOMPONENT, NULL); - frame = MATE_PANEL_APPLET_FRAME (matecomponent_frame); - _mate_panel_applet_frame_set_iid (frame, iid); - - g_object_set_data (G_OBJECT (frame), "mate-panel-applet-frame-activating", frame_act); - - CORBA_exception_init (&ev); - - matecomponent_activation_activate_from_id_async ((gchar *) iid, 0, - (MateComponentActivationCallback) mate_panel_applet_frame_matecomponent_activated, - frame, &ev); - - CORBA_exception_free (&ev); - - return TRUE; -} diff --git a/matecomponent/panel-module/mate-panel-applet-frame-matecomponent.h b/matecomponent/panel-module/mate-panel-applet-frame-matecomponent.h deleted file mode 100644 index b6246e26..00000000 --- a/matecomponent/panel-module/mate-panel-applet-frame-matecomponent.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * mate-panel-applet-frame-matecomponent.h: panel side container for applets - * - * Copyright (C) 2001 - 2003 Sun Microsystems, Inc. - * Copyright (C) 2010 Vincent Untz <[email protected]> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <[email protected]> - */ - -#ifndef __MATE_PANEL_APPLET_FRAME_MATECOMPONENT_H__ -#define __MATE_PANEL_APPLET_FRAME_MATECOMPONENT_H__ - -#include <mate-panel-applet-frame.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define PANEL_TYPE_APPLET_FRAME_MATECOMPONENT (mate_panel_applet_frame_matecomponent_get_type ()) -#define MATE_PANEL_APPLET_FRAME_MATECOMPONENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET_FRAME_MATECOMPONENT, MatePanelAppletFrameMateComponent)) -#define MATE_PANEL_APPLET_FRAME_MATECOMPONENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_APPLET_FRAME_MATECOMPONENT, MatePanelAppletFrameMateComponentClass)) -#define PANEL_IS_APPLET_FRAME_MATECOMPONENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_APPLET_FRAME_MATECOMPONENT)) -#define PANEL_IS_APPLET_FRAME_MATECOMPONENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_APPLET_FRAME_MATECOMPONENT)) -#define MATE_PANEL_APPLET_FRAME_MATECOMPONENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_APPLET_FRAME_MATECOMPONENT, MatePanelAppletFrameMateComponentClass)) - -typedef struct _MatePanelAppletFrameMateComponent MatePanelAppletFrameMateComponent; -typedef struct _MatePanelAppletFrameMateComponentClass MatePanelAppletFrameMateComponentClass; -typedef struct _MatePanelAppletFrameMateComponentPrivate MatePanelAppletFrameMateComponentPrivate; - -struct _MatePanelAppletFrameMateComponentClass { - MatePanelAppletFrameClass parent_class; -}; - -struct _MatePanelAppletFrameMateComponent{ - MatePanelAppletFrame parent; - - MatePanelAppletFrameMateComponentPrivate *priv; -}; - -GType mate_panel_applet_frame_matecomponent_get_type (void) G_GNUC_CONST; - -gboolean mate_panel_applet_frame_matecomponent_load (const gchar *iid, - MatePanelAppletFrameActivating *frame_act); - -#ifdef __cplusplus -} -#endif - -#endif /* __MATE_PANEL_APPLET_FRAME_MATECOMPONENT_H__ */ diff --git a/matecomponent/panel-module/mate-panel-applets-manager-matecomponent.c b/matecomponent/panel-module/mate-panel-applets-manager-matecomponent.c deleted file mode 100644 index 3a0187a8..00000000 --- a/matecomponent/panel-module/mate-panel-applets-manager-matecomponent.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * mate-panel-applets-manager-matecomponent.c - * - * Copyright (C) 2010 Vincent Untz <[email protected]> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> - -#include <string.h> -#include <libmatecomponent.h> - -#include <mate-panel-applets-manager.h> - -#include "mate-panel-applet-frame-matecomponent.h" - -#include "mate-panel-applets-manager-matecomponent.h" - -G_DEFINE_DYNAMIC_TYPE (MatePanelAppletsManagerMateComponent, mate_panel_applets_manager_matecomponent, PANEL_TYPE_APPLETS_MANAGER); - -struct _MatePanelAppletsManagerMateComponentPrivate -{ - GHashTable *applets; -}; - -static const char applet_requirements [] = - "has_all (repo_ids, ['IDL:MateComponent/Control:1.0'," - " 'IDL:MATE/Vertigo/MatePanelAppletShell:1.0']) && " - "defined (panel:icon)"; - -static char *applet_sort_criteria [] = { - "name", - NULL - }; - -static void -mate_panel_applets_manager_matecomponent_load_applet_infos (MatePanelAppletsManagerMateComponent *manager) -{ - MateComponent_ServerInfoList *applet_list; - CORBA_Environment env; - const char * const *langs; - GSList *langs_gslist; - int i; - - CORBA_exception_init (&env); - - applet_list = matecomponent_activation_query (applet_requirements, - applet_sort_criteria, - &env); - if (MATECOMPONENT_EX (&env)) { - g_warning ("MateComponent query returned exception %s\n", - MATECOMPONENT_EX_REPOID (&env)); - - CORBA_exception_free (&env); - CORBA_free (applet_list); - - return; - } - - CORBA_exception_free (&env); - - langs = g_get_language_names (); - - langs_gslist = NULL; - for (i = 0; langs[i]; i++) - langs_gslist = g_slist_prepend (langs_gslist, (char *) langs[i]); - - langs_gslist = g_slist_reverse (langs_gslist); - - for (i = 0; i < applet_list->_length; i++) { - MateComponent_ServerInfo *info; - const char *name, *description, *icon; - MatePanelAppletInfo *applet_info; - - info = &applet_list->_buffer[i]; - - name = matecomponent_server_info_prop_lookup (info, - "name", - langs_gslist); - description = matecomponent_server_info_prop_lookup (info, - "description", - langs_gslist); - icon = matecomponent_server_info_prop_lookup (info, - "panel:icon", - NULL); - - applet_info = mate_panel_applet_info_new (info->iid, name, description, icon, NULL); - - g_hash_table_insert (manager->priv->applets, g_strdup (info->iid), applet_info); - } - - g_slist_free (langs_gslist); - CORBA_free (applet_list); -} - -static GList * -mate_panel_applets_manager_matecomponent_get_applets (MatePanelAppletsManager *manager) -{ - MatePanelAppletsManagerMateComponent *matecomponent_manager = MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT (manager); - - GHashTableIter iter; - gpointer key, value; - GList *retval = NULL; - - g_hash_table_iter_init (&iter, matecomponent_manager->priv->applets); - while (g_hash_table_iter_next (&iter, &key, &value)) - retval = g_list_prepend (retval, value); - - return g_list_reverse (retval);; -} - -static gboolean -mate_panel_applets_manager_matecomponent_factory_activate (MatePanelAppletsManager *manager, - const gchar *iid) -{ - MatePanelAppletsManagerMateComponent *matecomponent_manager = MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT (manager); - MatePanelAppletInfo *info; - - /* we let matecomponent deal with that, but we need to return the right value */ - - info = g_hash_table_lookup (matecomponent_manager->priv->applets, iid); - - return (info != NULL); -} - -static gboolean -mate_panel_applets_manager_matecomponent_factory_deactivate (MatePanelAppletsManager *manager, - const gchar *iid) -{ - MatePanelAppletsManagerMateComponent *matecomponent_manager = MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT (manager); - MatePanelAppletInfo *info; - - /* we let matecomponent deal with that, but we need to return the right value */ - - info = g_hash_table_lookup (matecomponent_manager->priv->applets, iid); - - return (info != NULL); -} - -static MatePanelAppletInfo * -mate_panel_applets_manager_matecomponent_get_applet_info (MatePanelAppletsManager *manager, - const gchar *iid) -{ - MatePanelAppletsManagerMateComponent *matecomponent_manager = MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT (manager); - - return g_hash_table_lookup (matecomponent_manager->priv->applets, iid); -} - -static MatePanelAppletInfo * -mate_panel_applets_manager_matecomponent_get_applet_info_from_old_id (MatePanelAppletsManager *manager, - const gchar *iid) -{ - MatePanelAppletsManagerMateComponent *matecomponent_manager = MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT (manager); - - return g_hash_table_lookup (matecomponent_manager->priv->applets, iid); -} - -static gboolean -mate_panel_applets_manager_matecomponent_load_applet (MatePanelAppletsManager *manager, - const gchar *iid, - MatePanelAppletFrameActivating *frame_act) -{ - return mate_panel_applet_frame_matecomponent_load (iid, frame_act); -} - -static void -mate_panel_applets_manager_matecomponent_finalize (GObject *object) -{ - MatePanelAppletsManagerMateComponent *manager = MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT (object); - - if (manager->priv->applets) { - g_hash_table_destroy (manager->priv->applets); - manager->priv->applets = NULL; - } - - G_OBJECT_CLASS (mate_panel_applets_manager_matecomponent_parent_class)->finalize (object); -} - -static void -mate_panel_applets_manager_matecomponent_init (MatePanelAppletsManagerMateComponent *manager) -{ - manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, - PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT, - MatePanelAppletsManagerMateComponentPrivate); - - manager->priv->applets = g_hash_table_new_full (g_str_hash, - g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) mate_panel_applet_info_free); - - mate_panel_applets_manager_matecomponent_load_applet_infos (manager); -} - -static void -mate_panel_applets_manager_matecomponent_class_finalize (MatePanelAppletsManagerMateComponentClass *class) -{ -} - -static void -mate_panel_applets_manager_matecomponent_class_init (MatePanelAppletsManagerMateComponentClass *class) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (class); - MatePanelAppletsManagerClass *manager_class = MATE_PANEL_APPLETS_MANAGER_CLASS (class); - - /* This is a horrible hack: we shouldn't call matecomponent_init() here, but - * in g_io_module_load() or even - * mate_panel_applets_manager_matecomponent_register(). However, it looks like if - * there's no giomodule.cache file, the module gets unloaded, and - * matecomponent_init() gets called twice, which makes everythings goes wrong: - * matecomponent has been unloaded so believes it has to get initialized, but - * the types are already registered in the GType system. And bam. */ - - matecomponent_init (NULL, NULL); - - gobject_class->finalize = mate_panel_applets_manager_matecomponent_finalize; - - manager_class->get_applets = mate_panel_applets_manager_matecomponent_get_applets; - manager_class->factory_activate = mate_panel_applets_manager_matecomponent_factory_activate; - manager_class->factory_deactivate = mate_panel_applets_manager_matecomponent_factory_deactivate; - manager_class->get_applet_info = mate_panel_applets_manager_matecomponent_get_applet_info; - manager_class->get_applet_info_from_old_id = mate_panel_applets_manager_matecomponent_get_applet_info_from_old_id; - manager_class->load_applet = mate_panel_applets_manager_matecomponent_load_applet; - - g_type_class_add_private (class, sizeof (MatePanelAppletsManagerMateComponentPrivate)); -} - - -void -mate_panel_applets_manager_matecomponent_register (GIOModule *module) -{ - mate_panel_applets_manager_matecomponent_register_type (G_TYPE_MODULE (module)); - g_io_extension_point_implement (MATE_PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME, - PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT, - "matecomponent", - 10); -} diff --git a/matecomponent/panel-module/mate-panel-applets-manager-matecomponent.h b/matecomponent/panel-module/mate-panel-applets-manager-matecomponent.h deleted file mode 100644 index 88741ed8..00000000 --- a/matecomponent/panel-module/mate-panel-applets-manager-matecomponent.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * mate-panel-applets-manager-matecomponent.h - * - * Copyright (C) 2010 Vincent Untz <[email protected]> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT_H__ -#define __MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT_H__ - -#include <mate-panel-applets-manager.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT (mate_panel_applets_manager_matecomponent_get_type ()) -#define MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT, MatePanelAppletsManagerMateComponent)) -#define MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT, MatePanelAppletsManagerMateComponentClass)) -#define PANEL_IS_APPLETS_MANAGER_MATECOMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT)) -#define PANEL_IS_APPLETS_MANAGER_MATECOMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT)) -#define MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_APPLETS_MANAGER_MATECOMPONENT, MatePanelAppletsManagerMateComponentClass)) - -typedef struct _MatePanelAppletsManagerMateComponent MatePanelAppletsManagerMateComponent; -typedef struct _MatePanelAppletsManagerMateComponentClass MatePanelAppletsManagerMateComponentClass; -typedef struct _MatePanelAppletsManagerMateComponentPrivate MatePanelAppletsManagerMateComponentPrivate; - -struct _MatePanelAppletsManagerMateComponentClass { - MatePanelAppletsManagerClass parent_class; -}; - -struct _MatePanelAppletsManagerMateComponent { - MatePanelAppletsManager parent; - - /*< private > */ - MatePanelAppletsManagerMateComponentPrivate *priv; -}; - -GType mate_panel_applets_manager_matecomponent_get_type (void); - -#ifdef __cplusplus -} -#endif - -#endif /* __MATE_PANEL_APPLETS_MANAGER_MATECOMPONENT_H__ */ |