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"
26 #include "irreco_theme_download_dlg.h"
27 #include <hildon/hildon-gtk.h>
28 #include <hildon/hildon-pannable-area.h>
30 * @addtogroup IrrecoThemeManagerDlg
33 * @todo PURPOCE OF CLASS.
40 * Source file of @ref IrrecoThemeManagerDlg.
44 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
46 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
47 #define IRRECO_BACKGROUND_PREVIEW_WIDHT (IRRECO_SCREEN_WIDTH / 6)
48 #define IRRECO_BACKGROUND_PREVIEW_HEIGHT (IRRECO_SCREEN_HEIGHT / 6)
49 #define IRRECO_DEFAULT_BG (IRRECO_BG_IMAGE_DIR "/" IRRECO_DEFAULT_BG_IMAGE)
51 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
53 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
55 static void irreco_theme_manager_dlg_hide_banner(IrrecoThemeManagerDlg
*self
);
57 static void irreco_theme_manager_dlg_loader_stop(IrrecoThemeManagerDlg
*self
);
59 static void irreco_theme_manager_dlg_clean_details(IrrecoThemeManagerDlg
*self
);
62 irreco_theme_manager_dlg_loader_deb(IrrecoThemeManagerDlg
*self
);
65 irreco_theme_manager_dlg_loader_user(IrrecoThemeManagerDlg
*self
);
68 irreco_theme_manager_dlg_loader_web(IrrecoThemeManagerDlg
*self
);
71 irreco_theme_manager_dlg_loader_db(IrrecoThemeManagerDlg
*self
);
74 irreco_theme_manager_dlg_theme_db_detail_loader(IrrecoThemeManagerDlg
*self
);
77 irreco_theme_manager_dlg_display_theme_detail(IrrecoThemeManagerDlg
*self
,
80 static gboolean
irreco_theme_manager_dlg_map_event(IrrecoThemeManagerDlg
81 *self
, GdkEvent
*event
,
84 static void irreco_theme_manager_dlg_destroy_event(IrrecoThemeManagerDlg
88 static void irreco_theme_manager_dlg_row_activated_event(GtkTreeView
*tree_view
,
90 GtkTreeViewColumn
*column
,
91 IrrecoThemeManagerDlg
*self
);
93 static void irreco_theme_manager_dlg_row_expanded_event(GtkTreeView
*tree_view
,
96 IrrecoThemeManagerDlg
*self
);
98 static void irreco_theme_manager_dlg_row_collapsed_event(GtkTreeView
*tree_view
,
101 IrrecoThemeManagerDlg
*self
);
104 static void irreco_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
);
111 static void irreco_theme_manager_dlg_delete_theme(GtkButton
*button
,
112 IrrecoThemeManagerDlg
*self
);
114 static void irreco_theme_manager_dlg_selected_version(GtkComboBox
*widget
,
115 IrrecoThemeManagerDlg
*self
);
117 void irreco_theme_manager_update_theme_manager(IrrecoThemeManager
*self
);
119 static void irreco_theme_manager_dlg_new_theme(GtkButton
*button
,
120 IrrecoThemeManagerDlg
*self
);
122 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
124 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
126 /** Button responce codes. */
128 IRRECO_DEVICE_REFRESH
,
129 IRRECO_DOWNLOAD_THEME
,
133 /** GtkTreeStore colums. */
142 /** Version colums. */
149 /** Loader states. */
161 ROW_CHILDREN_LOADED
= 1 << 1,
162 ROW_TYPE_CATEGORY
= 1 << 2,
163 ROW_TYPE_DEB
= 1 << 3,
164 ROW_TYPE_USER
= 1 << 4,
165 ROW_TYPE_WEB
= 1 << 5,
166 ROW_TYPE_DB
= 1 << 6,
167 ROW_TYPE_LOADING
= 1 << 7
170 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
171 /* Construction & Destruction */
172 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
175 * @name Construction & Destruction
179 G_DEFINE_TYPE(IrrecoThemeManagerDlg
, irreco_theme_manager_dlg
, IRRECO_TYPE_DLG
)
181 static void irreco_theme_manager_dlg_finalize(GObject
*object
)
183 if (G_OBJECT_CLASS(irreco_theme_manager_dlg_parent_class
)->finalize
)
184 G_OBJECT_CLASS(irreco_theme_manager_dlg_parent_class
)->finalize(
189 irreco_theme_manager_dlg_class_init(IrrecoThemeManagerDlgClass
*klass
)
191 GObjectClass
*object_class
= G_OBJECT_CLASS(klass
);
192 object_class
->finalize
= irreco_theme_manager_dlg_finalize
;
195 static void irreco_theme_manager_dlg_init(IrrecoThemeManagerDlg
*self
)
197 GtkTreeViewColumn
*column
;
198 GtkCellRenderer
*renderer
;
199 GtkTreeSelection
*select
;
200 GtkWidget
*label_name
;
201 GtkWidget
*label_description
;
202 GtkWidget
*theme_info_frame
;
203 GtkWidget
*tree_view_frame
;
204 GtkWidget
*tree_view_hbox
;
205 GtkWidget
*preview_frame
;
206 PangoFontDescription
*initial_font
;
207 GtkWidget
*select_vbox
;
208 GtkWidget
*versions_hbox
;
209 GtkWidget
*comment_alignment
;
210 GtkWidget
*theme_info
;
212 GtkWidget
*info_vbox
;
213 GtkWidget
*theme_table
;
214 GtkWidget
*preview_event_box
;
215 GtkWidget
*tree_view_pannable
;
219 self
->theme_folder
= NULL
;
221 /* Construct dialog. */
222 gtk_window_set_title(GTK_WINDOW(self
),
223 _("Theme Manager "));
224 gtk_window_set_modal(GTK_WINDOW(self
), TRUE
);
225 gtk_window_set_destroy_with_parent(GTK_WINDOW(self
), TRUE
);
226 gtk_dialog_set_has_separator(GTK_DIALOG(self
), FALSE
);
229 self
->refresh_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
231 IRRECO_DEVICE_REFRESH
);
232 /*self->new_button= gtk_dialog_add_button (GTK_DIALOG(self),
233 _("New"), GTK_RESPONSE_NONE);*/
234 self
->edit_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
235 _("Edit"), GTK_RESPONSE_NONE
);
236 self
->upload_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
237 _("Upload"), IRRECO_UPLOAD_THEME
);
238 self
->download_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
239 _("Download"), IRRECO_DOWNLOAD_THEME
);
240 self
->clear_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
244 /* Create theme table */
245 table
= gtk_table_new(7,7,TRUE
);
246 gtk_table_set_col_spacings(GTK_TABLE (table
), 8);
247 gtk_table_set_row_spacings(GTK_TABLE (table
), 8);
248 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(self
)->vbox
),
249 irreco_gtk_align(GTK_WIDGET(table
),
250 0, 0, 1, 1, 8, 8, 8, 8));
251 /* Create tree_view_hbox */
252 tree_view_hbox
= gtk_hbox_new(FALSE
, 2);
254 /* Create Treeview */
255 self
->tree_store
= gtk_tree_store_new(
256 N_COLUMNS
, G_TYPE_STRING
, G_TYPE_INT
, G_TYPE_POINTER
);
257 self
->tree_view
= GTK_TREE_VIEW(hildon_gtk_tree_view_new_with_model(1,
258 GTK_TREE_MODEL(self
->tree_store
)));
260 renderer
= gtk_cell_renderer_text_new();
261 column
= gtk_tree_view_column_new_with_attributes(
262 NULL
, renderer
, "text", TEXT_COL
, NULL
);
263 gtk_tree_view_append_column(self
->tree_view
, column
);
265 gtk_box_pack_start(GTK_BOX(tree_view_hbox
), GTK_WIDGET(self
->tree_view
),
268 /* Create Frame for Treeview */
269 tree_view_frame
= gtk_frame_new("");
270 gtk_frame_set_label_widget(GTK_FRAME(tree_view_frame
),
271 irreco_gtk_label_bold("Themes", 0, 0, 0, 0, 0, 0));
273 /* Create theme_info */
275 theme_info
= gtk_table_new(7, 4, TRUE
);
276 gtk_table_set_col_spacings(GTK_TABLE(theme_info
), 8);
277 gtk_table_set_row_spacings(GTK_TABLE(theme_info
), 8);
280 self
->version_store
= gtk_tree_store_new(
281 2, G_TYPE_STRING
, G_TYPE_STRING
);
283 self
->combobox
= gtk_combo_box_new_text();
284 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(self
->combobox
), 1);
285 gtk_combo_box_set_model(GTK_COMBO_BOX(self
->combobox
),
286 GTK_TREE_MODEL(self
->version_store
));
287 gtk_widget_set_size_request(GTK_WIDGET(self
->combobox
), -1, 32);
289 theme_table
= gtk_table_new(5, 7, TRUE
);
290 gtk_table_set_col_spacings(GTK_TABLE(theme_table
), 1);
291 gtk_table_set_row_spacings(GTK_TABLE(theme_table
), 1);
293 info_vbox
= gtk_vbox_new(FALSE
, 1);
295 /* Create pannable areas */
296 tree_view_pannable
= hildon_pannable_area_new();
297 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(tree_view_pannable
), tree_view_hbox
);
298 gtk_container_add(GTK_CONTAINER(tree_view_frame
), tree_view_pannable
);
301 preview_event_box
= gtk_event_box_new();
302 self
->select_label
= gtk_label_new(" Select \ncategory");
304 /* Create frame for theme_info */
305 select_vbox
= gtk_vbox_new(FALSE
, 2);
306 versions_hbox
= gtk_hbox_new(FALSE
, 2);
307 theme_info_frame
= gtk_frame_new("");
308 gtk_frame_set_label_widget(GTK_FRAME(theme_info_frame
),
309 irreco_gtk_label_bold("Info", 0, 0, 0, 0, 0, 0));
310 self
->theme_info_alignment
= gtk_alignment_new(0, 0, 0, 0);
311 gtk_alignment_set_padding(GTK_ALIGNMENT(self
->theme_info_alignment
),
314 preview_frame
= gtk_frame_new(NULL
);
315 gtk_frame_set_shadow_type(GTK_FRAME(preview_frame
), GTK_SHADOW_OUT
);
317 self
->theme_image
= gtk_image_new();
318 gtk_image_set_from_file(GTK_IMAGE(self
->theme_image
), NULL
);
321 label_name
= gtk_label_new("Name: ");
322 self
->label_creator
= gtk_label_new("Author: ");
323 self
->label_download
= gtk_label_new("Downloads: ");
324 label_description
= gtk_label_new("Comment: ");
325 self
->label_combobox
= gtk_label_new("Version:");
326 gtk_widget_set_size_request(GTK_WIDGET(self
->label_download
), 50, -1);
328 self
->theme_name
= gtk_label_new("");
329 self
->theme_creator
= gtk_label_new("");
330 self
->theme_downloaded
= gtk_label_new("");
331 self
->theme_comment
= gtk_label_new("");
332 self
->theme_version
= gtk_label_new("");
334 comment_alignment
= gtk_alignment_new(0, 0, 0, 0);
335 gtk_widget_set_size_request(self
->theme_comment
,
337 gtk_alignment_set_padding(GTK_ALIGNMENT(comment_alignment
),
339 gtk_label_set_line_wrap(GTK_LABEL(self
->theme_comment
), TRUE
);
340 gtk_label_set_line_wrap_mode(GTK_LABEL(self
->theme_comment
),
343 gtk_misc_set_alignment(GTK_MISC(label_name
), 0, 0.5);
344 gtk_misc_set_alignment(GTK_MISC(self
->label_creator
), 0, 0.5);
345 gtk_misc_set_alignment(GTK_MISC(self
->label_download
), 0, 0.5);
346 gtk_misc_set_alignment(GTK_MISC(label_description
), 0, 0.5);
347 gtk_misc_set_alignment(GTK_MISC(self
->label_combobox
), 0, 0.5);
348 gtk_misc_set_alignment(GTK_MISC(self
->theme_name
), 0, 0.5);
349 gtk_misc_set_alignment(GTK_MISC(self
->theme_creator
), 0, 0.5);
350 gtk_misc_set_alignment(GTK_MISC(self
->theme_downloaded
), 0, 0.5);
351 gtk_misc_set_alignment(GTK_MISC(self
->theme_comment
), 0, 0.5);
352 gtk_misc_set_alignment(GTK_MISC(self
->theme_version
), 0, 0.5);
355 /*Attach WidGets to tables*/
356 gtk_table_attach_defaults(GTK_TABLE(table
),
357 tree_view_frame
, 0, 3, 0, 7);
358 gtk_table_attach_defaults(GTK_TABLE(theme_info
),
359 preview_event_box
, 0, 2, 4, 7);
360 gtk_table_attach_defaults(GTK_TABLE(theme_info
),
361 info_vbox
, 0, 4, 3, 4);
362 gtk_table_attach_defaults(GTK_TABLE(theme_info
),
363 theme_table
, 0, 4, 0, 3);
364 gtk_table_attach_defaults(GTK_TABLE(theme_table
),
365 label_name
, 0, 3, 0, 1);
366 gtk_table_attach_defaults(GTK_TABLE(theme_table
),
367 self
->label_creator
, 0, 3, 1, 2);
368 gtk_table_attach_defaults(GTK_TABLE(theme_table
),
369 self
->label_download
, 0, 3, 2, 3);
370 gtk_table_attach_defaults(GTK_TABLE(theme_table
),
371 label_description
, 0, 3, 3, 4);
372 /* gtk_table_attach_defaults(GTK_TABLE(theme_table),
373 self->label_combobox, 0, 3, 3, 4);
374 gtk_table_attach_defaults(GTK_TABLE(theme_table),
375 versions_hbox, 3, 7, 3, 4);*/
376 gtk_table_attach_defaults(GTK_TABLE(table
),
377 theme_info_frame
, 3, 7, 0, 7);
378 gtk_table_attach(GTK_TABLE(theme_table
), self
->theme_name
,
379 3, 7, 0, 1, GTK_FILL
, GTK_FILL
, 0, 0);
380 gtk_table_attach(GTK_TABLE(theme_table
), self
->theme_creator
,
381 3, 7, 1, 2, GTK_FILL
, GTK_FILL
, 0, 0);
382 gtk_table_attach(GTK_TABLE(theme_table
), self
->theme_downloaded
,
383 3, 7, 2, 3, GTK_FILL
, GTK_FILL
, 0, 0);
386 gtk_container_add(GTK_CONTAINER(preview_frame
),
388 gtk_container_add(GTK_CONTAINER(preview_event_box
),
390 gtk_container_add(GTK_CONTAINER(info_vbox
), comment_alignment
);
391 gtk_container_add(GTK_CONTAINER(comment_alignment
),
392 self
->theme_comment
);
393 gtk_container_add(GTK_CONTAINER(theme_info_frame
),
394 GTK_WIDGET(select_vbox
));
395 gtk_container_add(GTK_CONTAINER(select_vbox
),
396 GTK_WIDGET(self
->theme_info_alignment
));
397 gtk_container_add(GTK_CONTAINER(select_vbox
),
398 GTK_WIDGET(self
->select_label
));
399 gtk_container_add(GTK_CONTAINER(self
->theme_info_alignment
),
400 GTK_WIDGET(theme_info
));
401 gtk_container_add(GTK_CONTAINER(versions_hbox
),
402 GTK_WIDGET(self
->theme_version
));
403 gtk_container_add(GTK_CONTAINER(versions_hbox
),
404 GTK_WIDGET(self
->combobox
));
406 /*Set font size and style*/
408 initial_font
= pango_font_description_from_string ("Sans Bold 16");
409 gtk_widget_modify_font (self
->select_label
, initial_font
);
411 initial_font
= pango_font_description_from_string ("Sans Bold 12");
412 gtk_widget_modify_font (label_name
, initial_font
);
413 gtk_widget_modify_font (self
->label_creator
, initial_font
);
414 gtk_widget_modify_font (self
->label_download
, initial_font
);
415 gtk_widget_modify_font (label_description
, initial_font
);
416 gtk_widget_modify_font (self
->label_combobox
, initial_font
);
418 initial_font
= pango_font_description_from_string ("Sans 11");
419 gtk_widget_modify_font (self
->theme_name
, initial_font
);
420 gtk_widget_modify_font (self
->theme_creator
, initial_font
);
421 gtk_widget_modify_font (self
->theme_downloaded
, initial_font
);
422 gtk_widget_modify_font (self
->theme_comment
, initial_font
);
423 gtk_widget_modify_font (self
->theme_version
, initial_font
);
424 gtk_widget_modify_font (self
->combobox
, initial_font
);
426 /* Setup the selection handler for TREE */
427 select
= gtk_tree_view_get_selection(self
->tree_view
);
428 gtk_tree_selection_set_mode(select
, GTK_SELECTION_SINGLE
);
430 /* Signal handlers. */
431 g_signal_connect(G_OBJECT(self
), "map-event",
432 G_CALLBACK(irreco_theme_manager_dlg_map_event
), NULL
);
433 g_signal_connect(G_OBJECT(self
), "destroy",
434 G_CALLBACK(irreco_theme_manager_dlg_destroy_event
), NULL
);
435 g_signal_connect(G_OBJECT(self
->tree_view
), "row-activated",
436 G_CALLBACK(irreco_theme_manager_dlg_row_activated_event
),
438 g_signal_connect(G_OBJECT(self
->tree_view
), "row-expanded",
439 G_CALLBACK(irreco_theme_manager_dlg_row_expanded_event
),
441 g_signal_connect(G_OBJECT(self
->tree_view
), "row-collapsed",
442 G_CALLBACK(irreco_theme_manager_dlg_row_collapsed_event
),
444 g_signal_connect(G_OBJECT (select
), "changed",
445 G_CALLBACK (irreco_theme_manager_dlg_row_selected_event
),
447 g_signal_connect(G_OBJECT (self
->combobox
), "changed",
448 G_CALLBACK (irreco_theme_manager_dlg_selected_version
),
450 g_signal_connect(G_OBJECT(preview_event_box
),
451 "button-release-event",
452 G_CALLBACK(irreco_theme_manager_dlg_preview_dlg
),
454 g_signal_connect(G_OBJECT(self
->clear_button
),
456 G_CALLBACK(irreco_theme_manager_dlg_delete_theme
),
458 g_signal_connect(G_OBJECT(self
->edit_button
),
460 G_CALLBACK(irreco_theme_manager_dlg_new_theme
),
462 /*g_signal_connect(G_OBJECT(self->new_button),
464 G_CALLBACK(irreco_theme_manager_dlg_new_theme),
467 gtk_tree_view_set_enable_tree_lines(self
->tree_view
, TRUE
);
468 g_object_set (G_OBJECT (self
->tree_view
), "show-expanders", TRUE
, NULL
);
469 g_object_set (G_OBJECT (self
->tree_view
), "level-indentation", 0, NULL
);
470 gtk_tree_view_set_rubber_banding(self
->tree_view
, FALSE
);
472 gtk_widget_set_size_request(GTK_WIDGET(self
), 696, 306);
473 gtk_widget_show_all(GTK_WIDGET(self
));
478 GtkWidget
*irreco_theme_manager_dlg_new(IrrecoData
*irreco_data
,
481 IrrecoThemeManagerDlg
*self
;
485 self
= g_object_new(IRRECO_TYPE_THEME_MANAGER_DLG
, NULL
);
486 irreco_dlg_set_parent(IRRECO_DLG(self
), parent
);
487 irreco_theme_manager_dlg_set_irreco_data(self
, irreco_data
);
489 IRRECO_RETURN_PTR(self
);
493 * Show whole preview image
497 gboolean
irreco_theme_manager_dlg_preview_dlg(GtkWidget
*widget
,
498 GdkEventButton
*event
,
499 IrrecoThemeManagerDlg
*self
)
501 GtkWidget
*image
, *event_box
;
502 GtkWidget
*preview_dialog
;
506 if(self
->preview_add
!= NULL
||
507 self
->webdb_theme
->preview_button
!= NULL
) {
509 preview_dialog
= irreco_dlg_new();
510 gtk_window_set_title(GTK_WINDOW(preview_dialog
), _("Preview"));
511 gtk_window_set_modal(GTK_WINDOW(preview_dialog
), TRUE
);
512 gtk_window_set_destroy_with_parent(GTK_WINDOW(preview_dialog
), TRUE
);
513 gtk_dialog_set_has_separator(GTK_DIALOG(preview_dialog
), FALSE
);
515 gtk_widget_set_size_request(preview_dialog
, 185, -1);
517 event_box
= gtk_event_box_new();
518 image
= gtk_image_new();
519 if(self
->preview_add
!= NULL
){
520 gtk_image_set_from_file(GTK_IMAGE(image
), self
->preview_add
);
523 gtk_image_set_from_pixbuf(GTK_IMAGE(image
),
524 GDK_PIXBUF(self
->webdb_theme
->preview_button
));
527 gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(preview_dialog
)->vbox
),
529 gtk_container_add(GTK_CONTAINER(event_box
), image
);
531 g_signal_connect_swapped(G_OBJECT(event_box
),
532 "button-release-event",
533 G_CALLBACK(gtk_widget_destroy
),
536 gtk_widget_show_all(GTK_WIDGET(preview_dialog
));
538 IRRECO_RETURN_BOOL(TRUE
);
547 irreco_theme_manager_dlg_selected_version(GtkComboBox
*widget
,
548 IrrecoThemeManagerDlg
*self
)
555 if(!gtk_combo_box_get_active_iter(widget
, &iter
)) {
558 gtk_tree_model_get(GTK_TREE_MODEL(self
->version_store
), &iter
,
561 if (self
->webdb_theme
== NULL
|| self
->webdb_theme
->id
!= atoi(id
)) {
562 IRRECO_DEBUG("SELECTED ID: %d\n", atoi(id
));
563 self
->selected_theme_id
= atoi(id
);
564 self
->loader_func_id
= g_idle_add(G_SOURCEFUNC(
565 irreco_theme_manager_dlg_theme_db_detail_loader
),
576 static void irreco_theme_manager_dlg_delete_theme(GtkButton
*button
,
577 IrrecoThemeManagerDlg
*self
)
580 const gchar
*name
= gtk_label_get_label(GTK_LABEL(self
->theme_name
));
581 GString
*message
= g_string_new(NULL
);
584 g_string_append_printf(
585 message
, _("Are you sure you want to\n "
586 "delete %s theme?"),name
);
588 if (irreco_yes_no_dlg(GTK_WINDOW(self
), message
->str
)){
590 irreco_theme_manager_remove_theme(
591 self
->irreco_data
->theme_manager
, name
);
592 gtk_button_clicked(GTK_BUTTON(self
->refresh_button
));
595 g_string_free(message
, TRUE
);
605 void irreco_theme_manager_dlg_set_layout_button(IrrecoThemeManagerDlg
*self
)
607 IrrecoStringTable
*table
;
608 gchar
*un_mmc1
= NULL
;
609 gchar
*un_mmc2
= NULL
;
610 gchar
*pressed_mmc1
= NULL
;
611 gchar
*pressed_mmc2
= NULL
;
612 gchar
*button_dir
= NULL
;
613 GString
*bg_mmc
= NULL
;
616 bg_mmc
= g_string_new(NULL
);
617 table
= self
->irreco_data
->irreco_layout_array
;
619 /* Check layouts buttons */
620 IRRECO_STRING_TABLE_FOREACH_DATA(self
->theme
->buttons
,
621 IrrecoThemeButton
*, temp_button
)
623 button_dir
= g_strrstr(temp_button
->image_up
->str
, "/irreco");
624 un_mmc1
= g_strconcat("/home/user/MyDocs/irreco", button_dir
, NULL
);
625 un_mmc2
= g_strconcat("/home/user/MyDocs/irreco", button_dir
, NULL
);
627 button_dir
= g_strrstr(temp_button
->image_down
->str
, "/irreco");
628 pressed_mmc1
= g_strconcat("/home/user/MyDocs/irreco", button_dir
, NULL
);
629 pressed_mmc2
= g_strconcat("/home/user/MyDocs/irreco", button_dir
, NULL
);
631 if (!irreco_is_file(temp_button
->image_up
->str
)) {
633 IRRECO_STRING_TABLE_FOREACH(table
, key
,
634 IrrecoButtonLayout
*,
637 IRRECO_PTR_ARRAY_FORWARDS(layout
->button_array
,
638 IrrecoButton
*, button
)
640 if (button
->style
!= NULL
&&
641 g_str_equal(button
->style
->style_name
->str
,
642 temp_button
->style_name
->str
)) {
644 if (irreco_is_file(un_mmc1
)) {
646 button
->style
->image_up
,
649 button
->style
->image_down
,
651 } else if (irreco_is_file(un_mmc2
)) {
653 button
->style
->image_up
,
656 button
->style
->image_down
,
659 button
->type
= IRRECO_BTYPE_GTK_BUTTON
;
660 irreco_button_set_style(button
, NULL
);
661 irreco_button_create_widget(button
);
665 IRRECO_PTR_ARRAY_FORWARDS_END
667 IRRECO_STRING_TABLE_FOREACH_END
669 IRRECO_STRING_TABLE_FOREACH_END
671 irreco_config_save_layouts(self
->irreco_data
);
673 /* Check layouts bg:s */
674 IRRECO_STRING_TABLE_FOREACH_DATA(self
->theme
->backgrounds
,
675 IrrecoThemeBg
*, temp_bg
)
677 if (!irreco_is_file(temp_bg
->image_name
->str
)) {
679 IRRECO_STRING_TABLE_FOREACH(table
, key
,
680 IrrecoButtonLayout
*,
682 g_string_printf(bg_mmc
, "%s" ,
683 irreco_button_layout_get_bg_image(
686 g_string_erase(bg_mmc
, 10, 1);
687 g_string_insert_c(bg_mmc
, 10, 1);
689 if (irreco_is_file(bg_mmc
->str
)) {
691 irreco_button_layout_set_bg_image(
692 layout
, bg_mmc
->str
);
695 g_string_erase(bg_mmc
, 10, 1);
696 g_string_insert_c(bg_mmc
, 10, 2);
698 if (irreco_is_file(bg_mmc
->str
)) {
700 irreco_button_layout_set_bg_image(
701 layout
, bg_mmc
->str
);
703 irreco_button_layout_set_bg_image(
707 IRRECO_STRING_TABLE_FOREACH_END
710 IRRECO_STRING_TABLE_FOREACH_END
712 g_string_free(bg_mmc
, TRUE
);
713 if (un_mmc1
!= NULL
) g_free(un_mmc1
);
714 if (un_mmc2
!= NULL
) g_free(un_mmc2
);
715 if (pressed_mmc1
!= NULL
) g_free(pressed_mmc1
);
716 if (pressed_mmc2
!= NULL
) g_free(pressed_mmc2
);
721 *Create new theme or edit theme
723 static void irreco_theme_manager_dlg_new_theme(GtkButton
*button
,
724 IrrecoThemeManagerDlg
*self
)
728 /* Check which button */
729 /* Create new theme */
730 if (g_str_equal("New", gtk_button_get_label(button
))) {
731 IrrecoTheme
*new_theme
= NULL
;
732 new_theme
= irreco_theme_new();
734 if (irreco_theme_creator_dlg_run(GTK_WINDOW(self
),
735 self
->irreco_data
, new_theme
)) {
736 gtk_button_clicked(GTK_BUTTON(self
->refresh_button
));
741 IrrecoTheme
*new_theme
= NULL
;
744 IrrecoWindowManager
* manager
;
745 /* Create temp theme folder */
746 temp_dir
= g_strconcat("cp -r ", self
->theme
->path
->str
, " ",
747 "/home/user/MyDocs/irreco/irreco_temp", NULL
);
748 rm_dir
= g_strconcat("rm -r ",
749 "/home/user/MyDocs/irreco/irreco_temp", NULL
);
750 /* Delete temp dir */
751 if (irreco_is_dir("/home/user/MyDocs/irreco/irreco_temp")) {
756 new_theme
= irreco_theme_new_from_dir(
757 "/home/user/MyDocs/irreco/irreco_temp");
759 irreco_theme_set(new_theme
, self
->theme
->name
->str
,
760 self
->theme
->path
->str
,
761 self
->theme
->source
->str
,
762 self
->theme
->author
->str
,
763 self
->theme
->comment
->str
,
764 self
->theme
->preview_button_name
->str
,
765 self
->theme
->version
->str
);
767 IRRECO_DEBUG("Pointer: %p \n", (void*) self
->theme
);
768 IRRECO_DEBUG("New_Pointer: %p \n", (void*) new_theme
);
769 irreco_theme_print(new_theme
);
771 if (irreco_theme_creator_dlg_run(GTK_WINDOW(self
),
772 self
->irreco_data
, new_theme
)) {
774 irreco_theme_manager_dlg_set_layout_button(self
);
776 self
->theme
= irreco_theme_copy(new_theme
);
778 irreco_config_save_layouts(self
->irreco_data
);
780 gtk_button_clicked(GTK_BUTTON(self
->refresh_button
));
784 manager
= self
->irreco_data
->window_manager
;
785 irreco_window_edit_set_layout(manager
->edit_window
,
786 manager
->current_layout
);
788 /* remove temp theme */
793 irreco_theme_free(new_theme
);
800 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
801 /* Private Functions */
802 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
805 * @name Private Functions
813 static void irreco_theme_manager_dlg_clean_details(IrrecoThemeManagerDlg
*self
)
817 gtk_widget_show_all(GTK_WIDGET(self
));
819 GTK_LABEL(self
->theme_name
), "-");
821 GTK_LABEL(self
->theme_creator
), "-");
823 GTK_LABEL(self
->theme_comment
), "-");
825 GTK_LABEL(self
->theme_downloaded
), "-");
826 gtk_image_clear(GTK_IMAGE(self
->theme_image
));
827 self
->preview_add
=NULL
;
829 gtk_widget_hide(self
->upload_button
);
830 gtk_widget_hide(self
->download_button
);
831 gtk_widget_hide(self
->clear_button
);
832 gtk_widget_hide(self
->edit_button
);
833 gtk_widget_hide(self
->theme_info_alignment
);
834 gtk_widget_show(self
->select_label
);
840 * Have the childern of this item been loaded.
842 * @return TRUE if children have been loade, FALSE otherwise.
846 irreco_theme_manager_dlg_row_is_loaded(IrrecoThemeManagerDlg
*self
,
852 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
853 iter
, FLAG_COL
, &i
, -1);
854 if (i
& ROW_CHILDREN_LOADED
) IRRECO_RETURN_BOOL(TRUE
);
856 IRRECO_RETURN_BOOL(FALSE
);
863 static gint
irreco_theme_manager_dlg_row_get_type(IrrecoThemeManagerDlg
*self
,
870 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
871 iter
, FLAG_COL
, &i
, -1);
872 if (i
& ROW_TYPE_CATEGORY
)
873 IRRECO_RETURN_ENUM(ROW_TYPE_CATEGORY
);
874 if (i
& ROW_TYPE_DEB
)
875 IRRECO_RETURN_ENUM(ROW_TYPE_DEB
);
876 if (i
& ROW_TYPE_USER
)
877 IRRECO_RETURN_ENUM(ROW_TYPE_USER
);
878 if (i
& ROW_TYPE_WEB
)
879 IRRECO_RETURN_ENUM(ROW_TYPE_WEB
);
881 IRRECO_RETURN_ENUM(ROW_TYPE_DB
);
882 if (i
& ROW_TYPE_LOADING
)
883 IRRECO_RETURN_ENUM(ROW_TYPE_LOADING
);
884 IRRECO_RETURN_INT(0);
888 * Show hildon progressbar banner.
890 * This function will create a new banner if one has not been created yet,
891 * if banner already exists, it's properties will be changed.
893 * @param text Text to show.
894 * @param fraction Value of progress.
897 static void irreco_theme_manager_dlg_set_banner(IrrecoThemeManagerDlg
*self
,
903 if (self
->banner
== NULL
) {
904 self
->banner
= hildon_banner_show_progress(
905 GTK_WIDGET(self
), NULL
, "");
908 hildon_banner_set_text(HILDON_BANNER(self
->banner
), text
);
909 hildon_banner_set_fraction(HILDON_BANNER(self
->banner
), fraction
);
915 * Destroy banner, if it exists.
918 static void irreco_theme_manager_dlg_hide_banner(IrrecoThemeManagerDlg
*self
)
923 gtk_widget_destroy(self
->banner
);
931 * Start a loader state machine if one is not running already.
935 gboolean
irreco_theme_manager_dlg_loader_start(IrrecoThemeManagerDlg
*self
,
936 GSourceFunc function
,
937 GtkTreeIter
*parent_iter
)
941 if (self
->loader_func_id
== 0) {
943 self
->loader_parent_iter
= gtk_tree_iter_copy(
947 self
->loader_func_id
= g_idle_add(function
, self
);
949 IRRECO_ERROR("Loader function pointer not given.\n");
952 IRRECO_RETURN_BOOL(TRUE
);
957 * Stop and cleanup loader if a loader is running.
960 static void irreco_theme_manager_dlg_loader_stop(IrrecoThemeManagerDlg
*self
)
964 if (self
->loader_func_id
!= 0) {
965 g_source_remove(self
->loader_func_id
);
966 self
->loader_func_id
= 0;
967 self
->loader_state
= 0;
968 if (self
->loader_parent_iter
) {
969 gtk_tree_iter_free(self
->loader_parent_iter
);
971 self
->loader_parent_iter
= NULL
;
977 irreco_theme_manager_dlg_loader_user(IrrecoThemeManagerDlg
*self
)
981 switch (self
->loader_state
) {
982 case LOADER_STATE_INIT
: {
984 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."),
986 self
->loader_state
= LOADER_STATE_LOOP
;
987 irreco_theme_manager_dlg_clean_details(self
);
988 if (!irreco_theme_manager_does_user_exist(
989 self
->irreco_data
->theme_manager
)) {
990 self
->loader_state
= LOADER_STATE_END
;
991 self
->loader_iter
= NULL
;
995 gtk_tree_store_append(self
->tree_store
,
997 gtk_tree_store_set(self
->tree_store
,
999 TEXT_COL
, _("My Themes"),
1000 FLAG_COL
, ROW_TYPE_CATEGORY
,
1001 DATA_COL
, NULL
, -1);
1003 self
->loader_iter
= gtk_tree_iter_copy(&iter
);
1006 IRRECO_RETURN_BOOL(TRUE
);
1010 case LOADER_STATE_LOOP
: {
1012 IrrecoData
*irreco_data
= NULL
;
1013 IrrecoThemeManager
*theme_manager
= NULL
;
1015 IrrecoStringTable
*categories
= NULL
;
1018 irreco_data
= self
->irreco_data
;
1019 theme_manager
= irreco_data
->theme_manager
;
1020 categories
= irreco_theme_manager_get_themes(theme_manager
);
1022 IRRECO_STRING_TABLE_FOREACH_DATA(categories
,
1023 IrrecoTheme
*, theme
)
1025 if (g_utf8_collate(theme
->source
->str
, "user") == 0){
1027 /* Add loading item into category. */
1028 gtk_tree_store_append(self
->tree_store
,
1031 gtk_tree_store_set(self
->tree_store
,
1037 DATA_COL
, NULL
, -1);
1039 IRRECO_STRING_TABLE_FOREACH_END
1041 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."),
1043 self
->loader_state
= LOADER_STATE_END
;
1044 IRRECO_RETURN_BOOL(TRUE
);
1047 case LOADER_STATE_END
:
1048 if (self
->loader_iter
!= NULL
) {
1049 gtk_tree_iter_free(self
->loader_iter
);
1051 irreco_theme_manager_dlg_hide_banner(self
);
1052 irreco_theme_manager_dlg_loader_stop(self
);
1054 irreco_theme_manager_dlg_loader_start(self
,
1055 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_deb
),NULL
);
1058 IRRECO_RETURN_BOOL(FALSE
);
1064 * This loader will request a list of categories from the theme and
1065 * update the TreeView accordingly. Every category row created by this loader
1066 * will have row type ROW_TYPE_DEB.
1070 static gboolean
irreco_theme_manager_dlg_loader_deb(IrrecoThemeManagerDlg
*self
)
1074 switch (self
->loader_state
) {
1075 case LOADER_STATE_INIT
: {
1077 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."),
1079 self
->loader_state
= LOADER_STATE_LOOP
;
1080 irreco_theme_manager_dlg_clean_details(self
);
1082 if (!irreco_theme_manager_does_deb_exist(
1083 self
->irreco_data
->theme_manager
)) {
1084 self
->loader_state
= LOADER_STATE_END
;
1085 self
->loader_iter
= NULL
;
1088 gtk_tree_store_append(self
->tree_store
,
1090 gtk_tree_store_set(self
->tree_store
,
1092 TEXT_COL
, _("Built In"),
1093 FLAG_COL
, ROW_TYPE_CATEGORY
,
1094 DATA_COL
, NULL
, -1);
1096 self
->loader_iter
= gtk_tree_iter_copy(&iter
);
1098 IRRECO_RETURN_BOOL(TRUE
);
1102 case LOADER_STATE_LOOP
: {
1104 IrrecoData
*irreco_data
= NULL
;
1105 IrrecoThemeManager
*theme_manager
= NULL
;
1107 IrrecoStringTable
*categories
= NULL
;
1109 irreco_data
= self
->irreco_data
;
1110 theme_manager
= irreco_data
->theme_manager
;
1111 categories
= irreco_theme_manager_get_themes(theme_manager
);
1113 IRRECO_STRING_TABLE_FOREACH_DATA(categories
,
1114 IrrecoTheme
*, theme
)
1115 if (g_utf8_collate(theme
->source
->str
, "deb") == 0){
1117 /* Add loading item into category. */
1118 gtk_tree_store_append(self
->tree_store
,
1119 &iter
, self
->loader_iter
);
1120 gtk_tree_store_set(self
->tree_store
,
1124 FLAG_COL
, ROW_TYPE_DEB
,
1125 DATA_COL
, NULL
, -1);
1127 IRRECO_STRING_TABLE_FOREACH_END
1129 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."),
1131 self
->loader_state
= LOADER_STATE_END
;
1132 IRRECO_RETURN_BOOL(TRUE
);
1135 case LOADER_STATE_END
: {
1136 GtkTreeIter iter
, iter_loading
;
1137 if (self
->loader_iter
!= NULL
) {
1138 gtk_tree_iter_free(self
->loader_iter
);
1140 irreco_theme_manager_dlg_hide_banner(self
);
1141 irreco_theme_manager_dlg_loader_stop(self
);
1143 /* Create database row */
1144 gtk_tree_store_append(self
->tree_store
, &iter
, NULL
);
1145 gtk_tree_store_set(self
->tree_store
, &iter
,
1146 TEXT_COL
, _("Database"),
1147 FLAG_COL
, ROW_TYPE_CATEGORY
,
1148 DATA_COL
, NULL
, -1);
1150 /* Add loading item into manufacturer. */
1151 gtk_tree_store_append(self
->tree_store
, &iter_loading
, &iter
);
1152 gtk_tree_store_set(self
->tree_store
, &iter_loading
,
1153 TEXT_COL
, _("Loading ..."),
1154 FLAG_COL
, ROW_TYPE_LOADING
,
1155 DATA_COL
, NULL
, -1);
1157 irreco_theme_manager_dlg_loader_start(self
,
1158 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_web
), NULL
);
1162 IRRECO_RETURN_BOOL(FALSE
);
1165 static gboolean
irreco_theme_manager_dlg_loader_db(IrrecoThemeManagerDlg
*self
)
1169 switch (self
->loader_state
) {
1170 case LOADER_STATE_INIT
:{
1172 irreco_theme_manager_dlg_set_banner(self
, _("Loading themes"),
1174 self
->loader_state
= LOADER_STATE_LOOP
;
1175 self
->theme_loader_index
= 0;
1176 irreco_theme_manager_dlg_clean_details(self
);
1178 /* Check if loading item exist */
1179 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self
->tree_store
),
1180 &iter
, self
->loader_iter
, 0);
1182 if(irreco_theme_manager_dlg_row_get_type(self
,
1183 &iter
) != ROW_TYPE_LOADING
) {
1184 self
->loader_state
= LOADER_STATE_END
;
1187 IRRECO_RETURN_BOOL(TRUE
);
1191 case LOADER_STATE_LOOP
: {
1193 GtkTreeIter iter_loading
;
1194 IrrecoStringTable
*themes
= NULL
;
1195 IrrecoWebdbTheme
*theme_by_id
;
1196 IrrecoWebdbCache
*webdb_cache
= NULL
;
1200 webdb_cache
= irreco_data_get_webdb_cache(self
->irreco_data
,
1203 if (!irreco_webdb_cache_get_themes(webdb_cache
, &themes
)) {
1204 irreco_error_dlg(GTK_WINDOW(self
),
1205 irreco_webdb_cache_get_error(
1207 self
->loader_state
= LOADER_STATE_END
;
1208 IRRECO_RETURN_BOOL(TRUE
);
1211 if (!irreco_string_table_index(themes
,
1212 (guint
)self
->theme_loader_index
, &id
, NULL
)) {
1213 irreco_error_dlg(GTK_WINDOW(self
), "Can't find theme");
1214 self
->loader_state
= LOADER_STATE_END
;
1215 IRRECO_RETURN_BOOL(TRUE
);
1218 if (!irreco_webdb_cache_get_theme_by_id(webdb_cache
,
1221 irreco_error_dlg(GTK_WINDOW(self
),
1222 irreco_webdb_cache_get_error(
1224 self
->loader_state
= LOADER_STATE_END
;
1225 IRRECO_RETURN_BOOL(TRUE
);
1228 gtk_tree_store_append(self
->tree_store
, &iter
,
1231 gtk_tree_store_set(self
->tree_store
, &iter
,
1232 TEXT_COL
, theme_by_id
->name
->str
,
1233 FLAG_COL
, ROW_TYPE_DB
,
1236 banner
= ++self
->theme_loader_index
;
1237 banner
/= (gfloat
) irreco_string_table_lenght (themes
);
1239 irreco_theme_manager_dlg_set_banner(self
, _("Loading themes"),
1241 if (banner
>= 1.0) {
1242 self
->loader_state
= LOADER_STATE_END
;
1245 /* Delete loading item */
1246 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self
->tree_store
),
1247 &iter_loading
, self
->loader_iter
,
1249 if(irreco_theme_manager_dlg_row_get_type(self
,
1250 &iter_loading
) == ROW_TYPE_LOADING
) {
1251 gtk_tree_store_remove(self
->tree_store
, &iter_loading
);
1254 IRRECO_RETURN_BOOL(TRUE
);
1257 case LOADER_STATE_END
:
1258 if (self
->loader_iter
!= NULL
) {
1259 gtk_tree_iter_free(self
->loader_iter
);
1261 irreco_theme_manager_dlg_hide_banner(self
);
1262 irreco_theme_manager_dlg_loader_stop(self
);
1265 IRRECO_RETURN_BOOL(FALSE
);
1269 static gboolean
irreco_theme_manager_dlg_loader_web(IrrecoThemeManagerDlg
*self
)
1273 switch (self
->loader_state
) {
1274 case LOADER_STATE_INIT
: {
1276 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."),
1278 self
->loader_state
= LOADER_STATE_LOOP
;
1279 irreco_theme_manager_dlg_clean_details(self
);
1280 if (!irreco_theme_manager_does_web_exist(
1281 self
->irreco_data
->theme_manager
)) {
1282 self
->loader_state
= LOADER_STATE_END
;
1283 self
->loader_iter
= NULL
;
1286 gtk_tree_store_append(self
->tree_store
,
1288 gtk_tree_store_set(self
->tree_store
,
1290 TEXT_COL
, _("Downloaded"),
1291 FLAG_COL
, ROW_TYPE_CATEGORY
,
1292 DATA_COL
, NULL
, -1);
1294 self
->loader_iter
= gtk_tree_iter_copy(&iter
);
1296 IRRECO_RETURN_BOOL(TRUE
);
1298 case LOADER_STATE_LOOP
: {
1300 IrrecoData
*irreco_data
= NULL
;
1301 IrrecoThemeManager
*theme_manager
= NULL
;
1303 IrrecoStringTable
*categories
= NULL
;
1305 irreco_data
= self
->irreco_data
;
1306 theme_manager
= irreco_data
->theme_manager
;
1307 categories
= irreco_theme_manager_get_themes(theme_manager
);
1309 IRRECO_STRING_TABLE_FOREACH_DATA(categories
,
1310 IrrecoTheme
*, theme
)
1312 if (g_utf8_collate(theme
->source
->str
, "web") == 0){
1314 /* Add loading item into category. */
1315 gtk_tree_store_append(self
->tree_store
,
1318 gtk_tree_store_set(self
->tree_store
,
1324 DATA_COL
, NULL
, -1);
1326 IRRECO_STRING_TABLE_FOREACH_END
1328 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."),
1330 self
->loader_state
= LOADER_STATE_END
;
1331 IRRECO_RETURN_BOOL(TRUE
);
1334 case LOADER_STATE_END
:
1335 if (self
->loader_iter
!= NULL
) {
1336 gtk_tree_iter_free(self
->loader_iter
);
1338 irreco_theme_manager_dlg_hide_banner(self
);
1339 irreco_theme_manager_dlg_loader_stop(self
);
1342 IRRECO_RETURN_BOOL(FALSE
);
1346 * Show theme details
1352 irreco_theme_manager_dlg_display_theme_detail(IrrecoThemeManagerDlg
*self
,
1355 IrrecoThemeManager
*theme_manager
= self
->irreco_data
->theme_manager
;
1356 IrrecoThemeButton
*button
= NULL
;
1357 const gchar
*theme_name
;
1361 gtk_image_clear(GTK_IMAGE(self
->theme_image
));
1363 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
1364 iter
, TEXT_COL
, &theme_name
, -1);
1365 irreco_string_table_get(theme_manager
->themes
, theme_name
,
1366 (gpointer
*) &self
->theme
);
1368 gtk_label_set_text(GTK_LABEL(self
->theme_name
),
1369 self
->theme
->name
->str
);
1370 gtk_label_set_text(GTK_LABEL(self
->theme_creator
),
1371 self
->theme
->author
->str
);
1372 gtk_label_set_text(GTK_LABEL(self
->theme_comment
),
1373 self
->theme
->comment
->str
);
1374 gtk_label_set_text(GTK_LABEL(self
->theme_version
),
1375 self
->theme
->version
->str
);
1377 if (self
->theme
->preview_button_name
->len
> 0) {
1378 button
=irreco_theme_get_button(self
->theme
,
1379 self
->theme
->preview_button_name
->str
);
1382 irreco_string_table_index(self
->theme
->buttons
,
1383 0, &key
, (gpointer
*) &button
);
1386 if (button
!= NULL
) {
1387 IRRECO_DEBUG("Preview-button: %s\n", button
->image_up
->str
);
1389 gtk_image_set_from_file(GTK_IMAGE(self
->theme_image
),
1390 button
->image_up
->str
);
1392 self
->preview_add
= button
->image_up
->str
;
1394 self
->preview_add
= NULL
;
1396 self
->webdb_theme
= NULL
;
1398 IRRECO_RETURN_BOOL(TRUE
);
1402 irreco_theme_manager_dlg_theme_db_detail_loader(IrrecoThemeManagerDlg
*self
)
1406 switch (self
->loader_state
) {
1407 case LOADER_STATE_INIT
:{
1408 irreco_theme_manager_dlg_set_banner(self
,
1409 _("Loading ..."), 0.5);
1410 self
->loader_state
= LOADER_STATE_LOOP
;
1411 IRRECO_RETURN_BOOL(TRUE
);
1414 case LOADER_STATE_LOOP
: {
1415 gchar
*download_count
;
1417 IrrecoWebdbCache
*webdb_cache
= irreco_data_get_webdb_cache(
1421 /* Get WebdbTheme with preview-button */
1422 if (!irreco_webdb_cache_get_preview_button(webdb_cache
,
1423 self
->selected_theme_id
,
1424 &self
->webdb_theme
)) {
1425 irreco_error_dlg(GTK_WINDOW(self
),
1426 irreco_webdb_cache_get_error(
1429 self
->loader_state
= LOADER_STATE_END
;
1430 IRRECO_RETURN_BOOL(TRUE
);
1433 gtk_image_clear(GTK_IMAGE(self
->theme_image
));
1435 gtk_label_set_text(GTK_LABEL(self
->theme_name
),
1436 self
->webdb_theme
->name
->str
);
1437 gtk_label_set_text(GTK_LABEL(self
->theme_creator
),
1438 self
->webdb_theme
->creator
->str
);
1439 gtk_label_set_text(GTK_LABEL(self
->theme_comment
),
1440 self
->webdb_theme
->comment
->str
);
1442 /* Clear combobox */
1443 gtk_tree_store_clear(self
->version_store
);
1445 IRRECO_STRING_TABLE_FOREACH(self
->webdb_theme
->versions
,
1450 gtk_tree_store_append(self
->version_store
,
1454 gtk_tree_store_set(self
->version_store
, &iter
,
1458 if (g_utf8_collate (date
,
1459 self
->webdb_theme
->uploaded
->str
) == 0) {
1460 gtk_combo_box_set_active(GTK_COMBO_BOX(
1465 IRRECO_STRING_TABLE_FOREACH_END
1467 /*scale_combobox(self);*/
1469 download_count
= g_strdup_printf("%d",
1470 self
->webdb_theme
->download_count
);
1472 gtk_label_set_text(GTK_LABEL(self
->theme_downloaded
),
1474 g_free(download_count
);
1476 if (self
->webdb_theme
->preview_button
!= NULL
) {
1477 gtk_image_set_from_pixbuf(GTK_IMAGE(self
->theme_image
),
1478 self
->webdb_theme
->preview_button
);
1480 IRRECO_DEBUG("preview_button is NULL\n");
1482 self
->preview_add
= NULL
;
1484 self
->loader_state
= LOADER_STATE_END
;
1485 IRRECO_RETURN_BOOL(TRUE
);
1488 case LOADER_STATE_END
:
1489 irreco_theme_manager_dlg_hide_banner(self
);
1490 irreco_theme_manager_dlg_loader_stop(self
);
1492 IRRECO_RETURN_BOOL(FALSE
);
1500 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1502 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1505 * @name Public Functions
1509 void irreco_theme_manager_dlg_set_irreco_data(IrrecoThemeManagerDlg
*self
,
1510 IrrecoData
*irreco_data
)
1514 self
->irreco_data
= irreco_data
;
1519 void irreco_show_theme_manager_dlg(IrrecoData
*irreco_data
, GtkWindow
*parent
)
1521 IrrecoThemeManagerDlg
*self
;
1523 gboolean loop
= TRUE
;
1524 gboolean refresh
= FALSE
;
1525 IrrecoWebdbCache
*webdb_cache
= NULL
;
1529 self
= IRRECO_THEME_MANAGER_DLG(irreco_theme_manager_dlg_new(
1530 irreco_data
, parent
));
1532 webdb_cache
= irreco_data_get_webdb_cache(self
->irreco_data
, FALSE
);
1536 response
= IRRECO_DEVICE_REFRESH
;
1540 response
= gtk_dialog_run(GTK_DIALOG(self
));
1544 case IRRECO_DOWNLOAD_THEME
:
1545 if (irreco_theme_download_dlg_run(
1547 self
->selected_theme_id
,
1548 GTK_WINDOW(self
))) {
1553 case IRRECO_UPLOAD_THEME
:
1554 if (irreco_theme_upload_dlg_run(GTK_WINDOW(self
),
1563 case IRRECO_DEVICE_REFRESH
:
1564 if (self
->loader_func_id
!= 0) {
1567 IRRECO_DEBUG("IRRECO_DEVICE_REFRESH\n");
1568 gtk_tree_store_clear(self
->tree_store
);
1569 irreco_theme_manager_update_theme_manager
1570 (self
->irreco_data
->theme_manager
);
1572 if (webdb_cache
->theme_id_hash
!= NULL
) {
1573 g_hash_table_remove_all(
1574 webdb_cache
->theme_id_hash
);
1575 self
->webdb_theme
= NULL
;
1578 IRRECO_STRING_TABLE_FOREACH_DATA(
1579 irreco_data
->theme_manager
->themes
,
1580 IrrecoTheme
*, theme
)
1581 irreco_theme_check(theme
);
1582 IRRECO_STRING_TABLE_FOREACH_END
1584 irreco_theme_manager_dlg_loader_start(self
,
1586 irreco_theme_manager_dlg_loader_user
),
1588 gtk_label_set_text(GTK_LABEL(self
->select_label
),
1589 " Select \ncategory");
1592 case GTK_RESPONSE_DELETE_EVENT
:
1593 IRRECO_DEBUG("GTK_RESPONSE_DELETE_EVENT\n");
1599 gtk_widget_destroy(GTK_WIDGET(self
));
1608 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1609 /* Events and Callbacks */
1610 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1613 * @name Events and Callbacks
1618 irreco_theme_manager_dlg_map_event(IrrecoThemeManagerDlg
*self
,
1625 irreco_theme_manager_dlg_loader_start(
1626 self
, G_SOURCEFUNC(irreco_theme_manager_dlg_loader_user
),
1629 IRRECO_RETURN_BOOL(FALSE
);
1633 irreco_theme_manager_dlg_destroy_event(IrrecoThemeManagerDlg
*self
,
1637 irreco_theme_manager_dlg_loader_stop(self
);
1642 irreco_theme_manager_dlg_row_activated_event(GtkTreeView
*tree_view
,
1644 GtkTreeViewColumn
*column
,
1645 IrrecoThemeManagerDlg
*self
)
1649 if (gtk_tree_view_row_expanded(tree_view
, path
)) {
1650 gtk_tree_view_expand_row(tree_view
, path
, FALSE
);
1652 gtk_tree_view_collapse_row(tree_view
, path
);
1658 irreco_theme_manager_dlg_row_expanded_event(GtkTreeView
*tree_view
,
1661 IrrecoThemeManagerDlg
*self
)
1663 gchar
*row_name
= NULL
;
1666 irreco_theme_manager_dlg_clean_details(self
);
1667 gtk_label_set_text(GTK_LABEL(self
->select_label
), "Select \ntheme");
1670 if (self
->loader_func_id
!= 0) {
1671 gtk_tree_view_collapse_row(tree_view
, path
);
1674 if (!irreco_theme_manager_dlg_row_is_loaded(self
, iter
)){
1675 switch (irreco_theme_manager_dlg_row_get_type(self
, iter
)){
1676 case ROW_TYPE_CATEGORY
:
1677 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
1678 iter
, TEXT_COL
, &row_name
, -1);
1680 if(g_utf8_collate(row_name
, "Database") != 0) {
1684 self
->loader_iter
= gtk_tree_iter_copy(iter
);
1685 irreco_theme_manager_dlg_loader_start(self
,
1686 G_SOURCEFUNC(irreco_theme_manager_dlg_loader_db
), NULL
);
1691 if (row_name
!= NULL
) g_free(row_name
);
1696 irreco_theme_manager_dlg_row_collapsed_event(GtkTreeView
*tree_view
,
1699 IrrecoThemeManagerDlg
*self
)
1704 gtk_label_set_text(GTK_LABEL(self
->select_label
), " Select\ncategory");
1706 irreco_theme_manager_dlg_clean_details(self
);
1712 irreco_theme_manager_dlg_row_selected_event(GtkTreeSelection
*sel
,
1713 IrrecoThemeManagerDlg
*self
)
1716 GtkTreeModel
*model
;
1721 if (gtk_tree_selection_get_selected (sel
, &model
, &iter
))
1723 switch (irreco_theme_manager_dlg_row_get_type(self
, &iter
)) {
1726 IRRECO_DEBUG("ROW_TYPE_DEB\n");
1728 gtk_widget_hide(self
->select_label
);
1729 gtk_widget_show(self
->theme_info_alignment
);
1730 gtk_widget_hide(self
->label_download
);
1731 gtk_widget_hide(self
->theme_downloaded
);
1732 gtk_widget_hide(self
->label_combobox
);
1733 gtk_widget_hide(self
->combobox
);
1734 gtk_widget_hide(self
->theme_version
);
1735 gtk_widget_hide(self
->theme_creator
);
1736 gtk_widget_hide(self
->label_creator
);
1738 gtk_widget_hide(self
->upload_button
);
1739 gtk_widget_hide(self
->download_button
);
1740 gtk_widget_hide(self
->clear_button
);
1741 /*gtk_widget_show(self->new_button);*/
1742 gtk_widget_hide(self
->edit_button
);
1745 irreco_theme_manager_dlg_display_theme_detail(self
,
1750 IRRECO_DEBUG("ROW_TYPE_USER\n");
1752 gtk_widget_hide(self
->select_label
);
1753 gtk_widget_show(self
->theme_info_alignment
);
1754 gtk_widget_hide(self
->label_download
);
1755 gtk_widget_hide(self
->theme_downloaded
);
1756 gtk_widget_show(self
->theme_creator
);
1757 gtk_widget_show(self
->label_creator
);
1759 gtk_widget_show(self
->label_combobox
);
1760 gtk_widget_hide(self
->combobox
);
1761 gtk_widget_show(self
->theme_version
);
1763 gtk_widget_show(self
->upload_button
);
1764 gtk_widget_show(self
->clear_button
);
1765 gtk_widget_hide(self
->download_button
);
1766 gtk_widget_show(self
->edit_button
);
1767 /*gtk_widget_hide(self->new_button);*/
1769 irreco_theme_manager_dlg_display_theme_detail(self
,
1774 IRRECO_DEBUG("ROW_TYPE_WEB\n");
1776 gtk_widget_show(self
->clear_button
);
1777 gtk_widget_hide(self
->upload_button
);
1778 gtk_widget_hide(self
->download_button
);
1779 /*gtk_widget_show(self->new_button);*/
1780 gtk_widget_hide(self
->edit_button
);
1783 gtk_widget_hide(self
->select_label
);
1784 gtk_widget_show(self
->theme_creator
);
1785 gtk_widget_show(self
->label_creator
);
1786 gtk_widget_hide(self
->label_download
);
1787 gtk_widget_hide(self
->theme_downloaded
);
1789 gtk_widget_hide(self
->combobox
);
1790 gtk_widget_show(self
->label_combobox
);
1791 gtk_widget_show(self
->theme_version
);
1793 gtk_widget_show(self
->theme_info_alignment
);
1795 irreco_theme_manager_dlg_display_theme_detail(self
,
1800 IRRECO_DEBUG("ROW_TYPE_DB\n");
1802 if (self
->loader_func_id
!= 0) {
1806 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
1807 &iter
, DATA_COL
, &id
, -1);
1809 gtk_widget_hide(self
->clear_button
);
1810 gtk_widget_hide(self
->upload_button
);
1811 gtk_widget_show(self
->download_button
);
1812 /*gtk_widget_show(self->new_button);*/
1813 gtk_widget_hide(self
->edit_button
);
1816 gtk_widget_show(self
->combobox
);
1817 gtk_widget_show(self
->label_combobox
);
1818 gtk_widget_hide(self
->theme_version
);
1820 gtk_widget_hide(self
->select_label
);
1821 gtk_widget_show(self
->theme_creator
);
1822 gtk_widget_show(self
->label_creator
);
1823 gtk_widget_show(self
->label_download
);
1824 gtk_widget_show(self
->theme_downloaded
);
1826 gtk_widget_show(self
->theme_info_alignment
);
1828 IRRECO_DEBUG("SELECTED ID: %d\n", atoi(id
));
1830 self
->selected_theme_id
= atoi(id
);
1831 self
->loader_func_id
= g_idle_add(G_SOURCEFUNC(
1832 irreco_theme_manager_dlg_theme_db_detail_loader
),
1837 irreco_theme_manager_dlg_clean_details(self
);