~ubuntu-branches/ubuntu/precise/empathy/precise-proposed-201205180810

« back to all changes in this revision

Viewing changes to libempathy-gtk/empathy-contact-list-view.c

  • Committer: Bazaar Package Importer
  • Author(s): Brian Curtis, Brian Curtis, Ken VanDine
  • Date: 2011-06-01 10:35:24 UTC
  • mfrom: (1.1.70 upstream) (6.3.44 experimental)
  • Revision ID: james.westby@ubuntu.com-20110601103524-wx3wgp71394730jt
Tags: 3.1.1-1ubuntu1
[ Brian Curtis ]
* Merge with Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Drop geoclue/mapping build-depends (they are in Universe)
  - Add Vcz-Bzr link
  - Add Suggests on telepathy-idle
  - Bump telepathy-butterfly, telepathy-haze to recommends
  - Don't recommend the freedesktop sound theme we have an ubuntu one
  - Add build depend for libunity-dev
* debian/rules:
  - Use autoreconf.mk
  - Disable map and location
* debian/empathy.install:
  - Install message indicator configuration
* debian/indicators/empathy:
  - Message indicator configuration
* debian/patches/01_lpi.patch:
  - Add Launchpad integration
* debian/patches/10_use_notify_osd_icons.patch:
  - Use the notify-osd image for new messages
* debian/patches/34_start_raised_execpt_in_session.patch
  - If not started with the session, we should always raise
* debian/patches/36_chat_window_default_size.patch:
  - Make the default chat window size larger
* debian/patches/37_facebook_default.patch:
  - Make facebook the default chat account type
* debian/patches/38_lp_569289.patch
  - Set freenode as default IRC network for new IRC accounts 
* debian/patches/41_unity_launcher_progress.patch
  - Display file transfer progress in the unity launcher

[ Ken VanDine ]
* debian/control
  - build depend on libgcr-3-dev instead of libgcr-dev
  - dropped build depends for libindicate, we will use telepathy-indicator
  - Depend on dconf-gsettings-backend | gsettings-backend
  - Added a Recommends for telepathy-indicator
* +debian/empathy.gsettings-override
  - Added an override for notifications-focus
* debian/patches/series
  - commented out 23_idomessagedialog_for_voip_and_ft.patch, until ido has 
    been ported to gtk3

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <libempathy/empathy-tp-contact-factory.h>
38
38
#include <libempathy/empathy-contact-list.h>
39
39
#include <libempathy/empathy-contact-groups.h>
40
 
#include <libempathy/empathy-dispatcher.h>
 
40
#include <libempathy/empathy-request-util.h>
41
41
#include <libempathy/empathy-utils.h>
42
42
 
43
43
#include "empathy-contact-list-view.h"
112
112
        { "text/contact-id", 0, DND_DRAG_TYPE_CONTACT_ID },
113
113
};
114
114
 
115
 
static GdkAtom drag_atoms_dest[G_N_ELEMENTS (drag_types_dest)];
116
 
static GdkAtom drag_atoms_source[G_N_ELEMENTS (drag_types_source)];
117
 
 
118
115
enum {
119
116
        DRAG_CONTACT_RECEIVED,
120
117
        LAST_SIGNAL
396
393
        const gchar   *contact_id = NULL;
397
394
        gchar         *new_group = NULL;
398
395
        gchar         *old_group = NULL;
399
 
        gboolean       success = TRUE;
400
396
        gboolean       new_group_is_fake, old_group_is_fake = TRUE;
401
397
 
402
398
        priv = GET_PRIV (view);
440
436
 
441
437
        if (!connection) {
442
438
                DEBUG ("Failed to get connection for account '%s'", account_id);
443
 
                success = FALSE;
444
439
                g_free (new_group);
445
440
                g_free (old_group);
446
441
                g_object_unref (account_manager);
763
758
        str = g_strconcat (account_id, ":", contact_id, NULL);
764
759
 
765
760
        if (info == DND_DRAG_TYPE_CONTACT_ID) {
766
 
                gtk_selection_data_set (selection, drag_atoms_source[info], 8,
 
761
                gtk_selection_data_set (selection,
 
762
                                        gdk_atom_intern ("text/contact-id", FALSE), 8,
767
763
                                        (guchar *) str, strlen (str) + 1);
768
764
        }
769
765
 
803
799
        guint32                 time;
804
800
} MenuPopupData;
805
801
 
 
802
static void
 
803
menu_deactivate_cb (GtkMenuShell *menushell,
 
804
                    gpointer user_data)
 
805
{
 
806
        /* FIXME: we shouldn't have to disconnec the signal (bgo #641327) */
 
807
        g_signal_handlers_disconnect_by_func (menushell,
 
808
                menu_deactivate_cb, user_data);
 
809
 
 
810
        gtk_menu_detach (GTK_MENU (menushell));
 
811
}
 
812
 
806
813
static gboolean
807
814
contact_list_view_popup_menu_idle_cb (gpointer user_data)
808
815
{
815
822
        }
816
823
 
817
824
        if (menu) {
818
 
                g_signal_connect (menu, "deactivate",
819
 
                                  G_CALLBACK (gtk_menu_detach), NULL);
820
825
                gtk_menu_attach_to_widget (GTK_MENU (menu),
821
826
                                           GTK_WIDGET (data->view), NULL);
822
827
                gtk_widget_show (menu);
823
828
                gtk_menu_popup (GTK_MENU (menu),
824
829
                                NULL, NULL, NULL, NULL,
825
830
                                data->button, data->time);
 
831
 
 
832
                /* menu is initially unowned but gtk_menu_attach_to_widget () taked its
 
833
                 * floating ref. We can either wait that the treeview releases its ref
 
834
                 * when it will be destroyed (when leaving Empathy) or explicitely
 
835
                 * detach the menu when it's not displayed any more.
 
836
                 * We go for the latter as we don't want to keep useless menus in memory
 
837
                 * during the whole lifetime of Empathy. */
 
838
                g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivate_cb),
 
839
                        NULL);
826
840
        }
827
841
 
828
842
        g_slice_free (MenuPopupData, data);
853
867
                                      GdkEventKey            *event,
854
868
                                      gpointer                user_data)
855
869
{
856
 
        if (event->keyval == GDK_Menu) {
 
870
        if (event->keyval == GDK_KEY_Menu) {
857
871
                MenuPopupData *data;
858
872
 
859
873
                data = g_slice_new (MenuPopupData);
888
902
 
889
903
        if (contact) {
890
904
                DEBUG ("Starting a chat");
891
 
                empathy_dispatcher_chat_with_contact (contact,
 
905
                empathy_chat_with_contact (contact,
892
906
                        gtk_get_current_event_time ());
893
907
                g_object_unref (contact);
894
908
        }
920
934
 
921
935
        event = (GdkEventButton *) gtk_get_current_event ();
922
936
 
923
 
        menu = gtk_menu_new ();
 
937
        menu = empathy_context_menu_new (GTK_WIDGET (view));
924
938
        shell = GTK_MENU_SHELL (menu);
925
939
 
926
940
        /* audio */
933
947
        gtk_menu_shell_append (shell, item);
934
948
        gtk_widget_show (item);
935
949
 
936
 
        g_signal_connect (menu, "deactivate",
937
 
                          G_CALLBACK (gtk_menu_detach), NULL);
938
 
        gtk_menu_attach_to_widget (GTK_MENU (menu),
939
 
                                   GTK_WIDGET (view), NULL);
940
950
        gtk_widget_show (menu);
941
951
        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
942
952
                        event->button, event->time);
943
 
        g_object_ref_sink (menu);
944
 
        g_object_unref (menu);
945
953
 
946
954
        g_object_unref (contact);
947
955
}
952
960
                                       gboolean                is_group,
953
961
                                       gboolean                is_active)
954
962
{
955
 
        GdkColor  color;
956
 
        GtkStyle *style;
957
 
 
958
 
        style = gtk_widget_get_style (GTK_WIDGET (view));
959
 
 
960
963
        if (!is_group && is_active) {
961
 
                color = style->bg[GTK_STATE_SELECTED];
 
964
                GdkRGBA color;
 
965
                GtkStyleContext *style;
 
966
 
 
967
                style = gtk_widget_get_style_context (GTK_WIDGET (view));
 
968
 
 
969
                gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED,
 
970
        &color);
962
971
 
963
972
                /* Here we take the current theme colour and add it to
964
973
                 * the colour for white and average the two. This
965
974
                 * gives a colour which is inline with the theme but
966
975
                 * slightly whiter.
967
976
                 */
968
 
                color.red = (color.red + (style->white).red) / 2;
969
 
                color.green = (color.green + (style->white).green) / 2;
970
 
                color.blue = (color.blue + (style->white).blue) / 2;
 
977
                empathy_make_color_whiter (&color);
971
978
 
972
979
                g_object_set (cell,
973
 
                              "cell-background-gdk", &color,
 
980
                              "cell-background-rgba", &color,
974
981
                              NULL);
975
982
        } else {
976
983
                g_object_set (cell,
977
 
                              "cell-background-gdk", NULL,
 
984
                              "cell-background-rgba", NULL,
978
985
                              NULL);
979
986
        }
980
987
}
1279
1286
        GdkEventKey *eventkey = ((GdkEventKey *) event);
1280
1287
        gboolean ret = FALSE;
1281
1288
 
1282
 
        if (eventkey->keyval == GDK_Up || eventkey->keyval == GDK_Down) {
 
1289
        if (eventkey->keyval == GDK_KEY_Up || eventkey->keyval == GDK_KEY_Down) {
1283
1290
                GdkEvent *new_event;
1284
1291
 
1285
1292
                new_event = gdk_event_copy (event);
1497
1504
        EmpathyContactListViewPriv *priv = GET_PRIV (view);
1498
1505
        GtkCellRenderer            *cell;
1499
1506
        GtkTreeViewColumn          *col;
1500
 
        guint                       i;
1501
1507
 
1502
1508
        priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (
1503
1509
                        GTK_TREE_MODEL (priv->store), NULL));
1629
1635
 
1630
1636
        /* Actually add the column now we have added all cell renderers */
1631
1637
        gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
1632
 
 
1633
 
        /* Drag & Drop. */
1634
 
        for (i = 0; i < G_N_ELEMENTS (drag_types_dest); ++i) {
1635
 
                drag_atoms_dest[i] = gdk_atom_intern (drag_types_dest[i].target,
1636
 
                                                      FALSE);
1637
 
        }
1638
 
 
1639
 
        for (i = 0; i < G_N_ELEMENTS (drag_types_source); ++i) {
1640
 
                drag_atoms_source[i] = gdk_atom_intern (drag_types_source[i].target,
1641
 
                                                        FALSE);
1642
 
        }
1643
1638
}
1644
1639
 
1645
1640
static void
1875
1870
EmpathyContact *
1876
1871
empathy_contact_list_view_dup_selected (EmpathyContactListView *view)
1877
1872
{
1878
 
        EmpathyContactListViewPriv *priv;
1879
1873
        GtkTreeSelection          *selection;
1880
1874
        GtkTreeIter                iter;
1881
1875
        GtkTreeModel              *model;
1883
1877
 
1884
1878
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
1885
1879
 
1886
 
        priv = GET_PRIV (view);
1887
 
 
1888
1880
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
1889
1881
        if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
1890
1882
                return NULL;
1900
1892
EmpathyContactListFlags
1901
1893
empathy_contact_list_view_get_flags (EmpathyContactListView *view)
1902
1894
{
1903
 
        EmpathyContactListViewPriv *priv;
1904
1895
        GtkTreeSelection          *selection;
1905
1896
        GtkTreeIter                iter;
1906
1897
        GtkTreeModel              *model;
1908
1899
 
1909
1900
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), 0);
1910
1901
 
1911
 
        priv = GET_PRIV (view);
1912
 
 
1913
1902
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
1914
1903
        if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
1915
1904
                return 0;
1926
1915
empathy_contact_list_view_get_selected_group (EmpathyContactListView *view,
1927
1916
                                              gboolean *is_fake_group)
1928
1917
{
1929
 
        EmpathyContactListViewPriv *priv;
1930
1918
        GtkTreeSelection          *selection;
1931
1919
        GtkTreeIter                iter;
1932
1920
        GtkTreeModel              *model;
1936
1924
 
1937
1925
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
1938
1926
 
1939
 
        priv = GET_PRIV (view);
1940
 
 
1941
1927
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
1942
1928
        if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
1943
1929
                return NULL;