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"
28 * PURPOCE OF FILE. TODO TODO TODO
30 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
32 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
34 #define IRRECO_BACKGROUND_PREVIEW_WIDHT (IRRECO_SCREEN_WIDTH / 6)
35 #define IRRECO_BACKGROUND_PREVIEW_HEIGHT (IRRECO_SCREEN_HEIGHT / 6)
38 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
40 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
42 static void irreco_theme_manager_dlg_clean_details(IrrecoThemeManagerDlg
*self
);
44 static gboolean
irreco_theme_manager_dlg_loader_categ(IrrecoThemeManagerDlg
47 static gboolean
irreco_theme_manager_dlg_display_config_detail(
48 IrrecoThemeManagerDlg
*self
,
51 static gboolean
irreco_show_theme_manager_dlg_map_event(IrrecoThemeManagerDlg
52 *self
, GdkEvent
*event
,
54 static void irreco_show_theme_manager_dlg_destroy_event(IrrecoThemeManagerDlg
55 *self
, gpointer user_data
);
57 static void irreco_show_theme_manager_dlg_row_activated_event(GtkTreeView
60 GtkTreeViewColumn
*column
,
61 IrrecoThemeManagerDlg
*self
);
63 static void irreco_show_theme_manager_dlg_row_expanded_event(GtkTreeView
*tree_view
,
66 IrrecoThemeManagerDlg
*self
);
67 static void irreco_show_theme_manager_dlg_row_collapsed_event(GtkTreeView
*tree_view
, GtkTreeIter
*iter
,
69 IrrecoThemeManagerDlg
*self
);
72 static void irreco_show_theme_manager_dlg_row_selected_event(GtkTreeSelection
73 *sel
, IrrecoThemeManagerDlg
*self
);
75 gboolean
irreco_theme_manager_preview_dlg(GtkWidget
*widget
,
76 GdkEventButton
*event
,
77 IrrecoThemeManagerDlg
*self
);
79 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
81 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
83 /** Button responce codes. */
88 /** GtkTreeStore colums. */
109 ROW_CHILDREN_LOADED
= 1 << 1,
110 ROW_TYPE_CATEGORY
= 1 << 2,
111 ROW_TYPE_DEB
= 1 << 3,
112 ROW_TYPE_USER
= 1 << 4,
113 ROW_TYPE_WEB
= 1 << 5,
114 ROW_TYPE_LOADING
= 1 << 6
119 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
120 /* Construction & Destruction */
121 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
123 G_DEFINE_TYPE(IrrecoThemeManagerDlg
, irreco_theme_manager_dlg
, IRRECO_TYPE_DLG
)
125 static void irreco_theme_manager_dlg_finalize(GObject
*object
)
127 if (G_OBJECT_CLASS(irreco_theme_manager_dlg_parent_class
)->finalize
)
128 G_OBJECT_CLASS(irreco_theme_manager_dlg_parent_class
)->finalize(
132 static void irreco_theme_manager_dlg_class_init(IrrecoThemeManagerDlgClass
*klass
)
134 GObjectClass
*object_class
= G_OBJECT_CLASS(klass
);
135 object_class
->finalize
= irreco_theme_manager_dlg_finalize
;
138 static void irreco_theme_manager_dlg_init(IrrecoThemeManagerDlg
*self
)
140 GtkTreeViewColumn
*column
;
141 GtkCellRenderer
*renderer
;
142 GtkTreeSelection
*select
;
143 GtkWidget
*label_name
;
144 GtkWidget
*label_description
;
145 GtkWidget
*label_creator
;
146 GtkWidget
*label_combobox
;
147 GtkWidget
*label_rate
;
148 GtkWidget
*label_download
;
149 GtkWidget
*theme_info_alignment
;
150 GtkWidget
*theme_info_frame
;
151 GtkWidget
*tree_view_frame
;
152 GtkWidget
*tree_view_hbox
;
153 GtkWidget
*preview_frame
;
155 PangoFontDescription
*initial_font
;
159 /* Construct dialog. */
160 gtk_window_set_title(GTK_WINDOW(self
),
161 _("Theme Manager "));
162 /*gtk_window_set_decorated (GTK_WINDOW(self), FALSE);*/
163 gtk_window_set_modal(GTK_WINDOW(self
), TRUE
);
164 gtk_window_set_destroy_with_parent(GTK_WINDOW(self
), TRUE
);
165 gtk_dialog_set_has_separator(GTK_DIALOG(self
), FALSE
);
166 gtk_dialog_add_buttons(GTK_DIALOG(self
),
167 GTK_STOCK_REFRESH
, IRRECO_DEVICE_REFRESH
,
168 GTK_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
,
169 GTK_STOCK_OK
, GTK_RESPONSE_OK
,
173 self
->table
= gtk_table_new(7,7,TRUE
);
174 gtk_table_set_col_spacings(GTK_TABLE (self
->table
), 8);
175 gtk_table_set_row_spacings(GTK_TABLE (self
->table
), 8);
176 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(self
)->vbox
),
177 irreco_gtk_align(GTK_WIDGET(self
->table
),
178 0, 0, 1, 1, 8, 8, 8, 8));
179 /* Create tree_view_hbox */
181 tree_view_hbox
= gtk_hbox_new(FALSE
, 2);
183 /* Create Treeview */
184 self
->tree_store
= gtk_tree_store_new(
185 N_COLUMNS
, G_TYPE_STRING
, G_TYPE_INT
, G_TYPE_POINTER
);
186 self
->tree_view
= GTK_TREE_VIEW(gtk_tree_view_new_with_model(
187 GTK_TREE_MODEL(self
->tree_store
)));
189 renderer
= gtk_cell_renderer_text_new();
190 column
= gtk_tree_view_column_new_with_attributes(
191 NULL
, renderer
, "text", TEXT_COL
, NULL
);
192 gtk_tree_view_append_column(self
->tree_view
, column
);
194 gtk_box_pack_start(GTK_BOX(tree_view_hbox
), GTK_WIDGET(self
->tree_view
),
197 /* Create scrollbar for Treeview */
198 self
->scrollbar
= gtk_vscrollbar_new(gtk_tree_view_get_vadjustment(
199 GTK_TREE_VIEW(self
->tree_view
)));
200 gtk_box_pack_start(GTK_BOX(tree_view_hbox
), GTK_WIDGET(self
->scrollbar
),
203 /* Create Frame for Treeview */
204 tree_view_frame
= gtk_frame_new("");
205 gtk_frame_set_label_widget(GTK_FRAME(tree_view_frame
),
206 irreco_gtk_label_bold("Themes", 0, 0, 0, 0, 0, 0));
208 gtk_container_add(GTK_CONTAINER(tree_view_frame
),
209 GTK_WIDGET(tree_view_hbox
));
214 /* Create theme_info */
217 self
->theme_info
= gtk_table_new(7, 4, TRUE
);
218 gtk_table_set_col_spacings(GTK_TABLE(self
->theme_info
), 8);
219 gtk_table_set_row_spacings(GTK_TABLE(self
->theme_info
), 8);
225 /* Scrolled window for info */
226 self
->info_scrollbar
= gtk_scrolled_window_new(NULL
, NULL
);
227 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(
228 self
->info_scrollbar
),
229 GTK_POLICY_AUTOMATIC
,
230 GTK_POLICY_AUTOMATIC
);
239 self
->combobox
= gtk_combo_box_new_text();
240 gtk_combo_box_insert_text(GTK_COMBO_BOX(self
->combobox
),
243 self
->theme_table
= gtk_table_new(5, 7, TRUE
);
244 gtk_table_set_col_spacings(GTK_TABLE(self
->theme_table
), 1);
245 gtk_table_set_row_spacings(GTK_TABLE(self
->theme_table
), 1);
248 self
->info_vbox
= gtk_vbox_new(FALSE
, 1);
252 self
->preview_event_box
= gtk_event_box_new();
256 /* Create frame for theme_info */
258 theme_info_frame
= gtk_frame_new("");
259 gtk_frame_set_label_widget(GTK_FRAME(theme_info_frame
),
260 irreco_gtk_label_bold("Info", 0, 0, 0, 0, 0, 0));
261 theme_info_alignment
= gtk_alignment_new(0, 0, 0, 0);
262 gtk_alignment_set_padding(GTK_ALIGNMENT(theme_info_alignment
),
266 preview_frame
= gtk_frame_new(NULL
);
267 gtk_frame_set_shadow_type(GTK_FRAME(preview_frame
), GTK_SHADOW_OUT
);
269 self
->theme_image
= gtk_image_new();
270 gtk_image_set_from_file(GTK_IMAGE(self
->theme_image
), NULL
);
276 label_rate
= gtk_label_new(" Rating");
277 label_name
= gtk_label_new("Name: ");
278 label_creator
= gtk_label_new("Author: ");
279 label_download
= gtk_label_new("Downloads: ");
280 label_description
= gtk_label_new("Comment: ");
281 label_combobox
= gtk_label_new("Versions:");
283 self
->theme_name
= gtk_label_new("");
284 self
->theme_creator
= gtk_label_new("");
285 self
->theme_downloaded
= gtk_label_new("");
286 self
->theme_comment
= gtk_label_new("");
288 gtk_misc_set_alignment(GTK_MISC(label_rate
), 0, 0.5);
289 gtk_misc_set_alignment(GTK_MISC(label_name
), 0, 0.5);
290 gtk_misc_set_alignment(GTK_MISC(label_creator
), 0, 0.5);
291 gtk_misc_set_alignment(GTK_MISC(label_download
), 0, 0.5);
292 gtk_misc_set_alignment(GTK_MISC(label_description
), 0, 0.5);
293 gtk_misc_set_alignment(GTK_MISC(label_combobox
), 0, 0.5);
294 gtk_misc_set_alignment(GTK_MISC(self
->theme_name
), 0, 0.5);
295 gtk_misc_set_alignment(GTK_MISC(self
->theme_creator
), 0, 0.5);
296 gtk_misc_set_alignment(GTK_MISC(self
->theme_downloaded
), 0, 0.5);
297 gtk_misc_set_alignment(GTK_MISC(self
->theme_comment
), 0, 0.5);
302 /*Attach WidGets to tables*/
305 gtk_table_attach(GTK_TABLE(self
->theme_info
), self
->info_scrollbar
,
306 0, 4, 4, 7, GTK_FILL
, GTK_FILL
, 0, 0);
308 gtk_table_attach_defaults(GTK_TABLE(self
->table
),
309 tree_view_frame
, 0, 3, 0, 7);
310 gtk_table_attach_defaults(GTK_TABLE(self
->theme_info
),
311 self
->preview_event_box
, 3, 4, 0, 3);
312 gtk_table_attach_defaults(GTK_TABLE(self
->theme_info
),
313 label_rate
, 3, 4, 3, 4);
314 gtk_table_attach_defaults(GTK_TABLE(self
->theme_info
),
315 self
->theme_table
, 0, 3, 0, 4);
316 gtk_table_attach_defaults(GTK_TABLE(self
->theme_table
),
317 label_name
, 0, 3, 0, 1);
318 gtk_table_attach_defaults(GTK_TABLE(self
->theme_table
),
319 label_creator
, 0, 3, 1, 2);
320 gtk_table_attach_defaults(GTK_TABLE(self
->theme_table
),
321 label_download
, 0, 3, 2, 3);
322 gtk_table_attach_defaults(GTK_TABLE(self
->theme_table
),
323 label_description
, 0, 3, 4, 5);
324 gtk_table_attach_defaults(GTK_TABLE(self
->theme_table
),
325 label_combobox
, 0, 3, 3, 4);
326 gtk_table_attach_defaults(GTK_TABLE(self
->theme_table
),
327 self
->combobox
, 3, 7, 3, 4);
328 gtk_table_attach_defaults(GTK_TABLE(self
->table
),
329 theme_info_frame
, 3, 7, 0, 7);
330 gtk_table_attach(GTK_TABLE(self
->theme_table
), self
->theme_name
,
331 3, 7, 0, 1, GTK_FILL
, GTK_FILL
, 0, 0);
332 gtk_table_attach(GTK_TABLE(self
->theme_table
), self
->theme_creator
,
333 3, 7, 1, 2, GTK_FILL
, GTK_FILL
, 0, 0);
334 gtk_table_attach(GTK_TABLE(self
->theme_table
), self
->theme_downloaded
,
335 3, 7, 2, 3, GTK_FILL
, GTK_FILL
, 0, 0);
340 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(
341 self
->info_scrollbar
), self
->info_vbox
);
343 gtk_container_add(GTK_CONTAINER(preview_frame
),
345 gtk_container_add(GTK_CONTAINER(self
->preview_event_box
),
351 gtk_container_add(GTK_CONTAINER(self
->info_scrollbar
),
352 GTK_WIDGET(self
->info_vbox
));
353 gtk_container_add(GTK_CONTAINER(self
->info_vbox
), self
->theme_comment
);
354 gtk_container_add(GTK_CONTAINER(theme_info_frame
),
355 GTK_WIDGET(theme_info_alignment
));
356 gtk_container_add(GTK_CONTAINER(theme_info_alignment
),
357 GTK_WIDGET(self
->theme_info
));
360 /*Set font size and style*/
362 initial_font
= pango_font_description_from_string ("Sans Bold 12");
363 gtk_widget_modify_font (label_rate
, initial_font
);
364 gtk_widget_modify_font (label_name
, initial_font
);
365 gtk_widget_modify_font (label_creator
, initial_font
);
366 gtk_widget_modify_font (label_download
, initial_font
);
367 gtk_widget_modify_font (label_description
, initial_font
);
368 gtk_widget_modify_font (label_combobox
, initial_font
);
370 initial_font
= pango_font_description_from_string ("Sans 11");
371 gtk_widget_modify_font (self
->theme_name
, initial_font
);
372 gtk_widget_modify_font (self
->theme_creator
, initial_font
);
373 gtk_widget_modify_font (self
->theme_downloaded
, initial_font
);
374 gtk_widget_modify_font (self
->theme_comment
, initial_font
);
378 /* Setup the selection handler for TREE */
379 select
= gtk_tree_view_get_selection(self
->tree_view
);
380 gtk_tree_selection_set_mode(select
, GTK_SELECTION_SINGLE
);
382 /* Signal handlers. */
383 g_signal_connect(G_OBJECT(self
), "map-event",
384 G_CALLBACK(irreco_show_theme_manager_dlg_map_event
), NULL
);
385 g_signal_connect(G_OBJECT(self
), "destroy",
386 G_CALLBACK(irreco_show_theme_manager_dlg_destroy_event
), NULL
);
387 g_signal_connect(G_OBJECT(self
->tree_view
), "row-activated",
388 G_CALLBACK(irreco_show_theme_manager_dlg_row_activated_event
),
390 g_signal_connect(G_OBJECT(self
->tree_view
), "row-expanded",
391 G_CALLBACK(irreco_show_theme_manager_dlg_row_expanded_event
),
393 g_signal_connect(G_OBJECT(self
->tree_view
), "row-collapsed",
394 G_CALLBACK(irreco_show_theme_manager_dlg_row_collapsed_event
),
396 g_signal_connect(G_OBJECT (select
), "changed",
397 G_CALLBACK (irreco_show_theme_manager_dlg_row_selected_event
),
400 g_signal_connect(G_OBJECT(self
->preview_event_box
),
401 "button-release-event",
402 G_CALLBACK(irreco_theme_manager_preview_dlg
),
408 gtk_tree_view_set_enable_tree_lines(self
->tree_view
, TRUE
);
409 g_object_set (G_OBJECT (self
->tree_view
), "show-expanders", TRUE
, NULL
);
410 g_object_set (G_OBJECT (self
->tree_view
), "level-indentation", 0, NULL
);
411 gtk_tree_view_set_rubber_banding(self
->tree_view
, FALSE
);
413 gtk_widget_set_size_request(GTK_WIDGET(self
), 696, 396);
414 gtk_widget_show_all(GTK_WIDGET(self
));
419 GtkWidget
*irreco_theme_manager_dlg_new(IrrecoData
*irreco_data
,
422 IrrecoThemeManagerDlg
*self
;
425 self
= g_object_new(IRRECO_TYPE_THEME_MANAGER_DLG
, NULL
);
426 irreco_dlg_set_parent(IRRECO_DLG(self
), parent
);
427 irreco_theme_manager_dlg_set_irreco_data(self
, irreco_data
);
428 IRRECO_RETURN_PTR(self
);
432 * Show whole preview image
436 gboolean
irreco_theme_manager_preview_dlg(GtkWidget
*widget
,
437 GdkEventButton
*event
,
438 IrrecoThemeManagerDlg
*self
)
442 if(self
->preview_add
!=NULL
){
444 GtkWidget
*image
, *event_box
;
445 GtkWidget
*new_preview_dialog
;
448 new_preview_dialog
=gtk_message_dialog_new (NULL
,
450 GTK_MESSAGE_OTHER
, GTK_BUTTONS_NONE
, NULL
);
452 event_box
= gtk_event_box_new();
453 image
= gtk_image_new();
455 gtk_image_set_from_file(GTK_IMAGE(image
), self
->preview_add
);
457 gtk_container_add(GTK_CONTAINER(event_box
),
461 g_signal_connect_swapped(G_OBJECT(event_box
),
462 "button-release-event",
463 G_CALLBACK(gtk_widget_destroy
),
468 gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG(
469 new_preview_dialog
), event_box
);
471 gtk_widget_show_all(GTK_WIDGET(new_preview_dialog
));
473 IRRECO_RETURN_BOOL(TRUE
);
477 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
478 /* Private Functions */
479 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
487 static void irreco_theme_manager_dlg_clean_details(IrrecoThemeManagerDlg
*self
)
496 GTK_LABEL(self
->theme_name
), "-");
498 GTK_LABEL(self
->theme_creator
), "-");
500 GTK_LABEL(self
->theme_comment
), "-");
502 GTK_LABEL(self
->theme_downloaded
), "-");
503 gtk_image_set_from_file(GTK_IMAGE(self
->theme_image
),
505 self
->preview_add
=NULL
;
510 * Have the childern of this item been loaded.
512 * @return TRUE if children have been loade, FALSE otherwise.
516 static gboolean
irreco_theme_manager_dlg_row_is_loaded(IrrecoThemeManagerDlg
517 *self
, GtkTreeIter
*iter
)
522 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
523 iter
, FLAG_COL
, &i
, -1);
524 if (i
& ROW_CHILDREN_LOADED
) IRRECO_RETURN_BOOL(TRUE
);
525 IRRECO_RETURN_BOOL(FALSE
);
533 static gint
irreco_theme_manager_dlg_row_get_type(IrrecoThemeManagerDlg
*self
,
539 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
540 iter
, FLAG_COL
, &i
, -1);
541 if (i
& ROW_TYPE_CATEGORY
)
542 IRRECO_RETURN_ENUM(ROW_TYPE_CATEGORY
);
543 if (i
& ROW_TYPE_DEB
)
544 IRRECO_RETURN_ENUM(ROW_TYPE_DEB
);
545 if (i
& ROW_TYPE_USER
)
546 IRRECO_RETURN_ENUM(ROW_TYPE_USER
);
547 if (i
& ROW_TYPE_WEB
)
548 IRRECO_RETURN_ENUM(ROW_TYPE_WEB
);
549 if (i
& ROW_TYPE_LOADING
)
550 IRRECO_RETURN_ENUM(ROW_TYPE_LOADING
);
551 IRRECO_RETURN_INT(0);
555 * Show hildon progressbar banner.
557 * This function will create a new banner if one has not been created yet,
558 * if banner already exists, it's properties will be changed.
560 * @param text Text to show.
561 * @param fraction Value of progress.
564 static void irreco_theme_manager_dlg_set_banner(IrrecoThemeManagerDlg
*self
,
569 if (self
->banner
== NULL
) {
570 self
->banner
= hildon_banner_show_progress(
571 GTK_WIDGET(self
), NULL
, "");
574 hildon_banner_set_text(HILDON_BANNER(self
->banner
), text
);
575 hildon_banner_set_fraction(HILDON_BANNER(self
->banner
), fraction
);
580 * Destroy banner, if it exists.
583 static void irreco_theme_manager_dlg_hide_banner(IrrecoThemeManagerDlg
*self
)
587 gtk_widget_destroy(self
->banner
);
594 * Start a loader state machine if one is not running already.
597 static void irreco_theme_manager_dlg_loader_start(IrrecoThemeManagerDlg
*self
,
598 GSourceFunc function
,
599 GtkTreeIter
*parent_iter
)
603 if (self
->loader_func_id
== 0) {
605 self
->loader_parent_iter
= gtk_tree_iter_copy(
610 self
->loader_func_id
= g_idle_add(function
, self
);
612 IRRECO_ERROR("Loader function pointer not given.\n");
620 * Stop and cleanup loader if a loader is running.
623 static void irreco_theme_manager_dlg_loader_stop(IrrecoThemeManagerDlg
*self
)
626 if (self
->loader_func_id
!= 0) {
627 g_source_remove(self
->loader_func_id
);
628 self
->loader_func_id
= 0;
629 self
->loader_state
= 0;
630 if (self
->loader_parent_iter
) {
631 gtk_tree_iter_free(self
->loader_parent_iter
);
633 self
->loader_parent_iter
= NULL
;
641 * This loader will request a list of categories from the theme and
642 * update the TreeView accordingly. Every category row created by this loader
643 * will have row type ROW_TYPE_DEB.
646 static gboolean
irreco_theme_manager_dlg_loader_categ(IrrecoThemeManagerDlg
651 switch (self
->loader_state
) {
652 case LOADER_STATE_INIT
: {
654 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."), 0);
655 self
->loader_state
= LOADER_STATE_LOOP
;
656 irreco_theme_manager_dlg_clean_details(self
);
657 gtk_tree_store_append(self
->tree_store
,
659 gtk_tree_store_set(self
->tree_store
,
661 TEXT_COL
, _("Installed"),
662 FLAG_COL
, ROW_TYPE_CATEGORY
,
665 self
->loader_iter
= gtk_tree_iter_copy(&iter
);
668 IRRECO_RETURN_BOOL(TRUE
);
672 case LOADER_STATE_LOOP
: {
674 IrrecoData
*irreco_data
= NULL
;
675 IrrecoThemeManager
*theme_manager
= NULL
;
677 IrrecoStringTable
*categories
= NULL
;
680 irreco_data
= self
->irreco_data
;
681 theme_manager
= irreco_data
->theme_manager
;
682 categories
= irreco_theme_manager_get_themes(theme_manager
);
684 IRRECO_STRING_TABLE_FOREACH_DATA(categories
,
685 IrrecoTheme
*, theme
)
687 if (g_utf8_collate(theme
->source
->str
, "deb") == 0){
689 /* Add loading item into category. */
690 gtk_tree_store_append(self
->tree_store
,
691 &iter
, self
->loader_iter
);
692 gtk_tree_store_set(self
->tree_store
,
694 TEXT_COL
, theme
->name
->str
,
695 FLAG_COL
, ROW_TYPE_DEB
,
698 IRRECO_STRING_TABLE_FOREACH_END
700 irreco_error_dlg(GTK_WINDOW(self),
701 irreco_theme_manager_cache_get_error(
702 theme_manager_cache));
705 irreco_theme_manager_dlg_set_banner(self
, _("Loading ..."), 1);
706 self
->loader_state
= LOADER_STATE_END
;
707 IRRECO_RETURN_BOOL(TRUE
);
710 case LOADER_STATE_END
:
711 gtk_tree_iter_free(self
->loader_iter
);
712 irreco_theme_manager_dlg_hide_banner(self
);
713 irreco_theme_manager_dlg_loader_stop(self
);
716 IRRECO_RETURN_BOOL(FALSE
);
721 * Theme Configuration details loader.
726 static gboolean
irreco_theme_manager_dlg_display_config_detail(
727 IrrecoThemeManagerDlg
*self
, GtkTreeIter
* iter
)
729 /*IrrecoWebdbCache *webdb_cache = NULL;*/
730 const gchar
*theme_name
= NULL
;
731 IrrecoThemeManager
*theme_manager
= self
->irreco_data
->theme_manager
;
737 gtk_tree_model_get(GTK_TREE_MODEL(self
->tree_store
),
738 iter
, TEXT_COL
, &theme_name
, -1);
739 IRRECO_PRINTF("&theme_name: %s\n", theme_name
);
741 irreco_string_table_get (theme_manager
->themes
, theme_name
,
742 (gpointer
*) &theme
);
744 self
->preview_button
= theme
->preview_button
;
748 GTK_LABEL(self
->theme_name
), theme
->name
->str
);
750 GTK_LABEL(self
->theme_creator
), theme
->author
->str
);
752 GTK_LABEL(self
->theme_comment
), theme
->comment
->str
);
755 IRRECO_PRINTF("theme->preview_button_name: %s\n",
756 theme
->preview_button_name
->str
);
757 /* if (theme->preview_button != NULL) {
758 gtk_image_set_from_pixbuf(GTK_IMAGE(self->theme_image),
759 GDK_PIXBUF(theme->preview_button));
760 self->preview_button = theme->preview_button;
764 else*/ if (theme
->preview_button_name
->len
> 0) {
765 IrrecoThemeButton
*button
= irreco_theme_get_button(theme
,
766 theme
->preview_button_name
->str
);
768 gtk_image_set_from_file(GTK_IMAGE(self
->theme_image
),
769 theme
->preview_button_name
->str
);
771 IRRECO_DEBUG("button->image_up->str: %s\n",
772 button
->image_up
->str
);
773 gtk_image_set_from_file(GTK_IMAGE(self
->theme_image
),
774 button
->image_up
->str
);
776 self
->preview_add
= button
->image_up
->str
;
778 IRRECO_PRINTF("NAMEEE %s\n", self
->preview_add
);
783 IrrecoThemeButton
*button
;
786 irreco_string_table_index(theme
->buttons
,
787 0, &key
, (gpointer
*) &button
);
789 IRRECO_DEBUG("button->image_up->str: %s\n",
790 button
->image_up
->str
);
791 gtk_image_set_from_file(GTK_IMAGE(self
->theme_image
),
792 button
->image_up
->str
);
794 self
->preview_add
= button
->image_up
->str
;
796 IRRECO_PRINTF("NAMEEE %s\n", self
->preview_add
);
802 /*g_string_printf(download_count, "%s times",
803 self->config->file_download_count->str);
804 gtk_label_set_text(GTK_LABEL(self->theme_downloaded),
805 self->config->downloaded->str);
806 g_string_free(download_count, TRUE);*/
812 gtk_label_set_text(GTK_LABEL(self->config_uploaded),
813 self->config->file_uploaded->str);
815 g_string_printf(download_count, "%s times",
816 self->config->file_download_count->str);
817 gtk_label_set_text(GTK_LABEL(self->config_download_count),
818 download_count->str);
819 g_string_free(download_count, TRUE);*/
821 gtk_widget_show_all(GTK_WIDGET(self
));
822 IRRECO_RETURN_BOOL(TRUE
);
827 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
829 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
831 void irreco_theme_manager_dlg_set_irreco_data(IrrecoThemeManagerDlg
*self
,
832 IrrecoData
*irreco_data
)
835 self
->irreco_data
= irreco_data
;
839 void irreco_show_theme_manager_dlg(IrrecoData
*irreco_data
, GtkWindow
*parent
)
841 IrrecoThemeManagerDlg
*self
;
843 gboolean loop
= TRUE
;
846 self
= IRRECO_THEME_MANAGER_DLG(irreco_theme_manager_dlg_new(
847 irreco_data
, parent
));
849 response
= gtk_dialog_run(GTK_DIALOG(self
));
851 case IRRECO_DEVICE_REFRESH
:
852 IRRECO_DEBUG("IRRECO_DEVICE_REFRESH\n");
853 gtk_tree_store_clear(self
->tree_store
);
854 /*irreco_data_get_theme_manager_cache(self->irreco_data,
856 irreco_theme_manager_dlg_loader_start(self
,
858 irreco_theme_manager_dlg_loader_categ
),
862 case GTK_RESPONSE_CANCEL
:
863 IRRECO_DEBUG("GTK_RESPONSE_CANCEL\n");
867 case GTK_RESPONSE_OK
:
868 IRRECO_DEBUG("GTK_RESPONSE_OK\n");
869 /*loop = !irreco_theme_manager_dlg_load_file(self);*/
875 gtk_widget_destroy(GTK_WIDGET(self
));
881 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
882 /* Events and Callbacks */
883 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
885 static gboolean
irreco_show_theme_manager_dlg_map_event(IrrecoThemeManagerDlg
*self
,
890 irreco_theme_manager_dlg_loader_start(
891 self
, G_SOURCEFUNC(irreco_theme_manager_dlg_loader_categ
),
893 IRRECO_RETURN_BOOL(FALSE
);
896 static void irreco_show_theme_manager_dlg_destroy_event(
897 IrrecoThemeManagerDlg
*self
,
901 irreco_theme_manager_dlg_loader_stop(self
);
905 static void irreco_show_theme_manager_dlg_row_activated_event(GtkTreeView
908 GtkTreeViewColumn
*column
,
909 IrrecoThemeManagerDlg
*self
)
913 if (gtk_tree_view_row_expanded(tree_view
, path
)) {
914 gtk_tree_view_expand_row(tree_view
, path
, FALSE
);
916 gtk_tree_view_collapse_row(tree_view
, path
);
921 static void irreco_show_theme_manager_dlg_row_expanded_event(
922 GtkTreeView
*tree_view
,
925 IrrecoThemeManagerDlg
*self
)
929 irreco_theme_manager_dlg_clean_details(self
);
931 if (self
->loader_func_id
!= 0) {
932 gtk_tree_view_collapse_row(tree_view
, path
);
935 if (!irreco_theme_manager_dlg_row_is_loaded(self
, iter
)) {
936 switch (irreco_theme_manager_dlg_row_get_type(self
, iter
)) {
937 case ROW_TYPE_CATEGORY
:
938 /*irreco_theme_manager_dlg_loader_start(self,
940 irreco_theme_manager_dlg_loader_categ),
945 /*irreco_theme_manager_dlg_loader_start(self,
947 irreco_theme_manager_dlg_loader_categ),
952 /*irreco_theme_manager_dlg_loader_start(self,
954 irreco_theme_manager_dlg_loader_config),
963 static void irreco_show_theme_manager_dlg_row_collapsed_event(GtkTreeView
*tree_view
,
966 IrrecoThemeManagerDlg
*self
)
970 irreco_theme_manager_dlg_clean_details(self
);
975 static void irreco_show_theme_manager_dlg_row_selected_event(GtkTreeSelection
976 *sel
, IrrecoThemeManagerDlg
*self
)
983 if (gtk_tree_selection_get_selected (sel
, &model
, &iter
))
985 switch (irreco_theme_manager_dlg_row_get_type(self
, &iter
)) {
989 IRRECO_DEBUG("ROW_TYPE_DEB\n");
990 irreco_theme_manager_dlg_display_config_detail(self
,
998 irreco_theme_manager_dlg_clean_details(self
);