[gnome-chess/chess-telepathy-networking-support-664946-rebase: 28/64] Create a chat channel on clicking chat



commit c92fb33e0729477a21ee142338a64f69fd599294
Author: Chandni Verma <chandniverma2112 gmail com>
Date:   Wed Sep 5 18:21:21 2012 +0530

    Create a chat channel on clicking chat

 libgames-contacts/GamesContacts-1.0.vapi |    4 ++++
 src/chess-launcher.vala                  |   26 +++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/libgames-contacts/GamesContacts-1.0.vapi b/libgames-contacts/GamesContacts-1.0.vapi
index 856ce8f..3773b44 100644
--- a/libgames-contacts/GamesContacts-1.0.vapi
+++ b/libgames-contacts/GamesContacts-1.0.vapi
@@ -218,6 +218,8 @@ namespace GamesContacts
         [CCode (has_construct_function = false)]
         protected Contact ();
         public bool can_do_action (GamesContacts.ActionType action_type);
+        public static GamesContacts.Contact dup_best_for_action (Folks.Individual individual,
+          GamesContacts.ActionType action_type);
         public bool can_play_glchess ();
         public static bool equal (void* contact1, void* contact2);
         public unowned string get_alias ();
@@ -393,5 +395,7 @@ namespace GamesContacts
         NONE,
         GROUPS_SAVE
     }
+    [CCode (cheader_filename = "games-channel-request-utils.h")]
+    public static void chat_with_contact (GamesContacts.Contact contact, int64 timestamp);
 }
 
diff --git a/src/chess-launcher.vala b/src/chess-launcher.vala
index 7276e7f..2cb7010 100644
--- a/src/chess-launcher.vala
+++ b/src/chess-launcher.vala
@@ -487,7 +487,31 @@ public class ChessLauncher : Gtk.Window
         }
     }
 
-//    [CCode (cname = "G_MODULE_EXPORT chat_clicked_cb", instance_pos = -1)]
+    [CCode (cname = "G_MODULE_EXPORT chat_clicked_cb", instance_pos = -1)]
+    public void chat_clicked_cb (Gtk.Button button)
+    {
+      unowned Gtk.TreeModel individual_store;
+      Gtk.TreeIter iter;
+      Folks.Individual? individual = null;
+      GamesContacts.Contact contact;
+      int64 timestamp = TelepathyGLib.user_action_time_from_x11 (0);
+
+      var selection = individual_view.get_selection ();
+      if (selection.get_selected (out individual_store, out iter))
+      {
+          (individual_store)  get (iter,
+              GamesContacts.IndividualStoreCol.INDIVIDUAL, out individual);
+
+          if (individual != null)
+          {
+              contact = GamesContacts.Contact.dup_best_for_action (
+                  individual, GamesContacts.ActionType.PLAY_GLCHESS);
+
+              GamesContacts.chat_with_contact (contact, timestamp);
+          }
+      }
+    }
+
     [CCode (cname = "G_MODULE_EXPORT remote_player_selected_cb", instance_pos = -1)]
     public void remote_player_selected_cb (Gtk.Button button)
     {



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