comparison src/gtkconv.c @ 4689:69b19e132df0

[gaim-migrate @ 5000] create_prpl_icon()'s API changed. Fixed. Also, added the beginnings of drag-and-dorp support. It's broken. It does nothing. Enjoy. Make me toast. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 10 Mar 2003 05:54:25 +0000
parents 283fb289c510
children cb5b23dfd82b
comparison
equal deleted inserted replaced
4688:0a35ec3585ef 4689:69b19e132df0
42 #include <gdk/gdkkeysyms.h> 42 #include <gdk/gdkkeysyms.h>
43 #include "prpl.h" 43 #include "prpl.h"
44 #include "gtkimhtml.h" 44 #include "gtkimhtml.h"
45 #include "dnd-hints.h" 45 #include "dnd-hints.h"
46 #include "sound.h" 46 #include "sound.h"
47 #include "gtklist.h"
47 48
48 #ifdef _WIN32 49 #ifdef _WIN32
49 #include "win32dep.h" 50 #include "win32dep.h"
50 #endif 51 #endif
51 52
2000 2001
2001 struct gaim_connection *gc; 2002 struct gaim_connection *gc;
2002 GtkWidget *box; 2003 GtkWidget *box;
2003 GtkWidget *label; 2004 GtkWidget *label;
2004 GtkWidget *image; 2005 GtkWidget *image;
2005 GdkPixmap *pixmap = NULL; 2006 GdkPixbuf *pixbuf, *scale;
2006 GdkBitmap *mask = NULL;
2007 2007
2008 found_online = TRUE; 2008 found_online = TRUE;
2009 2009
2010 gc = (struct gaim_connection *)gcs->data; 2010 gc = (struct gaim_connection *)gcs->data;
2011 2011
2012 /* Create a pixmap for the protocol icon. */ 2012 /* Create a pixmap for the protocol icon. */
2013 create_prpl_icon(gtkwin->window, gc, &pixmap, &mask); 2013 pixbuf = create_prpl_icon(gc->account);
2014 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
2014 2015
2015 /* Now convert it to GtkImage */ 2016 /* Now convert it to GtkImage */
2016 if (pixmap == NULL) 2017 if (pixbuf == NULL)
2017 image = gtk_image_new(); 2018 image = gtk_image_new();
2018 else 2019 else
2019 image = gtk_image_new_from_pixmap(pixmap, mask); 2020 image = gtk_image_new_from_pixbuf(scale);
2020 2021
2021 gtk_size_group_add_widget(sg, image); 2022 gtk_size_group_add_widget(sg, image);
2022 2023
2023 if (pixmap != NULL) g_object_unref(pixmap); 2024 g_object_unref(G_OBJECT(scale));
2024 if (mask != NULL) g_object_unref(mask); 2025 g_object_unref(G_OBJECT(pixbuf));
2025 2026
2026 /* Make our menu item */ 2027 /* Make our menu item */
2027 menuitem = gtk_radio_menu_item_new_with_label(group, gc->username); 2028 menuitem = gtk_radio_menu_item_new_with_label(group, gc->username);
2028 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); 2029 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem));
2029 2030
2067 struct gaim_conversation *conv; 2068 struct gaim_conversation *conv;
2068 struct gaim_account *account; 2069 struct gaim_account *account;
2069 GtkWidget *box; 2070 GtkWidget *box;
2070 GtkWidget *label; 2071 GtkWidget *label;
2071 GtkWidget *image; 2072 GtkWidget *image;
2072 GdkPixmap *pixmap = NULL; 2073 GdkPixbuf *pixbuf, *scale;
2073 GdkBitmap *mask = NULL;
2074 2074
2075 conv = (struct gaim_conversation *)convs->data; 2075 conv = (struct gaim_conversation *)convs->data;
2076 2076
2077 if (conv == deleted_conv) 2077 if (conv == deleted_conv)
2078 continue; 2078 continue;
2087 2087
2088 first_offline = FALSE; 2088 first_offline = FALSE;
2089 } 2089 }
2090 2090
2091 /* Create a pixmap for the protocol icon. */ 2091 /* Create a pixmap for the protocol icon. */
2092 create_prpl_icon(gtkwin->window, account->gc, &pixmap, &mask); 2092 pixbuf = create_prpl_icon(account);
2093 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
2094 GDK_INTERP_BILINEAR);
2093 2095
2094 /* Now convert it to GtkImage */ 2096 /* Now convert it to GtkImage */
2095 if (pixmap == NULL) 2097 if (pixbuf == NULL)
2096 image = gtk_image_new(); 2098 image = gtk_image_new();
2097 else 2099 else
2098 image = gtk_image_new_from_pixmap(pixmap, mask); 2100 image = gtk_image_new_from_pixbuf(scale);
2099 2101
2100 gtk_size_group_add_widget(sg, image); 2102 gtk_size_group_add_widget(sg, image);
2101 2103
2102 if (pixmap != NULL) g_object_unref(pixmap); 2104 if (scale != NULL) g_object_unref(scale);
2103 if (mask != NULL) g_object_unref(mask); 2105 if (pixbuf != NULL) g_object_unref(pixbuf);
2104 2106
2105 /* Make our menu item */ 2107 /* Make our menu item */
2106 menuitem = gtk_radio_menu_item_new_with_label(group, 2108 menuitem = gtk_radio_menu_item_new_with_label(group,
2107 account->username); 2109 account->username);
2108 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); 2110 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem));
2528 gtk_widget_show(gtkim->sep2); 2530 gtk_widget_show(gtkim->sep2);
2529 2531
2530 /* Now, um, just kind of all over the place. Huh? */ 2532 /* Now, um, just kind of all over the place. Huh? */
2531 2533
2532 /* Add button */ 2534 /* Add button */
2533 if (gaim_find_buddy(gaim_conversation_get_gc(conv), 2535 if (gaim_find_buddy(gaim_conversation_get_account(conv),
2534 gaim_conversation_get_name(conv)) == NULL) { 2536 gaim_conversation_get_name(conv)) == NULL) {
2537
2535 gtkim->add = gaim_gtk_change_text(_("Add"), gtkim->add, 2538 gtkim->add = gaim_gtk_change_text(_("Add"), gtkim->add,
2536 GTK_STOCK_ADD, type); 2539 GTK_STOCK_ADD, type);
2537 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add, 2540 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add,
2538 _("Add the user to your buddy list"), NULL); 2541 _("Add the user to your buddy list"), NULL);
2539 } 2542 }
3191 gaim_window_switch_conversation(win, 3194 gaim_window_switch_conversation(win,
3192 gaim_conversation_get_index(next_conv)); 3195 gaim_conversation_get_index(next_conv));
3193 } 3196 }
3194 } 3197 }
3195 3198
3199 static void
3200 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
3201 GtkSelectionData *sd, guint info, guint t, gpointer data)
3202 {
3203 do_error_dialog("MWAHAHAHA! I AM A TROLL! I AM GOING TO EAT YOU!",
3204 NULL, GAIM_WARNING);
3205 }
3196 3206
3197 /************************************************************************** 3207 /**************************************************************************
3198 * GTK+ window ops 3208 * GTK+ window ops
3199 **************************************************************************/ 3209 **************************************************************************/
3200 static struct gaim_conversation_ui_ops * 3210 static struct gaim_conversation_ui_ops *
3320 gtkwin = GAIM_GTK_WINDOW(win); 3330 gtkwin = GAIM_GTK_WINDOW(win);
3321 3331
3322 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); 3332 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index);
3323 } 3333 }
3324 3334
3335 static const GtkTargetEntry te[] =
3336 {
3337 {"text/plain", 0, 0},
3338 {"text/uri-list", 1, 0},
3339 {"STRING", 2, 0}
3340 };
3341
3325 static void 3342 static void
3326 gaim_gtk_add_conversation(struct gaim_window *win, 3343 gaim_gtk_add_conversation(struct gaim_window *win,
3327 struct gaim_conversation *conv) 3344 struct gaim_conversation *conv)
3328 { 3345 {
3329 struct gaim_gtk_window *gtkwin; 3346 struct gaim_gtk_window *gtkwin;
3379 g_free(gtkconv); 3396 g_free(gtkconv);
3380 conv->ui_data = NULL; 3397 conv->ui_data = NULL;
3381 3398
3382 return; 3399 return;
3383 } 3400 }
3401
3402 /* Setup drag-and-drop */
3403 gtk_drag_dest_set(pane,
3404 GTK_DEST_DEFAULT_MOTION |
3405 GTK_DEST_DEFAULT_DROP,
3406 te, sizeof(te) / sizeof(GtkTargetEntry),
3407 GDK_ACTION_COPY);
3408 gtk_drag_dest_set(gtkconv->imhtml,
3409 GTK_DEST_DEFAULT_MOTION |
3410 GTK_DEST_DEFAULT_HIGHLIGHT |
3411 GTK_DEST_DEFAULT_DROP,
3412 te, sizeof(te) / sizeof(GtkTargetEntry),
3413 GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE);
3414 gtk_drag_dest_set(gtkconv->entry,
3415 GTK_DEST_DEFAULT_MOTION |
3416 GTK_DEST_DEFAULT_DROP,
3417 te, sizeof(te) / sizeof(GtkTargetEntry),
3418 GDK_ACTION_COPY);
3419
3420 g_signal_connect(G_OBJECT(pane), "drag_data_received",
3421 G_CALLBACK(conv_dnd_recv), conv);
3422 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received",
3423 G_CALLBACK(conv_dnd_recv), conv);
3424 #if 0
3425 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received",
3426 G_CALLBACK(conv_dnd_recv), conv);
3427 #endif
3384 3428
3385 /* 3429 /*
3386 * Write the New Conversation log string. 3430 * Write the New Conversation log string.
3387 * 3431 *
3388 * This should probably be elsewhere, but then, logging should 3432 * This should probably be elsewhere, but then, logging should