static void gdict_source_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GdictSource *source = GDICT_SOURCE (object); switch (prop_id) { case PROP_NAME: gdict_source_set_name (source, g_value_get_string (value)); break; case PROP_DESCRIPTION: gdict_source_set_description (source, g_value_get_string (value)); break; case PROP_TRANSPORT: gdict_source_set_transport (source, g_value_get_enum (value), NULL); break; case PROP_DATABASE: gdict_source_set_database (source, g_value_get_string (value)); break; case PROP_STRATEGY: gdict_source_set_strategy (source, g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/** * gdict_source_loader_remove_source: * @loader: a #GdictSourceLoader * @name: name of a dictionary source * * Removes the dictionary source @name from @loader. This function will * also remove the dictionary source definition file bound to it. * * Return value: %TRUE if the dictionary source was successfully removed * * Since: 1.0 */ gboolean gdict_source_loader_remove_source (GdictSourceLoader *loader, const gchar *name) { GdictSourceLoaderPrivate *priv; GSList *l; g_return_val_if_fail (GDICT_IS_SOURCE_LOADER (loader), FALSE); g_return_val_if_fail (name != NULL, FALSE); priv = loader->priv; if (priv->paths_dirty) gdict_source_loader_update_sources (loader); for (l = priv->sources; l != NULL; l = l->next) { GdictSource *s = GDICT_SOURCE (l->data); if (strcmp (gdict_source_get_name (s), name) == 0) { gchar *filename; g_object_get (G_OBJECT (s), "filename", &filename, NULL); if (g_unlink (filename) == -1) { g_warning ("Unable to remove filename '%s' for the " "dictionary source '%s'\n", filename, name); return FALSE; } g_hash_table_remove (priv->sources_by_name, name); priv->sources = g_slist_remove_link (priv->sources, l); g_object_unref (s); g_slist_free (l); return TRUE; } } return FALSE; }
static void update_sources_view (GdictPrefDialog *dialog) { const GSList *sources, *l; gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->sources_view), NULL); gtk_list_store_clear (dialog->sources_list); /* force update of the sources list */ gdict_source_loader_update (dialog->loader); sources = gdict_source_loader_get_sources (dialog->loader); for (l = sources; l != NULL; l = l->next) { GdictSource *source = GDICT_SOURCE (l->data); GtkTreeIter iter; const gchar *name, *description; gboolean is_active = FALSE; name = gdict_source_get_name (source); description = gdict_source_get_description (source); if (!description) description = name; if (strcmp (name, dialog->active_source) == 0) is_active = TRUE; gtk_list_store_append (dialog->sources_list, &iter); gtk_list_store_set (dialog->sources_list, &iter, SOURCES_ACTIVE_COLUMN, is_active, SOURCES_NAME_COLUMN, name, SOURCES_DESCRIPTION_COLUMN, description, -1); } gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->sources_view), GTK_TREE_MODEL (dialog->sources_list)); /* select the currently active source name */ gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->sources_list), select_active_source_name, dialog); }
static void gdict_source_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GdictSource *source = GDICT_SOURCE (object); GdictSourcePrivate *priv = source->priv; switch (prop_id) { case PROP_FILENAME: g_value_set_string (value, priv->filename); break; case PROP_NAME: g_value_set_string (value, priv->name); break; case PROP_DESCRIPTION: g_value_set_string (value, priv->description); break; case PROP_EDITABLE: g_value_set_boolean (value, priv->editable); break; case PROP_DATABASE: g_value_set_string (value, priv->database); break; case PROP_STRATEGY: g_value_set_string (value, priv->strategy); break; case PROP_TRANSPORT: g_value_set_enum (value, priv->transport); break; case PROP_CONTEXT: g_value_set_object (value, gdict_source_peek_context (source)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }