static void gn_combo_history_mateconf_load (GnComboHistory *history) { gchar *key; GSList *mateconf_items, *last; g_return_if_fail (GN_IS_COMBO_HISTORY (history)); g_return_if_fail (history->priv->mateconf_client != NULL); g_return_if_fail (history->priv->id != NULL); gn_combo_free_items (history); key = g_strconcat ("/apps/mate-settings/", "mate-nettool", "/history-", history->priv->id, NULL); mateconf_items = mateconf_client_get_list (history->priv->mateconf_client, key, MATECONF_VALUE_STRING, NULL); g_free (key); /* truncate the list */ last = g_slist_nth (mateconf_items, history->priv->max_history - 1); if (last) { g_slist_foreach (last->next, (GFunc) g_free, NULL); g_slist_free (last->next); last->next = NULL; } history->priv->items = mateconf_items; }
static void gn_combo_history_finalize (GObject *object) { GnComboHistory *history = GN_COMBO_HISTORY (object); if (history->priv) { if (history->priv->combo) { g_object_unref (G_OBJECT (history->priv->combo)); history->priv->combo = NULL; } if (history->priv->id) { g_free (history->priv->id); history->priv->id = NULL; } gn_combo_free_items (history); g_object_unref (G_OBJECT (history->priv->settings)); history->priv->settings = NULL; } if (G_OBJECT_CLASS (parent_class)->finalize) (* G_OBJECT_CLASS (parent_class)->finalize) (object); }
static void gn_combo_history_finalize (GObject *object) { GnComboHistory *history = GN_COMBO_HISTORY (object); if (history->priv) { if (history->priv->combo) { g_object_unref (G_OBJECT (history->priv->combo)); history->priv->combo = NULL; } if (history->priv->id) { g_free (history->priv->id); history->priv->id = NULL; } gn_combo_free_items (history); if (history->priv->mateconf_notify != 0) { mateconf_client_notify_remove (history->priv->mateconf_client, history->priv->mateconf_notify); history->priv->mateconf_notify = 0; } if (history->priv->mateconf_client) { g_object_unref (G_OBJECT (history->priv->mateconf_client)); history->priv->mateconf_client = NULL; } } if (G_OBJECT_CLASS (parent_class)->finalize) (* G_OBJECT_CLASS (parent_class)->finalize) (object); }
void gn_combo_history_clear (GnComboHistory *history) { g_return_if_fail (GN_IS_COMBO_HISTORY (history)); if (history->priv->items) { gn_combo_free_items (history); gn_combo_history_settings_save (history); } }
static void gn_combo_history_settings_load (GnComboHistory *history) { gchar **items; guint i; g_return_if_fail (GN_IS_COMBO_HISTORY (history)); g_return_if_fail (history->priv->id != NULL); gn_combo_free_items (history); history->priv->items = NULL; items = g_settings_get_strv (history->priv->settings, history->priv->id); for (i = 0; items[i] && i < history->priv->max_history; i++) history->priv->items = g_slist_append (history->priv->items, g_strdup (items[i])); g_strfreev (items); }