[chronojump/optimizeRFD] New products language can be changed
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/optimizeRFD] New products language can be changed
- Date: Sun, 3 Jan 2021 17:07:56 +0000 (UTC)
commit 6cdf8541f308a33df8eb5a594e6750133a5ac58e
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Dec 29 21:14:29 2020 +0100
New products language can be changed
glade/app1.glade | 89 ++++++++++++++++++++++++++++++++++++++++++++--------
src/gui/app1/menu.cs | 2 +-
src/gui/app1/news.cs | 48 ++++++++++++++++++++++++----
3 files changed, 119 insertions(+), 20 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 602d1b1f8..ec2232901 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -23580,6 +23580,9 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -28426,18 +28429,6 @@ Concentric</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Tests
will be filmed</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
<widget class="GtkHBox"
id="hbox_video_encoder_capturing">
<property name="can_focus">False</property>
<property name="spacing">4</property>
@@ -28474,6 +28465,18 @@ Concentric</property>
</packing>
</child>
<child>
+ <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Tests
will be filmed</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox"
id="hbox_video_encoder_no_capturing">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -36717,6 +36720,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -42602,6 +42608,63 @@ then click this button.</property>
<widget class="GtkVBox" id="vbox148">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <child>
+ <widget class="GtkHBox" id="hbox451">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkHBox" id="hbox452">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">16</property>
+ <child>
+ <widget class="GtkRadioButton"
id="radio_news_language_english">
+ <property name="label"
translatable="yes">English</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled"
handler="on_radio_news_language_english_toggled" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton"
id="radio_news_language_spanish">
+ <property name="label"
translatable="yes">Spanish</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property
name="group">radio_news_language_english</property>
+ <signal name="toggled"
handler="on_radio_news_language_spanish_toggled" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<widget class="GtkHBox" id="hbox443">
<property name="visible">True</property>
@@ -42675,7 +42738,7 @@ then click this button.</property>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
diff --git a/src/gui/app1/menu.cs b/src/gui/app1/menu.cs
index 7963d7ba7..62881a247 100644
--- a/src/gui/app1/menu.cs
+++ b/src/gui/app1/menu.cs
@@ -310,7 +310,7 @@ public partial class ChronoJumpWindow
private void on_button_menu_news_clicked (object o, EventArgs args)
{
//fill the widget
- news_fill(newsAtDB_l, preferences.newsLanguageEs);
+ news_fill(preferences.newsLanguageEs);
//sensitivity and notebook management
menus_and_mode_sensitive(false);
diff --git a/src/gui/app1/news.cs b/src/gui/app1/news.cs
index 2d08eb415..24a502853 100644
--- a/src/gui/app1/news.cs
+++ b/src/gui/app1/news.cs
@@ -30,27 +30,39 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_news_yellow;
[Widget] Gtk.Label label_news_frame;
[Widget] Gtk.Alignment alignment_news;
+ [Widget] Gtk.RadioButton radio_news_language_english;
+ [Widget] Gtk.RadioButton radio_news_language_spanish;
[Widget] Gtk.Label label_news_title;
[Widget] Gtk.Label label_news_description_and_link;
[Widget] Gtk.Image image_news;
Pixbuf image_news_pixbuf;
- private void news_fill (List<News> news_l, bool langEs)
+ private void news_fill (bool langEs)
{
- if(news_l.Count == 0)
+ if(newsAtDB_l.Count == 0)
return;
- News news = news_l[0];
+ if(langEs)
+ radio_news_language_spanish.Active = true;
+ else
+ radio_news_language_english.Active = true;
- label_news_title.Text = "<b>" + news.GetTitle(langEs) + "</b>";
- label_news_title.UseMarkup = true;
- label_news_description_and_link.Text = news.GetDescription(langEs) + "\n\n" +
news.GetLink(langEs);
+ News news = newsAtDB_l[0];
+ news_setLabels(news, langEs);
news_loadImage(news);
+
alignment_news.Show(); // is hidden at beginning to allow being well shown when filled
}
+ private void news_setLabels(News news, bool langEs)
+ {
+ label_news_title.Text = "<b>" + news.GetTitle(langEs) + "</b>";
+ label_news_title.UseMarkup = true;
+ label_news_description_and_link.Text = news.GetDescription(langEs) + "\n\n" +
news.GetLink(langEs);
+ }
+
private void news_loadImage(News news)
{
//TODO: share method for getting extension
@@ -70,4 +82,28 @@ public partial class ChronoJumpWindow
}
}
+ private void on_radio_news_language_english_toggled (object o, EventArgs args)
+ {
+ newsLanguageRadioChanged(false);
+ }
+ private void on_radio_news_language_spanish_toggled (object o, EventArgs args)
+ {
+ newsLanguageRadioChanged(true);
+ }
+ private void newsLanguageRadioChanged (bool langEs)
+ {
+ // 1) update preferences.newsLanguageEs and also SQL
+ Sqlite.Open();
+ preferences.newsLanguageEs = Preferences.PreferencesChange(
+ SqlitePreferences.NewsLanguageEs, preferences.newsLanguageEs,
+ langEs);
+ Sqlite.Close();
+
+ // 2) rewrite the labels
+ if(newsAtDB_l.Count == 0)
+ return;
+
+ News news = newsAtDB_l[0];
+ news_setLabels(news, langEs);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]