G_MODULE_EXPORT void 
gw_addvocabularywindow_add_cb (GtkWidget *widget, gpointer data)
{
    GwAddVocabularyWindow *window;
    GwAddVocabularyWindowPrivate *priv;
    GwAddVocabularyWindowClass *klass;
    GtkListStore *wordstore;
    const gchar *kanji, *furigana, *definitions;

    window = GW_ADDVOCABULARYWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_ADDVOCABULARYWINDOW));
    g_return_if_fail (window != NULL);
    priv = window->priv;
    klass = GW_ADDVOCABULARYWINDOW_CLASS (G_OBJECT_GET_CLASS (window));

    kanji = gw_addvocabularywindow_get_kanji (window);
    furigana = gw_addvocabularywindow_get_furigana (window);
    definitions = gw_addvocabularywindow_get_definitions (window);
    wordstore = gw_addvocabularywindow_get_wordstore (window);
    priv->wordstore = GW_VOCABULARYWORDSTORE (wordstore);

    gw_vocabularywordstore_load (priv->wordstore, NULL);
    gw_vocabularywordstore_new_word (priv->wordstore, &(priv->iter), NULL, kanji, furigana, definitions);

    if (klass->last_selected_list_name != NULL)
      g_free (klass->last_selected_list_name);
    klass->last_selected_list_name = g_strdup (gw_addvocabularywindow_get_list (window));

    priv->valid = TRUE;

    g_signal_emit (G_OBJECT (window), klass->signalid[GW_ADDVOCABULARYWINDOW_CLASS_SIGNALID_WORD_ADDED], 0);

    gtk_widget_destroy (GTK_WIDGET (window));
}
Exemple #2
0
GtkListStore*
gw_addvocabularywindow_get_wordstore (GwAddVocabularyWindow *window)
{
    //Declarations
    GwApplication *application;
    GtkListStore *wordstore;
    GtkListStore *liststore;
    const gchar *name;

    //Initializations
    application = gw_window_get_application (GW_WINDOW (window));
    liststore = gw_application_get_vocabularyliststore (application);
    name = gw_addvocabularywindow_get_list (window);
    wordstore = gw_vocabularyliststore_get_wordstore_by_name (GW_VOCABULARYLISTSTORE (liststore), name);

    return wordstore;
}
Exemple #3
0
gboolean
gw_addvocabularywindow_validate (GwAddVocabularyWindow *window)
{
    GwAddVocabularyWindowPrivate *priv;
    const gchar *kanji, *furigana, *definitions, *list;
    gboolean has_kanji, has_furigana, has_definitions, has_list;
    gboolean valid;

    priv = window->priv;
    kanji = gw_addvocabularywindow_get_kanji (window);
    furigana = gw_addvocabularywindow_get_furigana (window);
    definitions = gw_addvocabularywindow_get_definitions (window);
    list = gw_addvocabularywindow_get_list (window);

    has_kanji = (strlen (kanji) > 0);
    has_furigana = (strlen (furigana) > 0);
    has_definitions = (strlen (definitions) > 0);
    has_list = (strlen (list) > 0);
    valid = ((has_kanji || has_furigana || has_definitions) && has_list);

    gtk_widget_set_sensitive (GTK_WIDGET (priv->add_button), valid);

    return valid;
}