]> git.0d.be Git - empathy.git/commitdiff
Move GtkTargetLists into priv so they're no longer static
authorShaun McCance <Shaun McCance>
Mon, 5 Oct 2009 20:09:46 +0000 (15:09 -0500)
committerShaun McCance <shaunm@gnome.org>
Tue, 24 Nov 2009 21:15:30 +0000 (15:15 -0600)
libempathy-gtk/empathy-contact-list-view.c
src/empathy-chat-window.c

index 0dc5cba1453b30537468eeb89b67298aee7a6eb1..0a9b260f82cc740c95a80daf0dbd2f62cc0b81f0 100644 (file)
@@ -65,6 +65,7 @@ typedef struct {
        EmpathyContactListFeatureFlags  list_features;
        EmpathyContactFeatureFlags      contact_features;
        GtkWidget                      *tooltip_widget;
+       GtkTargetList                  *file_targets;
 } EmpathyContactListViewPriv;
 
 typedef struct {
@@ -417,7 +418,6 @@ contact_list_view_drag_motion (GtkWidget      *widget,
 {
        EmpathyContactListViewPriv *priv;
        GtkTreeModel               *model;
-       static GtkTargetList  *file_targets = NULL;
        GdkAtom                target;
        GtkTreeIter            iter;
        static DragMotionData *dm = NULL;
@@ -430,11 +430,6 @@ contact_list_view_drag_motion (GtkWidget      *widget,
        priv = GET_PRIV (EMPATHY_CONTACT_LIST_VIEW (widget));
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
 
-       if (file_targets == NULL) {
-               file_targets = gtk_target_list_new (drag_types_dest_file,
-                                                   G_N_ELEMENTS (drag_types_dest_file));
-       }
-
        is_row = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
                                                x,
                                                y,
@@ -460,7 +455,7 @@ contact_list_view_drag_motion (GtkWidget      *widget,
                gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (widget), NULL, 0);
                return FALSE;
        }
-       target = gtk_drag_dest_find_target (widget, context, file_targets);
+       target = gtk_drag_dest_find_target (widget, context, priv->file_targets);
        gtk_tree_model_get_iter (model, &iter, path);
 
        if (target == GDK_NONE) {
@@ -1266,6 +1261,9 @@ contact_list_view_finalize (GObject *object)
        if (priv->tooltip_widget) {
                gtk_widget_destroy (priv->tooltip_widget);
        }
+       if (priv->file_targets) {
+               gtk_target_list_unref (priv->file_targets);
+       }
 
        G_OBJECT_CLASS (empathy_contact_list_view_parent_class)->finalize (object);
 }
@@ -1396,6 +1394,10 @@ empathy_contact_list_view_init (EmpathyContactListView *view)
                                              empathy_contact_list_store_row_separator_func,
                                              NULL, NULL);
 
+       /* Set up drag target lists. */
+       priv->file_targets = gtk_target_list_new (drag_types_dest_file,
+                                                 G_N_ELEMENTS (drag_types_dest_file));
+
        /* Connect to tree view signals rather than override. */
        g_signal_connect (view, "button-press-event",
                          G_CALLBACK (contact_list_view_button_press_event_cb),
index a6bd5f259d3db16a0087af4925044be82fb82231..cd2aeaffeda9f374fc0d4b4c6f5bae29b2222706 100644 (file)
@@ -80,6 +80,8 @@ typedef struct {
        NotifyNotification *notification;
        NotificationData *notification_data;
 
+       GtkTargetList *move_targets;
+
        /* Menu items. */
        GtkUIManager *ui_manager;
        GtkAction   *menu_conv_insert_smiley;
@@ -1335,15 +1337,12 @@ chat_window_drag_motion (GtkWidget        *widget,
                         guint             time,
                         EmpathyChatWindow *window)
 {
-       static GtkTargetList *list = NULL;
        GdkAtom target;
+       EmpathyChatWindowPriv *priv;
 
-       if (list == NULL) {
-               list = gtk_target_list_new (drag_types_dest_move,
-                                           G_N_ELEMENTS (drag_types_dest_move));
-       }
+       priv = GET_PRIV (window);
 
-       target = gtk_drag_dest_find_target (widget, context, list);
+       target = gtk_drag_dest_find_target (widget, context, priv->move_targets);
        /* If target != GDK_NONE, this target type is a type we should move
           instead of copy.  That's a notebook tab.  Other drag types, such
           as files or contacts, use copy.
@@ -1518,6 +1517,10 @@ chat_window_finalize (GObject *object)
                        }
        }
 
+       if (priv->move_targets) {
+               gtk_target_list_unref (priv->move_targets);
+       }
+
        chat_windows = g_list_remove (chat_windows, window);
        gtk_widget_destroy (priv->dialog);
 
@@ -1629,6 +1632,10 @@ empathy_chat_window_init (EmpathyChatWindow *window)
 
        g_object_unref (accel_group);
 
+       /* Set up drag target lists */
+       priv->move_targets = gtk_target_list_new (drag_types_dest_move,
+                                                 G_N_ELEMENTS (drag_types_dest_move));
+
        /* Set up smiley menu */
        smiley_manager = empathy_smiley_manager_dup_singleton ();
        submenu = empathy_smiley_menu_new (smiley_manager,