Cleanup of old stuff from upload dialog.
[irreco.git] / irreco / trunk / src / core / irreco_theme_upload_dlg.c
blob7583ac32e0d9e08d7a4b0cf08416a5e41debec6e
1 /*
2 * irreco - Ir Remote Control
3 * Copyright (C) 2007 Arto Karppinen (arto.karppinen@iki.fi)
4 * 2008 Joni Kokko (t5kojo01@students.oamk.fi)
5 * 2008 Harri Vattulainen (t5vaha01@students.oamk.fi)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "irreco_theme_upload_dlg.h"
23 /* TODO needed? */
24 #include <hildon/hildon-color-button.h>
25 #include <hildon/hildon-file-chooser-dialog.h>
29 /**
30 * @addtogroup IrrecoThemeUploadDlg
31 * @ingroup Irreco
33 * Allow user to set theme settings and upload it.
35 * @{
38 /**
39 * @file
40 * Source file of @ref IrrecoThemeUploadDlg.
45 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
46 /* Datatypes */
47 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
49 #define IRRECO_THEME_UPLOAD_PREVIEW_WIDHT (IRRECO_SCREEN_WIDTH / 6)
50 #define IRRECO_THEME_UPLOAD_PREVIEW_HEIGHT (IRRECO_SCREEN_HEIGHT / 6)
54 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
55 /* Prototypes */
56 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
57 static gboolean _check_texts(IrrecoThemeUploadDlg *self);
61 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
62 /* Construction & Destruction */
63 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
65 /**
66 * @name Construction & Destruction
67 * @{
70 G_DEFINE_TYPE(IrrecoThemeUploadDlg, irreco_theme_upload_dlg,
71 IRRECO_TYPE_INTERNAL_DLG)
73 static void irreco_theme_upload_dlg_constructed(GObject *object)
75 IrrecoThemeUploadDlg *self;
77 GtkWidget *hbox_lr;
78 /*GtkWidget *vbox;*/
80 IRRECO_ENTER
82 G_OBJECT_CLASS(irreco_theme_upload_dlg_parent_class)->constructed(object);
83 self = IRRECO_THEME_UPLOAD_DLG(object);
85 /* Construct dialog. */
86 gtk_window_set_title(GTK_WINDOW(self), _("Upload theme"));
87 gtk_window_set_modal(GTK_WINDOW(self), TRUE);
88 gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE);
89 gtk_dialog_set_has_separator(GTK_DIALOG(self), FALSE);
90 gtk_dialog_add_buttons(GTK_DIALOG(self),
91 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
92 GTK_STOCK_OK, GTK_RESPONSE_OK,
93 NULL);
97 /* Create widgets. */
98 hbox_lr = gtk_hbox_new(FALSE, 0);
100 /* Build dialog. */
101 gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(self)->vbox),
102 hbox_lr);
104 /* Radio button signals. */
105 /* TODO Connect preview view to somewhere */
106 /*g_signal_connect(G_OBJECT(self->radio_default), "toggled",
107 G_CALLBACK(_signal_type_toggled),
108 self);
109 g_object_set_data(G_OBJECT(self->radio_default),
110 "IrrecoButtonLayoutBgType",
111 (gpointer) IRRECO_THEME_UPLOAD_DEFAULT);
112 g_signal_connect(G_OBJECT(self->radio_color), "toggled",
113 G_CALLBACK(_signal_type_toggled),
114 self);
115 g_object_set_data(G_OBJECT(self->radio_color),
116 "IrrecoButtonLayoutBgType",
117 (gpointer) IRRECO_THEME_UPLOAD_COLOR);
118 g_signal_connect(G_OBJECT(self->radio_image), "toggled",
119 G_CALLBACK(_signal_type_toggled),
120 self);
121 g_object_set_data(G_OBJECT(self->radio_image),
122 "IrrecoButtonLayoutBgType",
123 (gpointer) IRRECO_THEME_UPLOAD_IMAGE);*/
125 /* Button signals. */
126 /*g_signal_connect(G_OBJECT(button_image), "clicked",
127 G_CALLBACK(_signal_image_clicked),
128 self);
129 g_signal_connect(G_OBJECT(self->color_button), "clicked",
130 G_CALLBACK(_signal_color_clicked),
131 self);
132 g_signal_connect(G_OBJECT(preview_event_box), "button-release-event",
133 G_CALLBACK(_signal_preview_clicked),
134 self);*/
136 /* Signal handler for theme_bg_browser*/
137 /*g_signal_connect(G_OBJECT(IRRECO_LISTBOX(
138 self->theme_bg_browser->images)->tree_selection),
139 "changed",
140 G_CALLBACK(_signal_theme_image_selection_changed),
141 self);*/
143 gtk_widget_show_all(GTK_WIDGET(self));
144 IRRECO_RETURN
147 static void irreco_theme_upload_dlg_init(IrrecoThemeUploadDlg *self)
149 IRRECO_ENTER
150 self->theme_name = g_string_new(NULL);
151 self->author = g_string_new(NULL);
152 self->comments = g_string_new(NULL);
153 IRRECO_RETURN
156 static void irreco_theme_upload_dlg_finalize(GObject *object)
158 IrrecoThemeUploadDlg *self;
159 IRRECO_ENTER
161 self = IRRECO_THEME_UPLOAD_DLG(object);
162 g_string_free(self->theme_name, TRUE);
163 self->theme_name = NULL;
164 g_string_free(self->author, TRUE);
165 self->author = NULL;
166 g_string_free(self->comments, TRUE);
167 self->comments = NULL;
169 G_OBJECT_CLASS(irreco_theme_upload_dlg_parent_class)->finalize(object);
170 IRRECO_RETURN
173 static void irreco_theme_upload_dlg_class_init(IrrecoThemeUploadDlgClass *klass)
175 GObjectClass* object_class = G_OBJECT_CLASS (klass);
176 /* IrrecoDlgClass* parent_class = IRRECO_DLG_CLASS (klass); */
178 object_class->finalize = irreco_theme_upload_dlg_finalize;
179 object_class->constructed = irreco_theme_upload_dlg_constructed;
182 GtkWidget *irreco_theme_upload_dlg_new(IrrecoData *irreco_data,
183 GtkWindow *parent_window)
185 IrrecoThemeUploadDlg *self;
186 IRRECO_ENTER
188 self = g_object_new(IRRECO_TYPE_THEME_UPLOAD_DLG,
189 "irreco-data", irreco_data,
190 NULL);
191 irreco_dlg_set_parent(IRRECO_DLG(self), parent_window);
192 IRRECO_RETURN_PTR(self);
196 * @deprecated
197 * @todo Replace calls to irreco_theme_upload_dlg_create() with
198 * irreco_theme_upload_dlg_new().
200 IrrecoThemeUploadDlg *irreco_theme_upload_dlg_create(IrrecoData *irreco_data,
201 GtkWindow *parent_window)
203 IRRECO_ENTER
204 IRRECO_RETURN_PTR(irreco_theme_upload_dlg_new(
205 irreco_data, parent_window));
209 * @deprecated
210 * @todo Replace calls to irreco_theme_upload_dlg_destroy() with
211 * gtk_widget_destroy().
213 void irreco_theme_upload_dlg_destroy(IrrecoThemeUploadDlg * self)
215 IRRECO_ENTER
216 gtk_widget_destroy(GTK_WIDGET(self));
217 IRRECO_RETURN
220 /** @} */
224 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
225 /* Private Functions */
226 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
228 * @name Private Functions
229 * @{
231 static gboolean _check_texts(IrrecoThemeUploadDlg *self)
233 IRRECO_ENTER
234 /* TODO Check self->theme_name etc to be correct and whine if are not */
235 IRRECO_RETURN_BOOL(TRUE);
237 /** @} */
241 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
242 /* Public Functions */
243 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
246 * Show dialog, and ask user for input.
248 /* TODO pass themename/theme instead of irreco_layout */
249 gboolean irreco_theme_upload_dlg_run(IrrecoThemeUploadDlg *self,
250 IrrecoButtonLayout *irreco_layout)
252 IRRECO_ENTER
253 #if 0
254 /* Setup dialog. */
255 self->type = irreco_button_layout_get_bg_type(irreco_layout);
256 irreco_gstring_set(self->filename,
257 irreco_button_layout_get_bg_image(irreco_layout));
258 hildon_color_button_set_color(
259 HILDON_COLOR_BUTTON(self->color_button),
260 irreco_button_layout_get_bg_color(irreco_layout));
262 /* Prepare ui. */
263 _sync_radio(self);
264 _draw_preview(self);
265 #endif
266 run_dialog_again:
267 if (gtk_dialog_run(GTK_DIALOG(self)) == GTK_RESPONSE_OK) {
268 /* TODO Check text lengths at priv func */
269 if(!_check_texts(self)) {
270 goto run_dialog_again;
273 /* TODO Show login/reg dialog */
274 /* TODO If logged, theme_setpreview(theme, preview) */
275 /* TODO rip theme into pieces and toss 'em into func that shoves bits into soup */
276 /* +author, comments, loginname and passwdsha */
278 /*GdkColor *color;
279 g_object_get(G_OBJECT(self->color_button),
280 "color", &color, NULL);
281 irreco_button_layout_set_bg_type(irreco_layout,
282 self->type);
283 irreco_button_layout_set_bg_color(irreco_layout, color);
284 irreco_button_layout_set_bg_image(
285 irreco_layout, self->filename->str);
287 IRRECO_PRINTF("%i\n",
288 irreco_button_layout_get_bg_type(irreco_layout));
290 IRRECO_RETURN_BOOL(TRUE); */
292 IRRECO_RETURN_BOOL(FALSE);
295 /** @} */
299 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
300 /* Events and Callbacks */
301 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
304 * @name Events and Callbacks
305 * @{
307 /* TODO Event for selecting preview image */
308 /** @} */
312 /** @} */