[chronojump] SocialPoll is sent ok (and care for security of other entry)



commit 943ab14799ec3cea6afc13bde12079bda593065b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 8 14:13:31 2021 +0200

    SocialPoll is sent ok (and care for security of other entry)

 glade/app1.glade          | 32 +++++++++++++++---------
 src/gui/sendLogAndPoll.cs | 64 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 12 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 9671c84ef..c40e15292 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -25684,6 +25684,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -31881,6 +31884,18 @@ 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>
@@ -31917,18 +31932,6 @@ 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>
@@ -41008,6 +41011,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -48736,6 +48742,7 @@ then click this button.</property>
                                                             <property 
name="secondary_icon_activatable">False</property>
                                                             <property 
name="primary_icon_sensitive">True</property>
                                                             <property 
name="secondary_icon_sensitive">True</property>
+                                                            <signal name="changed" 
handler="on_entry_social_network_poll_other_changed" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -48794,6 +48801,7 @@ then click this button.</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="can_default">True</property>
                                                             <property 
name="receives_default">False</property>
+                                                            <signal name="clicked" 
handler="on_button_social_network_poll_send_clicked" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
diff --git a/src/gui/sendLogAndPoll.cs b/src/gui/sendLogAndPoll.cs
index c5cc0c9e4..796c0e2ef 100644
--- a/src/gui/sendLogAndPoll.cs
+++ b/src/gui/sendLogAndPoll.cs
@@ -44,8 +44,15 @@ public partial class ChronoJumpWindow
 
        //--- send poll ----
 
+       [Widget] Gtk.RadioButton radio_social_network_poll_nsnc;
+       [Widget] Gtk.RadioButton radio_social_network_poll_facebook;
+       [Widget] Gtk.RadioButton radio_social_network_poll_instagram;
+       [Widget] Gtk.RadioButton radio_social_network_poll_tiktok;
+       [Widget] Gtk.RadioButton radio_social_network_poll_twitch;
+       [Widget] Gtk.RadioButton radio_social_network_poll_youtube;
        [Widget] Gtk.RadioButton radio_social_network_poll_other;
        [Widget] Gtk.Entry entry_social_network_poll_other;
+       [Widget] Gtk.Button button_social_network_poll_send;
 
 
        //--- send log ----
@@ -149,6 +156,63 @@ public partial class ChronoJumpWindow
        private void on_radio_social_network_poll_toggled (object o, EventArgs args)
        {
                entry_social_network_poll_other.Sensitive = (o == (object) radio_social_network_poll_other);
+
+               button_social_network_poll_send_sensitivity();
+       }
+
+       private void on_entry_social_network_poll_other_changed (object o, EventArgs args)
+       {
+               button_social_network_poll_send_sensitivity();
+       }
+
+       private void button_social_network_poll_send_sensitivity()
+       {
+               button_social_network_poll_send.Sensitive =
+                       ! (radio_social_network_poll_other.Active && entry_social_network_poll_other.Text == 
"");
+       }
+
+       private void on_button_social_network_poll_send_clicked (object o, EventArgs args)
+       {
+               string socialNetwork = "";
+               if(radio_social_network_poll_nsnc.Active)
+                       socialNetwork = "NSNC";
+               else if(radio_social_network_poll_facebook.Active)
+                       socialNetwork = "Facebook";
+               else if(radio_social_network_poll_instagram.Active)
+                       socialNetwork = "Instagram";
+               else if(radio_social_network_poll_tiktok.Active)
+                       socialNetwork = "TikTok";
+               else if(radio_social_network_poll_twitch.Active)
+                       socialNetwork = "Twitch";
+               else if(radio_social_network_poll_youtube.Active)
+                       socialNetwork = "Youtube";
+               else if(radio_social_network_poll_other.Active)
+                       socialNetwork = Util.MakeValidSQLAndFileName(entry_social_network_poll_other.Text);
+
+               Json js = new Json();
+               bool success = js.SocialNetworkPoll(preferences.machineID, socialNetwork);
+
+               LogB.Information(string.Format("on_button_social_network_poll_send_clicked, success: {0}, 
message: {1}", success, js.ResultMessage));
+               /*
+               if(success) {
+                       button_send_log.Label = Catalog.GetString("Thanks");
+                       button_send_log.Sensitive = false;
+
+                       image_send_log_yes.Show();
+                       image_send_log_no.Hide();
+                       LogB.Information(js.ResultMessage);
+               } else {
+                       button_send_log.Label = Catalog.GetString("Try again");
+
+                       image_send_log_yes.Hide();
+                       image_send_log_no.Show();
+                       LogB.Error(js.ResultMessage);
+               }
+
+               TextBuffer tb = new TextBuffer (new TextTagTable());
+               tb.Text = js.ResultMessage;
+               textview_send_log_message.Buffer = tb;
+               */
        }
 
        //--- send log and send poll----


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]