static void conv_placement_by_number(PidginConversation *conv) { PidginWindow *win = NULL; GList *wins = NULL; if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate")) win = pidgin_conv_window_last_with_type(purple_conversation_get_type(conv->active_conv)); else if ((wins = pidgin_conv_windows_get_list()) != NULL) win = g_list_last(wins)->data; if (win == NULL) { win = pidgin_conv_window_new(); pidgin_conv_window_add_gtkconv(win, conv); pidgin_conv_window_show(win); } else { int max_count = purple_prefs_get_int("/plugins/gtk/extplacement/placement_number"); int count = pidgin_conv_window_get_gtkconv_count(win); if (count < max_count) pidgin_conv_window_add_gtkconv(win, conv); else { GList *l = NULL; for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) { win = l->data; if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") && purple_conversation_get_type(pidgin_conv_window_get_active_conversation(win)) != purple_conversation_get_type(conv->active_conv)) continue; count = pidgin_conv_window_get_gtkconv_count(win); if (count < max_count) { pidgin_conv_window_add_gtkconv(win, conv); return; } } win = pidgin_conv_window_new(); pidgin_conv_window_add_gtkconv(win, conv); pidgin_conv_window_show(win); } } }
/** * Create a conversation window and merge it with the given Buddy List window * * This is the real core of the plugin right here. It initializes the Buddy * List with a conversation window just like the project advertises. See the * function pwm_split_conversation() to reverse this effect. * * @param[in] gtkblist The Buddy List that will be able to show conversations **/ void pwm_merge_conversation(PidginBuddyList *gtkblist) { PidginWindow * gtkconvwin; /*< The mutilated conversations for gtkblist */ GtkBindingSet *binding_set; /*< The binding set of GtkIMHtml widgets */ /* Sanity check: If the Buddy List is already merged, don't mess with * it. */ if (pwm_blist_get_convs(gtkblist) != NULL) return; binding_set = gtk_binding_set_by_class(g_type_class_ref(GTK_TYPE_IMHTML)); gtkconvwin = pidgin_conv_window_new(); /* Tie the Buddy List and conversation window instances together. */ g_object_set_data(G_OBJECT(gtkblist->notebook), "pwm_convs", gtkconvwin); g_object_set_data(G_OBJECT(gtkconvwin->notebook), "pwm_blist", gtkblist); /* Backup the Buddy List window title for restoring it later. */ pwm_store(gtkblist, "title", g_strdup(gtk_window_get_title(GTK_WINDOW(gtkblist->window)))); /* Move the conversation notebook into the Buddy List window. */ pwm_create_paned_layout(gtkblist, purple_prefs_get_string(PREF_SIDE)); /* Display the instructions tab for new users. */ pwm_init_dummy_conversation(gtkblist); pwm_show_dummy_conversation(gtkblist); /* Pass focus events from Buddy List to conversation window. */ g_object_connect(G_OBJECT(gtkblist->window), "signal::focus-in-event", G_CALLBACK(focus_in_event_cb), gtkconvwin->window, NULL); /* Point the conversation window structure at the Buddy List's window. */ pwm_store(gtkblist, "conv_window", gtkconvwin->window); gtkconvwin->window = gtkblist->window; /* Block these "move-cursor" bindings for conversation event handlers. */ /* XXX: These are skipped in any GtkIMHtml, not just the conversations. */ /* XXX: Furthermore, there is no event to undo this effect. */ gtk_binding_entry_skip(binding_set, GDK_Up, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_Down, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_Page_Up, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_Page_Down, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_KP_Page_Up, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_KP_Page_Down, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_Tab, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_KP_Tab, GDK_CONTROL_MASK); gtk_binding_entry_skip(binding_set, GDK_ISO_Left_Tab, GDK_CONTROL_MASK); }
static void stroke_new_win(GtkWidget *widget, void *data) { PidginWindow *new_win, *old_win; PurpleConversation *conv; conv = (PurpleConversation *)data; old_win = PIDGIN_CONVERSATION(conv)->win; if (pidgin_conv_window_get_gtkconv_count(old_win) <= 1) return; new_win = pidgin_conv_window_new(); pidgin_conv_window_remove_gtkconv(old_win, PIDGIN_CONVERSATION(conv)); pidgin_conv_window_add_gtkconv(new_win, PIDGIN_CONVERSATION(conv)); pidgin_conv_window_show(new_win); }