xchat-gnome r2660 - in trunk: . src/fe-gnome
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: xchat-gnome r2660 - in trunk: . src/fe-gnome
- Date: Sun, 7 Sep 2008 14:09:12 +0000 (UTC)
Author: chpe
Date: Sun Sep 7 14:09:12 2008
New Revision: 2660
URL: http://svn.gnome.org/viewvc/xchat-gnome?rev=2660&view=rev
Log:
* src/fe-gnome/conversation-panel.c: (conversation_panel_init),
(drag_data_received): Simplify DND code.
Modified:
trunk/ChangeLog
trunk/src/fe-gnome/conversation-panel.c
Modified: trunk/src/fe-gnome/conversation-panel.c
==============================================================================
--- trunk/src/fe-gnome/conversation-panel.c (original)
+++ trunk/src/fe-gnome/conversation-panel.c Sun Sep 7 14:09:12 2008
@@ -185,24 +185,6 @@
};
#define DROP_FILE_PASTE_MAX_SIZE 1024
-enum
-{
- TARGET_URI_LIST,
- TARGET_UTF8_STRING,
- TARGET_TEXT,
- TARGET_COMPOUND_TEXT,
- TARGET_STRING,
- TARGET_TEXT_PLAIN,
-};
-
-static GtkTargetEntry target_table[] = {
- { "text/uri-list", 0, TARGET_URI_LIST },
- { "UTF8_STRING", 0, TARGET_UTF8_STRING },
- { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT },
- { "TEXT", 0, TARGET_TEXT },
- { "STRING", 0, TARGET_STRING },
- { "text/plain", 0, TARGET_TEXT_PLAIN }
-};
static struct User dialog_user;
@@ -272,7 +254,9 @@
g_signal_connect (G_OBJECT (panel), "style-set", G_CALLBACK (style_set_callback), panel);
g_signal_connect (G_OBJECT (panel->priv->xtext), "drag_data_received", G_CALLBACK (drag_data_received), panel);
gtk_drag_dest_set (panel->priv->xtext, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
- target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY | GDK_ACTION_ASK);
+ NULL, 0, GDK_ACTION_COPY | GDK_ACTION_ASK);
+ gtk_drag_dest_add_uri_targets (panel->priv->xtext);
+ gtk_drag_dest_add_text_targets (panel->priv->xtext);
#ifdef USE_XLIB
gdk_window_set_events (gdk_get_default_root_window (), GDK_PROPERTY_CHANGE_MASK);
@@ -756,24 +740,7 @@
drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
GtkSelectionData *selection_data, guint info, guint time, ConversationPanel *panel)
{
- switch (info) {
- case TARGET_TEXT:
- case TARGET_STRING:
- case TARGET_COMPOUND_TEXT:
- case TARGET_UTF8_STRING:
- case TARGET_TEXT_PLAIN:
- {
- char *txt = (char *) gtk_selection_data_get_text (selection_data);
- if (gui.current_session != NULL) {
- handle_multiline (gui.current_session, txt, TRUE, FALSE);
- }
-
- g_free (txt);
- break;
- }
- case TARGET_URI_LIST:
- {
- char *uri_list;
+ if (gtk_targets_include_uri (&selection_data->target, 1)) {
gchar **uris;
gint nb_uri;
@@ -782,15 +749,9 @@
return;
}
- if (selection_data->format != 8 || selection_data->length == 0) {
- g_printerr (_("URI list dropped on XChat-GNOME had wrong format (%d) or length (%d)\n"),
- selection_data->format, selection_data->length);
- return;
- }
-
- uri_list = g_strndup ((char*) selection_data->data, selection_data->length);
- uris = g_strsplit (uri_list, "\r\n", 0);
- g_free (uri_list);
+ uris = gtk_selection_data_get_uris (selection_data);
+ if (!uris)
+ return;
free_dropped_files (panel);
@@ -843,7 +804,15 @@
}
}
}
- }
+ } else if (gtk_targets_include_text (&selection_data->target, 1)) {
+ char *txt;
+
+ txt = (char *) gtk_selection_data_get_text (selection_data);
+ if (gui.current_session != NULL) {
+ handle_multiline (gui.current_session, txt, TRUE, FALSE);
+ }
+
+ g_free (txt);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]