1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
3 * irreco - Ir Remote Control
4 * Copyright (C) 2008 Pekka Gehör (pegu6@msn.com)
6 * irreco_theme_creator_dlg.c is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * irreco_theme_creator_dlg.c is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "irreco_theme_creator_dlg.h"
21 #include "irreco_button_browser_dlg.h"
22 #include "irreco_theme_creator_backgrounds.h"
23 #include "irreco_theme_creator_buttons.h"
24 #include "irreco_background_creator_dlg.h"
25 #include "irreco_button_creator_dlg.h"
26 #include <hildon/hildon-banner.h>
27 #include <hildon/hildon-color-button.h>
28 #include <hildon/hildon-file-chooser-dialog.h>
29 #include "irreco_theme_upload_dlg.h"
33 * @addtogroup IrrecoThemeCreatorDlg
42 * Source file of @ref IrrecoThemeCreatorDlg.
44 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
46 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
48 #define IRRECO_BUTTON_PREVIEW_WIDHT (IRRECO_SCREEN_WIDTH / 6)
49 #define IRRECO_BUTTON_PREVIEW_HEIGHT (IRRECO_SCREEN_HEIGHT / 6)
72 LOADER_STATE_BACKGROUNDS
,
76 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
78 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
80 static void _loader_start(IrrecoThemeCreatorDlg
*self
, GSourceFunc function
);
81 static void _loader_stop(IrrecoThemeCreatorDlg
*self
);
82 static void irreco_theme_creator_dlg_preview_image(GtkWidget
*widget
,
83 GdkEventButton
*event
,
84 IrrecoThemeCreatorDlg
*self
);
87 irreco_theme_creator_dlg_notebook_changed(GtkNotebook
*notebook
,
88 GtkNotebookPage
*page
,
90 IrrecoThemeCreatorDlg
*self
);
93 irreco_theme_creator_dlg_display_theme_detail(IrrecoThemeCreatorDlg
*self
,
95 static void irreco_theme_creator_dlg_new_bg_button(GtkButton
*button
,
96 IrrecoThemeCreatorDlg
*self
);
97 static void irreco_theme_creator_dlg_edit_bg_button(GtkButton
*button
,
98 IrrecoThemeCreatorDlg
*self
);
99 static void _set_preview(IrrecoThemeCreatorDlg
*self
);
101 static void irreco_theme_creator_dlg_delete_bg_button(GtkButton
*button
,
102 IrrecoThemeCreatorDlg
*self
);
104 void _set_theme_details(IrrecoThemeCreatorDlg
*self
, IrrecoTheme
*irreco_theme
);
105 void _create_bg_and_button_widgets(IrrecoThemeCreatorDlg
*self
);
106 void _set_button_new_details(IrrecoThemeCreatorDlg
*self
,
107 IrrecoThemeButton
*old_button
,
108 IrrecoThemeButton
*button
);
109 void _set_bg_new_details(IrrecoThemeCreatorDlg
*self
,
110 IrrecoThemeBg
*old_bg
,
112 void _set_edited_theme_details(IrrecoThemeCreatorDlg
*self
);
113 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
114 /* Construction & Destruction */
115 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
118 * @name Construction & Destruction
122 G_DEFINE_TYPE(IrrecoThemeCreatorDlg
, irreco_theme_creator_dlg
,
123 IRRECO_TYPE_INTERNAL_DLG
)
125 static void irreco_theme_creator_dlg_constructed(GObject
*object
)
127 /* TODO: Add initialization code here */
129 IrrecoData
*irreco_data
;
130 IrrecoThemeCreatorDlg
*self
;
133 GtkWidget
*table_about
;
134 GtkWidget
*label_author
;
135 GtkWidget
*label_name
;
136 GtkWidget
*frame_comments
;
137 GtkWidget
*scrolled_comments
;
139 GtkWidget
*preview_button_frame
;
145 G_OBJECT_CLASS(irreco_theme_creator_dlg_parent_class
)->constructed(object
);
146 self
= IRRECO_THEME_CREATOR_DLG(object
);
147 irreco_data
= irreco_internal_dlg_get_irreco_data(IRRECO_INTERNAL_DLG(self
));
149 /* Construct dialog. */
150 gtk_window_set_title(GTK_WINDOW(self
), _("Theme Creator "));
151 gtk_window_set_modal(GTK_WINDOW(self
), TRUE
);
152 gtk_window_set_destroy_with_parent(GTK_WINDOW(self
), TRUE
);
153 gtk_dialog_set_has_separator(GTK_DIALOG(self
), FALSE
);
156 self
->cancel_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
158 GTK_RESPONSE_CANCEL
);
159 self
->save_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
162 self
->add_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
163 _("Add"), GTK_RESPONSE_NONE
);
164 self
->edit_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
167 self
->delete_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
171 /* Create widgets. */
172 self
->notebook
= gtk_notebook_new();
176 table_about
= gtk_table_new(7, 9, TRUE
);
177 label_author
= gtk_label_new(_("Author:"));
178 label_name
= gtk_label_new(_("Name: "));
179 self
->entry_author
= gtk_entry_new();
180 self
->entry_name
= gtk_entry_new();
181 frame_comments
= gtk_frame_new("");
182 scrolled_comments
= gtk_scrolled_window_new(NULL
, NULL
);
183 self
->textview_comments
= gtk_text_view_new();
184 preview_button_frame
= gtk_frame_new("");
185 self
->preview_event_box
= gtk_event_box_new();
186 self
->preview_image
= gtk_image_new();
187 gtk_image_set_from_file(GTK_IMAGE(self
->preview_image
), NULL
);
188 self
->hbox_backgrounds
= gtk_hbox_new(FALSE
, 2);
189 self
->hbox_buttons
= gtk_hbox_new(FALSE
, 2);
192 /* Set frame text bold */
193 gtk_frame_set_label_widget(GTK_FRAME(frame_comments
),
194 irreco_gtk_label_bold(
195 "Comments", 0, 0, 0, 0, 0, 0));
196 gtk_frame_set_label_widget(GTK_FRAME(preview_button_frame
),
197 irreco_gtk_label_bold(
198 "Preview button", 0, 0, 0, 0, 0, 0));
200 /* Create Notebook tabs. */
202 gtk_notebook_append_page(GTK_NOTEBOOK(self
->notebook
),
203 irreco_gtk_align(GTK_WIDGET(table_about
),
204 0, 0, 1, 1, 8, 8, 8, 8),
205 gtk_label_new("About"));
206 gtk_notebook_append_page(GTK_NOTEBOOK(self
->notebook
),
207 irreco_gtk_align(GTK_WIDGET(self
->hbox_buttons
),
208 0, 0, 1, 1, 8, 8, 8, 8),
209 gtk_label_new("Buttons"));
210 gtk_notebook_append_page(GTK_NOTEBOOK(self
->notebook
),
211 irreco_gtk_align(GTK_WIDGET(
212 self
->hbox_backgrounds
),
213 0, 0, 1, 1, 8, 8, 8, 8),
214 gtk_label_new("Backgrounds"));
217 gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(self
)->vbox
),
221 /* Set widgets on the table_about */
223 gtk_table_set_row_spacings(GTK_TABLE(table_about
), 6);
224 gtk_table_set_col_spacings(GTK_TABLE(table_about
), 6);
226 gtk_table_attach_defaults(GTK_TABLE(table_about
),
227 label_author
, 0, 2, 0, 1);
228 gtk_table_attach_defaults(GTK_TABLE(table_about
),
229 label_name
, 0, 2, 1, 2);
230 gtk_table_attach_defaults(GTK_TABLE(table_about
),
231 self
->entry_author
, 2, 9, 0, 1);
232 gtk_table_attach_defaults(GTK_TABLE(table_about
),
233 self
->entry_name
, 2, 9, 1, 2);
234 gtk_table_attach_defaults(GTK_TABLE(table_about
),
235 frame_comments
, 0, 6, 2, 7);
236 gtk_table_attach_defaults(GTK_TABLE(table_about
),
237 preview_button_frame
, 6, 9, 2, 7);
241 /* set preview image*/
244 gtk_container_add(GTK_CONTAINER(preview_button_frame
),
245 self
->preview_event_box
);
246 gtk_container_add(GTK_CONTAINER(self
->preview_event_box
),
247 self
->preview_image
);
251 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(self
->textview_comments
),
254 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_comments
),
256 GTK_POLICY_AUTOMATIC
);
258 gtk_container_add(GTK_CONTAINER(frame_comments
), scrolled_comments
);
259 gtk_container_add(GTK_CONTAINER(scrolled_comments
),
260 self
->textview_comments
);
262 /* Signal handlers. */
264 g_signal_connect(G_OBJECT(self
->notebook
), "switch-page",
265 G_CALLBACK(irreco_theme_creator_dlg_notebook_changed
),
268 g_signal_connect(G_OBJECT(self
->preview_event_box
),
269 "button-release-event",
270 G_CALLBACK(irreco_theme_creator_dlg_preview_image
),
273 g_signal_connect(G_OBJECT(self
->add_button
), "clicked",
274 G_CALLBACK(irreco_theme_creator_dlg_new_bg_button
),
276 g_signal_connect(G_OBJECT(self
->edit_button
), "clicked",
277 G_CALLBACK(irreco_theme_creator_dlg_edit_bg_button
),
279 g_signal_connect(G_OBJECT(self
->delete_button
), "clicked",
280 G_CALLBACK(irreco_theme_creator_dlg_delete_bg_button
),
283 gtk_widget_show_all(GTK_WIDGET(self
));
288 static void irreco_theme_creator_dlg_init(IrrecoThemeCreatorDlg
*self
)
294 static void irreco_theme_creator_dlg_finalize(GObject
*object
)
296 IrrecoThemeCreatorDlg
*self
;
299 self
= IRRECO_THEME_CREATOR_DLG(object
);
301 G_OBJECT_CLASS(irreco_theme_creator_dlg_parent_class
)->finalize(object
);
308 irreco_theme_creator_dlg_class_init(IrrecoThemeCreatorDlgClass
*klass
)
310 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
312 object_class
->finalize
= irreco_theme_creator_dlg_finalize
;
313 object_class
->constructed
= irreco_theme_creator_dlg_constructed
;
319 *irreco_theme_creator_dlg_new(IrrecoData
*irreco_data
, GtkWindow
*parent
)
321 IrrecoThemeCreatorDlg
*self
;
324 self
= g_object_new(IRRECO_TYPE_THEME_CREATOR_DLG
,
325 "irreco-data", irreco_data
,
327 /*self = g_object_new(IRRECO_TYPE_THEME_CREATOR_DLG, NULL);*/
328 irreco_dlg_set_parent(IRRECO_DLG(self
), parent
);
330 IRRECO_RETURN_PTR(self
);
335 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
336 /* Private Functions */
337 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
339 * @name Private Functions
344 * Start a loader state machine if one is not running already.
346 static void _loader_start(IrrecoThemeCreatorDlg
*self
, GSourceFunc function
)
350 if (self
->loader_func_id
== 0) {
351 self
->loader_func_id
= g_idle_add((GSourceFunc
)function
, self
);
358 * Stop and cleanup loader if a loader is running.
360 static void _loader_stop(IrrecoThemeCreatorDlg
*self
)
363 /*_hide_banner(self);*/
364 if (self
->loader_func_id
!= 0) {
365 g_source_remove(self
->loader_func_id
);
366 self
->loader_func_id
= 0;
367 self
->loader_state
= 0;
373 irreco_theme_creator_dlg_display_theme_detail(IrrecoThemeCreatorDlg
*self
,
378 IRRECO_PRINTF("Page_nro %d\n", page
);
379 IRRECO_RETURN_BOOL(TRUE
);
384 * Sets the theme details
387 void _set_theme_details(IrrecoThemeCreatorDlg
*self
, IrrecoTheme
*irreco_theme
)
392 gtk_entry_set_text(GTK_ENTRY(self
->entry_name
),
393 self
->theme
->name
->str
);
394 gtk_entry_set_text(GTK_ENTRY(self
->entry_author
),
395 self
->theme
->author
->str
);
397 self
->buffer_comments
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(
398 self
->textview_comments
));
399 gtk_text_buffer_set_text(GTK_TEXT_BUFFER(self
->buffer_comments
),
400 self
->theme
->comment
->str
,
402 self
->backgrounds
= irreco_theme_creator_backgrounds_new(
406 self
->buttons
= irreco_theme_creator_buttons_new(GTK_WINDOW(self
),
409 /* Set window title */
410 gtk_window_set_title(GTK_WINDOW(self
), _("Theme Editor "));
415 gtk_container_add(GTK_CONTAINER(self
->hbox_buttons
), self
->buttons
);
416 gtk_container_add(GTK_CONTAINER(self
->hbox_backgrounds
),
423 void _create_bg_and_button_widgets(IrrecoThemeCreatorDlg
*self
)
427 self
->backgrounds
= irreco_theme_creator_backgrounds_new(
431 self
->buttons
= irreco_theme_creator_buttons_new(GTK_WINDOW(self
),
435 gtk_container_add(GTK_CONTAINER(self
->hbox_buttons
), self
->buttons
);
436 gtk_container_add(GTK_CONTAINER(self
->hbox_backgrounds
),
442 * Update shown preview image
444 static void _set_preview(IrrecoThemeCreatorDlg
*self
)
448 /* if theme contains preview image, use it, else get first button */
449 if(self
->preview_name
) {
450 IRRECO_DEBUG("Preview set in dlg, using it\n");
451 } else if(strlen(self
->theme
->preview_button_name
->str
) != 0) {
453 IRRECO_DEBUG("Preview set to theme, using it\n");
454 strtblkey
= g_strdup_printf("%s/%s", self
->theme
->name
->str
,
455 self
->theme
->preview_button_name
->str
);
456 /*IRRECO_DEBUG("key: %s\n", strtblkey);*/
457 if(irreco_string_table_get(self
->theme
->buttons
, strtblkey
,
458 (gpointer
*) &self
->preview_button
)) {
459 self
->preview_name
= self
->preview_button
->image_up
->str
;
461 IRRECO_DEBUG("Theme preview set wrong\n");
465 IRRECO_DEBUG("No preview set, using first button of theme\n");
466 irreco_string_table_index(self
->theme
->buttons
, 0, &key
,
467 (gpointer
*) &self
->preview_button
);
468 if(self
->preview_button
) {
469 self
->preview_name
= self
->preview_button
->image_up
->str
;
472 gtk_image_set_from_file(GTK_IMAGE(self
->preview_image
),
477 void _set_edited_theme_details(IrrecoThemeCreatorDlg
*self
)
479 GtkTextIter startiter
;
483 self
->buffer_comments
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(
484 self
->textview_comments
));
486 gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(self
->buffer_comments
),
488 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(self
->buffer_comments
),
492 irreco_theme_set(self
->theme
,
493 gtk_entry_get_text(GTK_ENTRY(self
->entry_name
)),
496 gtk_entry_get_text(GTK_ENTRY(self
->entry_author
)),
497 gtk_text_buffer_get_text(GTK_TEXT_BUFFER(
498 self
->buffer_comments
),
502 self
->preview_button
->name
->str
,
510 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
512 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
515 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
516 /* Public Functions */
517 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
519 irreco_theme_creator_dlg_run(GtkWindow
*parent_window
, IrrecoData
*irreco_data
,
520 IrrecoTheme
*irreco_theme
)
522 IrrecoThemeCreatorDlg
*self
;
524 gboolean loop
= TRUE
;
525 gboolean rvalue
= FALSE
;
526 /*GtkTextIter startiter;
527 GtkTextIter enditer;*/
530 self
= (IrrecoThemeCreatorDlg
*)irreco_theme_creator_dlg_new(irreco_data
,
532 self
->parent_window
= GTK_WINDOW(self
);
533 self
->loader_func_id
= 0;
534 self
->irreco_data
= irreco_data
;
535 self
->preview_name
= NULL
;
536 irreco_theme_print(irreco_theme
);
537 self
->theme
= irreco_theme
;
538 IRRECO_DEBUG("Pointer: %p \n", (void*) self
->theme
);
539 IRRECO_DEBUG("Pointer: %p \n", (void*) irreco_theme
);
541 /* Check whether the theme of a blank*/
542 if (irreco_string_table_lenght(irreco_theme
->buttons
) != 0) {
543 /* Sets the theme details */
544 _set_theme_details(self
, irreco_theme
);
546 /* create blank bg:s and buttons widgets */
547 _create_bg_and_button_widgets(self
);
551 response
= gtk_dialog_run(GTK_DIALOG(self
));
553 case GTK_RESPONSE_OK
:
555 self
->loader_state
= LOADER_STATE_INIT
;
556 _loader_start(self
, NULL
);
557 /* Call set edited_theme_details functio */
558 _set_edited_theme_details(self
);
565 case GTK_RESPONSE_CANCEL
:
566 IRRECO_DEBUG("GTK_RESPONSE_CANCEL\n");
573 IRRECO_DEBUG("default\n");
579 gtk_widget_destroy(GTK_WIDGET(self
));
581 IRRECO_RETURN_BOOL(rvalue
);
587 irreco_theme_creator_dlg_notebook_changed(GtkNotebook
*notebook
,
588 GtkNotebookPage
*page
,
590 IrrecoThemeCreatorDlg
*self
)
598 gtk_widget_show(self
->cancel_button
);
599 gtk_widget_show(self
->save_button
);
600 gtk_widget_hide(self
->add_button
);
601 gtk_widget_hide(self
->edit_button
);
602 gtk_widget_hide(self
->delete_button
);
604 irreco_theme_creator_dlg_display_theme_detail(self
, page_num
);
608 gtk_widget_hide(self
->cancel_button
);
609 gtk_widget_hide(self
->save_button
);
610 gtk_widget_show(self
->add_button
);
611 gtk_widget_show(self
->edit_button
);
612 gtk_widget_show(self
->delete_button
);
614 irreco_theme_creator_dlg_display_theme_detail(self
, page_num
);
615 gtk_widget_show_all(GTK_WIDGET(self
->buttons
));
619 gtk_widget_hide(self
->cancel_button
);
620 gtk_widget_hide(self
->save_button
);
621 gtk_widget_show(self
->add_button
);
622 gtk_widget_show(self
->edit_button
);
623 gtk_widget_show(self
->delete_button
);
625 irreco_theme_creator_dlg_display_theme_detail(self
, page_num
);
626 gtk_widget_show_all(GTK_WIDGET(self
->backgrounds
));
631 IRRECO_DEBUG("default\n");
638 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
639 /* Events and Callbacks */
640 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
643 * @name Events and Callbacks
647 static void irreco_theme_creator_dlg_preview_image(GtkWidget
*widget
,
648 GdkEventButton
*event
,
649 IrrecoThemeCreatorDlg
*self
)
652 IrrecoThemeButton
*preview_theme_button
= NULL
;
655 if (self
->theme
!= NULL
) {
656 preview_theme_button
= irreco_button_browser_dlg_run(
661 if(preview_theme_button
) {
662 IRRECO_DEBUG("Set preview button to theme and self->\n");
664 self
->preview_name
= preview_theme_button
->image_up
->str
;
665 self
->preview_button
= preview_theme_button
;
676 *Create new background or button
679 static void irreco_theme_creator_dlg_new_bg_button(GtkButton
*button
,
680 IrrecoThemeCreatorDlg
*self
)
684 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(
685 self
->notebook
))==BACKGROUNDS
) {
687 IrrecoThemeBg
*new_bg
= NULL
;
688 new_bg
= irreco_theme_bg_new();
690 if (irreco_background_creator_dlg_run(self
->irreco_data
,
692 GTK_WINDOW(self
), new_bg
)) {
693 irreco_string_table_add(self
->theme
->backgrounds
,
694 new_bg
->image_name
->str
,
696 irreco_theme_creator_backgrounds_refresh(
697 IRRECO_THEME_CREATOR_BACKGROUNDS(
699 /*irreco_theme_bg_free(new_bg);*/
701 /*irreco_theme_bg_free(new_bg);*/
704 IrrecoThemeButton
*new_button
= NULL
;
705 new_button
= irreco_theme_button_new(NULL
);
707 if (irreco_button_creator_dlg_run(self
->irreco_data
, self
->theme
,
708 GTK_WINDOW(self
), new_button
)) {
709 irreco_string_table_add(self
->theme
->buttons
,
710 new_button
->name
->str
,
712 irreco_theme_creator_buttons_refresh(
713 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
));
714 /*irreco_theme_button_free(new_button);*/
716 /*irreco_theme_button_free(new_button);*/
724 *Create edit background or button
727 static void irreco_theme_creator_dlg_edit_bg_button(GtkButton
*button
,
728 IrrecoThemeCreatorDlg
*self
)
731 /* Check which page */
733 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(
734 self
->notebook
)) == BACKGROUNDS
) {
736 IrrecoThemeBg
*bg
= NULL
;
737 IrrecoThemeBg
*new_bg
= NULL
;
738 IrrecoThemeBg
*old_bg
= NULL
;
740 bg
= irreco_theme_creator_backgrounds_get_selected_bg(
741 IRRECO_THEME_CREATOR_BACKGROUNDS(self
->backgrounds
));
742 /* check whether the background image of the selected */
744 new_bg
= irreco_theme_bg_copy(bg
);
746 IRRECO_PRINTF("Pointer: %p \n", (void*) self
->theme
);
748 if (irreco_background_creator_dlg_run(self
->irreco_data
,
752 old_bg
= irreco_theme_bg_copy(bg
);
753 irreco_theme_bg_set(bg
, new_bg
->image_name
->str
,
754 new_bg
->image_path
->str
);
755 /* check whether the bg strings changed */
756 _set_bg_new_details(self
, old_bg
, bg
);
758 irreco_theme_creator_backgrounds_refresh(
759 IRRECO_THEME_CREATOR_BACKGROUNDS(
767 IRRECO_DEBUG("the background is not selected\n");
771 IrrecoThemeButton
*button
= NULL
;
772 IrrecoThemeButton
*new_button
= NULL
;
773 IrrecoThemeButton
*old_button
= NULL
;
775 button
= irreco_theme_creator_buttons_get_selected_button(
776 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
));
777 /* check whether the button image of the selected */
779 new_button
= irreco_theme_button_copy(button
);
781 if (irreco_button_creator_dlg_run(self
->irreco_data
,
785 old_button
= irreco_theme_button_copy(button
);
786 irreco_theme_button_print(new_button
);
787 irreco_theme_button_set(button
,
788 new_button
->style_name
->str
,
789 new_button
->name
->str
,
790 new_button
->allow_text
,
791 new_button
->image_up
->str
,
792 new_button
->image_down
->str
,
793 new_button
->text_format_up
->str
,
794 new_button
->text_format_down
->str
,
795 new_button
->text_padding
,
796 new_button
->text_h_align
,
797 new_button
->text_v_align
);
798 /* Check Button details and set again */
799 _set_button_new_details(self
, old_button
, button
);
802 irreco_theme_creator_buttons_refresh(
803 IRRECO_THEME_CREATOR_BUTTONS(
805 /*irreco_theme_button_free(new_button);*/
807 /*irreco_theme_button_free(new_button);*/
810 IRRECO_DEBUG("the button is not selected\n");
815 void _set_bg_new_details(IrrecoThemeCreatorDlg
*self
,
816 IrrecoThemeBg
*old_bg
,
821 if (!(g_str_equal(old_bg
->image_name
->str
, bg
->image_name
->str
))) {
822 irreco_string_table_change_key(self
->theme
->backgrounds
,
823 old_bg
->image_name
->str
,
824 bg
->image_name
->str
);
826 IRRECO_DEBUG("BG_NAME is same");
828 if (!(g_str_equal(old_bg
->image_path
->str
, bg
->image_path
->str
))) {
829 irreco_string_table_change_key(self
->theme
->backgrounds
,
830 old_bg
->image_path
->str
,
831 bg
->image_path
->str
);
833 IRRECO_DEBUG("BG_PATH is same");
838 void _set_button_new_details(IrrecoThemeCreatorDlg
*self
,
839 IrrecoThemeButton
*old_button
,
840 IrrecoThemeButton
*button
)
844 if (!(g_str_equal(old_button
->style_name
->str
,
845 button
->style_name
->str
))) {
846 irreco_string_table_change_key(self
->theme
->buttons
,
847 old_button
->style_name
->str
,
848 button
->style_name
->str
);
850 IRRECO_DEBUG("BUTTON_STYLE_NAME is the same\n");
852 if (!(g_str_equal(old_button
->name
->str
, button
->name
->str
))) {
853 irreco_string_table_change_key(self
->theme
->buttons
,
854 old_button
->name
->str
,
857 IRRECO_DEBUG("BUTTON_NAME is the same\n");
859 if (!(g_str_equal(old_button
->image_up
->str
, button
->image_up
->str
))) {
860 irreco_string_table_change_key(self
->theme
->buttons
,
861 old_button
->image_up
->str
,
862 button
->image_up
->str
);
864 IRRECO_DEBUG("String is the same\n");
866 if (!(g_str_equal(old_button
->image_down
->str
,
867 button
->image_down
->str
))) {
868 irreco_string_table_change_key(self
->theme
->buttons
,
869 old_button
->image_down
->str
,
870 button
->image_down
->str
);
872 IRRECO_DEBUG("String is the same\n");
874 if (!(g_str_equal(old_button
->text_format_up
->str
,
875 button
->text_format_up
->str
))) {
876 irreco_string_table_change_key(self
->theme
->buttons
,
877 old_button
->text_format_up
->str
,
878 button
->text_format_up
->str
);
880 IRRECO_DEBUG("String is the same\n");
882 if (!(g_str_equal(old_button
->text_format_up
->str
,
883 button
->text_format_up
->str
))) {
884 irreco_string_table_change_key(self
->theme
->buttons
,
885 old_button
->text_format_up
->str
,
886 button
->text_format_up
->str
);
888 IRRECO_DEBUG("String is the same\n");
890 if (!(g_str_equal(old_button
->text_format_down
->str
,
891 button
->text_format_down
->str
))) {
892 irreco_string_table_change_key(self
->theme
->buttons
,
893 old_button
->text_format_down
->str
,
894 button
->text_format_down
->str
);
896 IRRECO_DEBUG("String is the same\n");
898 if (old_button
->allow_text
== button
->allow_text
) {
899 irreco_string_table_change_key(self
->theme
->buttons
,
900 g_strdup_printf("%d",
901 old_button
->allow_text
),
902 g_strdup_printf("%d",
903 button
->allow_text
));
905 IRRECO_DEBUG("Value is the same\n");
907 if (old_button
->text_padding
== button
->text_padding
) {
908 irreco_string_table_change_key(self
->theme
->buttons
,
909 g_strdup_printf("%d",
910 old_button
->text_padding
),
911 g_strdup_printf("%d",
912 button
->text_padding
));
914 IRRECO_DEBUG("Value is the same\n");
916 if (old_button
->text_h_align
== button
->text_h_align
) {
917 irreco_string_table_change_key(self
->theme
->buttons
,
918 g_strdup_printf("%f",
919 old_button
->text_h_align
),
920 g_strdup_printf("%f",
921 button
->text_h_align
));
923 IRRECO_DEBUG("Value is the same\n");
925 if (old_button
->text_v_align
== button
->text_v_align
) {
926 irreco_string_table_change_key(self
->theme
->buttons
,
927 g_strdup_printf("%f",
928 old_button
->text_v_align
),
929 g_strdup_printf("%f",
930 button
->text_v_align
));
932 IRRECO_DEBUG("Value is the same\n");
937 static void irreco_theme_creator_dlg_delete_bg_button(GtkButton
*button
,
938 IrrecoThemeCreatorDlg
*self
)
944 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(
945 self
->notebook
)) == BACKGROUNDS
) {
947 bg
= irreco_theme_creator_backgrounds_get_selected_bg(
948 IRRECO_THEME_CREATOR_BACKGROUNDS(self
->backgrounds
));
949 if (irreco_theme_creator_backgrounds_remove_selected(
950 IRRECO_THEME_CREATOR_BACKGROUNDS(self
->backgrounds
))) {
951 irreco_string_table_remove((self
->theme
)->backgrounds
,
952 bg
->image_name
->str
);
955 IrrecoThemeButton
*button
;
956 button
= irreco_theme_creator_buttons_get_selected_button(
957 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
));
958 if (irreco_theme_creator_buttons_remove_selected(
959 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
))) {
960 irreco_string_table_remove((self
->theme
)->buttons
,