comparison src/gtkconv.c @ 11206:86d3ce670f05

[gaim-migrate @ 13334] Warn when you close a conversation window with unread messages committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 08 Aug 2005 03:44:32 +0000
parents dbc518c453f2
children e552095ec599
comparison
equal deleted inserted replaced
11205:567998f226c1 11206:86d3ce670f05
43 #include "cmds.h" 43 #include "cmds.h"
44 #include "debug.h" 44 #include "debug.h"
45 #include "imgstore.h" 45 #include "imgstore.h"
46 #include "log.h" 46 #include "log.h"
47 #include "notify.h" 47 #include "notify.h"
48 #include "prefs.h"
49 #include "prpl.h" 48 #include "prpl.h"
50 #include "request.h" 49 #include "request.h"
51 #include "sound.h" 50 #include "sound.h"
52 #include "util.h" 51 #include "util.h"
53 52
57 #include "gtkdialogs.h" 56 #include "gtkdialogs.h"
58 #include "gtkimhtml.h" 57 #include "gtkimhtml.h"
59 #include "gtkimhtmltoolbar.h" 58 #include "gtkimhtmltoolbar.h"
60 #include "gtklog.h" 59 #include "gtklog.h"
61 #include "gtkpounce.h" 60 #include "gtkpounce.h"
61 #include "gtkprefs.h"
62 #include "gtkprivacy.h" 62 #include "gtkprivacy.h"
63 #include "gtkutils.h" 63 #include "gtkutils.h"
64 #include "gtkstock.h" 64 #include "gtkstock.h"
65 65
66 #define AUTO_RESPONSE "&lt;AUTO-REPLY&gt; : " 66 #define AUTO_RESPONSE "&lt;AUTO-REPLY&gt; : "
109 GaimConversation *conv; 109 GaimConversation *conv;
110 110
111 } InviteBuddyInfo; 111 } InviteBuddyInfo;
112 112
113 static GtkWidget *invite_dialog = NULL; 113 static GtkWidget *invite_dialog = NULL;
114 static GtkWidget *warn_close_dialog = NULL;
114 115
115 /* Prototypes. <-- because Paco-Paco hates this comment. */ 116 /* Prototypes. <-- because Paco-Paco hates this comment. */
116 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); 117 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first);
117 static GList *generate_invite_user_names(GaimConnection *gc); 118 static GList *generate_invite_user_names(GaimConnection *gc);
118 static void add_chat_buddy_common(GaimConversation *conv, 119 static void add_chat_buddy_common(GaimConversation *conv,
120 static gboolean tab_complete(GaimConversation *conv); 121 static gboolean tab_complete(GaimConversation *conv);
121 static void update_typing_icon(GaimGtkConversation *gtkconv); 122 static void update_typing_icon(GaimGtkConversation *gtkconv);
122 static gboolean update_send_as_selection(GaimConvWindow *win); 123 static gboolean update_send_as_selection(GaimConvWindow *win);
123 static char *item_factory_translate_func (const char *path, gpointer func_data); 124 static char *item_factory_translate_func (const char *path, gpointer func_data);
124 125
126 static void
127 do_close(GtkWidget *w, int resp, GaimConvWindow *win)
128 {
129 gtk_widget_destroy(warn_close_dialog);
130 warn_close_dialog = NULL;
131
132 if (resp == GTK_RESPONSE_OK)
133 gaim_conv_window_destroy(win);
134 }
135
136 static void build_warn_close_dialog(GaimConvWindow *win)
137 {
138 GaimGtkWindow *gtkwin;
139 GtkWidget *label;
140 GtkWidget *vbox, *hbox;
141 GtkWidget *img;
142
143 g_return_if_fail(warn_close_dialog == NULL);
144
145 gtkwin = GAIM_GTK_WINDOW(win);
146
147 warn_close_dialog = gtk_dialog_new_with_buttons(
148 _("Confirm close"),
149 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL,
150 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
151 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
152
153 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog),
154 GTK_RESPONSE_OK);
155
156 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog),
157 6);
158 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE);
159 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog),
160 FALSE);
161
162 /* Setup the outside spacing. */
163 vbox = GTK_DIALOG(warn_close_dialog)->vbox;
164
165 gtk_box_set_spacing(GTK_BOX(vbox), 12);
166 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
167
168 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING,
169 GTK_ICON_SIZE_DIALOG);
170 /* Setup the inner hbox and put the dialog's icon in it. */
171 hbox = gtk_hbox_new(FALSE, 12);
172 gtk_container_add(GTK_CONTAINER(vbox), hbox);
173 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
174 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
175
176 /* Setup the right vbox. */
177 vbox = gtk_vbox_new(FALSE, 12);
178 gtk_container_add(GTK_CONTAINER(hbox), vbox);
179
180 label = gtk_label_new(_("You have unread messages. Are you sure you want to continue?"));
181 gtk_widget_set_size_request(label, 350, -1);
182 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
183 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
184 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
185
186 gaim_gtk_prefs_checkbox(_("Warn me when I close the window with unread messages"),
187 "/gaim/gtk/conversations/warn_on_unread_close", vbox);
188
189 /* Connect the signals. */
190 g_signal_connect(G_OBJECT(warn_close_dialog), "response",
191 G_CALLBACK(do_close), win);
192
193 }
194
125 /************************************************************************** 195 /**************************************************************************
126 * Callbacks 196 * Callbacks
127 **************************************************************************/ 197 **************************************************************************/
128 static gint 198 static gint
129 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) 199 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d)
130 { 200 {
131 GaimConvWindow *win = (GaimConvWindow *)d; 201 GaimConvWindow *win = (GaimConvWindow *)d;
132 202
203 if (gaim_prefs_get_bool(
204 "/gaim/gtk/conversations/warn_on_unread_close"))
205 {
206 GList *l;
207 for (l = gaim_conv_window_get_conversations(win);
208 l != NULL; l = l->next)
209 {
210 GaimConversation *conv = l->data;
211 if (gaim_conversation_get_type(conv)
212 == GAIM_CONV_IM
213 && gaim_conversation_get_unseen(conv)
214 == GAIM_UNSEEN_TEXT)
215 {
216 build_warn_close_dialog(win);
217 gtk_widget_show_all(warn_close_dialog);
218
219 return TRUE;
220 }
221 }
222 }
133 gaim_conv_window_destroy(win); 223 gaim_conv_window_destroy(win);
134 224
135 return TRUE; 225 return TRUE;
136 } 226 }
137 227
6129 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); 6219 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", "");
6130 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); 6220 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", "");
6131 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); 6221 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3);
6132 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); 6222 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE);
6133 gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP); 6223 gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP);
6224 gaim_prefs_add_bool("/gaim/gtk/conversations/warn_on_unread_close", TRUE);
6134 6225
6135 /* Conversations -> Chat */ 6226 /* Conversations -> Chat */
6136 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); 6227 gaim_prefs_add_none("/gaim/gtk/conversations/chat");
6137 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); 6228 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410);
6138 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); 6229 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160);