void gn_combo_history_add (GnComboHistory *history, const gchar *text) { GSList *item; g_return_if_fail (GN_IS_COMBO_HISTORY (history)); g_return_if_fail (text != NULL); if ((item = g_slist_find_custom (history->priv->items, (gpointer) text, compare))) { /* item is already in list, remove them */ history->priv->items = g_slist_remove (history->priv->items, item->data); } if (g_slist_length (history->priv->items) >= history->priv->max_history) { item = g_slist_last (history->priv->items); history->priv->items = g_slist_remove (history->priv->items, item->data); } history->priv->items = g_slist_prepend (history->priv->items, g_strdup (text)); gn_combo_history_set_popdown_strings (history); gn_combo_history_settings_save (history); }
static void gn_on_mateconf_history_changed (MateConfClient *client, guint cnxn_id, MateConfEntry *entry, gpointer gdata) { GnComboHistory *history; history = GN_COMBO_HISTORY (gdata); gn_combo_history_mateconf_load (history); gn_combo_history_set_popdown_strings (history); }
static void gn_on_settings_history_changed (GSettings *settings, gchar *key, gpointer gdata) { GnComboHistory *history; history = GN_COMBO_HISTORY (gdata); if (!g_str_equal (key, history->priv->id)) return; gn_combo_history_settings_load (history); gn_combo_history_set_popdown_strings (history); }
void gn_combo_history_set_combo (GnComboHistory *history, GtkComboBox *combo) { g_return_if_fail (GN_IS_COMBO_HISTORY (history)); g_return_if_fail (GTK_IS_COMBO_BOX (combo)); if (history->priv->combo) g_object_unref (G_OBJECT (history->priv->combo)); history->priv->combo = combo; gn_combo_history_settings_load (history); gn_combo_history_set_popdown_strings (history); gtk_combo_box_set_active (GTK_COMBO_BOX (history->priv->combo), -1); gtk_entry_set_text ( GTK_ENTRY (gtk_bin_get_child ( GTK_BIN (history->priv->combo))), ""); g_object_ref (G_OBJECT (history->priv->combo)); }