/** * gdict_source_chooser_refresh: * @chooser: a #GdictSourceChooser * * Forces a refresh on the contents of the source chooser widget * * Since: 0.12 */ void gdict_source_chooser_refresh (GdictSourceChooser *chooser) { GdictSourceChooserPrivate *priv; g_return_if_fail (GDICT_IS_SOURCE_CHOOSER (chooser)); priv = chooser->priv; if (priv->loader) { const GSList *sources, *l; if (priv->treeview) gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), NULL); gtk_list_store_clear (priv->store); sources = gdict_source_loader_get_sources (priv->loader); for (l = sources; l != NULL; l = l->next) { GdictSource *source = l->data; const gchar *name, *description; GdictSourceTransport transport; gint weight; transport = gdict_source_get_transport (source); name = gdict_source_get_name (source); description = gdict_source_get_description (source); weight = PANGO_WEIGHT_NORMAL; if (priv->current_source && !strcmp (priv->current_source, name)) weight = PANGO_WEIGHT_BOLD; gtk_list_store_insert_with_values (priv->store, NULL, -1, SOURCE_TRANSPORT, transport, SOURCE_NAME, name, SOURCE_DESCRIPTION, description, SOURCE_CURRENT, weight, -1); } if (priv->treeview) gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), GTK_TREE_MODEL (priv->store)); } }
static void update_dialog_ui (GdictSourceDialog *dialog) { GdictSource *source; /* TODO - add code to update the contents of the dialog depending * on the action; if we are in _CREATE, no action is needed */ switch (dialog->action) { case GDICT_SOURCE_DIALOG_VIEW: case GDICT_SOURCE_DIALOG_EDIT: if (!dialog->source_name) { g_warning ("Attempting to retrieve source, but no " "source name has been defined. Aborting..."); return; } source = gdict_source_loader_get_source (dialog->loader, dialog->source_name); if (!source) { g_warning ("Attempting to retrieve source, but no " "source named `%s' was found. Aborting...", dialog->source_name); return; } g_object_ref (source); dialog->source = source; set_text_to_entry (dialog, "description_entry", gdict_source_get_description (source)); dialog->transport = gdict_source_get_transport (source); gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->transport_combo), (gint) dialog->transport); /* set the context for the database and strategy choosers */ dialog->context = gdict_source_get_context (source); if (!dialog->context) { g_warning ("Attempting to retrieve the context, but " "none was found for source `%s'.", dialog->source_name); return; } set_transport_settings (dialog); gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (dialog->db_chooser), dialog->context); gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER (dialog->db_chooser)); gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (dialog->strat_chooser), dialog->context); gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER (dialog->strat_chooser)); break; case GDICT_SOURCE_DIALOG_CREATE: /* DICTD transport is default */ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->transport_combo), 0); g_signal_emit_by_name (dialog->transport_combo, "changed"); break; default: g_assert_not_reached (); break; } }