gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r32332 - in gnunet-gtk: contrib src/conversation


From: gnunet
Subject: [GNUnet-SVN] r32332 - in gnunet-gtk: contrib src/conversation
Date: Thu, 13 Feb 2014 03:25:58 +0100

Author: hark
Date: 2014-02-13 03:25:58 +0100 (Thu, 13 Feb 2014)
New Revision: 32332

Modified:
   gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
   gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
   gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
Log:
make buttons become insensitive/sensitive 


Modified: gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade        
2014-02-12 20:20:59 UTC (rev 32331)
+++ gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade        
2014-02-13 02:25:58 UTC (rev 32332)
@@ -368,14 +368,15 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButtonBox" 
id="GNUNET_GTK_conversation_buttons">
-                            <property name="visible">True</property>
+                          <object class="GtkButtonBox" 
id="GNUNET_GTK_conversation_active_call_list_buttons">
                             <property name="can_focus">False</property>
+                            <property name="border_width">2</property>
                             <property name="orientation">vertical</property>
                             <property name="layout_style">start</property>
                             <child>
                               <object class="GtkImage" 
id="GNUNET_GTK_status_icon">
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">False</property>
                                 <property name="tooltip_text" 
translatable="yes">Status indicator</property>
                                 <property name="icon_name">bluefish</property>
@@ -391,6 +392,7 @@
                                 <property name="label" 
translatable="yes">import Addr</property>
                                 <property 
name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">True</property>
                                 <property 
name="use_action_appearance">False</property>
@@ -408,6 +410,7 @@
                                 <property name="label" 
translatable="yes">accept</property>
                                 <property 
name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">True</property>
                                 <property 
name="use_action_appearance">False</property>
@@ -424,6 +427,7 @@
                                 <property name="label" 
translatable="yes">hangup</property>
                                 <property 
name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">True</property>
                                 <property 
name="use_action_appearance">False</property>
@@ -436,10 +440,11 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkButton" 
id="GNUNET_GTK_conversation_pause_button">
-                                <property name="label" 
translatable="yes">pause</property>
+                              <object class="GtkButton" 
id="GNUNET_GTK_conversation_suspend_button">
+                                <property name="label" 
translatable="yes">suspend</property>
                                 <property 
name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">True</property>
                                 <property 
name="use_action_appearance">False</property>
@@ -456,6 +461,7 @@
                                 <property name="label" 
translatable="yes">resume</property>
                                 <property 
name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">True</property>
                                 <property 
name="use_action_appearance">False</property>
@@ -841,20 +847,6 @@
       </object>
     </child>
   </object>
-  <object class="GtkListStore" 
id="gnunet_conversation_gtk_active_calls_liststore">
-    <columns>
-      <!-- column-name caller_id -->
-      <column type="gchararray"/>
-      <!-- column-name caller -->
-      <column type="gpointer"/>
-      <!-- column-name caller_num -->
-      <column type="gint"/>
-      <!-- column-name caller_type -->
-      <column type="gint"/>
-      <!-- column-name caller_state -->
-      <column type="gint"/>
-    </columns>
-  </object>
   <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_liststore">
     <columns>
       <!-- column-name contactName -->
@@ -871,6 +863,20 @@
       <column type="gpointer"/>
     </columns>
   </object>
+  <object class="GtkListStore" 
id="gnunet_conversation_gtk_active_calls_liststore">
+    <columns>
+      <!-- column-name caller_id -->
+      <column type="gchararray"/>
+      <!-- column-name caller -->
+      <column type="gpointer"/>
+      <!-- column-name caller_num -->
+      <column type="gint"/>
+      <!-- column-name caller_type -->
+      <column type="gint"/>
+      <!-- column-name caller_state -->
+      <column type="gint"/>
+    </columns>
+  </object>
   <object class="GtkListStore" id="gnunet_conversation_gtk_history_liststore">
     <columns>
       <!-- column-name logTime -->

Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.c       2014-02-12 
20:20:59 UTC (rev 32331)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.c       2014-02-13 
02:25:58 UTC (rev 32332)
@@ -129,6 +129,8 @@
   gtk_statusbar_push (GTK_STATUSBAR (status_bar),
                       GPOINTER_TO_INT (status_bar_context), buff);
   g_free (buff);
+  
+  GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed();
 
 
 }
@@ -153,8 +155,6 @@
   GtkWindow *main_window;
   GtkImage *status_icon;
 
-
-
   main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
 
   status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon"));
@@ -163,8 +163,6 @@
 
   //LOG (_("Tray icon changed to: `%s' "), icon_name);
 
-
-
   GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status");
 }
 
@@ -267,7 +265,7 @@
   gint valid = 0;
   //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
 
-  LOG (_("set incoming call state:%u caller: "),state);
+//  LOG (_("set incoming call state:%u caller: "),state);
  
   valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), 
&gtkiter ); 
     
@@ -304,15 +302,14 @@
           switch (state)
             {
             case CT_hangup:
-              LOG("remove line cause hangup");
+              //LOG("remove line cause hangup");
               gtk_list_store_remove(active_liststore,&gtkiter);
             break;  
 
             case CT_rejected:
-              LOG("remove line cause rejected");
+              //LOG("remove line cause rejected");
               gtk_list_store_remove(active_liststore,&gtkiter);
             break;  
-          
             default:
                          
                gtk_list_store_set(active_liststore, &gtkiter,
@@ -329,6 +326,8 @@
        
     }//end while
 
+    //update statsbar
+    update_status("");
 
 
 }
@@ -386,19 +385,9 @@
                         ,-1);
 
 
-    //What is this callername thing? 
-//    strncpy (&callerName, &caller_id, 50);
-//    callerName[52] = '\0';
-    
-    //TODO:new call notification, should be passed a reference to the call
-    //TODO: rename: quick_message to call_notification(caller);
-//    quick_message ("der is een beller", caller_id);
-    // TODO: make sound
-
     break;
 
   case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:
-    //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:");
     //gtk
     
     valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), 
&gtkiter1 ); 
@@ -408,8 +397,7 @@
     
     while (valid)
     {
-    /* Walk through the list, reading each row */
-       //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid");
+      //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid");
 
       gchar *str_data;
       gint   int_data;
@@ -432,42 +420,10 @@
     
     
 
-    //gcl_active = NULL;
     phone_state = PS_LISTEN;
     //add to call history list
     //history_add(CH_HANGUP, cl->caller_id);
     
-
-    ///END gtk
-    
-    //old
-   /* 
-    for (cl = cl_head; NULL != cl; cl = cl->next)
-      if (caller == cl->caller)
-        break;
-
-    if (NULL == cl)
-    {
-      GNUNET_break (0);
-      return;
-    }
-    
-    LOG (_("Call from `%s' terminated\n"), cl->caller_id);
-    
-   
-    GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
-    GNUNET_free (cl->caller_id);
-    
-    //
-    if (cl == cl_active)
-    {
-      cl_active = NULL;
-      phone_state = PS_LISTEN;
-    }
-    GNUNET_free (cl);
-    */
-    //destroy call accept dialog
-    //gtk_widget_destroy (GTK_WIDGET (dialog));
     break;
 
   }
@@ -488,12 +444,10 @@
   switch (code)
   {
   case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
-    update_state ();
     set_incoming_call_state(cls,CT_suspended);
     LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id);
     break;
   case GNUNET_CONVERSATION_EC_CALLER_RESUME:
-    update_state ();
     set_incoming_call_state(cls,CT_active);
     LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id);
     break;
@@ -791,7 +745,7 @@
       if (cl == cl_active)
         continue;
       //UPDATE_STATUS (_("#%u: `%s'"), cl->caller_num, cl->caller_id);
-      LOG ("%s", _("Calls waiting:"));
+//      LOG ("%s", _("Calls waiting:"));
     }
   }
 }
@@ -857,7 +811,7 @@
 {
   struct CallList *cl;
   char buf[32];
-
+/*
   if (NULL != call)
   {
     switch (call_state)
@@ -873,6 +827,7 @@
       return;
     }
   }
+*/
   switch (phone_state)
   {
   case PS_LOOKUP_EGO:
@@ -880,14 +835,13 @@
     LOG ("%s", _("There is no call that could be resumed right now."));
     return;
   case PS_LISTEN:
-    /* expected state, do resume logic */
     break;
   case PS_ACCEPTED:
     LOG (_("Already talking with `%s', cannot resume a call right now."),
          peer_name);
     return;
   }
-  
+  /*
   GNUNET_assert (NULL == cl_active);
   cl = cl_head;
   if (NULL == cl)
@@ -908,10 +862,10 @@
     return;
   }
   cl_active = cl;
+  */
   
+  GNUNET_CONVERSATION_caller_resume (sel_caller, speaker, mic);
   set_incoming_call_state(sel_caller,CT_active);
-
-  GNUNET_CONVERSATION_caller_resume (sel_caller, speaker, mic);
   phone_state = PS_ACCEPTED;
 }
 
@@ -926,15 +880,15 @@
 {
   struct CallList *cl;
   char buf[32];
-  LOG("do reject");
-//  set_incoming_call_state(sel_caller,CT_rejected);
 
+  /*
   if (NULL != call)
   {
     GNUNET_CONVERSATION_call_stop (call);
     call = NULL;
     return;
   }
+  */
   switch (phone_state)
   {
   case PS_LOOKUP_EGO:
@@ -990,7 +944,7 @@
     */
     set_incoming_call_state(sel_caller,CT_hangup);
     GNUNET_CONVERSATION_caller_hang_up(sel_caller);
-    cl_active = NULL;
+    //cl_active = NULL;
     phone_state = PS_LISTEN;
     break;
   }
@@ -1441,86 +1395,18 @@
 //  FPRINTF (stderr, "line %i", line);
 }
 
-/* gui stuff start */
-/*
- * Accept call window
- * TODO: rename this
- *
- * @param message message in the dialogbox
- * @param caller_id
- */
-
-/*
-void
-quick_message (gchar * message, const char *caller_id)
-{
-  GtkWidget *caller_name, *notification, *content_area;
-  GtkWidget *dialog;
-  GtkWindow *main_window;
-
-  main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
-  // Create the widgets
-
-
-  dialog =
-      gtk_dialog_new_with_buttons ("Incoming call!", main_window,
-                                   GTK_DIALOG_DESTROY_WITH_PARENT,
-                                   _("Accept call"), GTK_RESPONSE_ACCEPT,
-                                   _("Reject call"), GTK_RESPONSE_REJECT,
-                                   _("Decide later"), GTK_RESPONSE_CANCEL,
-                                   NULL);
-  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
-
-  notification = gtk_label_new ("Incoming call from:");
-  caller_name = gtk_label_new (caller_id);
-
-  // Add the labels, and show everything we've added to the dialog
-  gtk_container_add (GTK_CONTAINER (content_area), notification);
-  gtk_container_add (GTK_CONTAINER (content_area), caller_name);
-  gtk_widget_show_all (GTK_WIDGET (dialog));
-
-  switch (gtk_dialog_run (GTK_DIALOG (dialog)))
-  {
-  case GTK_RESPONSE_ACCEPT:
-    do_status ("");
-    gtk_widget_destroy (GTK_WIDGET (dialog));
-//    do_accept ("0");
-    break;
-  case GTK_RESPONSE_REJECT:
-//    do_reject (caller_selected);
-    do_status ("");
-    gtk_widget_destroy (GTK_WIDGET (dialog));
-    break;
-  case GTK_RESPONSE_CANCEL:
-    do_status ("");
-    gtk_widget_destroy (GTK_WIDGET (dialog));
-    break;
-  }
-
-
-}
-*/
-
-
-
 /**
  * call clicked
  */
 void
 GNUNET_CONVERSATION_GTK_on_call_clicked ()
 {
-//  char *to_addr = malloc((MAX_TO_ADDR+1)*sizeof(char));
   char *to_addr;
   GtkEntry *address_entry;
 
   address_entry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_address"));
   to_addr = gtk_entry_get_text (address_entry);
 
-//  strncpy(to_addr, gtk_entry_get_text (address_entry), MAX_TO_ADDR);
-//  to_addr[strlen(to_addr)+1] = '\0';
-//    FPRINTF (stderr, _("calling: %s \n"), to_addr );
-
   do_call (to_addr);
   //disable_button ("GNUNET_GTK_conversation_accept_button");
   do_status ();
@@ -1566,7 +1452,6 @@
 void
 GNUNET_CONVERSATION_GTK_on_reject_clicked ()
 {
-  LOG ("reject clicked \n");
   do_reject (caller_selected);
 }
 
@@ -1576,14 +1461,7 @@
 void
 GNUNET_CONVERSATION_GTK_on_pause_clicked ()
 {
-//    GtkEntry *entry;
   do_suspend (caller_selected);
-  //FPRINTF (stderr, "pause clicked \n");
-  //do_pause("");
-  //  entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address")));
-  //FPRINTF (stderr, gtk_entry_get_text (entry));
-//    gtk_entry_set_text (entry, "testtextje");
-//  show_infobar ();
 }
 
 /**
@@ -1592,7 +1470,6 @@
 void
 GNUNET_CONVERSATION_GTK_on_resume_clicked ()
 {
-  //FPRINTF (stderr, "reject clicked \n");
   do_resume (caller_selected);
 }
 
@@ -1602,11 +1479,7 @@
 void
 GNUNET_CONVERSATION_GTK_on_status_clicked ()
 {
-
-
-//    do_accept("0");
   do_status ();
-  //quick_message('hee blaaat you have a call from blaat');
 }
 
 
@@ -1881,7 +1754,7 @@
                       0, &tempName,
                       1, &tempEgo,
                       -1);
-  FPRINTF(stderr,"blat: %s\n", tempName);
+//  FPRINTF(stderr,"blat: %s\n", tempName);
   temp_zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo);
   gtk_list_store_clear(contacts_liststore);
 /*
@@ -1945,7 +1818,6 @@
     gboolean valid;
     gint row_count = 0;
 
-    //LOG("test");
     valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), 
&gtkiter ); 
     
     if (!valid) 
@@ -1965,7 +1837,7 @@
       {
        // LOG (_("info for active call:%s number: %u row: %u"), 
str_data,int_data,row_count);
         currentlySelectedCallAddress = str_data;
-       FPRINTF(stderr,"cal addr: %s\n",currentlySelectedCallAddress);
+//     FPRINTF(stderr,"cal addr: %s\n",currentlySelectedCallAddress);
         break ;
       }
     g_free (str_data);
@@ -1978,14 +1850,25 @@
 }
 
 /*
- * @brief executed when selecting a call
+ * @brief executed when selecting a different item in active call list
  */
 
 void
 GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed()
 {
+    update_active_call_list_buttons();
+}
+
+/*
+ * @brief sets caller_selected, and enables or disables the active call list 
buttons
+ */
+void
+update_active_call_list_buttons()
+{
    gchar *caller_id;
    gpointer cl_caller;
+   gint     cl_caller_state;
+   gint     cl_caller_type;
    GtkTreeSelection *active_selection;
    GtkTreeIter gcl_selected;
 //   active_liststore_selection = 
get_object("GNUNET_CONVERSATION_GTK_active_calls_selection");
@@ -1999,15 +1882,103 @@
         gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected, 
                             AL_caller, &cl_caller,
                             AL_caller_id, &caller_id,
+                            AL_caller_state, &cl_caller_state,
                             -1);
                  
         caller_selected = cl_caller;
 
-        //LOG("SELECTION: %s ",caller_id);
-        print_call_info();    
+        
gtk_widget_show(get_object("GNUNET_GTK_conversation_active_call_list_buttons" 
));
 
+
+        // make global?
+        GtkWidget *b_contact, *b_accept, *b_hangup, *b_suspend, *b_resume;
+        b_contact = GTK_WIDGET (get_object 
("GNUNET_GTK_conversation_use_current_button"));
+        b_accept  = GTK_WIDGET (get_object 
("GNUNET_GTK_conversation_accept_button"));
+        b_hangup  = GTK_WIDGET (get_object 
("GNUNET_GTK_conversation_hangup_button"));
+        b_suspend = GTK_WIDGET (get_object 
("GNUNET_GTK_conversation_suspend_button"));
+        b_resume  = GTK_WIDGET (get_object 
("GNUNET_GTK_conversation_resume_button"));
+
+        
+        switch (cl_caller_state) 
+        {
+            /* buttons:
+             *  contact
+             *  accept
+             *  hangup
+             *  suspend
+             *  resume
+             *
+             *  TODO: check if there is incoming or outgoing call, 
+             *         disable resume and accept buttons.
+             *         or suspend that other call
+             */
+
+            case CT_active:
+            // hangup, pause
+            //LOG("CT_active state: %u ",cl_caller_state);
+            gtk_widget_set_sensitive(b_contact, 1);
+            gtk_widget_set_sensitive(b_accept, 0);
+            gtk_widget_set_sensitive(b_hangup, 1);
+            gtk_widget_set_sensitive(b_suspend, 1);
+            gtk_widget_set_sensitive(b_resume, 0);
+            break;
+            case CT_ringing:
+            // pickup, phonebook
+            //LOG("CT_ring show button");
+            gtk_widget_set_sensitive(b_contact, 1);
+            if (phone_state == PS_LISTEN)
+            {
+            gtk_widget_set_sensitive(b_accept, 1);
+            }else{
+            gtk_widget_set_sensitive(b_accept, 0);
+            }
+
+            
+            gtk_widget_set_sensitive(b_hangup, 0);
+            gtk_widget_set_sensitive(b_suspend, 0);
+            gtk_widget_set_sensitive(b_resume, 0);
+            break;
+            case CT_rejected:
+            //add to phonebook
+            //LOG("CT_rejected ");
+            gtk_widget_set_sensitive(b_contact, 1);
+            gtk_widget_set_sensitive(b_accept, 0);
+            gtk_widget_set_sensitive(b_hangup, 0);
+            gtk_widget_set_sensitive(b_suspend, 0);
+            gtk_widget_set_sensitive(b_resume, 0);
+
+            break;
+            case CT_suspended:
+            // resume, hangup
+            //LOG("CT_suspended ");
+            gtk_widget_set_sensitive(b_contact, 1 );
+            gtk_widget_set_sensitive(b_accept, 0);
+            gtk_widget_set_sensitive(b_hangup, 1);
+            gtk_widget_set_sensitive(b_suspend, 0);
+            //gtk_widget_set_sensitive(b_resume, 1);
+            if (phone_state == PS_LISTEN)
+            {
+            gtk_widget_set_sensitive(b_resume, 1);
+            }else{
+            gtk_widget_set_sensitive(b_resume, 0);
+            }
+            break;
+            default:
+            GNUNET_break(0);
+            break;
+        }        
+       print_call_info();    
    }
-}
+   else
+   {
+    
+    LOG("nothing selected");
+    
+    
gtk_widget_hide(get_object("GNUNET_GTK_conversation_active_call_list_buttons" 
));
+    
+   }
+
+} //end function
 /*
  * @brief active call list type data function
  */

Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.h       2014-02-12 
20:20:59 UTC (rev 32331)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.h       2014-02-13 
02:25:58 UTC (rev 32332)
@@ -65,6 +65,7 @@
 /**
  * callerstate (state of incoming call)
  */
+
 enum {
   CT_active,
   CT_suspended,
@@ -73,6 +74,7 @@
   CT_hangup,
   CT_rejected
 };
+
 /**
  * type of call
  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]