Commit f35ac95c authored by Daniel Garcia Moreno's avatar Daniel Garcia Moreno

Merge branch 'profile-fields' into 'master'

Profile fields

See merge request !22
parents de9565d3 65eba1cd
Pipeline #37622 passed with stage
in 12 minutes and 8 seconds
......@@ -46,6 +46,7 @@ typedef struct
GtkWidget *profile_name;
GtkWidget *name;
GtkWidget *email;
GtkWidget *team_email;
/* Profiles Page 2 */
GtkWidget *languages_fetcher;
......@@ -87,6 +88,9 @@ on_assistant_apply (GtkAssistant * assistant)
gtk_entry_get_text (GTK_ENTRY
(priv->email)));
gtr_profile_set_group_email (profile,
gtk_entry_get_text (GTK_ENTRY (priv->team_email)));
gtr_profile_set_language_name (profile,
gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)));
......@@ -99,9 +103,6 @@ on_assistant_apply (GtkAssistant * assistant)
gtr_profile_set_encoding (profile,
gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)));
gtr_profile_set_group_email (profile,
gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)));
gtr_profile_set_plural_forms (profile,
gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)));
......@@ -138,7 +139,7 @@ on_assistant_prepare (GtkAssistant * assistant, GtkWidget * page)
gtk_entry_get_text (GTK_ENTRY (priv->name)),
gtk_entry_get_text (GTK_ENTRY (priv->email)),
gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)),
gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)),
gtk_entry_get_text (GTK_ENTRY (priv->team_email)),
gtr_languages_fetcher_get_language_code (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)),
gtr_languages_fetcher_get_charset (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)),
gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER (priv->languages_fetcher)),
......@@ -212,6 +213,18 @@ on_profile1_entry_changed (GtkWidget * widget, GtrAssistant * as)
/* Translator email */
text = gtk_entry_get_text (GTK_ENTRY (priv->email));
if (text && *text)
gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
else
{
gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
FALSE);
return;
}
/* Team email */
text = gtk_entry_get_text (GTK_ENTRY (priv->team_email));
if (text && *text)
gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
else
......@@ -242,10 +255,10 @@ create_profiles_page1 (GtrAssistant * as)
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
label = gtk_label_new (NULL);
markup = g_strdup_printf("<b>%s</b>", _("Profile name:"));
markup = g_strdup_printf("<b>%s</b>", _("Profile name"));
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free(markup);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
......@@ -264,10 +277,10 @@ create_profiles_page1 (GtrAssistant * as)
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
label = gtk_label_new (NULL);
markup = g_strdup_printf("<b>%s</b>", ("Translator name:"));
markup = g_strdup_printf("<b>%s</b>", ("Translator name"));
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free(markup);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
......@@ -286,10 +299,10 @@ create_profiles_page1 (GtrAssistant * as)
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
label = gtk_label_new (NULL);
markup = g_strdup_printf("<b>%s</b>", _("Translator email:"));
markup = g_strdup_printf("<b>%s</b>", _("Translator email"));
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free(markup);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
......@@ -300,8 +313,36 @@ create_profiles_page1 (GtrAssistant * as)
g_signal_connect (G_OBJECT (priv->email), "changed",
G_CALLBACK (on_profile1_entry_changed), as);
/*
* Team email:
*/
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
label = gtk_label_new (NULL);
markup = g_strdup_printf("<b>%s</b>", _("Team email"));
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free(markup);
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
priv->team_email = gtk_entry_new ();
gtk_widget_show (priv->team_email);
gtk_box_pack_start (GTK_BOX (hbox), priv->team_email, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (priv->team_email), "changed",
G_CALLBACK (on_profile1_entry_changed), as);
gtk_assistant_append_page (GTK_ASSISTANT (as), box);
gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Profile"));
/**
* Default values
*/
gtk_entry_set_text (GTK_ENTRY (priv->profile_name), "default");
gtk_entry_set_text (GTK_ENTRY (priv->name), g_get_real_name ());
}
static void
......@@ -363,14 +404,6 @@ on_profile2_entry_changed (GtkWidget * widget, GtrAssistant * as)
return;
}
/* Team email */
text = gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
if (text && *text)
gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
else
gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
/* Plural form */
text = gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
......
/*
* Copyright (C) 2018 Daniel Garcia Moreno <danigm@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gtr-language.h"
#include "gtr-lang-button.h"
typedef struct
{
GtkWidget *lang;
GtkWidget *lang_list;
GtkWidget *popup;
gchar *lang_name;
} GtrLangButtonPrivate;
struct _GtrLangButton
{
GtkMenuButton parent_instance;
};
enum
{
CHANGED,
LAST_SIGNAL
};
G_DEFINE_TYPE_WITH_PRIVATE (GtrLangButton, gtr_lang_button, GTK_TYPE_MENU_BUTTON)
static guint signals[LAST_SIGNAL] = { 0 };
static gint
compare_languages_name (gconstpointer a,
gconstpointer b)
{
GtrLanguage *lang1, *lang2;
const gchar *name1, *name2;
lang1 = (GtrLanguage *) a;
lang2 = (GtrLanguage *) b;
name1 = gtr_language_get_name (lang1);
name2 = gtr_language_get_name (lang2);
return g_utf8_collate (name1, name2);
}
static void
change_language (GtkListBox *box,
GtkListBoxRow *row,
GtrLangButton *self)
{
GtrLangButtonPrivate *priv = gtr_lang_button_get_instance_private (self);
GtkWidget *label = gtk_bin_get_child (GTK_BIN (row));
gtr_lang_button_set_lang (self, gtk_label_get_text (GTK_LABEL (label)));
gtk_popover_popdown (GTK_POPOVER (priv->popup));
}
static void
filter_language (GtkEditable *entry,
GtrLangButton *self)
{
GtrLangButtonPrivate *priv = gtr_lang_button_get_instance_private (self);
const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
gchar *uptext = g_ascii_strup (text, -1);
const GSList *languages, *l;
GList *children;
languages = gtr_language_get_languages ();
languages = g_slist_sort ((GSList*)languages, compare_languages_name);
children = gtk_container_get_children (GTK_CONTAINER (priv->lang_list));
while (children)
{
GtkWidget *w = GTK_WIDGET (children->data);
gtk_container_remove (GTK_CONTAINER (priv->lang_list), w);
children = g_list_next (children);
}
for (l = languages; l != NULL; l = g_slist_next (l))
{
GtrLanguage *lang = (GtrLanguage *)l->data;
const gchar *langname = gtr_language_get_name (lang);
GtkWidget *child;
gchar *uplang = g_ascii_strup (langname, -1);
if (g_strrstr (uplang, uptext) == NULL) {
g_free (uplang);
continue;
}
g_free (uplang);
child = gtk_label_new (langname);
gtk_label_set_xalign (GTK_LABEL (child), 0.0);
gtk_container_add (GTK_CONTAINER (priv->lang_list), child);
}
gtk_widget_show_all (priv->lang_list);
g_free (uptext);
}
static void
gtr_lang_button_finalize (GObject *object)
{
GtrLangButtonPrivate *priv = gtr_lang_button_get_instance_private (GTR_LANG_BUTTON (object));
g_clear_pointer (&priv->lang_name, g_free);
G_OBJECT_CLASS (gtr_lang_button_parent_class)->finalize (object);
}
static void
gtr_lang_button_class_init (GtrLangButtonClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gtr_lang_button_finalize;
signals[CHANGED] =
g_signal_newv ("changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
NULL, NULL, NULL, NULL,
G_TYPE_NONE, 0, NULL);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/translator/gtr-lang-button.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtrLangButton, lang);
gtk_widget_class_bind_template_child_private (widget_class, GtrLangButton, lang_list);
gtk_widget_class_bind_template_child_private (widget_class, GtrLangButton, popup);
}
static void
gtr_lang_button_init (GtrLangButton *self)
{
const GSList *languages, *l;
GtrLangButtonPrivate *priv = gtr_lang_button_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
languages = gtr_language_get_languages ();
languages = g_slist_sort ((GSList*)languages, compare_languages_name);
for (l = languages; l != NULL; l = g_slist_next (l))
{
GtrLanguage *lang = (GtrLanguage *)l->data;
GtkWidget *child = gtk_label_new (gtr_language_get_name (lang));
gtk_label_set_xalign (GTK_LABEL (child), 0.0);
gtk_container_add (GTK_CONTAINER (priv->lang_list), child);
}
gtk_widget_show_all (priv->lang_list);
priv->lang_name = NULL;
g_signal_connect (priv->lang_list,
"row-activated",
G_CALLBACK (change_language),
self);
g_signal_connect (priv->lang,
"changed",
G_CALLBACK (filter_language),
self);
}
GtrLangButton*
gtr_lang_button_new () {
GtrLangButton *self = g_object_new (GTR_TYPE_LANG_BUTTON, NULL);
return self;
}
const gchar *
gtr_lang_button_get_lang (GtrLangButton *self)
{
GtrLangButtonPrivate *priv = gtr_lang_button_get_instance_private (self);
return priv->lang_name;
}
void
gtr_lang_button_set_lang (GtrLangButton *self,
const gchar *name)
{
GtrLangButtonPrivate *priv = gtr_lang_button_get_instance_private (self);
g_clear_pointer (&priv->lang_name, g_free);
priv->lang_name = g_strdup (name);
gtk_button_set_label (GTK_BUTTON (self), name);
g_signal_emit (self, signals[CHANGED], 0, NULL);
}
/*
* Copyright (C) 2018 Daniel Garcia Moreno <danigm@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GTR_TYPE_LANG_BUTTON (gtr_lang_button_get_type())
G_DECLARE_FINAL_TYPE (GtrLangButton, gtr_lang_button, GTR, LANG_BUTTON, GtkMenuButton)
GtrLangButton* gtr_lang_button_new ();
const gchar * gtr_lang_button_get_lang (GtrLangButton *self);
void gtr_lang_button_set_lang (GtrLangButton *self,
const gchar *name);
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkPopover" id="popup">
<property name="can_focus">False</property>
<property name="position">right</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkEntry" id="lang">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="height_request">200</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="lang_list">
<property name="name">lang_list</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<template class="GtrLangButton" parent="GtkMenuButton">
<property name="label" translatable="yes">Choose Language</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="popover">popup</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Choose Language</property>
</object>
</child>
</template>
</interface>
......@@ -22,6 +22,7 @@
#include "gtr-languages-fetcher.h"
#include "gtr-language.h"
#include "gtr-utils.h"
#include "gtr-lang-button.h"
#include <string.h>
typedef struct
......@@ -32,8 +33,8 @@ typedef struct
GtkWidget *encoding;
GtkWidget *team_email;
GtkWidget *plural_forms;
GtkWidget *advanced;
GtkListStore *language_store;
GtkListStore *code_store;
} GtrLanguagesFetcherPrivate;
......@@ -77,22 +78,6 @@ gtr_languages_fetcher_class_init (GtrLanguagesFetcherClass *klass)
0);
}
static gint
compare_languages_name (gconstpointer a,
gconstpointer b)
{
GtrLanguage *lang1, *lang2;
const gchar *name1, *name2;
lang1 = (GtrLanguage *) a;
lang2 = (GtrLanguage *) b;
name1 = gtr_language_get_name (lang1);
name2 = gtr_language_get_name (lang2);
return g_utf8_collate (name1, name2);
}
static gint
compare_languages_code (gconstpointer a,
gconstpointer b)
......@@ -119,20 +104,6 @@ append_from_languages (GtrLanguagesFetcher *fetcher)
plurals = g_hash_table_new (g_str_hash, g_int_equal);
languages = gtr_language_get_languages ();
languages = g_slist_sort ((GSList *)languages, compare_languages_name);
for (l = languages; l != NULL; l = g_slist_next (l))
{
GtrLanguage *lang = (GtrLanguage *)l->data;
GtkTreeIter iter1;
gtk_list_store_append (priv->language_store, &iter1);
gtk_list_store_set (priv->language_store, &iter1,
0, gtr_language_get_name (lang),
1, lang,
-1);
}
languages = g_slist_sort ((GSList *)languages, compare_languages_code);
for (l = languages; l != NULL; l = g_slist_next (l))
......@@ -173,12 +144,12 @@ fill_encoding_and_charset (GtrLanguagesFetcher *fetcher)
text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->charset))));
if (text == NULL || *text == '\0')
if (text == NULL || *text == '\0' || !gtk_widget_is_sensitive (priv->charset))
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->charset), 0);
text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->encoding))));
if (text == NULL || *text == '\0')
if (text == NULL || *text == '\0' || !gtk_widget_is_sensitive (priv->encoding))
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->encoding), 0);
}
......@@ -186,34 +157,19 @@ static void
fill_from_language_entry (GtrLanguagesFetcher *fetcher,
GtrLanguage *lang)
{
const gchar *entry_text;
GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
fill_encoding_and_charset (fetcher);
entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language_code))));
if (*entry_text == '\0')
{
const gchar *code;
code = gtr_language_get_code (lang);
if (code != NULL && *code != '\0')
gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language_code))), code);
}
entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))));
if (*entry_text == '\0')
{
const gchar *plural_form;
plural_form = gtr_language_get_plural_form (lang);
if (plural_form != NULL && *plural_form != '\0')
gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))), plural_form);
}
}
static void
......@@ -225,7 +181,7 @@ fill_from_language_code_entry (GtrLanguagesFetcher *fetcher,
fill_encoding_and_charset (fetcher);
entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language))));
entry_text = gtr_lang_button_get_lang (GTR_LANG_BUTTON (priv->language));
if (*entry_text == '\0')
{
......@@ -234,7 +190,7 @@ fill_from_language_code_entry (GtrLanguagesFetcher *fetcher,
name = gtr_language_get_name (lang);
if (name != NULL && *name != '\0')
gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language))), name);
gtr_lang_button_set_lang (GTR_LANG_BUTTON (priv->language), name);
}
entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))));
......@@ -254,18 +210,15 @@ typedef void (* fill_method) (GtrLanguagesFetcher *fetcher, GtrLanguage *lang);
static void
fill_boxes (GtrLanguagesFetcher *fetcher,
GtkEntry *entry,
const gchar *text,
GtkTreeModel *store,
fill_method fill)
{
const gchar *text;
gchar *entry_row;
GtkTreeIter iter;
GtrLanguage *lang;
gboolean found = FALSE;
text = gtk_entry_get_text (entry);
if (text == NULL || *text == '\0' ||
!gtk_tree_model_get_iter_first (store, &iter))
return;
......@@ -298,22 +251,25 @@ fill_boxes (GtrLanguagesFetcher *fetcher,
}
static void
on_language_activate (GtkEntry *entry,
on_language_activate (GtrLangButton *btn,
GtrLanguagesFetcher *fetcher)
{
GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
fill_boxes (fetcher, entry, GTK_TREE_MODEL (priv->language_store),
fill_from_language_entry);
}
static gboolean
on_language_focus_out_event (GtkEntry *entry,
GdkEvent *event,
GtrLanguagesFetcher *fetcher)
{
on_language_activate (entry, fetcher);
const gchar *text = gtr_lang_button_get_lang (GTR_LANG_BUTTON (priv->language));
GtrLanguage *lang;
const GSList *l;
const GSList *languages = gtr_language_get_languages ();
return FALSE;
for (l = languages; l != NULL; l = g_slist_next (l))
{
lang = (GtrLanguage*)l->data;
const gchar *langname = gtr_language_get_name (lang);
if (text != NULL && strcmp (langname, text) == 0)
{
fill_from_language_entry (fetcher, lang);
break;
}
}
}
static void
......@@ -321,7 +277,9 @@ on_language_code_activate (GtkEntry *entry,
GtrLanguagesFetcher *fetcher)
{
GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
fill_boxes (fetcher, entry, GTK_TREE_MODEL (priv->code_store),
const gchar *text = gtk_entry_get_text (entry);
fill_boxes (fetcher, text, GTK_TREE_MODEL (priv->code_store),
fill_from_language_code_entry);
}
......@@ -342,6 +300,28 @@ on_combo_box_changed (GtkWidget *widget,
g_signal_emit (fetcher, signals[CHANGED], 0, NULL);
}
static void
on_advanced_changed (GtkToggleButton *widget,
GtrLanguagesFetcher *fetcher)
{
GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
gboolean active = gtk_toggle_button_get_active (widget);
gtk_widget_set_sensitive (priv->language_code, active);
gtk_widget_set_sensitive (priv->charset, active);
gtk_widget_set_sensitive (priv->encoding, active);
gtk_widget_set_sensitive (priv->plural_forms, active);
}
static void
on_lang_changed (GtkWidget *widget,
GtrLanguagesFetcher *fetcher)
{
GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
on_language_activate (GTR_LANG_BUTTON (priv->language), fetcher);
g_signal_emit (fetcher, signals[CHANGED], 0, NULL);
}
static void
gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
{
......@@ -349,7 +329,6 @@ gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
GtkBuilder *builder;
gchar *root_objects[] = {
"main_box",
"language_store",
"code_store",
NULL
};
......@@ -358,19 +337,22 @@ gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
gtk_orientable_set_orientation (GTK_ORIENTABLE (fetcher),
GTK_ORIENTATION_VERTICAL);
g_type_ensure (gtr_lang_button_get_type ());
builder = gtk_builder_new ();
gtk_builder_add_objects_from_resource (builder, "/org/gnome/translator/gtr-languages-fetcher.ui",
root_objects, NULL);
content = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
g_object_ref (content);
priv->language = GTK_WIDGET (gtk_builder_get_object (builder, "language"));
priv->language_code = GTK_WIDGET (gtk_builder_get_object (builder, "language_code"));
priv->charset = GTK_WIDGET (gtk_builder_get_object (builder, "charset"));
priv->encoding = GTK_WIDGET (gtk_builder_get_object (builder, "encoding"));
priv->team_email = GTK_WIDGET (gtk_builder_get_object (builder, "team_email"));
priv->plural_forms = GTK_WIDGET (gtk_builder_get_object (builder, "plural_forms"));
priv->language_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "language_store"));
priv->advanced = GTK_WIDGET (gtk_builder_get_object (builder, "advanced_check"));
priv->code_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "code_store"));
g_object_unref (builder);
gtk_box_pack_start (GTK_BOX (fetcher), content, FALSE, FALSE, 0);
......@@ -378,14 +360,10 @@ gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
/* add items to comboboxes */
append_from_languages (fetcher);
g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->language)),
"activate",
g_signal_connect (G_OBJECT (priv->language),
"clicked",
G_CALLBACK (on_language_activate),
fetcher);
g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->language)),
"focus-out-event",
G_CALLBACK (on_language_focus_out_event),
fetcher);
g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->language_code)),
"activate",
G_CALLBACK (on_language_code_activate),
......@@ -397,7 +375,7 @@ gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)