Fixed edit bg and button functions and clean code.
[irreco.git] / irreco / src / core / irreco_theme_manager_dlg.c
bloba72a1975d88348c5c09987010b9d2d6239b6acd3
1 /*
2 * irreco - Ir Remote Control
3 * Copyright (C) 2008 Pekka Gehör (pegu6@msn.com)
4 * Joni Kokko (t5kojo01@students.oamk.fi),
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "irreco_theme_manager_dlg.h"
22 #include <hildon/hildon-banner.h>
23 #include "irreco_webdb_register_dlg.h"
24 #include "irreco_select_instance_dlg.h"
25 #include "irreco_config.h"
27 /**
28 * @addtogroup IrrecoThemeManagerDlg
29 * @ingroup Irreco
31 * @todo PURPOCE OF CLASS.
33 * @{
36 /**
37 * @file
38 * Source file of @ref IrrecoThemeManagerDlg.
42 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
43 /* Datatypes */
44 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
45 #define IRRECO_BACKGROUND_PREVIEW_WIDHT (IRRECO_SCREEN_WIDTH / 6)
46 #define IRRECO_BACKGROUND_PREVIEW_HEIGHT (IRRECO_SCREEN_HEIGHT / 6)
49 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
50 /* Prototypes */
51 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
53 static void irreco_theme_manager_dlg_hide_banner(IrrecoThemeManagerDlg *self);
54 static void irreco_theme_manager_dlg_loader_stop(IrrecoThemeManagerDlg *self);
56 static void irreco_theme_manager_dlg_clean_details(IrrecoThemeManagerDlg *self);
58 static gboolean
59 irreco_theme_manager_dlg_loader_deb(IrrecoThemeManagerDlg *self);
60 static gboolean
61 irreco_theme_manager_dlg_loader_user(IrrecoThemeManagerDlg *self);
62 static gboolean
63 irreco_theme_manager_dlg_loader_web(IrrecoThemeManagerDlg *self);
64 static gboolean
65 irreco_theme_manager_dlg_loader_db(IrrecoThemeManagerDlg *self);
66 static gboolean
67 irreco_theme_manager_dlg_theme_db_detail_loader(IrrecoThemeManagerDlg *self);
68 static gboolean
69 irreco_theme_manager_dlg_bg_loader(IrrecoThemeManagerDlg *self);
70 static gboolean
71 irreco_theme_manager_dlg_button_loader(IrrecoThemeManagerDlg *self);
74 static gboolean
75 irreco_theme_manager_dlg_display_theme_detail(IrrecoThemeManagerDlg *self,
76 GtkTreeIter * iter);
78 static gboolean irreco_show_theme_manager_dlg_map_event(IrrecoThemeManagerDlg
79 *self, GdkEvent *event,
80 gpointer user_data);
81 static void irreco_show_theme_manager_dlg_destroy_event(IrrecoThemeManagerDlg
82 *self,
83 gpointer user_data);
85 static void
86 irreco_show_theme_manager_dlg_row_activated_event(GtkTreeView *tree_view,
87 GtkTreePath *path,
88 GtkTreeViewColumn *column,
89 IrrecoThemeManagerDlg*self);
91 static void
92 irreco_show_theme_manager_dlg_row_expanded_event(GtkTreeView *tree_view,
93 GtkTreeIter *iter,
94 GtkTreePath *path,
95 IrrecoThemeManagerDlg *self);
96 static void
97 irreco_show_theme_manager_dlg_row_collapsed_event(GtkTreeView *tree_view,
98 GtkTreeIter *iter,
99 GtkTreePath *path,
100 IrrecoThemeManagerDlg *self);
103 static void
104 irreco_show_theme_manager_dlg_row_selected_event(GtkTreeSelection *sel,
105 IrrecoThemeManagerDlg *self);
107 gboolean irreco_theme_manager_dlg_preview_dlg(GtkWidget *widget,
108 GdkEventButton *event,
109 IrrecoThemeManagerDlg *self);
112 static void irreco_theme_manager_dlg_upload_theme(GtkButton *button,
113 IrrecoThemeManagerDlg *self);
115 static void irreco_theme_manager_dlg_delete_theme(GtkButton *button,
116 IrrecoThemeManagerDlg *self);
117 static void
118 irreco_theme_manager_dlg_download_theme(GtkButton *button,
119 IrrecoThemeManagerDlg *self);
121 static void
122 irreco_theme_manager_dlg_selected_version_dlg(GtkComboBox *widget,
123 IrrecoThemeManagerDlg *self);
125 void irreco_theme_manager_update_theme_manager(IrrecoThemeManager *self);
127 static void irreco_theme_manager_dlg_new_theme(GtkButton *button,
128 IrrecoThemeManagerDlg *self);
130 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
131 /* Datatypes */
132 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
134 /** Button responce codes. */
135 enum {
136 IRRECO_DEVICE_REFRESH
139 /** GtkTreeStore colums. */
140 enum
142 TEXT_COL,
143 FLAG_COL,
144 DATA_COL,
145 N_COLUMNS
148 /** Version colums. */
149 enum
151 DATE_COL,
152 ID_COL
155 /** Loader states. */
156 enum
158 LOADER_STATE_INIT,
159 LOADER_STATE_LOOP,
160 LOADER_STATE_END,
161 LOADER_STATE_CLEANUP
164 /** Row flags. */
165 enum
167 ROW_CHILDREN_LOADED = 1 << 1,
168 ROW_TYPE_CATEGORY = 1 << 2,
169 ROW_TYPE_DEB = 1 << 3,
170 ROW_TYPE_USER = 1 << 4,
171 ROW_TYPE_WEB = 1 << 5,
172 ROW_TYPE_DB = 1 << 6,
173 ROW_TYPE_LOADING = 1 << 7
176 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
177 /* Construction & Destruction */
178 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
181 * @name Construction & Destruction
182 * @{
185 G_DEFINE_TYPE(IrrecoThemeManagerDlg, irreco_theme_manager_dlg, IRRECO_TYPE_DLG)
187 static void irreco_theme_manager_dlg_finalize(GObject *object)
189 if (G_OBJECT_CLASS(irreco_theme_manager_dlg_parent_class)->finalize)
190 G_OBJECT_CLASS(irreco_theme_manager_dlg_parent_class)->finalize(
191 object);
194 static void
195 irreco_theme_manager_dlg_class_init(IrrecoThemeManagerDlgClass *klass)
197 GObjectClass *object_class = G_OBJECT_CLASS(klass);
198 object_class->finalize = irreco_theme_manager_dlg_finalize;
201 static void irreco_theme_manager_dlg_init(IrrecoThemeManagerDlg *self)
203 GtkTreeViewColumn *column;
204 GtkCellRenderer *renderer;
205 GtkTreeSelection *select;
206 GtkWidget *label_name;
207 GtkWidget *label_description;
208 /*GtkWidget *label_rate;*/
209 GtkWidget *theme_info_frame;
210 GtkWidget *tree_view_frame;
211 GtkWidget *tree_view_hbox;
212 GtkWidget *preview_frame;
213 PangoFontDescription *initial_font;
214 GtkWidget *select_vbox;
215 GtkWidget *versions_hbox;
216 GtkWidget *comment_alignment;
217 GtkWidget *info_scrollbar;
218 GtkWidget *scrollbar;
219 GtkWidget *theme_info;
220 GtkWidget *table;
221 GtkWidget *info_vbox;
222 GtkWidget *done_button;
223 GtkWidget *theme_table;
224 GtkWidget *preview_event_box;
226 IRRECO_ENTER
228 self->theme_folder = NULL;
230 /* Construct dialog. */
231 gtk_window_set_title(GTK_WINDOW(self),
232 _("Theme Manager "));
233 /*gtk_window_set_decorated (GTK_WINDOW(self), FALSE);*/
234 gtk_window_set_modal(GTK_WINDOW(self), TRUE);
235 gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE);
236 gtk_dialog_set_has_separator(GTK_DIALOG(self), FALSE);
238 /*Buttons*/
240 self->refresh_button= gtk_dialog_add_button (GTK_DIALOG(self),
241 _("Refresh"),
242 IRRECO_DEVICE_REFRESH);
244 self->new_button= gtk_dialog_add_button (GTK_DIALOG(self),
245 _("New"), GTK_RESPONSE_NONE);
246 self->edit_button= gtk_dialog_add_button (GTK_DIALOG(self),
247 _("Edit"), GTK_RESPONSE_NONE);
249 self->upload_button= gtk_dialog_add_button (GTK_DIALOG(self),
250 _("Upload"), GTK_RESPONSE_NONE);
253 self->download_button= gtk_dialog_add_button (GTK_DIALOG(self),
254 _("Download"),
255 GTK_RESPONSE_NONE);
256 self->clear_button= gtk_dialog_add_button (GTK_DIALOG(self),
257 _("Delete"),
258 GTK_RESPONSE_NONE);
259 done_button= gtk_dialog_add_button (GTK_DIALOG(self),
260 _("Done"),
261 GTK_RESPONSE_CANCEL);
263 /* Create theme table */
265 table = gtk_table_new(7,7,TRUE);
266 gtk_table_set_col_spacings(GTK_TABLE (table), 8);
267 gtk_table_set_row_spacings(GTK_TABLE (table), 8);
268 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(self)->vbox),
269 irreco_gtk_align(GTK_WIDGET(table),
270 0, 0, 1, 1, 8, 8, 8, 8));
271 /* Create tree_view_hbox */
272 tree_view_hbox = gtk_hbox_new(FALSE, 2);
274 /* Create Treeview */
275 self->tree_store = gtk_tree_store_new(
276 N_COLUMNS, G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER);
277 self->tree_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(
278 GTK_TREE_MODEL(self->tree_store)));
280 renderer = gtk_cell_renderer_text_new();
281 column = gtk_tree_view_column_new_with_attributes(
282 NULL, renderer, "text", TEXT_COL, NULL);
283 gtk_tree_view_append_column(self->tree_view, column);
285 gtk_box_pack_start(GTK_BOX(tree_view_hbox), GTK_WIDGET(self->tree_view),
286 TRUE, TRUE, 0);
288 /* Create scrollbar for Treeview */
290 scrollbar = gtk_scrolled_window_new(NULL, NULL);
291 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollbar),
292 GTK_POLICY_AUTOMATIC,
293 GTK_POLICY_AUTOMATIC);
295 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(
296 scrollbar), tree_view_hbox);
298 /* Create Frame for Treeview */
299 tree_view_frame = gtk_frame_new("");
300 gtk_frame_set_label_widget(GTK_FRAME(tree_view_frame),
301 irreco_gtk_label_bold("Themes", 0, 0, 0, 0, 0, 0));
303 gtk_container_add(GTK_CONTAINER(tree_view_frame),
304 GTK_WIDGET(scrollbar));
306 /* Create theme_info */
308 theme_info = gtk_table_new(7, 4, TRUE);
309 gtk_table_set_col_spacings(GTK_TABLE(theme_info), 8);
310 gtk_table_set_row_spacings(GTK_TABLE(theme_info), 8);
312 /* Scrolled window for info */
313 info_scrollbar = gtk_scrolled_window_new(NULL, NULL);
314 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(
315 info_scrollbar),
316 GTK_POLICY_NEVER,
317 GTK_POLICY_AUTOMATIC);
319 /* Create combobox*/
320 self->version_store = gtk_tree_store_new(
321 2, G_TYPE_STRING, G_TYPE_STRING);
323 self->combobox = gtk_combo_box_new_text();
324 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(self->combobox), 1);
325 gtk_combo_box_set_model(GTK_COMBO_BOX(self->combobox),
326 GTK_TREE_MODEL(self->version_store));
328 theme_table = gtk_table_new(5, 7, TRUE);
329 gtk_table_set_col_spacings(GTK_TABLE(theme_table), 1);
330 gtk_table_set_row_spacings(GTK_TABLE(theme_table), 1);
332 info_vbox = gtk_vbox_new(FALSE, 1);
334 /*create eventbox*/
335 preview_event_box = gtk_event_box_new();
336 self->select_label = gtk_label_new(" Select \ncategory");
338 /* Create frame for theme_info */
339 select_vbox = gtk_vbox_new(FALSE, 2);
340 versions_hbox = gtk_hbox_new(FALSE, 2);
341 theme_info_frame = gtk_frame_new("");
342 gtk_frame_set_label_widget(GTK_FRAME(theme_info_frame),
343 irreco_gtk_label_bold("Info", 0, 0, 0, 0, 0, 0));
344 self->theme_info_alignment = gtk_alignment_new(0, 0, 0, 0);
345 gtk_alignment_set_padding(GTK_ALIGNMENT(self->theme_info_alignment),
346 0, 4, 8, 8);
349 preview_frame = gtk_frame_new(NULL);
350 gtk_frame_set_shadow_type(GTK_FRAME(preview_frame), GTK_SHADOW_OUT);
352 self->theme_image = gtk_image_new();
353 gtk_image_set_from_file(GTK_IMAGE(self->theme_image), NULL);
355 /*Dialog label*/
357 /*label_rate = gtk_label_new(" Rating");*/
358 label_name = gtk_label_new("Name: ");
359 self->label_creator = gtk_label_new("Author: ");
360 self->label_download= gtk_label_new("Downloads: ");
361 label_description = gtk_label_new("Comment: ");
362 self->label_combobox = gtk_label_new("Version:");
364 self->theme_name = gtk_label_new("");
365 self->theme_creator = gtk_label_new("");
366 self->theme_downloaded = gtk_label_new("");
367 self->theme_comment = gtk_label_new("");
368 self->theme_version = gtk_label_new("");
370 comment_alignment = gtk_alignment_new(0, 0, 0, 0);
371 gtk_widget_set_size_request(self->theme_comment,
372 330, -1);
373 gtk_alignment_set_padding(GTK_ALIGNMENT(comment_alignment),
374 0, 0, 20, 0);
375 gtk_label_set_line_wrap(GTK_LABEL(self->theme_comment), TRUE);
376 gtk_label_set_line_wrap_mode(GTK_LABEL(self->theme_comment),
377 PANGO_WRAP_WORD);
379 /*gtk_misc_set_alignment(GTK_MISC(label_rate), 0, 0.5);*/
380 gtk_misc_set_alignment(GTK_MISC(label_name), 0, 0.5);
381 gtk_misc_set_alignment(GTK_MISC(self->label_creator), 0, 0.5);
382 gtk_misc_set_alignment(GTK_MISC(self->label_download), 0, 0.5);
383 gtk_misc_set_alignment(GTK_MISC(label_description), 0, 0.5);
384 gtk_misc_set_alignment(GTK_MISC(self->label_combobox), 0, 0.5);
385 gtk_misc_set_alignment(GTK_MISC(self->theme_name), 0, 0.5);
386 gtk_misc_set_alignment(GTK_MISC(self->theme_creator), 0, 0.5);
387 gtk_misc_set_alignment(GTK_MISC(self->theme_downloaded), 0, 0.5);
388 gtk_misc_set_alignment(GTK_MISC(self->theme_comment), 0, 0.5);
389 gtk_misc_set_alignment(GTK_MISC(self->theme_version), 0, 0.5);
392 /*Attach WidGets to tables*/
394 gtk_table_attach(GTK_TABLE(theme_info), info_scrollbar,
395 0, 4, 4, 7, GTK_FILL, GTK_FILL, 0, 0);
397 gtk_table_attach_defaults(GTK_TABLE(table),
398 tree_view_frame, 0, 3, 0, 7);
399 gtk_table_attach_defaults(GTK_TABLE(theme_info),
400 preview_event_box, 3, 4, 0, 3);
401 /* gtk_table_attach_defaults(GTK_TABLE(self->theme_info),
402 label_rate, 3, 4, 3, 4);*/
403 gtk_table_attach_defaults(GTK_TABLE(theme_info),
404 theme_table, 0, 3, 0, 4);
405 gtk_table_attach_defaults(GTK_TABLE(theme_table),
406 label_name, 0, 3, 0, 1);
407 gtk_table_attach_defaults(GTK_TABLE(theme_table),
408 self->label_creator, 0, 3, 1, 2);
409 gtk_table_attach_defaults(GTK_TABLE(theme_table),
410 self->label_download, 0, 3, 2, 3);
411 gtk_table_attach_defaults(GTK_TABLE(theme_table),
412 label_description, 0, 3, 4, 5);
413 gtk_table_attach_defaults(GTK_TABLE(theme_table),
414 self->label_combobox, 0, 3, 3, 4);
415 gtk_table_attach_defaults(GTK_TABLE(theme_table),
416 versions_hbox, 3, 7, 3, 4);
417 gtk_table_attach_defaults(GTK_TABLE(table),
418 theme_info_frame, 3, 7, 0, 7);
419 gtk_table_attach(GTK_TABLE(theme_table), self->theme_name,
420 3, 7, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
421 gtk_table_attach(GTK_TABLE(theme_table), self->theme_creator,
422 3, 7, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
423 gtk_table_attach(GTK_TABLE(theme_table), self->theme_downloaded,
424 3, 7, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
426 /*Add WidGets*/
428 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(
429 info_scrollbar), info_vbox);
430 gtk_container_add(GTK_CONTAINER(preview_frame),
431 self->theme_image);
432 gtk_container_add(GTK_CONTAINER(preview_event_box),
433 preview_frame);
434 gtk_container_add(GTK_CONTAINER(info_vbox), comment_alignment);
435 gtk_container_add(GTK_CONTAINER(comment_alignment),
436 self->theme_comment);
437 gtk_container_add(GTK_CONTAINER(theme_info_frame),
438 GTK_WIDGET(select_vbox));
439 gtk_container_add(GTK_CONTAINER(select_vbox),
440 GTK_WIDGET(self->theme_info_alignment));
441 gtk_container_add(GTK_CONTAINER(select_vbox),
442 GTK_WIDGET(self->select_label));
443 gtk_container_add(GTK_CONTAINER(self->theme_info_alignment),
444 GTK_WIDGET(theme_info));
445 gtk_container_add(GTK_CONTAINER(versions_hbox),
446 GTK_WIDGET(self->theme_version));
447 gtk_container_add(GTK_CONTAINER(versions_hbox),
448 GTK_WIDGET(self->combobox));
450 /*Set font size and style*/
451 /* Font size*/
452 initial_font = pango_font_description_from_string ("Sans Bold 16");
453 gtk_widget_modify_font (self->select_label, initial_font);
455 initial_font = pango_font_description_from_string ("Sans Bold 12");
456 /*gtk_widget_modify_font (label_rate, initial_font);*/
457 gtk_widget_modify_font (label_name, initial_font);
458 gtk_widget_modify_font (self->label_creator, initial_font);
459 gtk_widget_modify_font (self->label_download, initial_font);
460 gtk_widget_modify_font (label_description, initial_font);
461 gtk_widget_modify_font (self->label_combobox, initial_font);
462 /* Font size*/
463 initial_font = pango_font_description_from_string ("Sans 11");
464 gtk_widget_modify_font (self->theme_name, initial_font);
465 gtk_widget_modify_font (self->theme_creator, initial_font);
466 gtk_widget_modify_font (self->theme_downloaded, initial_font);
467 gtk_widget_modify_font (self->theme_comment, initial_font);
468 gtk_widget_modify_font (self->theme_version, initial_font);
469 gtk_widget_modify_font (self->combobox, initial_font);
471 /* Setup the selection handler for TREE */
472 select = gtk_tree_view_get_selection(self->tree_view);
473 gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
475 /* Signal handlers. */
476 g_signal_connect(G_OBJECT(self), "map-event",
477 G_CALLBACK(irreco_show_theme_manager_dlg_map_event), NULL);
478 g_signal_connect(G_OBJECT(self), "destroy",
479 G_CALLBACK(irreco_show_theme_manager_dlg_destroy_event), NULL);
480 g_signal_connect(G_OBJECT(self->tree_view), "row-activated",
481 G_CALLBACK(irreco_show_theme_manager_dlg_row_activated_event),
482 self);
483 g_signal_connect(G_OBJECT(self->tree_view), "row-expanded",
484 G_CALLBACK(irreco_show_theme_manager_dlg_row_expanded_event),
485 self);
486 g_signal_connect(G_OBJECT(self->tree_view), "row-collapsed",
487 G_CALLBACK(irreco_show_theme_manager_dlg_row_collapsed_event),
488 self);
489 g_signal_connect(G_OBJECT (select), "changed",
490 G_CALLBACK (irreco_show_theme_manager_dlg_row_selected_event),
491 self);
492 g_signal_connect(G_OBJECT (self->combobox), "changed",
493 G_CALLBACK (irreco_theme_manager_dlg_selected_version_dlg),
494 self);
495 g_signal_connect(G_OBJECT(preview_event_box),
496 "button-release-event",
497 G_CALLBACK(irreco_theme_manager_dlg_preview_dlg),
498 self);
499 g_signal_connect(G_OBJECT(self->upload_button),
500 "clicked",
501 G_CALLBACK(irreco_theme_manager_dlg_upload_theme),
502 self);
503 g_signal_connect(G_OBJECT(self->clear_button),
504 "clicked",
505 G_CALLBACK(irreco_theme_manager_dlg_delete_theme),
506 self);
507 g_signal_connect(G_OBJECT(self->download_button),
508 "clicked",
509 G_CALLBACK(irreco_theme_manager_dlg_download_theme),
510 self);
511 g_signal_connect(G_OBJECT(self->edit_button),
512 "clicked",
513 G_CALLBACK(irreco_theme_manager_dlg_new_theme),
514 self);
515 g_signal_connect(G_OBJECT(self->new_button),
516 "clicked",
517 G_CALLBACK(irreco_theme_manager_dlg_new_theme),
518 self);
520 gtk_tree_view_set_enable_tree_lines(self->tree_view, TRUE);
521 g_object_set (G_OBJECT (self->tree_view), "show-expanders", TRUE, NULL);
522 g_object_set (G_OBJECT (self->tree_view), "level-indentation", 0, NULL);
523 gtk_tree_view_set_rubber_banding(self->tree_view, FALSE);
525 gtk_widget_set_size_request(GTK_WIDGET(self), 696, 396);
526 gtk_widget_show_all(GTK_WIDGET(self));
528 IRRECO_RETURN
531 GtkWidget *irreco_theme_manager_dlg_new(IrrecoData *irreco_data,
532 GtkWindow *parent)
534 IrrecoThemeManagerDlg *self;
536 IRRECO_ENTER
538 self = g_object_new(IRRECO_TYPE_THEME_MANAGER_DLG, NULL);
539 irreco_dlg_set_parent(IRRECO_DLG(self), parent);
540 irreco_theme_manager_dlg_set_irreco_data(self, irreco_data);
542 IRRECO_RETURN_PTR(self);
546 * Show whole preview image
550 gboolean irreco_theme_manager_dlg_preview_dlg(GtkWidget *widget,
551 GdkEventButton *event,
552 IrrecoThemeManagerDlg *self)
554 GtkWidget *image, *event_box;
555 GtkWidget *preview_dialog;
557 IRRECO_ENTER
559 if(self->preview_add != NULL ||
560 self->webdb_theme->preview_button != NULL) {
562 preview_dialog = irreco_dlg_new ();
563 gtk_window_set_title(GTK_WINDOW(preview_dialog), _("Preview"));
564 gtk_window_set_modal(GTK_WINDOW(preview_dialog), TRUE);
565 gtk_window_set_destroy_with_parent(GTK_WINDOW(preview_dialog), TRUE);
566 gtk_dialog_set_has_separator(GTK_DIALOG(preview_dialog), FALSE);
568 gtk_widget_set_size_request(preview_dialog, 185, -1);
570 event_box = gtk_event_box_new();
571 image = gtk_image_new();
572 if(self->preview_add != NULL){
573 gtk_image_set_from_file(GTK_IMAGE(image), self->preview_add);
575 }else{
576 gtk_image_set_from_pixbuf(GTK_IMAGE(image),
577 GDK_PIXBUF(self->webdb_theme->preview_button));
580 gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(preview_dialog)->vbox),
581 event_box);
582 gtk_container_add(GTK_CONTAINER(event_box), image);
584 g_signal_connect_swapped(G_OBJECT(event_box),
585 "button-release-event",
586 G_CALLBACK(gtk_widget_destroy),
587 preview_dialog);
589 gtk_widget_show_all(GTK_WIDGET(preview_dialog));
591 IRRECO_RETURN_BOOL(TRUE);
595 * Combobox versions
599 static void
600 irreco_theme_manager_dlg_selected_version_dlg(GtkComboBox *widget,
601 IrrecoThemeManagerDlg *self)
603 GtkTreeIter iter;
604 gchar *id;
606 IRRECO_ENTER
608 if(!gtk_combo_box_get_active_iter(widget, &iter)) {
609 IRRECO_RETURN
611 gtk_tree_model_get(GTK_TREE_MODEL(self->version_store), &iter,
612 ID_COL, &id, -1);
614 if (self->webdb_theme == NULL || self->webdb_theme->id != atoi(id)) {
615 IRRECO_DEBUG("SELECTED ID: %d\n", atoi(id));
616 self->selected_theme_id = atoi(id);
617 self->loader_func_id = g_idle_add(G_SOURCEFUNC(
618 irreco_theme_manager_dlg_theme_db_detail_loader),
619 self);
622 IRRECO_RETURN
626 * Delete user theme
629 static void irreco_theme_manager_dlg_delete_theme(GtkButton *button,
630 IrrecoThemeManagerDlg *self)
633 const gchar *name = gtk_label_get_label(GTK_LABEL(self->theme_name));
634 GString *message = g_string_new(NULL);
635 IRRECO_ENTER
637 g_string_append_printf(
638 message, _("Are you sure you want to\n "
639 "delete %s theme?"),name);
641 if (irreco_yes_no_dlg(GTK_WINDOW(self), message->str)){
643 irreco_theme_manager_remove_theme(
644 self->irreco_data->theme_manager, name);
645 gtk_button_clicked(GTK_BUTTON(self->refresh_button));
648 g_string_free(message, TRUE);
649 IRRECO_RETURN
653 * Download theme from DB
656 static void irreco_theme_manager_dlg_download_theme(GtkButton *button,
657 IrrecoThemeManagerDlg *self)
659 GtkWidget *radio1, *radio2, *radio3;
660 GtkWidget *label;
661 IrrecoTheme *theme;
662 IrrecoWebdbCache *webdb_cache = NULL;
663 gboolean theme_is_loaded = FALSE;
664 gint delete_mode = 0;
665 IrrecoTheme *same_theme = NULL;
666 gchar *same_theme_folder = NULL;
667 IrrecoThemeManager *theme_manager = self->irreco_data->theme_manager;
668 GString *message = g_string_new(NULL);
669 GString *path = g_string_new(NULL);
671 IRRECO_ENTER
673 webdb_cache = irreco_data_get_webdb_cache(self->irreco_data, FALSE);
674 self->download_dialog = irreco_dlg_new();
676 gtk_widget_set_size_request(self->download_dialog, 340, 160);
678 gtk_window_set_title(GTK_WINDOW(self->download_dialog),
679 _("Download theme"));
680 gtk_window_set_modal(GTK_WINDOW(self->download_dialog), TRUE);
681 gtk_window_set_destroy_with_parent(GTK_WINDOW(self->download_dialog),
682 TRUE);
683 gtk_dialog_set_has_separator(GTK_DIALOG(self->download_dialog), FALSE);
684 gtk_dialog_add_buttons(GTK_DIALOG(self->download_dialog),
685 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
686 GTK_STOCK_OK, GTK_RESPONSE_OK,
687 NULL);
689 label = gtk_label_new("Select save location");
691 radio1 = gtk_radio_button_new_with_label (NULL, "MMC1");
692 radio2 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(
693 radio1), "MMC2");
694 radio3 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(
695 radio2), "DEVICE");
697 gtk_box_pack_start_defaults(GTK_BOX(
698 GTK_DIALOG(self->download_dialog)->vbox),
699 label);
701 if(irreco_is_dir("/media/mmc1")) {
702 gtk_box_pack_start_defaults(GTK_BOX(
703 GTK_DIALOG(self->download_dialog)->vbox),
704 radio1);
707 if(irreco_is_dir("/media/mmc2")) {
708 gtk_box_pack_start_defaults(GTK_BOX(
709 GTK_DIALOG(self->download_dialog)->vbox),
710 radio2);
712 #if 0
713 gtk_box_pack_start_defaults(GTK_BOX(
714 GTK_DIALOG(self->download_dialog)->vbox),
715 radio3);
717 #endif
719 gtk_widget_show_all(GTK_WIDGET(self->download_dialog));
721 while (1) {
722 delete_mode = 0;
724 if (gtk_dialog_run(
725 GTK_DIALOG(self->download_dialog)) == GTK_RESPONSE_CANCEL){
726 break;
729 if (self->loader_func_id != 0) {
730 continue;
733 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio1))) {
734 self->theme_folder = "/media/mmc1/irreco/";
735 } else if (gtk_toggle_button_get_active(
736 GTK_TOGGLE_BUTTON(radio2))) {
737 self->theme_folder = "/media/mmc2/irreco/";
738 } else {
739 self->theme_folder = IRRECO_THEME_DIR;
742 if(!irreco_is_dir(self->theme_folder)) {
743 g_mkdir(self->theme_folder, 0777);
746 /* Create theme */
747 g_string_printf(path, "%s%s/", self->theme_folder,
748 self->webdb_theme->folder->str);
750 IRRECO_STRING_TABLE_FOREACH_DATA(theme_manager->themes,
751 IrrecoTheme *, theme)
752 /*Check theme name*/
753 if (g_str_equal(self->webdb_theme->name->str,
754 theme->name->str)) {
755 if (g_str_equal(theme->source->str, "deb")) {
756 g_string_printf(message,
757 _("The \"%s\" theme already exists.\n"
758 "Can't overwrite \"Built In themes\"\n"
759 "Please remove it first from the\n"
760 "Application Manager"),
761 theme->name->str);
763 irreco_error_dlg(GTK_WINDOW(
764 self->download_dialog),
765 message->str);
766 goto end;
768 delete_mode += 1;
769 same_theme = theme;
771 /*Check theme folder path*/
772 else if (g_str_equal(path->str,
773 g_strconcat(theme->path->str, "/", NULL))){
774 if (g_str_equal(theme->source->str, "deb")) {
775 g_string_printf(message,
776 _("This theme replaces \"%s\" theme.\n"
777 "Can't overwrite \"Built In themes\"\n"
778 "Please remove it first from the\n"
779 "Application Manager"),
780 theme->name->str);
782 irreco_error_dlg(GTK_WINDOW(
783 self->download_dialog),
784 message->str);
785 goto end;
787 delete_mode += 2;
788 same_theme_folder = g_strdup(theme->name->str);
790 IRRECO_STRING_TABLE_FOREACH_END
792 if (delete_mode == 1) {
793 g_string_printf(message,
794 _("The \"%s\" theme already exists.\n"
795 "Do you want to replace this theme?"),
796 same_theme->name->str);
797 } else if (delete_mode == 2) {
798 g_string_printf(message,
799 _("This theme replaces \"%s\" theme.\n"
800 "Do you want to continue?"),
801 same_theme_folder);
802 } else if (delete_mode == 3) {
803 g_string_printf(message,
804 _("This theme replaces themes\n"
805 "\"%s\" and \"%s\"\n"
806 "Do you want to continue?"),
807 same_theme->name->str,
808 same_theme_folder);
811 /* Check whether a theme folder already exists */
812 if (delete_mode != 0) {
813 /* Create dialog*/
814 if (!irreco_yes_no_dlg(
815 GTK_WINDOW(self->download_dialog), message->str)) {
816 continue;
817 } else {
818 /* Remove theme folder and then make it again*/
819 if (delete_mode == 1 || delete_mode == 3) {
820 gchar *rm_cmd = g_strconcat("rm -r ",
821 same_theme->path->str, NULL);
822 system(rm_cmd);
823 g_free(rm_cmd);
825 if (delete_mode == 2 || delete_mode == 3) {
826 irreco_theme_manager_remove_theme(
827 self->irreco_data->theme_manager,
828 same_theme_folder);
829 g_free(same_theme_folder);
834 /*Create folder */
835 g_mkdir(path->str, 0777);
837 /*Create new theme*/
838 if (delete_mode == 0 || delete_mode == 2) {
839 theme = irreco_theme_new();
840 irreco_theme_set(theme,
841 self->webdb_theme->name->str,
842 path->str, "web",
843 self->webdb_theme->creator->str,
844 self->webdb_theme->comment->str,
845 self->webdb_theme->preview_button_name->str,
846 self->webdb_theme->uploaded->str);
848 irreco_theme_update_keyfile(theme);
849 irreco_theme_free(theme);
850 } else {
851 irreco_theme_set(same_theme,
852 self->webdb_theme->name->str,
853 path->str, "web",
854 self->webdb_theme->creator->str,
855 self->webdb_theme->comment->str,
856 self->webdb_theme->preview_button_name->str,
857 self->webdb_theme->uploaded->str);
860 /* Get buttons and backgrounds */
861 self->loader_func_id = g_idle_add(G_SOURCEFUNC(
862 irreco_theme_manager_dlg_button_loader), self);
863 theme_is_loaded = TRUE;
866 end:
867 g_string_free(message, TRUE);
868 g_string_free(path, TRUE);
869 irreco_theme_manager_dlg_hide_banner(self);
870 irreco_theme_manager_dlg_loader_stop(self);
871 if(self->download_dialog != NULL) {
872 gtk_widget_destroy(GTK_WIDGET(self->download_dialog));
873 self->download_dialog = NULL;
874 if(theme_is_loaded == TRUE) {
875 gtk_button_clicked(GTK_BUTTON(self->refresh_button));
878 IRRECO_RETURN
882 * Upload user theme
886 static void irreco_theme_manager_dlg_upload_theme(GtkButton *button,
887 IrrecoThemeManagerDlg *self)
889 IRRECO_ENTER
891 if (irreco_theme_upload_dlg_run(GTK_WINDOW(self),
892 self->irreco_data, self->theme) == TRUE) {
893 gtk_button_clicked(GTK_BUTTON(self->refresh_button));
895 IRRECO_RETURN
899 *Create new theme or edit theme
901 static void irreco_theme_manager_dlg_new_theme(GtkButton *button,
902 IrrecoThemeManagerDlg *self){
904 IRRECO_ENTER
906 /* Check which button */
907 /* Create new theme */
908 if (g_str_equal("New", gtk_button_get_label(button))) {
910 IrrecoTheme *new_theme = NULL;
912 new_theme = irreco_theme_new();
913 /*IRRECO_PRINTF("Pointer: %p \n", (void*) new_theme);
914 IRRECO_PAUSE*/
915 irreco_theme_creator_dlg_run(GTK_WINDOW(self),
916 self->irreco_data, new_theme);
918 /* Edit theme */
919 } else {
921 IrrecoTheme *new_theme = NULL;
923 new_theme = irreco_theme_copy(self->theme);
924 IRRECO_DEBUG("Pointer: %p \n", (void*) self->theme);
925 IRRECO_DEBUG("New_Pointer: %p \n", (void*) new_theme);
927 if (irreco_theme_creator_dlg_run(GTK_WINDOW(self),
928 self->irreco_data, new_theme)) {
931 self->theme = irreco_theme_copy(new_theme);
932 gtk_button_clicked(GTK_BUTTON(self->refresh_button));
935 irreco_theme_free(new_theme);
941 IRRECO_RETURN
945 /** @} */
947 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
948 /* Private Functions */
949 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
952 * @name Private Functions
953 * @{
957 * Clean detail list
960 static void irreco_theme_manager_dlg_clean_details(IrrecoThemeManagerDlg *self)
963 IRRECO_ENTER
965 gtk_widget_show_all(GTK_WIDGET(self));
966 gtk_label_set_text(
967 GTK_LABEL(self->theme_name), "-");
968 gtk_label_set_text(
969 GTK_LABEL(self->theme_creator), "-");
970 gtk_label_set_text(
971 GTK_LABEL(self->theme_comment), "-");
972 gtk_label_set_text(
973 GTK_LABEL(self->theme_downloaded), "-");
974 gtk_image_clear(GTK_IMAGE(self->theme_image));
975 self->preview_add=NULL;
977 gtk_widget_hide(self->upload_button);
978 gtk_widget_hide(self->download_button);
979 gtk_widget_hide(self->clear_button);
980 gtk_widget_hide(self->theme_info_alignment);
981 gtk_widget_show(self->select_label);
984 IRRECO_RETURN
988 * Have the childern of this item been loaded.
990 * @return TRUE if children have been loade, FALSE otherwise.
993 static gboolean
994 irreco_theme_manager_dlg_row_is_loaded(IrrecoThemeManagerDlg *self,
995 GtkTreeIter *iter)
997 gint i;
999 IRRECO_ENTER
1001 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1002 iter, FLAG_COL, &i, -1);
1003 if (i & ROW_CHILDREN_LOADED) IRRECO_RETURN_BOOL(TRUE);
1005 IRRECO_RETURN_BOOL(FALSE);
1009 * Get type of row.
1012 static gint irreco_theme_manager_dlg_row_get_type(IrrecoThemeManagerDlg *self,
1013 GtkTreeIter *iter)
1015 gint i;
1017 IRRECO_ENTER
1019 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1020 iter, FLAG_COL, &i, -1);
1021 if (i & ROW_TYPE_CATEGORY)
1022 IRRECO_RETURN_ENUM(ROW_TYPE_CATEGORY);
1023 if (i & ROW_TYPE_DEB)
1024 IRRECO_RETURN_ENUM(ROW_TYPE_DEB);
1025 if (i & ROW_TYPE_USER)
1026 IRRECO_RETURN_ENUM(ROW_TYPE_USER);
1027 if (i & ROW_TYPE_WEB)
1028 IRRECO_RETURN_ENUM(ROW_TYPE_WEB);
1029 if (i & ROW_TYPE_DB)
1030 IRRECO_RETURN_ENUM(ROW_TYPE_DB);
1031 if (i & ROW_TYPE_LOADING)
1032 IRRECO_RETURN_ENUM(ROW_TYPE_LOADING);
1033 IRRECO_RETURN_INT(0);
1037 * Show hildon progressbar banner.
1039 * This function will create a new banner if one has not been created yet,
1040 * if banner already exists, it's properties will be changed.
1042 * @param text Text to show.
1043 * @param fraction Value of progress.
1046 static void irreco_theme_manager_dlg_set_banner(IrrecoThemeManagerDlg *self,
1047 const gchar *text,
1048 gdouble fraction)
1050 IRRECO_ENTER
1052 if (self->banner == NULL) {
1053 self->banner = hildon_banner_show_progress(
1054 GTK_WIDGET(self), NULL, "");
1057 hildon_banner_set_text(HILDON_BANNER(self->banner), text);
1058 hildon_banner_set_fraction(HILDON_BANNER(self->banner), fraction);
1060 IRRECO_RETURN
1064 * Destroy banner, if it exists.
1067 static void irreco_theme_manager_dlg_hide_banner(IrrecoThemeManagerDlg *self)
1069 IRRECO_ENTER
1071 if (self->banner) {
1072 gtk_widget_destroy(self->banner);
1073 self->banner = NULL;
1076 IRRECO_RETURN
1080 * Start a loader state machine if one is not running already.
1083 static
1084 gboolean irreco_theme_manager_dlg_loader_start(IrrecoThemeManagerDlg *self,
1085 GSourceFunc function,
1086 GtkTreeIter *parent_iter)
1088 IRRECO_ENTER
1090 if (self->loader_func_id == 0) {
1091 if (parent_iter) {
1092 self->loader_parent_iter = gtk_tree_iter_copy(
1093 parent_iter);
1095 if (function) {
1096 self->loader_func_id = g_idle_add(function, self);
1097 } else {
1098 IRRECO_ERROR("Loader function pointer not given.\n");
1101 IRRECO_RETURN_BOOL(TRUE);
1106 * Stop and cleanup loader if a loader is running.
1109 static void irreco_theme_manager_dlg_loader_stop(IrrecoThemeManagerDlg *self)
1111 IRRECO_ENTER
1113 if (self->loader_func_id != 0) {
1114 g_source_remove(self->loader_func_id);
1115 self->loader_func_id = 0;
1116 self->loader_state = 0;
1117 if (self->loader_parent_iter) {
1118 gtk_tree_iter_free(self->loader_parent_iter);
1120 self->loader_parent_iter = NULL;
1122 IRRECO_RETURN
1125 static gboolean
1126 irreco_theme_manager_dlg_loader_user(IrrecoThemeManagerDlg *self)
1128 IRRECO_ENTER
1130 switch (self->loader_state) {
1131 case LOADER_STATE_INIT: {
1132 GtkTreeIter iter;
1133 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1134 0.5);
1135 self->loader_state = LOADER_STATE_LOOP;
1136 irreco_theme_manager_dlg_clean_details(self);
1137 if (!irreco_theme_manager_does_user_exist(
1138 self->irreco_data->theme_manager)) {
1139 self->loader_state = LOADER_STATE_END;
1140 self->loader_iter = NULL;
1141 } else {
1144 gtk_tree_store_append(self->tree_store,
1145 &iter, NULL);
1146 gtk_tree_store_set(self->tree_store,
1147 &iter,
1148 TEXT_COL, _("My Themes"),
1149 FLAG_COL, ROW_TYPE_CATEGORY,
1150 DATA_COL, NULL, -1);
1152 self->loader_iter = gtk_tree_iter_copy(&iter);
1155 IRRECO_RETURN_BOOL(TRUE);
1159 case LOADER_STATE_LOOP: {
1161 IrrecoData *irreco_data = NULL;
1162 IrrecoThemeManager *theme_manager = NULL;
1163 GtkTreeIter iter;
1164 IrrecoStringTable *categories = NULL;
1167 irreco_data = self->irreco_data;
1168 theme_manager = irreco_data->theme_manager;
1169 categories = irreco_theme_manager_get_themes(theme_manager);
1171 IRRECO_STRING_TABLE_FOREACH_DATA(categories,
1172 IrrecoTheme *, theme)
1174 if (g_utf8_collate(theme->source->str, "user") == 0){
1176 /* Add loading item into category. */
1177 gtk_tree_store_append(self->tree_store,
1178 &iter,
1179 self->loader_iter);
1180 gtk_tree_store_set(self->tree_store,
1181 &iter,
1182 TEXT_COL,
1183 theme->name->str,
1184 FLAG_COL,
1185 ROW_TYPE_USER,
1186 DATA_COL, NULL, -1);
1188 IRRECO_STRING_TABLE_FOREACH_END
1190 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1191 1.0);
1192 self->loader_state = LOADER_STATE_END;
1193 IRRECO_RETURN_BOOL(TRUE);
1196 case LOADER_STATE_END:
1197 if (self->loader_iter != NULL) {
1198 gtk_tree_iter_free(self->loader_iter);
1200 irreco_theme_manager_dlg_hide_banner(self);
1201 irreco_theme_manager_dlg_loader_stop(self);
1203 irreco_theme_manager_dlg_loader_start(self,
1204 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_deb),NULL);
1207 IRRECO_RETURN_BOOL(FALSE);
1211 * Category loader.
1213 * This loader will request a list of categories from the theme and
1214 * update the TreeView accordingly. Every category row created by this loader
1215 * will have row type ROW_TYPE_DEB.
1219 static gboolean irreco_theme_manager_dlg_loader_deb(IrrecoThemeManagerDlg *self)
1221 IRRECO_ENTER
1223 switch (self->loader_state) {
1224 case LOADER_STATE_INIT: {
1225 GtkTreeIter iter;
1226 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1227 0.5);
1228 self->loader_state = LOADER_STATE_LOOP;
1229 irreco_theme_manager_dlg_clean_details(self);
1231 if (!irreco_theme_manager_does_deb_exist(
1232 self->irreco_data->theme_manager)) {
1233 self->loader_state = LOADER_STATE_END;
1234 self->loader_iter = NULL;
1235 } else {
1237 gtk_tree_store_append(self->tree_store,
1238 &iter, NULL);
1239 gtk_tree_store_set(self->tree_store,
1240 &iter,
1241 TEXT_COL, _("Built In"),
1242 FLAG_COL, ROW_TYPE_CATEGORY,
1243 DATA_COL, NULL, -1);
1245 self->loader_iter = gtk_tree_iter_copy(&iter);
1247 IRRECO_RETURN_BOOL(TRUE);
1251 case LOADER_STATE_LOOP: {
1253 IrrecoData *irreco_data = NULL;
1254 IrrecoThemeManager *theme_manager = NULL;
1255 GtkTreeIter iter;
1256 IrrecoStringTable *categories = NULL;
1258 irreco_data = self->irreco_data;
1259 theme_manager = irreco_data->theme_manager;
1260 categories = irreco_theme_manager_get_themes(theme_manager);
1262 IRRECO_STRING_TABLE_FOREACH_DATA(categories,
1263 IrrecoTheme *, theme)
1264 if (g_utf8_collate(theme->source->str, "deb") == 0){
1266 /* Add loading item into category. */
1267 gtk_tree_store_append(self->tree_store,
1268 &iter, self->loader_iter);
1269 gtk_tree_store_set(self->tree_store,
1270 &iter,
1271 TEXT_COL,
1272 theme->name->str,
1273 FLAG_COL, ROW_TYPE_DEB,
1274 DATA_COL, NULL, -1);
1276 IRRECO_STRING_TABLE_FOREACH_END
1278 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1279 1.0);
1280 self->loader_state = LOADER_STATE_END;
1281 IRRECO_RETURN_BOOL(TRUE);
1284 case LOADER_STATE_END: {
1285 GtkTreeIter iter, iter_loading;
1286 if (self->loader_iter != NULL) {
1287 gtk_tree_iter_free(self->loader_iter);
1289 irreco_theme_manager_dlg_hide_banner(self);
1290 irreco_theme_manager_dlg_loader_stop(self);
1292 /* Create database row */
1293 gtk_tree_store_append(self->tree_store, &iter, NULL);
1294 gtk_tree_store_set(self->tree_store, &iter,
1295 TEXT_COL, _("Database"),
1296 FLAG_COL, ROW_TYPE_CATEGORY,
1297 DATA_COL, NULL, -1);
1299 /* Add loading item into manufacturer. */
1300 gtk_tree_store_append(self->tree_store, &iter_loading, &iter);
1301 gtk_tree_store_set(self->tree_store, &iter_loading,
1302 TEXT_COL, _("Loading ..."),
1303 FLAG_COL, ROW_TYPE_LOADING,
1304 DATA_COL, NULL, -1);
1306 irreco_theme_manager_dlg_loader_start(self,
1307 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_web), NULL);
1311 IRRECO_RETURN_BOOL(FALSE);
1314 static gboolean irreco_theme_manager_dlg_loader_db(IrrecoThemeManagerDlg *self)
1316 IRRECO_ENTER
1318 switch (self->loader_state) {
1319 case LOADER_STATE_INIT:{
1320 GtkTreeIter iter;
1321 irreco_theme_manager_dlg_set_banner(self, _("Loading themes"),
1322 0.0);
1323 self->loader_state = LOADER_STATE_LOOP;
1324 self->theme_loader_index = 0;
1325 irreco_theme_manager_dlg_clean_details(self);
1327 /* Check if loading item exist */
1328 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self->tree_store),
1329 &iter, self->loader_iter, 0);
1331 if(irreco_theme_manager_dlg_row_get_type(self,
1332 &iter) != ROW_TYPE_LOADING) {
1333 self->loader_state = LOADER_STATE_END;
1336 IRRECO_RETURN_BOOL(TRUE);
1340 case LOADER_STATE_LOOP: {
1341 GtkTreeIter iter;
1342 GtkTreeIter iter_loading;
1343 IrrecoStringTable *themes = NULL;
1344 IrrecoWebdbTheme *theme_by_id;
1345 IrrecoWebdbCache *webdb_cache = NULL;
1346 const gchar *id;
1347 gfloat banner;
1349 webdb_cache = irreco_data_get_webdb_cache(self->irreco_data,
1350 FALSE);
1351 /* Get themes */
1352 if (!irreco_webdb_cache_get_themes(webdb_cache, &themes)) {
1353 irreco_error_dlg(GTK_WINDOW(self),
1354 irreco_webdb_cache_get_error(
1355 webdb_cache));
1356 self->loader_state = LOADER_STATE_END;
1357 IRRECO_RETURN_BOOL(TRUE);
1360 if (!irreco_string_table_index(themes,
1361 (guint)self->theme_loader_index, &id, NULL)) {
1362 irreco_error_dlg(GTK_WINDOW(self), "Can't find theme");
1363 self->loader_state = LOADER_STATE_END;
1364 IRRECO_RETURN_BOOL(TRUE);
1367 if (!irreco_webdb_cache_get_theme_by_id(webdb_cache,
1368 atoi(id),
1369 &theme_by_id)) {
1370 irreco_error_dlg(GTK_WINDOW(self),
1371 irreco_webdb_cache_get_error(
1372 webdb_cache));
1373 self->loader_state = LOADER_STATE_END;
1374 IRRECO_RETURN_BOOL(TRUE);
1377 gtk_tree_store_append(self->tree_store, &iter,
1378 self->loader_iter);
1380 gtk_tree_store_set(self->tree_store, &iter,
1381 TEXT_COL, theme_by_id->name->str,
1382 FLAG_COL, ROW_TYPE_DB,
1383 DATA_COL, id, -1);
1385 banner = ++self->theme_loader_index;
1386 banner /= (gfloat) irreco_string_table_lenght (themes);
1388 irreco_theme_manager_dlg_set_banner(self, _("Loading themes"),
1389 banner);
1390 if (banner >= 1.0) {
1391 self->loader_state = LOADER_STATE_END;
1394 /* Delete loading item */
1395 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self->tree_store),
1396 &iter_loading, self->loader_iter,
1398 if(irreco_theme_manager_dlg_row_get_type(self,
1399 &iter_loading) == ROW_TYPE_LOADING) {
1400 gtk_tree_store_remove(self->tree_store, &iter_loading);
1403 IRRECO_RETURN_BOOL(TRUE);
1406 case LOADER_STATE_END:
1407 if (self->loader_iter != NULL) {
1408 gtk_tree_iter_free(self->loader_iter);
1410 irreco_theme_manager_dlg_hide_banner(self);
1411 irreco_theme_manager_dlg_loader_stop(self);
1414 IRRECO_RETURN_BOOL(FALSE);
1418 static gboolean irreco_theme_manager_dlg_loader_web(IrrecoThemeManagerDlg *self)
1420 IRRECO_ENTER
1422 switch (self->loader_state) {
1423 case LOADER_STATE_INIT: {
1424 GtkTreeIter iter;
1425 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1426 0.5);
1427 self->loader_state = LOADER_STATE_LOOP;
1428 irreco_theme_manager_dlg_clean_details(self);
1429 if (!irreco_theme_manager_does_web_exist(
1430 self->irreco_data->theme_manager)) {
1431 self->loader_state = LOADER_STATE_END;
1432 self->loader_iter = NULL;
1433 } else {
1435 gtk_tree_store_append(self->tree_store,
1436 &iter, NULL);
1437 gtk_tree_store_set(self->tree_store,
1438 &iter,
1439 TEXT_COL, _("Downloaded"),
1440 FLAG_COL, ROW_TYPE_CATEGORY,
1441 DATA_COL, NULL, -1);
1443 self->loader_iter = gtk_tree_iter_copy(&iter);
1445 IRRECO_RETURN_BOOL(TRUE);
1447 case LOADER_STATE_LOOP: {
1449 IrrecoData *irreco_data = NULL;
1450 IrrecoThemeManager *theme_manager = NULL;
1451 GtkTreeIter iter;
1452 IrrecoStringTable *categories = NULL;
1454 irreco_data = self->irreco_data;
1455 theme_manager = irreco_data->theme_manager;
1456 categories = irreco_theme_manager_get_themes(theme_manager);
1458 IRRECO_STRING_TABLE_FOREACH_DATA(categories,
1459 IrrecoTheme *, theme)
1461 if (g_utf8_collate(theme->source->str, "web") == 0){
1463 /* Add loading item into category. */
1464 gtk_tree_store_append(self->tree_store,
1465 &iter,
1466 self->loader_iter);
1467 gtk_tree_store_set(self->tree_store,
1468 &iter,
1469 TEXT_COL,
1470 theme->name->str,
1471 FLAG_COL,
1472 ROW_TYPE_WEB,
1473 DATA_COL, NULL, -1);
1475 IRRECO_STRING_TABLE_FOREACH_END
1477 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1478 1.0);
1479 self->loader_state = LOADER_STATE_END;
1480 IRRECO_RETURN_BOOL(TRUE);
1483 case LOADER_STATE_END:
1484 if (self->loader_iter != NULL) {
1485 gtk_tree_iter_free(self->loader_iter);
1487 irreco_theme_manager_dlg_hide_banner(self);
1488 irreco_theme_manager_dlg_loader_stop(self);
1491 IRRECO_RETURN_BOOL(FALSE);
1495 * Show theme details
1497 * @todo
1500 static gboolean
1501 irreco_theme_manager_dlg_display_theme_detail(IrrecoThemeManagerDlg *self,
1502 GtkTreeIter * iter)
1504 IrrecoThemeManager *theme_manager = self->irreco_data->theme_manager;
1505 IrrecoThemeButton *button = NULL;
1506 const gchar *theme_name;
1508 IRRECO_ENTER
1510 gtk_image_clear(GTK_IMAGE(self->theme_image));
1512 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1513 iter, TEXT_COL, &theme_name, -1);
1514 irreco_string_table_get(theme_manager->themes, theme_name,
1515 (gpointer *) &self->theme);
1517 gtk_label_set_text(GTK_LABEL(self->theme_name),
1518 self->theme->name->str);
1519 gtk_label_set_text(GTK_LABEL(self->theme_creator),
1520 self->theme->author->str);
1521 gtk_label_set_text(GTK_LABEL(self->theme_comment),
1522 self->theme->comment->str);
1523 gtk_label_set_text(GTK_LABEL(self->theme_version),
1524 self->theme->version->str);
1526 if (self->theme->preview_button_name->len > 0) {
1527 button =irreco_theme_get_button(self->theme,
1528 self->theme->preview_button_name->str);
1529 } else {
1530 const gchar *key;
1531 irreco_string_table_index(self->theme->buttons,
1532 0, &key, (gpointer *) &button);
1535 if (button != NULL) {
1536 IRRECO_DEBUG("Preview-button: %s\n", button->image_up->str);
1538 gtk_image_set_from_file(GTK_IMAGE(self->theme_image),
1539 button->image_up->str);
1541 self->preview_add = button->image_up->str;
1542 } else {
1543 self->preview_add = NULL;
1545 self->webdb_theme = NULL;
1547 IRRECO_RETURN_BOOL(TRUE);
1550 static gboolean
1551 irreco_theme_manager_dlg_theme_db_detail_loader(IrrecoThemeManagerDlg *self)
1553 IRRECO_ENTER
1555 switch (self->loader_state) {
1556 case LOADER_STATE_INIT:{
1557 irreco_theme_manager_dlg_set_banner(self,
1558 _("Loading ..."), 0.5);
1559 self->loader_state = LOADER_STATE_LOOP;
1560 IRRECO_RETURN_BOOL(TRUE);
1563 case LOADER_STATE_LOOP: {
1564 gchar *download_count;
1565 gint index = 0;
1566 IrrecoWebdbCache *webdb_cache = irreco_data_get_webdb_cache(
1567 self->irreco_data,
1568 FALSE);
1570 /* Get WebdbTheme with preview-button */
1571 if (!irreco_webdb_cache_get_preview_button(webdb_cache,
1572 self->selected_theme_id,
1573 &self->webdb_theme)) {
1574 irreco_error_dlg(GTK_WINDOW(self),
1575 irreco_webdb_cache_get_error(
1576 webdb_cache));
1578 self->loader_state = LOADER_STATE_END;
1579 IRRECO_RETURN_BOOL(TRUE);
1582 gtk_image_clear(GTK_IMAGE(self->theme_image));
1584 gtk_label_set_text(GTK_LABEL(self->theme_name),
1585 self->webdb_theme->name->str);
1586 gtk_label_set_text(GTK_LABEL(self->theme_creator),
1587 self->webdb_theme->creator->str);
1588 gtk_label_set_text(GTK_LABEL(self->theme_comment),
1589 self->webdb_theme->comment->str);
1591 /* Clear combobox */
1592 gtk_tree_store_clear(self->version_store);
1594 IRRECO_STRING_TABLE_FOREACH(self->webdb_theme->versions,
1595 key, gchar *, date)
1596 GtkTreeIter iter;
1598 /* Append row */
1599 gtk_tree_store_append(self->version_store,
1600 &iter, NULL);
1602 /* Fill row */
1603 gtk_tree_store_set(self->version_store, &iter,
1604 DATE_COL, date,
1605 ID_COL, key, -1);
1607 if (g_utf8_collate (date,
1608 self->webdb_theme->uploaded->str) == 0) {
1609 gtk_combo_box_set_active(GTK_COMBO_BOX(
1610 self->combobox),
1611 index);
1613 index++;
1614 IRRECO_STRING_TABLE_FOREACH_END
1616 /*scale_combobox(self);*/
1618 download_count = g_strdup_printf("%d",
1619 self->webdb_theme->download_count);
1621 gtk_label_set_text(GTK_LABEL(self->theme_downloaded),
1622 download_count);
1623 g_free(download_count);
1625 if (self->webdb_theme->preview_button != NULL) {
1626 gtk_image_set_from_pixbuf(GTK_IMAGE(self->theme_image),
1627 self->webdb_theme->preview_button);
1628 } else {
1629 IRRECO_DEBUG("preview_button is NULL\n");
1631 self->preview_add = NULL;
1633 self->loader_state = LOADER_STATE_END;
1634 IRRECO_RETURN_BOOL(TRUE);
1637 case LOADER_STATE_END:
1638 irreco_theme_manager_dlg_hide_banner(self);
1639 irreco_theme_manager_dlg_loader_stop(self);
1641 IRRECO_RETURN_BOOL(FALSE);
1644 static gboolean irreco_theme_manager_dlg_bg_loader(IrrecoThemeManagerDlg *self)
1646 IRRECO_ENTER
1648 switch (self->loader_state) {
1649 case LOADER_STATE_INIT:{
1650 GString *path = g_string_new("");
1651 irreco_theme_manager_dlg_set_banner(self,
1652 _("Loading backgrounds..."),
1653 0.0);
1654 self->loader_state = LOADER_STATE_LOOP;
1655 self->theme_loader_index = 0;
1657 g_string_printf(path, "%s%s/bg/", self->theme_folder,
1658 self->webdb_theme->folder->str);
1660 IRRECO_DEBUG("mkdir %s\n", path->str);
1661 g_mkdir(path->str, 0777);
1662 g_string_free(path, TRUE);
1664 IRRECO_RETURN_BOOL(TRUE);
1667 case LOADER_STATE_LOOP: {
1668 IrrecoStringTable *bg_list = NULL;
1669 GString *path = g_string_new("");
1670 gfloat banner;
1671 const gchar *id;
1672 IrrecoWebdbCache *webdb_cache = irreco_data_get_webdb_cache(
1673 self->irreco_data,
1674 FALSE);
1675 /* Get backrounds */
1676 irreco_webdb_cache_get_backgrounds(webdb_cache,
1677 self->webdb_theme->id,
1678 &bg_list);
1680 g_string_printf(path, "%s%s/bg/", self->theme_folder,
1681 self->webdb_theme->folder->str);
1683 if (irreco_string_table_index(bg_list,
1684 (guint)self->theme_loader_index, &id, NULL) &&
1685 !g_str_equal(id, "0")) {
1686 irreco_webdb_cache_get_bg_by_id(webdb_cache, atoi(id),
1687 path->str);
1688 } else {
1689 self->loader_state = LOADER_STATE_END;
1690 goto end;
1693 banner = ++self->theme_loader_index;
1694 banner /= (gfloat) irreco_string_table_lenght (bg_list);
1696 irreco_theme_manager_dlg_set_banner(self,
1697 _("Loading backgrounds..."),
1698 banner);
1699 if (banner >= 1.0) {
1700 self->loader_state = LOADER_STATE_END;
1702 end:
1703 g_string_free(path, TRUE);
1704 IRRECO_RETURN_BOOL(TRUE);
1706 case LOADER_STATE_END:
1707 irreco_theme_manager_dlg_hide_banner(self);
1708 irreco_theme_manager_dlg_loader_stop(self);
1709 gtk_dialog_response(GTK_DIALOG(self->download_dialog),
1710 GTK_RESPONSE_CANCEL);
1712 IRRECO_RETURN_BOOL(FALSE);
1715 static gboolean
1716 irreco_theme_manager_dlg_button_loader(IrrecoThemeManagerDlg *self)
1718 IRRECO_ENTER
1720 switch (self->loader_state) {
1721 case LOADER_STATE_INIT:{
1722 GString *path = g_string_new("");
1723 irreco_theme_manager_dlg_set_banner(self,
1724 _("Loading buttons.."),
1725 0.0);
1726 self->loader_state = LOADER_STATE_LOOP;
1727 self->theme_loader_index = 0;
1729 g_string_printf(path, "%s%s/buttons/", self->theme_folder,
1730 self->webdb_theme->folder->str);
1732 IRRECO_DEBUG("mkdir %s\n", path->str);
1733 g_mkdir(path->str, 0777);
1734 g_string_free(path, TRUE);
1736 IRRECO_RETURN_BOOL(TRUE);
1739 case LOADER_STATE_LOOP: {
1740 IrrecoStringTable *button_list = NULL;
1741 GString *path = g_string_new("");
1742 gfloat banner;
1743 const gchar *id;
1744 IrrecoWebdbCache *webdb_cache = irreco_data_get_webdb_cache(
1745 self->irreco_data,
1746 FALSE);
1747 /* Get buttons */
1748 irreco_webdb_cache_get_buttons(webdb_cache,
1749 self->webdb_theme->id,
1750 &button_list);
1751 if (button_list == NULL) {
1752 self->loader_state = LOADER_STATE_END;
1753 goto end;
1756 g_string_printf(path, "%s%s/buttons/", self->theme_folder,
1757 self->webdb_theme->folder->str);
1759 if (irreco_string_table_index(button_list,
1760 (guint)self->theme_loader_index, &id, NULL) &&
1761 !g_str_equal(id, "0")) {
1762 irreco_webdb_cache_get_button_by_id(webdb_cache,
1763 atoi(id),
1764 path->str);
1765 } else {
1766 self->loader_state = LOADER_STATE_END;
1767 goto end;
1770 banner = ++self->theme_loader_index;
1771 banner /= (gfloat) irreco_string_table_lenght (button_list);
1773 irreco_theme_manager_dlg_set_banner(self,
1774 _("Loading buttons.."),
1775 banner);
1776 if (banner >= 1.0) {
1777 self->loader_state = LOADER_STATE_END;
1780 end:
1781 g_string_free(path, TRUE);
1782 IRRECO_RETURN_BOOL(TRUE);
1784 case LOADER_STATE_END:
1785 irreco_theme_manager_dlg_hide_banner(self);
1786 irreco_theme_manager_dlg_loader_stop(self);
1788 /* Get backgrounds */
1789 self->loader_func_id = g_idle_add(G_SOURCEFUNC(
1790 irreco_theme_manager_dlg_bg_loader), self);
1792 IRRECO_RETURN_BOOL(FALSE);
1795 /** @} */
1799 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1800 /* Functions */
1801 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1804 * @name Public Functions
1805 * @{
1808 void irreco_theme_manager_dlg_set_irreco_data(IrrecoThemeManagerDlg *self,
1809 IrrecoData *irreco_data)
1811 IRRECO_ENTER
1813 self->irreco_data = irreco_data;
1815 IRRECO_RETURN
1818 void irreco_show_theme_manager_dlg(IrrecoData *irreco_data, GtkWindow *parent)
1820 IrrecoThemeManagerDlg *self;
1821 gint response;
1822 gboolean loop = TRUE;
1823 IrrecoWebdbCache *webdb_cache = NULL;
1825 IRRECO_ENTER
1827 self = IRRECO_THEME_MANAGER_DLG(irreco_theme_manager_dlg_new(
1828 irreco_data, parent));
1830 webdb_cache = irreco_data_get_webdb_cache(self->irreco_data, FALSE);
1832 do {
1833 response = gtk_dialog_run(GTK_DIALOG(self));
1834 switch (response) {
1835 case IRRECO_DEVICE_REFRESH:
1836 if (self->loader_func_id != 0) {
1837 break;
1839 IRRECO_DEBUG("IRRECO_DEVICE_REFRESH\n");
1840 gtk_tree_store_clear(self->tree_store);
1841 irreco_theme_manager_update_theme_manager
1842 (self->irreco_data->theme_manager);
1844 if (webdb_cache->theme_id_hash != NULL) {
1845 g_hash_table_remove_all(
1846 webdb_cache->theme_id_hash);
1847 self->webdb_theme = NULL;
1850 IRRECO_STRING_TABLE_FOREACH_DATA(
1851 irreco_data->theme_manager->themes,
1852 IrrecoTheme *, theme)
1853 irreco_theme_check(theme);
1854 IRRECO_STRING_TABLE_FOREACH_END
1856 irreco_theme_manager_dlg_loader_start(self,
1857 G_SOURCEFUNC(
1858 irreco_theme_manager_dlg_loader_user),
1859 NULL);
1860 gtk_label_set_text(GTK_LABEL(self->select_label),
1861 " Select \ncategory");
1862 break;
1864 case GTK_RESPONSE_CANCEL:
1865 IRRECO_DEBUG("GTK_RESPONSE_CANCEL\n");
1866 loop = FALSE;
1867 break;
1869 } while (loop);
1871 gtk_widget_destroy(GTK_WIDGET(self));
1873 IRRECO_RETURN
1876 /** @} */
1880 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1881 /* Events and Callbacks */
1882 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1885 * @name Events and Callbacks
1886 * @{
1889 static gboolean
1890 irreco_show_theme_manager_dlg_map_event(IrrecoThemeManagerDlg *self,
1891 GdkEvent *event,
1892 gpointer user_data)
1895 IRRECO_ENTER
1897 irreco_theme_manager_dlg_loader_start(
1898 self, G_SOURCEFUNC(irreco_theme_manager_dlg_loader_user),
1899 NULL);
1901 IRRECO_RETURN_BOOL(FALSE);
1904 static void
1905 irreco_show_theme_manager_dlg_destroy_event(IrrecoThemeManagerDlg *self,
1906 gpointer user_data)
1908 IRRECO_ENTER
1909 irreco_theme_manager_dlg_loader_stop(self);
1910 IRRECO_RETURN
1913 static void
1914 irreco_show_theme_manager_dlg_row_activated_event(GtkTreeView *tree_view,
1915 GtkTreePath *path,
1916 GtkTreeViewColumn *column,
1917 IrrecoThemeManagerDlg *self)
1919 IRRECO_ENTER
1921 if (gtk_tree_view_row_expanded(tree_view, path)) {
1922 gtk_tree_view_expand_row(tree_view, path, FALSE);
1923 } else {
1924 gtk_tree_view_collapse_row(tree_view, path);
1926 IRRECO_RETURN
1929 static void
1930 irreco_show_theme_manager_dlg_row_expanded_event(GtkTreeView *tree_view,
1931 GtkTreeIter *iter,
1932 GtkTreePath *path,
1933 IrrecoThemeManagerDlg *self)
1935 gchar *row_name = NULL;
1936 IRRECO_ENTER
1938 irreco_theme_manager_dlg_clean_details(self);
1939 gtk_label_set_text(GTK_LABEL(self->select_label), "Select \ntheme");
1942 if (self->loader_func_id != 0) {
1943 gtk_tree_view_collapse_row(tree_view, path);
1946 if (!irreco_theme_manager_dlg_row_is_loaded(self, iter)){
1947 switch (irreco_theme_manager_dlg_row_get_type(self, iter)){
1948 case ROW_TYPE_CATEGORY:
1949 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1950 iter, TEXT_COL, &row_name, -1);
1952 if(g_utf8_collate(row_name, "Database") != 0) {
1953 goto end;
1956 self->loader_iter = gtk_tree_iter_copy(iter);
1957 irreco_theme_manager_dlg_loader_start(self,
1958 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_db), NULL);
1959 break;
1962 end:
1963 if (row_name != NULL) g_free(row_name);
1964 IRRECO_RETURN
1967 static void
1968 irreco_show_theme_manager_dlg_row_collapsed_event(GtkTreeView *tree_view,
1969 GtkTreeIter *iter,
1970 GtkTreePath *path,
1971 IrrecoThemeManagerDlg *self)
1974 IRRECO_ENTER
1976 gtk_label_set_text(GTK_LABEL(self->select_label), " Select\ncategory");
1978 irreco_theme_manager_dlg_clean_details(self);
1980 IRRECO_RETURN
1983 static void
1984 irreco_show_theme_manager_dlg_row_selected_event(GtkTreeSelection *sel,
1985 IrrecoThemeManagerDlg *self)
1987 GtkTreeIter iter;
1988 GtkTreeModel *model;
1989 const char *id;
1991 IRRECO_ENTER
1993 if (gtk_tree_selection_get_selected (sel, &model, &iter))
1995 switch (irreco_theme_manager_dlg_row_get_type(self, &iter)) {
1997 case ROW_TYPE_DEB:
1998 IRRECO_DEBUG("ROW_TYPE_DEB\n");
2000 gtk_widget_hide(self->select_label);
2001 gtk_widget_show(self->theme_info_alignment);
2002 gtk_widget_hide(self->label_download);
2003 gtk_widget_hide(self->theme_downloaded);
2004 gtk_widget_hide(self->label_combobox);
2005 gtk_widget_hide(self->combobox);
2006 gtk_widget_hide(self->theme_version);
2007 gtk_widget_hide(self->theme_creator);
2008 gtk_widget_hide(self->label_creator);
2010 gtk_widget_hide(self->upload_button);
2011 gtk_widget_hide(self->download_button);
2012 gtk_widget_hide(self->clear_button);
2013 gtk_widget_hide(self->new_button);
2014 gtk_widget_hide(self->edit_button);
2017 irreco_theme_manager_dlg_display_theme_detail(self,
2018 &iter);
2020 break;
2021 case ROW_TYPE_USER:
2022 IRRECO_DEBUG("ROW_TYPE_USER\n");
2024 gtk_widget_hide(self->select_label);
2025 gtk_widget_show(self->theme_info_alignment);
2026 gtk_widget_hide(self->label_download);
2027 gtk_widget_hide(self->theme_downloaded);
2028 gtk_widget_show(self->theme_creator);
2029 gtk_widget_show(self->label_creator);
2031 gtk_widget_show(self->label_combobox);
2032 gtk_widget_hide(self->combobox);
2033 gtk_widget_show(self->theme_version);
2035 gtk_widget_show(self->upload_button);
2036 gtk_widget_show(self->clear_button);
2037 gtk_widget_hide(self->download_button);
2038 gtk_widget_show(self->edit_button);
2039 gtk_widget_hide(self->new_button);
2041 irreco_theme_manager_dlg_display_theme_detail(self,
2042 &iter);
2044 break;
2045 case ROW_TYPE_WEB:
2046 IRRECO_DEBUG("ROW_TYPE_WEB\n");
2048 gtk_widget_show(self->clear_button);
2049 gtk_widget_hide(self->upload_button);
2050 gtk_widget_hide(self->download_button);
2051 gtk_widget_hide(self->new_button);
2052 gtk_widget_hide(self->edit_button);
2055 gtk_widget_hide(self->select_label);
2056 gtk_widget_show(self->theme_creator);
2057 gtk_widget_show(self->label_creator);
2058 gtk_widget_hide(self->label_download);
2059 gtk_widget_hide(self->theme_downloaded);
2061 gtk_widget_hide(self->combobox);
2062 gtk_widget_show(self->label_combobox);
2063 gtk_widget_show(self->theme_version);
2065 gtk_widget_show(self->theme_info_alignment);
2067 irreco_theme_manager_dlg_display_theme_detail(self,
2068 &iter);
2070 break;
2071 case ROW_TYPE_DB:
2072 IRRECO_DEBUG("ROW_TYPE_DB\n");
2074 if (self->loader_func_id != 0) {
2075 break;
2078 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
2079 &iter, DATA_COL, &id, -1);
2081 gtk_widget_hide(self->clear_button);
2082 gtk_widget_hide(self->upload_button);
2083 gtk_widget_show(self->download_button);
2084 gtk_widget_hide(self->new_button);
2085 gtk_widget_hide(self->edit_button);
2088 gtk_widget_show(self->combobox);
2089 gtk_widget_show(self->label_combobox);
2090 gtk_widget_hide(self->theme_version);
2092 gtk_widget_hide(self->select_label);
2093 gtk_widget_show(self->theme_creator);
2094 gtk_widget_show(self->label_creator);
2095 gtk_widget_show(self->label_download);
2096 gtk_widget_show(self->theme_downloaded);
2098 gtk_widget_show(self->theme_info_alignment);
2100 IRRECO_DEBUG("SELECTED ID: %d\n", atoi(id));
2102 self->selected_theme_id = atoi(id);
2103 self->loader_func_id = g_idle_add(G_SOURCEFUNC(
2104 irreco_theme_manager_dlg_theme_db_detail_loader),
2105 self);
2107 break;
2108 default:
2109 irreco_theme_manager_dlg_clean_details(self);
2110 break;
2114 IRRECO_RETURN
2116 /** @} */
2117 /** @} */