~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-client-gnome/src/contacts/calltree.c

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2011-04-05 14:14:13 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110405141413-hbwbunfsxpn2rtre
Tags: 0.9.13-1
* New upstream release
  - remove Debian patch (applied upstream)
* Fix watch file
* Remove unnecessary versioned dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include "../imwindow.h"
44
44
#include "searchbar.h"
45
45
 
 
46
// Messages used in menu item
 
47
#define SFL_CREATE_CONFERENCE "Create conference"
 
48
#define SFL_TRANSFER_CALL "Transfer call to"
 
49
 
46
50
GtkWidget *sw;
47
51
GtkCellRenderer *rend;
48
52
GtkTreeViewColumn *col;
49
53
GtkTreeSelection *sel;
50
54
 
 
55
GtkWidget *popupmenu = NULL;
 
56
GtkWidget *menu_items = NULL;
 
57
 
51
58
gint dragged_type;
52
59
gint selected_type;
53
60
 
70
77
static void drag_begin_cb (GtkWidget *widget, GdkDragContext *dc, gpointer data);
71
78
static void drag_end_cb (GtkWidget * mblist, GdkDragContext * context, gpointer data);
72
79
void drag_data_received_cb (GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data);
73
 
 
 
80
static void menuitem_response (gchar *);
74
81
 
75
82
enum {
76
83
    COLUMN_ACCOUNT_STATE = 0,
533
540
void
534
541
calltree_create (calltab_t* tab, gboolean searchbar_type)
535
542
{
 
543
    gchar *conference = SFL_CREATE_CONFERENCE;
 
544
    gchar *transfer = SFL_TRANSFER_CALL;
 
545
 
536
546
 
537
547
    tab->tree = gtk_vbox_new (FALSE, 10);
538
548
 
594
604
        // destination widget drag n drop signals
595
605
        g_signal_connect (G_OBJECT (tab->view), "drag_data_received", G_CALLBACK (drag_data_received_cb), NULL);
596
606
 
 
607
        popupmenu = gtk_menu_new ();
 
608
 
 
609
        menu_items = gtk_menu_item_new_with_label (transfer);
 
610
        g_signal_connect_swapped (menu_items, "activate",
 
611
                                  G_CALLBACK (menuitem_response), (gpointer) g_strdup (transfer));
 
612
        gtk_menu_shell_append (GTK_MENU_SHELL (popupmenu), menu_items);
 
613
        gtk_widget_show (menu_items);
 
614
 
 
615
        menu_items = gtk_menu_item_new_with_label (conference);
 
616
        g_signal_connect_swapped (menu_items, "activate",
 
617
                                  G_CALLBACK (menuitem_response), (gpointer) g_strdup (conference));
 
618
        gtk_menu_shell_append (GTK_MENU_SHELL (popupmenu), menu_items);
 
619
        gtk_widget_show (menu_items);
 
620
 
 
621
 
 
622
 
597
623
    }
598
624
 
599
625
 
1561
1587
                    // draged a call on itself
1562
1588
                } else {
1563
1589
                    // dragged a single call on a single call
1564
 
                    if (selected_call != NULL && dragged_call != NULL)
1565
 
                        sflphone_join_participant (selected_call->_callID, dragged_call->_callID);
 
1590
                    if (selected_call != NULL && dragged_call != NULL) {
 
1591
                        calltree_remove_call (current_calls, selected_call, NULL);
 
1592
                        calltree_add_call (current_calls, selected_call, NULL);
 
1593
                        gtk_menu_popup (GTK_MENU (popupmenu), NULL, NULL, NULL, NULL,
 
1594
                                               0, 0);
 
1595
 
 
1596
                        // sflphone_join_participant (selected_call->_callID, dragged_call->_callID);
 
1597
                    }
1566
1598
                }
1567
1599
            } else if (selected_type == A_CALL && dragged_type == A_CONFERENCE) {
1568
1600
 
1635
1667
        }
1636
1668
    } else {
1637
1669
 
1638
 
        // selected_path_depth == 2
1639
 
 
1640
1670
        if (dragged_path_depth == 1) {
1641
1671
 
1642
1672
            if (selected_type == A_CALL && dragged_type == A_CALL) {
1644
1674
                // dragged a conference call on a call
1645
1675
                sflphone_detach_participant (selected_call_id);
1646
1676
 
1647
 
                if (selected_call != NULL && dragged_call != NULL)
1648
 
                    sflphone_join_participant (selected_call->_callID, dragged_call->_callID);
 
1677
                if (selected_call != NULL && dragged_call != NULL) {
 
1678
                    // sflphone_join_participant (selected_call->_callID, dragged_call->_callID);
 
1679
                    gtk_menu_popup (GTK_MENU (popupmenu), NULL, NULL, NULL, NULL,
 
1680
                                                                   0, 0);
 
1681
 
 
1682
                }
1649
1683
 
1650
1684
            } else if (selected_type == A_CALL && dragged_type == A_CONFERENCE) {
1651
1685
 
1682
1716
                DEBUG ("Dragged a call in the same conference");
1683
1717
                calltree_remove_call (current_calls, selected_call, NULL);
1684
1718
                calltree_add_call (current_calls, selected_call, &parent_conference);
 
1719
                gtk_widget_hide(menu_items);
 
1720
                gtk_menu_popup (GTK_MENU (popupmenu), NULL, NULL, NULL, NULL,
 
1721
                                                               0, 0);
1685
1722
            } else {
1686
1723
 
1687
1724
 
1812
1849
        }
1813
1850
    }
1814
1851
}
 
1852
 
 
1853
/* Print a string when a menu item is selected */
 
1854
 
 
1855
static void menuitem_response( gchar *string )
 
1856
{
 
1857
    if(g_strcmp0(string, SFL_CREATE_CONFERENCE) == 0) {
 
1858
        sflphone_join_participant (selected_call->_callID, dragged_call->_callID);
 
1859
    }
 
1860
    else if(g_strcmp0(string, SFL_TRANSFER_CALL) == 0) {
 
1861
        g_print("Calltree: Transfering call %s, to %s", selected_call->_peer_number, dragged_call->_peer_number);
 
1862
        dbus_attended_transfer(selected_call, dragged_call);
 
1863
        calltree_remove_call(current_calls, selected_call, NULL);
 
1864
    }
 
1865
    else {
 
1866
        g_print("CallTree: Error unknown option selected in menu %s", string);
 
1867
    }
 
1868
 
 
1869
    // Make sure the create conference opetion will appear next time the menu pops
 
1870
    // The create conference option will hide if tow call from the same conference are draged on each other
 
1871
    gtk_widget_show(menu_items);
 
1872
 
 
1873
    printf ("%s\n", string);
 
1874
}
 
1875