static GdictContext * get_context_from_loader (GdictApplet *applet) { GdictAppletPrivate *priv = applet->priv; GdictSource *source; GdictContext *retval; if (!priv->source_name) priv->source_name = g_strdup (GDICT_DEFAULT_SOURCE_NAME); source = gdict_source_loader_get_source (priv->loader, priv->source_name); if (!source) { gchar *detail; detail = g_strdup_printf (_("No dictionary source available with name '%s'"), priv->source_name); gdict_show_error_dialog (NULL, _("Unable to find dictionary source"), NULL); g_free (detail); return NULL; } gdict_applet_set_database (applet, gdict_source_get_database (source)); gdict_applet_set_strategy (applet, gdict_source_get_strategy (source)); retval = gdict_source_get_context (source); if (!retval) { gchar *detail; detail = g_strdup_printf (_("No context available for source '%s'"), gdict_source_get_description (source)); gdict_show_error_dialog (NULL, _("Unable to create a context"), detail); g_free (detail); g_object_unref (source); return NULL; } g_object_unref (source); return retval; }
static GdictContext * get_context_from_loader (GtrDictPanel * panel) { GtrDictPanelPrivate *priv = panel->priv; GdictSource *source; GdictContext *retval; if (!priv->source_name) priv->source_name = g_strdup (DICTIONARY_DEFAULT_SOURCE_NAME); source = gdict_source_loader_get_source (priv->loader, priv->source_name); if (!source) { gchar *detail; detail = g_strdup_printf (_("No dictionary source available with name '%s'"), priv->source_name); gtr_dict_panel_create_warning_dialog (_ ("Unable to find dictionary source"), detail); g_free (detail); return NULL; } gtr_dict_panel_set_database (panel, gdict_source_get_database (source)); gtr_dict_panel_set_strategy (panel, gdict_source_get_strategy (source)); retval = gdict_source_get_context (source); if (!retval) { gchar *detail; detail = g_strdup_printf (_("No context available for source '%s'"), gdict_source_get_description (source)); gtr_dict_panel_create_warning_dialog (_ ("Unable to create a context"), detail); g_free (detail); g_object_unref (source); return NULL; } g_object_unref (source); return retval; }
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; } }