| 27 #include "gtkplugin.h" |
27 #include "gtkplugin.h" |
| 28 #include "gtkconv.h" |
28 #include "gtkconv.h" |
| 29 #include "gtkconvwin.h" |
29 #include "gtkconvwin.h" |
| 30 |
30 |
| 31 static void |
31 static void |
| 32 conv_placement_by_number(GaimGtkConversation *conv) |
32 conv_placement_by_number(PidginConversation *conv) |
| 33 { |
33 { |
| 34 GaimGtkWindow *win = NULL; |
34 PidginWindow *win = NULL; |
| 35 GList *wins = NULL; |
35 GList *wins = NULL; |
| 36 |
36 |
| 37 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate")) |
37 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate")) |
| 38 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); |
38 win = pidgin_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); |
| 39 else if ((wins = gaim_gtk_conv_windows_get_list()) != NULL) |
39 else if ((wins = pidgin_conv_windows_get_list()) != NULL) |
| 40 win = g_list_last(wins)->data; |
40 win = g_list_last(wins)->data; |
| 41 |
41 |
| 42 if (win == NULL) { |
42 if (win == NULL) { |
| 43 win = gaim_gtk_conv_window_new(); |
43 win = pidgin_conv_window_new(); |
| 44 |
44 |
| 45 gaim_gtk_conv_window_add_gtkconv(win, conv); |
45 pidgin_conv_window_add_gtkconv(win, conv); |
| 46 gaim_gtk_conv_window_show(win); |
46 pidgin_conv_window_show(win); |
| 47 } else { |
47 } else { |
| 48 int max_count = gaim_prefs_get_int("/plugins/gtk/extplacement/placement_number"); |
48 int max_count = gaim_prefs_get_int("/plugins/gtk/extplacement/placement_number"); |
| 49 int count = gaim_gtk_conv_window_get_gtkconv_count(win); |
49 int count = pidgin_conv_window_get_gtkconv_count(win); |
| 50 |
50 |
| 51 if (count < max_count) |
51 if (count < max_count) |
| 52 gaim_gtk_conv_window_add_gtkconv(win, conv); |
52 pidgin_conv_window_add_gtkconv(win, conv); |
| 53 else { |
53 else { |
| 54 GList *l = NULL; |
54 GList *l = NULL; |
| 55 |
55 |
| 56 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
56 for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) { |
| 57 win = l->data; |
57 win = l->data; |
| 58 |
58 |
| 59 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") && |
59 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") && |
| 60 gaim_conversation_get_type(gaim_gtk_conv_window_get_active_conversation(win)) != gaim_conversation_get_type(conv->active_conv)) |
60 gaim_conversation_get_type(pidgin_conv_window_get_active_conversation(win)) != gaim_conversation_get_type(conv->active_conv)) |
| 61 continue; |
61 continue; |
| 62 |
62 |
| 63 count = gaim_gtk_conv_window_get_gtkconv_count(win); |
63 count = pidgin_conv_window_get_gtkconv_count(win); |
| 64 if (count < max_count) { |
64 if (count < max_count) { |
| 65 gaim_gtk_conv_window_add_gtkconv(win, conv); |
65 pidgin_conv_window_add_gtkconv(win, conv); |
| 66 return; |
66 return; |
| 67 } |
67 } |
| 68 } |
68 } |
| 69 win = gaim_gtk_conv_window_new(); |
69 win = pidgin_conv_window_new(); |
| 70 |
70 |
| 71 gaim_gtk_conv_window_add_gtkconv(win, conv); |
71 pidgin_conv_window_add_gtkconv(win, conv); |
| 72 gaim_gtk_conv_window_show(win); |
72 pidgin_conv_window_show(win); |
| 73 } |
73 } |
| 74 } |
74 } |
| 75 } |
75 } |
| 76 |
76 |
| 77 static gboolean |
77 static gboolean |
| 78 plugin_load(GaimPlugin *plugin) |
78 plugin_load(GaimPlugin *plugin) |
| 79 { |
79 { |
| 80 gaim_gtkconv_placement_add_fnc("number", _("By conversation count"), |
80 pidginconv_placement_add_fnc("number", _("By conversation count"), |
| 81 &conv_placement_by_number); |
81 &conv_placement_by_number); |
| 82 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
82 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
| 83 return TRUE; |
83 return TRUE; |
| 84 } |
84 } |
| 85 |
85 |
| 86 static gboolean |
86 static gboolean |
| 87 plugin_unload(GaimPlugin *plugin) |
87 plugin_unload(GaimPlugin *plugin) |
| 88 { |
88 { |
| 89 gaim_gtkconv_placement_remove_fnc("number"); |
89 pidginconv_placement_remove_fnc("number"); |
| 90 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
90 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
| 91 return TRUE; |
91 return TRUE; |
| 92 } |
92 } |
| 93 |
93 |
| 94 static GaimPluginPrefFrame * |
94 static GaimPluginPrefFrame * |
| 125 { |
125 { |
| 126 GAIM_PLUGIN_MAGIC, |
126 GAIM_PLUGIN_MAGIC, |
| 127 GAIM_MAJOR_VERSION, |
127 GAIM_MAJOR_VERSION, |
| 128 GAIM_MINOR_VERSION, |
128 GAIM_MINOR_VERSION, |
| 129 GAIM_PLUGIN_STANDARD, /**< type */ |
129 GAIM_PLUGIN_STANDARD, /**< type */ |
| 130 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
130 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 131 0, /**< flags */ |
131 0, /**< flags */ |
| 132 NULL, /**< dependencies */ |
132 NULL, /**< dependencies */ |
| 133 GAIM_PRIORITY_DEFAULT, /**< priority */ |
133 GAIM_PRIORITY_DEFAULT, /**< priority */ |
| 134 "gtk-extplacement", /**< id */ |
134 "gtk-extplacement", /**< id */ |
| 135 N_("ExtPlacement"), /**< name */ |
135 N_("ExtPlacement"), /**< name */ |