Mercurial > pidgin
comparison src/gtkutils.c @ 9497:44a5bfa4730b
[gaim-migrate @ 10323]
Done with the file chooser for right clicking and saving icons.
There is a lot of code duplication here... I'm going to look
at the file chooser in the request API now.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 10 Jul 2004 15:18:02 +0000 |
parents | 05532ad61ed5 |
children | 6f0c90000bb5 |
comparison
equal
deleted
inserted
replaced
9496:27a595d413ff | 9497:44a5bfa4730b |
---|---|
107 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); | 107 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); |
108 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, | 108 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, |
109 (*text != '\0')); | 109 (*text != '\0')); |
110 } | 110 } |
111 | 111 |
112 static int | |
113 des_save_icon(GtkObject *obj, GdkEvent *e, | |
114 GaimGtkConversation *gtkconv) | |
115 { | |
116 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
117 gtkconv->u.im->save_icon = NULL; | |
118 | |
119 return TRUE; | |
120 } | |
121 | |
122 static void | |
123 do_save_icon(GtkObject *obj, GaimConversation *c) | |
124 { | |
125 GaimGtkConversation *gtkconv; | |
126 FILE *file; | |
127 const char *f; | |
128 GaimBuddyIcon *icon; | |
129 size_t len; | |
130 const void *data; | |
131 | |
132 | |
133 gtkconv = GAIM_GTK_CONVERSATION(c); | |
134 | |
135 f = gtk_file_selection_get_filename( | |
136 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
137 | |
138 if (gaim_gtk_check_if_dir(f, GTK_FILE_SELECTION(gtkconv->u.im->save_icon))) | |
139 return; | |
140 | |
141 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(c)); | |
142 data = gaim_buddy_icon_get_data(icon, &len); | |
143 | |
144 if ((len > 0) && (data != NULL) && (file = fopen(f, "wb")) != NULL) { | |
145 fwrite(data, 1, len, file); | |
146 fclose(file); | |
147 } else { | |
148 gaim_notify_error(NULL, NULL, | |
149 _("Can't save icon file to disk."), NULL); | |
150 } | |
151 | |
152 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
153 gtkconv->u.im->save_icon = NULL; | |
154 } | |
155 | |
156 static void | |
157 cancel_save_icon(GtkObject *obj, GaimGtkConversation *gtkconv) | |
158 { | |
159 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
160 gtkconv->u.im->save_icon = NULL; | |
161 } | |
162 | |
163 | |
164 void | |
165 gaim_gtk_save_icon_dialog(GtkObject *obj, GaimConversation *conv) | |
166 { | |
167 GaimGtkConversation *gtkconv; | |
168 char buf[BUF_LEN]; | |
169 | |
170 if (conv == NULL || gaim_conversation_get_type(conv) != GAIM_CONV_IM) | |
171 return; | |
172 | |
173 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
174 return; | |
175 | |
176 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
177 | |
178 if (gtkconv->u.im->save_icon != NULL) | |
179 { | |
180 gdk_window_raise(gtkconv->u.im->save_icon->window); | |
181 return; | |
182 } | |
183 | |
184 gtkconv->u.im->save_icon = gtk_file_selection_new(_("Save Icon")); | |
185 | |
186 gtk_file_selection_hide_fileop_buttons( | |
187 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
188 | |
189 g_snprintf(buf, BUF_LEN - 1, | |
190 "%s" G_DIR_SEPARATOR_S "%s.icon", | |
191 gaim_home_dir(), gaim_conversation_get_name(conv)); | |
192 | |
193 gtk_file_selection_set_filename( | |
194 GTK_FILE_SELECTION(gtkconv->u.im->save_icon), buf); | |
195 | |
196 g_signal_connect(G_OBJECT(gtkconv->u.im->save_icon), "delete_event", | |
197 G_CALLBACK(des_save_icon), gtkconv); | |
198 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->ok_button), "clicked", | |
199 G_CALLBACK(do_save_icon), conv); | |
200 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->cancel_button), "clicked", | |
201 G_CALLBACK(cancel_save_icon), gtkconv); | |
202 | |
203 gtk_widget_show(gtkconv->u.im->save_icon); | |
204 } | |
205 | |
206 int | 112 int |
207 gaim_gtk_get_dispstyle(GaimConversationType type) | 113 gaim_gtk_get_dispstyle(GaimConversationType type) |
208 { | 114 { |
209 int dispstyle = 2; | 115 int dispstyle = 2; |
210 int value; | 116 int value; |