Added scrolled window
[irreco.git] / irreco / src / core / irreco_theme_manager_dlg.c
blobf89d162e6c76841cf15dff762dea21a28222cc3f
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){
903 IRRECO_ENTER
904 /* Check which button */
905 /* Create new theme */
906 if (g_str_equal("New", gtk_button_get_label(button))) {
907 IrrecoTheme *new_theme = NULL;
908 new_theme = irreco_theme_new();
910 if (irreco_theme_creator_dlg_run(GTK_WINDOW(self),
911 self->irreco_data, new_theme)) {
912 gtk_button_clicked(GTK_BUTTON(self->refresh_button));
914 /* Edit theme */
915 } else {
916 IrrecoTheme *new_theme = NULL;
917 gchar *rm_dir;
918 gchar *temp_dir;
919 /* Create temp theme folder */
920 temp_dir = g_strconcat("cp -f -r ", self->theme->path->str, " ",
921 "/media/mmc2/irreco/irreco_temp", NULL);
922 rm_dir = g_strconcat("rm -f -r ",
923 "/media/mmc2/irreco/irreco_temp", NULL);
924 /* Delete temp dir */
925 if (irreco_is_dir("/media/mmc2/irreco/irreco_temp")) {
926 system(rm_dir);
928 system(temp_dir);
930 new_theme = irreco_theme_new_from_dir(
931 "/media/mmc2/irreco/irreco_temp");
933 irreco_theme_set(new_theme, self->theme->name->str,
934 self->theme->path->str,
935 self->theme->source->str,
936 self->theme->author->str,
937 self->theme->comment->str,
938 self->theme->preview_button_name->str,
939 self->theme->version->str);
941 IRRECO_DEBUG("Pointer: %p \n", (void*) self->theme);
942 IRRECO_DEBUG("New_Pointer: %p \n", (void*) new_theme);
943 irreco_theme_print(new_theme);
945 if (irreco_theme_creator_dlg_run(GTK_WINDOW(self),
946 self->irreco_data, new_theme)) {
947 self->theme = irreco_theme_copy(new_theme);
948 gtk_button_clicked(GTK_BUTTON(self->refresh_button));
950 /* remove temp theme */
951 system(rm_dir);
953 g_free(rm_dir);
954 g_free(temp_dir);
955 irreco_theme_free(new_theme);
957 IRRECO_RETURN
960 /** @} */
962 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
963 /* Private Functions */
964 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
967 * @name Private Functions
968 * @{
972 * Clean detail list
975 static void irreco_theme_manager_dlg_clean_details(IrrecoThemeManagerDlg *self)
977 IRRECO_ENTER
979 gtk_widget_show_all(GTK_WIDGET(self));
980 gtk_label_set_text(
981 GTK_LABEL(self->theme_name), "-");
982 gtk_label_set_text(
983 GTK_LABEL(self->theme_creator), "-");
984 gtk_label_set_text(
985 GTK_LABEL(self->theme_comment), "-");
986 gtk_label_set_text(
987 GTK_LABEL(self->theme_downloaded), "-");
988 gtk_image_clear(GTK_IMAGE(self->theme_image));
989 self->preview_add=NULL;
991 gtk_widget_hide(self->upload_button);
992 gtk_widget_hide(self->download_button);
993 gtk_widget_hide(self->clear_button);
994 gtk_widget_hide(self->theme_info_alignment);
995 gtk_widget_show(self->select_label);
997 IRRECO_RETURN
1001 * Have the childern of this item been loaded.
1003 * @return TRUE if children have been loade, FALSE otherwise.
1006 static gboolean
1007 irreco_theme_manager_dlg_row_is_loaded(IrrecoThemeManagerDlg *self,
1008 GtkTreeIter *iter)
1010 gint i;
1011 IRRECO_ENTER
1013 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1014 iter, FLAG_COL, &i, -1);
1015 if (i & ROW_CHILDREN_LOADED) IRRECO_RETURN_BOOL(TRUE);
1017 IRRECO_RETURN_BOOL(FALSE);
1021 * Get type of row.
1024 static gint irreco_theme_manager_dlg_row_get_type(IrrecoThemeManagerDlg *self,
1025 GtkTreeIter *iter)
1027 gint i;
1029 IRRECO_ENTER
1031 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1032 iter, FLAG_COL, &i, -1);
1033 if (i & ROW_TYPE_CATEGORY)
1034 IRRECO_RETURN_ENUM(ROW_TYPE_CATEGORY);
1035 if (i & ROW_TYPE_DEB)
1036 IRRECO_RETURN_ENUM(ROW_TYPE_DEB);
1037 if (i & ROW_TYPE_USER)
1038 IRRECO_RETURN_ENUM(ROW_TYPE_USER);
1039 if (i & ROW_TYPE_WEB)
1040 IRRECO_RETURN_ENUM(ROW_TYPE_WEB);
1041 if (i & ROW_TYPE_DB)
1042 IRRECO_RETURN_ENUM(ROW_TYPE_DB);
1043 if (i & ROW_TYPE_LOADING)
1044 IRRECO_RETURN_ENUM(ROW_TYPE_LOADING);
1045 IRRECO_RETURN_INT(0);
1049 * Show hildon progressbar banner.
1051 * This function will create a new banner if one has not been created yet,
1052 * if banner already exists, it's properties will be changed.
1054 * @param text Text to show.
1055 * @param fraction Value of progress.
1058 static void irreco_theme_manager_dlg_set_banner(IrrecoThemeManagerDlg *self,
1059 const gchar *text,
1060 gdouble fraction)
1062 IRRECO_ENTER
1064 if (self->banner == NULL) {
1065 self->banner = hildon_banner_show_progress(
1066 GTK_WIDGET(self), NULL, "");
1069 hildon_banner_set_text(HILDON_BANNER(self->banner), text);
1070 hildon_banner_set_fraction(HILDON_BANNER(self->banner), fraction);
1072 IRRECO_RETURN
1076 * Destroy banner, if it exists.
1079 static void irreco_theme_manager_dlg_hide_banner(IrrecoThemeManagerDlg *self)
1081 IRRECO_ENTER
1083 if (self->banner) {
1084 gtk_widget_destroy(self->banner);
1085 self->banner = NULL;
1088 IRRECO_RETURN
1092 * Start a loader state machine if one is not running already.
1095 static
1096 gboolean irreco_theme_manager_dlg_loader_start(IrrecoThemeManagerDlg *self,
1097 GSourceFunc function,
1098 GtkTreeIter *parent_iter)
1100 IRRECO_ENTER
1102 if (self->loader_func_id == 0) {
1103 if (parent_iter) {
1104 self->loader_parent_iter = gtk_tree_iter_copy(
1105 parent_iter);
1107 if (function) {
1108 self->loader_func_id = g_idle_add(function, self);
1109 } else {
1110 IRRECO_ERROR("Loader function pointer not given.\n");
1113 IRRECO_RETURN_BOOL(TRUE);
1118 * Stop and cleanup loader if a loader is running.
1121 static void irreco_theme_manager_dlg_loader_stop(IrrecoThemeManagerDlg *self)
1123 IRRECO_ENTER
1125 if (self->loader_func_id != 0) {
1126 g_source_remove(self->loader_func_id);
1127 self->loader_func_id = 0;
1128 self->loader_state = 0;
1129 if (self->loader_parent_iter) {
1130 gtk_tree_iter_free(self->loader_parent_iter);
1132 self->loader_parent_iter = NULL;
1134 IRRECO_RETURN
1137 static gboolean
1138 irreco_theme_manager_dlg_loader_user(IrrecoThemeManagerDlg *self)
1140 IRRECO_ENTER
1142 switch (self->loader_state) {
1143 case LOADER_STATE_INIT: {
1144 GtkTreeIter iter;
1145 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1146 0.5);
1147 self->loader_state = LOADER_STATE_LOOP;
1148 irreco_theme_manager_dlg_clean_details(self);
1149 if (!irreco_theme_manager_does_user_exist(
1150 self->irreco_data->theme_manager)) {
1151 self->loader_state = LOADER_STATE_END;
1152 self->loader_iter = NULL;
1153 } else {
1156 gtk_tree_store_append(self->tree_store,
1157 &iter, NULL);
1158 gtk_tree_store_set(self->tree_store,
1159 &iter,
1160 TEXT_COL, _("My Themes"),
1161 FLAG_COL, ROW_TYPE_CATEGORY,
1162 DATA_COL, NULL, -1);
1164 self->loader_iter = gtk_tree_iter_copy(&iter);
1167 IRRECO_RETURN_BOOL(TRUE);
1171 case LOADER_STATE_LOOP: {
1173 IrrecoData *irreco_data = NULL;
1174 IrrecoThemeManager *theme_manager = NULL;
1175 GtkTreeIter iter;
1176 IrrecoStringTable *categories = NULL;
1179 irreco_data = self->irreco_data;
1180 theme_manager = irreco_data->theme_manager;
1181 categories = irreco_theme_manager_get_themes(theme_manager);
1183 IRRECO_STRING_TABLE_FOREACH_DATA(categories,
1184 IrrecoTheme *, theme)
1186 if (g_utf8_collate(theme->source->str, "user") == 0){
1188 /* Add loading item into category. */
1189 gtk_tree_store_append(self->tree_store,
1190 &iter,
1191 self->loader_iter);
1192 gtk_tree_store_set(self->tree_store,
1193 &iter,
1194 TEXT_COL,
1195 theme->name->str,
1196 FLAG_COL,
1197 ROW_TYPE_USER,
1198 DATA_COL, NULL, -1);
1200 IRRECO_STRING_TABLE_FOREACH_END
1202 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1203 1.0);
1204 self->loader_state = LOADER_STATE_END;
1205 IRRECO_RETURN_BOOL(TRUE);
1208 case LOADER_STATE_END:
1209 if (self->loader_iter != NULL) {
1210 gtk_tree_iter_free(self->loader_iter);
1212 irreco_theme_manager_dlg_hide_banner(self);
1213 irreco_theme_manager_dlg_loader_stop(self);
1215 irreco_theme_manager_dlg_loader_start(self,
1216 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_deb),NULL);
1219 IRRECO_RETURN_BOOL(FALSE);
1223 * Category loader.
1225 * This loader will request a list of categories from the theme and
1226 * update the TreeView accordingly. Every category row created by this loader
1227 * will have row type ROW_TYPE_DEB.
1231 static gboolean irreco_theme_manager_dlg_loader_deb(IrrecoThemeManagerDlg *self)
1233 IRRECO_ENTER
1235 switch (self->loader_state) {
1236 case LOADER_STATE_INIT: {
1237 GtkTreeIter iter;
1238 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1239 0.5);
1240 self->loader_state = LOADER_STATE_LOOP;
1241 irreco_theme_manager_dlg_clean_details(self);
1243 if (!irreco_theme_manager_does_deb_exist(
1244 self->irreco_data->theme_manager)) {
1245 self->loader_state = LOADER_STATE_END;
1246 self->loader_iter = NULL;
1247 } else {
1249 gtk_tree_store_append(self->tree_store,
1250 &iter, NULL);
1251 gtk_tree_store_set(self->tree_store,
1252 &iter,
1253 TEXT_COL, _("Built In"),
1254 FLAG_COL, ROW_TYPE_CATEGORY,
1255 DATA_COL, NULL, -1);
1257 self->loader_iter = gtk_tree_iter_copy(&iter);
1259 IRRECO_RETURN_BOOL(TRUE);
1263 case LOADER_STATE_LOOP: {
1265 IrrecoData *irreco_data = NULL;
1266 IrrecoThemeManager *theme_manager = NULL;
1267 GtkTreeIter iter;
1268 IrrecoStringTable *categories = NULL;
1270 irreco_data = self->irreco_data;
1271 theme_manager = irreco_data->theme_manager;
1272 categories = irreco_theme_manager_get_themes(theme_manager);
1274 IRRECO_STRING_TABLE_FOREACH_DATA(categories,
1275 IrrecoTheme *, theme)
1276 if (g_utf8_collate(theme->source->str, "deb") == 0){
1278 /* Add loading item into category. */
1279 gtk_tree_store_append(self->tree_store,
1280 &iter, self->loader_iter);
1281 gtk_tree_store_set(self->tree_store,
1282 &iter,
1283 TEXT_COL,
1284 theme->name->str,
1285 FLAG_COL, ROW_TYPE_DEB,
1286 DATA_COL, NULL, -1);
1288 IRRECO_STRING_TABLE_FOREACH_END
1290 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1291 1.0);
1292 self->loader_state = LOADER_STATE_END;
1293 IRRECO_RETURN_BOOL(TRUE);
1296 case LOADER_STATE_END: {
1297 GtkTreeIter iter, iter_loading;
1298 if (self->loader_iter != NULL) {
1299 gtk_tree_iter_free(self->loader_iter);
1301 irreco_theme_manager_dlg_hide_banner(self);
1302 irreco_theme_manager_dlg_loader_stop(self);
1304 /* Create database row */
1305 gtk_tree_store_append(self->tree_store, &iter, NULL);
1306 gtk_tree_store_set(self->tree_store, &iter,
1307 TEXT_COL, _("Database"),
1308 FLAG_COL, ROW_TYPE_CATEGORY,
1309 DATA_COL, NULL, -1);
1311 /* Add loading item into manufacturer. */
1312 gtk_tree_store_append(self->tree_store, &iter_loading, &iter);
1313 gtk_tree_store_set(self->tree_store, &iter_loading,
1314 TEXT_COL, _("Loading ..."),
1315 FLAG_COL, ROW_TYPE_LOADING,
1316 DATA_COL, NULL, -1);
1318 irreco_theme_manager_dlg_loader_start(self,
1319 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_web), NULL);
1323 IRRECO_RETURN_BOOL(FALSE);
1326 static gboolean irreco_theme_manager_dlg_loader_db(IrrecoThemeManagerDlg *self)
1328 IRRECO_ENTER
1330 switch (self->loader_state) {
1331 case LOADER_STATE_INIT:{
1332 GtkTreeIter iter;
1333 irreco_theme_manager_dlg_set_banner(self, _("Loading themes"),
1334 0.0);
1335 self->loader_state = LOADER_STATE_LOOP;
1336 self->theme_loader_index = 0;
1337 irreco_theme_manager_dlg_clean_details(self);
1339 /* Check if loading item exist */
1340 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self->tree_store),
1341 &iter, self->loader_iter, 0);
1343 if(irreco_theme_manager_dlg_row_get_type(self,
1344 &iter) != ROW_TYPE_LOADING) {
1345 self->loader_state = LOADER_STATE_END;
1348 IRRECO_RETURN_BOOL(TRUE);
1352 case LOADER_STATE_LOOP: {
1353 GtkTreeIter iter;
1354 GtkTreeIter iter_loading;
1355 IrrecoStringTable *themes = NULL;
1356 IrrecoWebdbTheme *theme_by_id;
1357 IrrecoWebdbCache *webdb_cache = NULL;
1358 const gchar *id;
1359 gfloat banner;
1361 webdb_cache = irreco_data_get_webdb_cache(self->irreco_data,
1362 FALSE);
1363 /* Get themes */
1364 if (!irreco_webdb_cache_get_themes(webdb_cache, &themes)) {
1365 irreco_error_dlg(GTK_WINDOW(self),
1366 irreco_webdb_cache_get_error(
1367 webdb_cache));
1368 self->loader_state = LOADER_STATE_END;
1369 IRRECO_RETURN_BOOL(TRUE);
1372 if (!irreco_string_table_index(themes,
1373 (guint)self->theme_loader_index, &id, NULL)) {
1374 irreco_error_dlg(GTK_WINDOW(self), "Can't find theme");
1375 self->loader_state = LOADER_STATE_END;
1376 IRRECO_RETURN_BOOL(TRUE);
1379 if (!irreco_webdb_cache_get_theme_by_id(webdb_cache,
1380 atoi(id),
1381 &theme_by_id)) {
1382 irreco_error_dlg(GTK_WINDOW(self),
1383 irreco_webdb_cache_get_error(
1384 webdb_cache));
1385 self->loader_state = LOADER_STATE_END;
1386 IRRECO_RETURN_BOOL(TRUE);
1389 gtk_tree_store_append(self->tree_store, &iter,
1390 self->loader_iter);
1392 gtk_tree_store_set(self->tree_store, &iter,
1393 TEXT_COL, theme_by_id->name->str,
1394 FLAG_COL, ROW_TYPE_DB,
1395 DATA_COL, id, -1);
1397 banner = ++self->theme_loader_index;
1398 banner /= (gfloat) irreco_string_table_lenght (themes);
1400 irreco_theme_manager_dlg_set_banner(self, _("Loading themes"),
1401 banner);
1402 if (banner >= 1.0) {
1403 self->loader_state = LOADER_STATE_END;
1406 /* Delete loading item */
1407 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self->tree_store),
1408 &iter_loading, self->loader_iter,
1410 if(irreco_theme_manager_dlg_row_get_type(self,
1411 &iter_loading) == ROW_TYPE_LOADING) {
1412 gtk_tree_store_remove(self->tree_store, &iter_loading);
1415 IRRECO_RETURN_BOOL(TRUE);
1418 case LOADER_STATE_END:
1419 if (self->loader_iter != NULL) {
1420 gtk_tree_iter_free(self->loader_iter);
1422 irreco_theme_manager_dlg_hide_banner(self);
1423 irreco_theme_manager_dlg_loader_stop(self);
1426 IRRECO_RETURN_BOOL(FALSE);
1430 static gboolean irreco_theme_manager_dlg_loader_web(IrrecoThemeManagerDlg *self)
1432 IRRECO_ENTER
1434 switch (self->loader_state) {
1435 case LOADER_STATE_INIT: {
1436 GtkTreeIter iter;
1437 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1438 0.5);
1439 self->loader_state = LOADER_STATE_LOOP;
1440 irreco_theme_manager_dlg_clean_details(self);
1441 if (!irreco_theme_manager_does_web_exist(
1442 self->irreco_data->theme_manager)) {
1443 self->loader_state = LOADER_STATE_END;
1444 self->loader_iter = NULL;
1445 } else {
1447 gtk_tree_store_append(self->tree_store,
1448 &iter, NULL);
1449 gtk_tree_store_set(self->tree_store,
1450 &iter,
1451 TEXT_COL, _("Downloaded"),
1452 FLAG_COL, ROW_TYPE_CATEGORY,
1453 DATA_COL, NULL, -1);
1455 self->loader_iter = gtk_tree_iter_copy(&iter);
1457 IRRECO_RETURN_BOOL(TRUE);
1459 case LOADER_STATE_LOOP: {
1461 IrrecoData *irreco_data = NULL;
1462 IrrecoThemeManager *theme_manager = NULL;
1463 GtkTreeIter iter;
1464 IrrecoStringTable *categories = NULL;
1466 irreco_data = self->irreco_data;
1467 theme_manager = irreco_data->theme_manager;
1468 categories = irreco_theme_manager_get_themes(theme_manager);
1470 IRRECO_STRING_TABLE_FOREACH_DATA(categories,
1471 IrrecoTheme *, theme)
1473 if (g_utf8_collate(theme->source->str, "web") == 0){
1475 /* Add loading item into category. */
1476 gtk_tree_store_append(self->tree_store,
1477 &iter,
1478 self->loader_iter);
1479 gtk_tree_store_set(self->tree_store,
1480 &iter,
1481 TEXT_COL,
1482 theme->name->str,
1483 FLAG_COL,
1484 ROW_TYPE_WEB,
1485 DATA_COL, NULL, -1);
1487 IRRECO_STRING_TABLE_FOREACH_END
1489 irreco_theme_manager_dlg_set_banner(self, _("Loading ..."),
1490 1.0);
1491 self->loader_state = LOADER_STATE_END;
1492 IRRECO_RETURN_BOOL(TRUE);
1495 case LOADER_STATE_END:
1496 if (self->loader_iter != NULL) {
1497 gtk_tree_iter_free(self->loader_iter);
1499 irreco_theme_manager_dlg_hide_banner(self);
1500 irreco_theme_manager_dlg_loader_stop(self);
1503 IRRECO_RETURN_BOOL(FALSE);
1507 * Show theme details
1509 * @todo
1512 static gboolean
1513 irreco_theme_manager_dlg_display_theme_detail(IrrecoThemeManagerDlg *self,
1514 GtkTreeIter * iter)
1516 IrrecoThemeManager *theme_manager = self->irreco_data->theme_manager;
1517 IrrecoThemeButton *button = NULL;
1518 const gchar *theme_name;
1520 IRRECO_ENTER
1522 gtk_image_clear(GTK_IMAGE(self->theme_image));
1524 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1525 iter, TEXT_COL, &theme_name, -1);
1526 irreco_string_table_get(theme_manager->themes, theme_name,
1527 (gpointer *) &self->theme);
1529 gtk_label_set_text(GTK_LABEL(self->theme_name),
1530 self->theme->name->str);
1531 gtk_label_set_text(GTK_LABEL(self->theme_creator),
1532 self->theme->author->str);
1533 gtk_label_set_text(GTK_LABEL(self->theme_comment),
1534 self->theme->comment->str);
1535 gtk_label_set_text(GTK_LABEL(self->theme_version),
1536 self->theme->version->str);
1538 if (self->theme->preview_button_name->len > 0) {
1539 button =irreco_theme_get_button(self->theme,
1540 self->theme->preview_button_name->str);
1541 } else {
1542 const gchar *key;
1543 irreco_string_table_index(self->theme->buttons,
1544 0, &key, (gpointer *) &button);
1547 if (button != NULL) {
1548 IRRECO_DEBUG("Preview-button: %s\n", button->image_up->str);
1550 gtk_image_set_from_file(GTK_IMAGE(self->theme_image),
1551 button->image_up->str);
1553 self->preview_add = button->image_up->str;
1554 } else {
1555 self->preview_add = NULL;
1557 self->webdb_theme = NULL;
1559 IRRECO_RETURN_BOOL(TRUE);
1562 static gboolean
1563 irreco_theme_manager_dlg_theme_db_detail_loader(IrrecoThemeManagerDlg *self)
1565 IRRECO_ENTER
1567 switch (self->loader_state) {
1568 case LOADER_STATE_INIT:{
1569 irreco_theme_manager_dlg_set_banner(self,
1570 _("Loading ..."), 0.5);
1571 self->loader_state = LOADER_STATE_LOOP;
1572 IRRECO_RETURN_BOOL(TRUE);
1575 case LOADER_STATE_LOOP: {
1576 gchar *download_count;
1577 gint index = 0;
1578 IrrecoWebdbCache *webdb_cache = irreco_data_get_webdb_cache(
1579 self->irreco_data,
1580 FALSE);
1582 /* Get WebdbTheme with preview-button */
1583 if (!irreco_webdb_cache_get_preview_button(webdb_cache,
1584 self->selected_theme_id,
1585 &self->webdb_theme)) {
1586 irreco_error_dlg(GTK_WINDOW(self),
1587 irreco_webdb_cache_get_error(
1588 webdb_cache));
1590 self->loader_state = LOADER_STATE_END;
1591 IRRECO_RETURN_BOOL(TRUE);
1594 gtk_image_clear(GTK_IMAGE(self->theme_image));
1596 gtk_label_set_text(GTK_LABEL(self->theme_name),
1597 self->webdb_theme->name->str);
1598 gtk_label_set_text(GTK_LABEL(self->theme_creator),
1599 self->webdb_theme->creator->str);
1600 gtk_label_set_text(GTK_LABEL(self->theme_comment),
1601 self->webdb_theme->comment->str);
1603 /* Clear combobox */
1604 gtk_tree_store_clear(self->version_store);
1606 IRRECO_STRING_TABLE_FOREACH(self->webdb_theme->versions,
1607 key, gchar *, date)
1608 GtkTreeIter iter;
1610 /* Append row */
1611 gtk_tree_store_append(self->version_store,
1612 &iter, NULL);
1614 /* Fill row */
1615 gtk_tree_store_set(self->version_store, &iter,
1616 DATE_COL, date,
1617 ID_COL, key, -1);
1619 if (g_utf8_collate (date,
1620 self->webdb_theme->uploaded->str) == 0) {
1621 gtk_combo_box_set_active(GTK_COMBO_BOX(
1622 self->combobox),
1623 index);
1625 index++;
1626 IRRECO_STRING_TABLE_FOREACH_END
1628 /*scale_combobox(self);*/
1630 download_count = g_strdup_printf("%d",
1631 self->webdb_theme->download_count);
1633 gtk_label_set_text(GTK_LABEL(self->theme_downloaded),
1634 download_count);
1635 g_free(download_count);
1637 if (self->webdb_theme->preview_button != NULL) {
1638 gtk_image_set_from_pixbuf(GTK_IMAGE(self->theme_image),
1639 self->webdb_theme->preview_button);
1640 } else {
1641 IRRECO_DEBUG("preview_button is NULL\n");
1643 self->preview_add = NULL;
1645 self->loader_state = LOADER_STATE_END;
1646 IRRECO_RETURN_BOOL(TRUE);
1649 case LOADER_STATE_END:
1650 irreco_theme_manager_dlg_hide_banner(self);
1651 irreco_theme_manager_dlg_loader_stop(self);
1653 IRRECO_RETURN_BOOL(FALSE);
1656 static gboolean irreco_theme_manager_dlg_bg_loader(IrrecoThemeManagerDlg *self)
1658 IRRECO_ENTER
1660 switch (self->loader_state) {
1661 case LOADER_STATE_INIT:{
1662 GString *path = g_string_new("");
1663 irreco_theme_manager_dlg_set_banner(self,
1664 _("Loading backgrounds..."),
1665 0.0);
1666 self->loader_state = LOADER_STATE_LOOP;
1667 self->theme_loader_index = 0;
1669 g_string_printf(path, "%s%s/bg/", self->theme_folder,
1670 self->webdb_theme->folder->str);
1672 IRRECO_DEBUG("mkdir %s\n", path->str);
1673 g_mkdir(path->str, 0777);
1674 g_string_free(path, TRUE);
1676 IRRECO_RETURN_BOOL(TRUE);
1679 case LOADER_STATE_LOOP: {
1680 IrrecoStringTable *bg_list = NULL;
1681 GString *path = g_string_new("");
1682 gfloat banner;
1683 const gchar *id;
1684 IrrecoWebdbCache *webdb_cache = irreco_data_get_webdb_cache(
1685 self->irreco_data,
1686 FALSE);
1687 /* Get backrounds */
1688 irreco_webdb_cache_get_backgrounds(webdb_cache,
1689 self->webdb_theme->id,
1690 &bg_list);
1692 g_string_printf(path, "%s%s/bg/", self->theme_folder,
1693 self->webdb_theme->folder->str);
1695 if (irreco_string_table_index(bg_list,
1696 (guint)self->theme_loader_index, &id, NULL) &&
1697 !g_str_equal(id, "0")) {
1698 irreco_webdb_cache_get_bg_by_id(webdb_cache, atoi(id),
1699 path->str);
1700 } else {
1701 self->loader_state = LOADER_STATE_END;
1702 goto end;
1705 banner = ++self->theme_loader_index;
1706 banner /= (gfloat) irreco_string_table_lenght (bg_list);
1708 irreco_theme_manager_dlg_set_banner(self,
1709 _("Loading backgrounds..."),
1710 banner);
1711 if (banner >= 1.0) {
1712 self->loader_state = LOADER_STATE_END;
1714 end:
1715 g_string_free(path, TRUE);
1716 IRRECO_RETURN_BOOL(TRUE);
1718 case LOADER_STATE_END:
1719 irreco_theme_manager_dlg_hide_banner(self);
1720 irreco_theme_manager_dlg_loader_stop(self);
1721 gtk_dialog_response(GTK_DIALOG(self->download_dialog),
1722 GTK_RESPONSE_CANCEL);
1724 IRRECO_RETURN_BOOL(FALSE);
1727 static gboolean
1728 irreco_theme_manager_dlg_button_loader(IrrecoThemeManagerDlg *self)
1730 IRRECO_ENTER
1732 switch (self->loader_state) {
1733 case LOADER_STATE_INIT:{
1734 GString *path = g_string_new("");
1735 irreco_theme_manager_dlg_set_banner(self,
1736 _("Loading buttons.."),
1737 0.0);
1738 self->loader_state = LOADER_STATE_LOOP;
1739 self->theme_loader_index = 0;
1741 g_string_printf(path, "%s%s/buttons/", self->theme_folder,
1742 self->webdb_theme->folder->str);
1744 IRRECO_DEBUG("mkdir %s\n", path->str);
1745 g_mkdir(path->str, 0777);
1746 g_string_free(path, TRUE);
1748 IRRECO_RETURN_BOOL(TRUE);
1751 case LOADER_STATE_LOOP: {
1752 IrrecoStringTable *button_list = NULL;
1753 GString *path = g_string_new("");
1754 gfloat banner;
1755 const gchar *id;
1756 IrrecoWebdbCache *webdb_cache = irreco_data_get_webdb_cache(
1757 self->irreco_data,
1758 FALSE);
1759 /* Get buttons */
1760 irreco_webdb_cache_get_buttons(webdb_cache,
1761 self->webdb_theme->id,
1762 &button_list);
1763 if (button_list == NULL) {
1764 self->loader_state = LOADER_STATE_END;
1765 goto end;
1768 g_string_printf(path, "%s%s/buttons/", self->theme_folder,
1769 self->webdb_theme->folder->str);
1771 if (irreco_string_table_index(button_list,
1772 (guint)self->theme_loader_index, &id, NULL) &&
1773 !g_str_equal(id, "0")) {
1774 irreco_webdb_cache_get_button_by_id(webdb_cache,
1775 atoi(id),
1776 path->str);
1777 } else {
1778 self->loader_state = LOADER_STATE_END;
1779 goto end;
1782 banner = ++self->theme_loader_index;
1783 banner /= (gfloat) irreco_string_table_lenght (button_list);
1785 irreco_theme_manager_dlg_set_banner(self,
1786 _("Loading buttons.."),
1787 banner);
1788 if (banner >= 1.0) {
1789 self->loader_state = LOADER_STATE_END;
1792 end:
1793 g_string_free(path, TRUE);
1794 IRRECO_RETURN_BOOL(TRUE);
1796 case LOADER_STATE_END:
1797 irreco_theme_manager_dlg_hide_banner(self);
1798 irreco_theme_manager_dlg_loader_stop(self);
1800 /* Get backgrounds */
1801 self->loader_func_id = g_idle_add(G_SOURCEFUNC(
1802 irreco_theme_manager_dlg_bg_loader), self);
1804 IRRECO_RETURN_BOOL(FALSE);
1807 /** @} */
1811 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1812 /* Functions */
1813 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1816 * @name Public Functions
1817 * @{
1820 void irreco_theme_manager_dlg_set_irreco_data(IrrecoThemeManagerDlg *self,
1821 IrrecoData *irreco_data)
1823 IRRECO_ENTER
1825 self->irreco_data = irreco_data;
1827 IRRECO_RETURN
1830 void irreco_show_theme_manager_dlg(IrrecoData *irreco_data, GtkWindow *parent)
1832 IrrecoThemeManagerDlg *self;
1833 gint response;
1834 gboolean loop = TRUE;
1835 IrrecoWebdbCache *webdb_cache = NULL;
1837 IRRECO_ENTER
1839 self = IRRECO_THEME_MANAGER_DLG(irreco_theme_manager_dlg_new(
1840 irreco_data, parent));
1842 webdb_cache = irreco_data_get_webdb_cache(self->irreco_data, FALSE);
1844 do {
1845 response = gtk_dialog_run(GTK_DIALOG(self));
1846 switch (response) {
1847 case IRRECO_DEVICE_REFRESH:
1848 if (self->loader_func_id != 0) {
1849 break;
1851 IRRECO_DEBUG("IRRECO_DEVICE_REFRESH\n");
1852 gtk_tree_store_clear(self->tree_store);
1853 irreco_theme_manager_update_theme_manager
1854 (self->irreco_data->theme_manager);
1856 if (webdb_cache->theme_id_hash != NULL) {
1857 g_hash_table_remove_all(
1858 webdb_cache->theme_id_hash);
1859 self->webdb_theme = NULL;
1862 IRRECO_STRING_TABLE_FOREACH_DATA(
1863 irreco_data->theme_manager->themes,
1864 IrrecoTheme *, theme)
1865 irreco_theme_check(theme);
1866 IRRECO_STRING_TABLE_FOREACH_END
1868 irreco_theme_manager_dlg_loader_start(self,
1869 G_SOURCEFUNC(
1870 irreco_theme_manager_dlg_loader_user),
1871 NULL);
1872 gtk_label_set_text(GTK_LABEL(self->select_label),
1873 " Select \ncategory");
1874 break;
1876 case GTK_RESPONSE_CANCEL:
1877 IRRECO_DEBUG("GTK_RESPONSE_CANCEL\n");
1878 loop = FALSE;
1879 break;
1881 } while (loop);
1883 gtk_widget_destroy(GTK_WIDGET(self));
1885 IRRECO_RETURN
1888 /** @} */
1892 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1893 /* Events and Callbacks */
1894 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1897 * @name Events and Callbacks
1898 * @{
1901 static gboolean
1902 irreco_show_theme_manager_dlg_map_event(IrrecoThemeManagerDlg *self,
1903 GdkEvent *event,
1904 gpointer user_data)
1907 IRRECO_ENTER
1909 irreco_theme_manager_dlg_loader_start(
1910 self, G_SOURCEFUNC(irreco_theme_manager_dlg_loader_user),
1911 NULL);
1913 IRRECO_RETURN_BOOL(FALSE);
1916 static void
1917 irreco_show_theme_manager_dlg_destroy_event(IrrecoThemeManagerDlg *self,
1918 gpointer user_data)
1920 IRRECO_ENTER
1921 irreco_theme_manager_dlg_loader_stop(self);
1922 IRRECO_RETURN
1925 static void
1926 irreco_show_theme_manager_dlg_row_activated_event(GtkTreeView *tree_view,
1927 GtkTreePath *path,
1928 GtkTreeViewColumn *column,
1929 IrrecoThemeManagerDlg *self)
1931 IRRECO_ENTER
1933 if (gtk_tree_view_row_expanded(tree_view, path)) {
1934 gtk_tree_view_expand_row(tree_view, path, FALSE);
1935 } else {
1936 gtk_tree_view_collapse_row(tree_view, path);
1938 IRRECO_RETURN
1941 static void
1942 irreco_show_theme_manager_dlg_row_expanded_event(GtkTreeView *tree_view,
1943 GtkTreeIter *iter,
1944 GtkTreePath *path,
1945 IrrecoThemeManagerDlg *self)
1947 gchar *row_name = NULL;
1948 IRRECO_ENTER
1950 irreco_theme_manager_dlg_clean_details(self);
1951 gtk_label_set_text(GTK_LABEL(self->select_label), "Select \ntheme");
1954 if (self->loader_func_id != 0) {
1955 gtk_tree_view_collapse_row(tree_view, path);
1958 if (!irreco_theme_manager_dlg_row_is_loaded(self, iter)){
1959 switch (irreco_theme_manager_dlg_row_get_type(self, iter)){
1960 case ROW_TYPE_CATEGORY:
1961 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
1962 iter, TEXT_COL, &row_name, -1);
1964 if(g_utf8_collate(row_name, "Database") != 0) {
1965 goto end;
1968 self->loader_iter = gtk_tree_iter_copy(iter);
1969 irreco_theme_manager_dlg_loader_start(self,
1970 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_db), NULL);
1971 break;
1974 end:
1975 if (row_name != NULL) g_free(row_name);
1976 IRRECO_RETURN
1979 static void
1980 irreco_show_theme_manager_dlg_row_collapsed_event(GtkTreeView *tree_view,
1981 GtkTreeIter *iter,
1982 GtkTreePath *path,
1983 IrrecoThemeManagerDlg *self)
1986 IRRECO_ENTER
1988 gtk_label_set_text(GTK_LABEL(self->select_label), " Select\ncategory");
1990 irreco_theme_manager_dlg_clean_details(self);
1992 IRRECO_RETURN
1995 static void
1996 irreco_show_theme_manager_dlg_row_selected_event(GtkTreeSelection *sel,
1997 IrrecoThemeManagerDlg *self)
1999 GtkTreeIter iter;
2000 GtkTreeModel *model;
2001 const char *id;
2003 IRRECO_ENTER
2005 if (gtk_tree_selection_get_selected (sel, &model, &iter))
2007 switch (irreco_theme_manager_dlg_row_get_type(self, &iter)) {
2009 case ROW_TYPE_DEB:
2010 IRRECO_DEBUG("ROW_TYPE_DEB\n");
2012 gtk_widget_hide(self->select_label);
2013 gtk_widget_show(self->theme_info_alignment);
2014 gtk_widget_hide(self->label_download);
2015 gtk_widget_hide(self->theme_downloaded);
2016 gtk_widget_hide(self->label_combobox);
2017 gtk_widget_hide(self->combobox);
2018 gtk_widget_hide(self->theme_version);
2019 gtk_widget_hide(self->theme_creator);
2020 gtk_widget_hide(self->label_creator);
2022 gtk_widget_hide(self->upload_button);
2023 gtk_widget_hide(self->download_button);
2024 gtk_widget_hide(self->clear_button);
2025 gtk_widget_hide(self->new_button);
2026 gtk_widget_hide(self->edit_button);
2029 irreco_theme_manager_dlg_display_theme_detail(self,
2030 &iter);
2032 break;
2033 case ROW_TYPE_USER:
2034 IRRECO_DEBUG("ROW_TYPE_USER\n");
2036 gtk_widget_hide(self->select_label);
2037 gtk_widget_show(self->theme_info_alignment);
2038 gtk_widget_hide(self->label_download);
2039 gtk_widget_hide(self->theme_downloaded);
2040 gtk_widget_show(self->theme_creator);
2041 gtk_widget_show(self->label_creator);
2043 gtk_widget_show(self->label_combobox);
2044 gtk_widget_hide(self->combobox);
2045 gtk_widget_show(self->theme_version);
2047 gtk_widget_show(self->upload_button);
2048 gtk_widget_show(self->clear_button);
2049 gtk_widget_hide(self->download_button);
2050 gtk_widget_show(self->edit_button);
2051 gtk_widget_hide(self->new_button);
2053 irreco_theme_manager_dlg_display_theme_detail(self,
2054 &iter);
2056 break;
2057 case ROW_TYPE_WEB:
2058 IRRECO_DEBUG("ROW_TYPE_WEB\n");
2060 gtk_widget_show(self->clear_button);
2061 gtk_widget_hide(self->upload_button);
2062 gtk_widget_hide(self->download_button);
2063 gtk_widget_hide(self->new_button);
2064 gtk_widget_hide(self->edit_button);
2067 gtk_widget_hide(self->select_label);
2068 gtk_widget_show(self->theme_creator);
2069 gtk_widget_show(self->label_creator);
2070 gtk_widget_hide(self->label_download);
2071 gtk_widget_hide(self->theme_downloaded);
2073 gtk_widget_hide(self->combobox);
2074 gtk_widget_show(self->label_combobox);
2075 gtk_widget_show(self->theme_version);
2077 gtk_widget_show(self->theme_info_alignment);
2079 irreco_theme_manager_dlg_display_theme_detail(self,
2080 &iter);
2082 break;
2083 case ROW_TYPE_DB:
2084 IRRECO_DEBUG("ROW_TYPE_DB\n");
2086 if (self->loader_func_id != 0) {
2087 break;
2090 gtk_tree_model_get(GTK_TREE_MODEL(self->tree_store),
2091 &iter, DATA_COL, &id, -1);
2093 gtk_widget_hide(self->clear_button);
2094 gtk_widget_hide(self->upload_button);
2095 gtk_widget_show(self->download_button);
2096 gtk_widget_hide(self->new_button);
2097 gtk_widget_hide(self->edit_button);
2100 gtk_widget_show(self->combobox);
2101 gtk_widget_show(self->label_combobox);
2102 gtk_widget_hide(self->theme_version);
2104 gtk_widget_hide(self->select_label);
2105 gtk_widget_show(self->theme_creator);
2106 gtk_widget_show(self->label_creator);
2107 gtk_widget_show(self->label_download);
2108 gtk_widget_show(self->theme_downloaded);
2110 gtk_widget_show(self->theme_info_alignment);
2112 IRRECO_DEBUG("SELECTED ID: %d\n", atoi(id));
2114 self->selected_theme_id = atoi(id);
2115 self->loader_func_id = g_idle_add(G_SOURCEFUNC(
2116 irreco_theme_manager_dlg_theme_db_detail_loader),
2117 self);
2119 break;
2120 default:
2121 irreco_theme_manager_dlg_clean_details(self);
2122 break;
2126 IRRECO_RETURN
2128 /** @} */
2129 /** @} */