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_edited_theme_details(IrrecoThemeCreatorDlg
*self
);
107 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
108 /* Construction & Destruction */
109 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
112 * @name Construction & Destruction
116 G_DEFINE_TYPE(IrrecoThemeCreatorDlg
, irreco_theme_creator_dlg
,
117 IRRECO_TYPE_INTERNAL_DLG
)
119 static void irreco_theme_creator_dlg_constructed(GObject
*object
)
121 /* TODO: Add initialization code here */
123 IrrecoData
*irreco_data
;
124 IrrecoThemeCreatorDlg
*self
;
126 GtkWidget
*scrolled_table
;
127 GtkWidget
*table_about
;
128 GtkWidget
*label_author
;
129 GtkWidget
*label_name
;
130 GtkWidget
*frame_comments
;
131 GtkWidget
*scrolled_comments
;
133 GtkWidget
*preview_button_frame
;
139 G_OBJECT_CLASS(irreco_theme_creator_dlg_parent_class
)->constructed(object
);
140 self
= IRRECO_THEME_CREATOR_DLG(object
);
141 irreco_data
= irreco_internal_dlg_get_irreco_data(IRRECO_INTERNAL_DLG(self
));
143 /* Construct dialog. */
144 gtk_window_set_title(GTK_WINDOW(self
), _("Theme Creator "));
145 gtk_window_set_modal(GTK_WINDOW(self
), TRUE
);
146 gtk_window_set_destroy_with_parent(GTK_WINDOW(self
), TRUE
);
147 gtk_dialog_set_has_separator(GTK_DIALOG(self
), FALSE
);
150 self
->cancel_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
152 GTK_RESPONSE_CANCEL
);
153 self
->save_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
156 self
->add_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
157 _("Add"), GTK_RESPONSE_NONE
);
158 self
->edit_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
161 self
->delete_button
= gtk_dialog_add_button (GTK_DIALOG(self
),
165 /* Create widgets. */
166 self
->notebook
= gtk_notebook_new();
170 scrolled_table
= gtk_scrolled_window_new(NULL
, NULL
);
171 table_about
= gtk_table_new(7, 9, TRUE
);
172 label_author
= gtk_label_new(_("Author:"));
173 label_name
= gtk_label_new(_("Name: "));
174 self
->entry_author
= gtk_entry_new();
175 self
->entry_name
= gtk_entry_new();
176 frame_comments
= gtk_frame_new("");
177 scrolled_comments
= gtk_scrolled_window_new(NULL
, NULL
);
178 self
->textview_comments
= gtk_text_view_new();
179 preview_button_frame
= gtk_frame_new("");
180 self
->preview_event_box
= gtk_event_box_new();
181 self
->preview_image
= gtk_image_new();
182 gtk_image_set_from_file(GTK_IMAGE(self
->preview_image
), NULL
);
183 self
->hbox_backgrounds
= gtk_hbox_new(FALSE
, 2);
184 self
->hbox_buttons
= gtk_hbox_new(FALSE
, 2);
186 /* equal to the text of the left-side */
187 gtk_misc_set_alignment(GTK_MISC(label_name
), 0, 0.5);
188 gtk_misc_set_alignment(GTK_MISC(label_author
), 0, 0.5);
191 /* Set frame text bold */
192 gtk_frame_set_label_widget(GTK_FRAME(frame_comments
),
193 irreco_gtk_label_bold(
194 "Comments", 0, 0, 0, 0, 0, 0));
195 gtk_frame_set_label_widget(GTK_FRAME(preview_button_frame
),
196 irreco_gtk_label_bold(
197 "Preview button", 0, 0, 0, 0, 0, 0));
199 /* Set table on the scrolled */
200 /*gtk_container_add(GTK_CONTAINER(scrolled_table),
203 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(
205 GTK_WIDGET(table_about
));
207 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_table
),
209 GTK_POLICY_AUTOMATIC
);
211 /* Create Notebook tabs. */
213 gtk_notebook_append_page(GTK_NOTEBOOK(self
->notebook
),
214 irreco_gtk_align(GTK_WIDGET(scrolled_table
),
215 0, 0, 1, 1, 8, 8, 8, 8),
216 gtk_label_new("About"));
217 gtk_notebook_append_page(GTK_NOTEBOOK(self
->notebook
),
218 irreco_gtk_align(GTK_WIDGET(self
->hbox_buttons
),
219 0, 0, 1, 1, 8, 8, 8, 8),
220 gtk_label_new("Buttons"));
221 gtk_notebook_append_page(GTK_NOTEBOOK(self
->notebook
),
222 irreco_gtk_align(GTK_WIDGET(
223 self
->hbox_backgrounds
),
224 0, 0, 1, 1, 8, 8, 8, 8),
225 gtk_label_new("Backgrounds"));
228 gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(self
)->vbox
),
232 /* Set widgets on the table_about */
234 gtk_table_set_row_spacings(GTK_TABLE(table_about
), 6);
235 gtk_table_set_col_spacings(GTK_TABLE(table_about
), 6);
237 gtk_table_attach_defaults(GTK_TABLE(table_about
),
238 label_author
, 0, 2, 0, 1);
239 gtk_table_attach_defaults(GTK_TABLE(table_about
),
240 label_name
, 0, 2, 1, 2);
241 gtk_table_attach_defaults(GTK_TABLE(table_about
),
242 self
->entry_author
, 2, 9, 0, 1);
243 gtk_table_attach_defaults(GTK_TABLE(table_about
),
244 self
->entry_name
, 2, 9, 1, 2);
245 gtk_table_attach_defaults(GTK_TABLE(table_about
),
246 frame_comments
, 0, 6, 2, 7);
247 gtk_table_attach_defaults(GTK_TABLE(table_about
),
248 preview_button_frame
, 6, 9, 2, 7);
251 /* set preview image*/
254 gtk_container_add(GTK_CONTAINER(preview_button_frame
),
255 self
->preview_event_box
);
256 gtk_container_add(GTK_CONTAINER(self
->preview_event_box
),
257 self
->preview_image
);
261 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(self
->textview_comments
),
264 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_comments
),
266 GTK_POLICY_AUTOMATIC
);
268 gtk_container_add(GTK_CONTAINER(frame_comments
), scrolled_comments
);
269 gtk_container_add(GTK_CONTAINER(scrolled_comments
),
270 self
->textview_comments
);
272 /* Signal handlers. */
274 g_signal_connect(G_OBJECT(self
->notebook
), "switch-page",
275 G_CALLBACK(irreco_theme_creator_dlg_notebook_changed
),
278 g_signal_connect(G_OBJECT(self
->preview_event_box
),
279 "button-release-event",
280 G_CALLBACK(irreco_theme_creator_dlg_preview_image
),
283 g_signal_connect(G_OBJECT(self
->add_button
), "clicked",
284 G_CALLBACK(irreco_theme_creator_dlg_new_bg_button
),
286 g_signal_connect(G_OBJECT(self
->edit_button
), "clicked",
287 G_CALLBACK(irreco_theme_creator_dlg_edit_bg_button
),
289 g_signal_connect(G_OBJECT(self
->delete_button
), "clicked",
290 G_CALLBACK(irreco_theme_creator_dlg_delete_bg_button
),
293 gtk_widget_set_size_request(GTK_WIDGET(self
), 696, 396);
294 gtk_widget_show_all(GTK_WIDGET(self
));
298 static void irreco_theme_creator_dlg_init(IrrecoThemeCreatorDlg
*self
)
304 static void irreco_theme_creator_dlg_finalize(GObject
*object
)
306 IrrecoThemeCreatorDlg
*self
;
309 self
= IRRECO_THEME_CREATOR_DLG(object
);
311 G_OBJECT_CLASS(irreco_theme_creator_dlg_parent_class
)->finalize(object
);
316 irreco_theme_creator_dlg_class_init(IrrecoThemeCreatorDlgClass
*klass
)
318 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
320 object_class
->finalize
= irreco_theme_creator_dlg_finalize
;
321 object_class
->constructed
= irreco_theme_creator_dlg_constructed
;
326 *irreco_theme_creator_dlg_new(IrrecoData
*irreco_data
, GtkWindow
*parent
)
328 IrrecoThemeCreatorDlg
*self
;
331 self
= g_object_new(IRRECO_TYPE_THEME_CREATOR_DLG
,
332 "irreco-data", irreco_data
,
334 /*self = g_object_new(IRRECO_TYPE_THEME_CREATOR_DLG, NULL);*/
335 irreco_dlg_set_parent(IRRECO_DLG(self
), parent
);
337 IRRECO_RETURN_PTR(self
);
342 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
343 /* Private Functions */
344 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
346 * @name Private Functions
351 * Start a loader state machine if one is not running already.
353 static void _loader_start(IrrecoThemeCreatorDlg
*self
, GSourceFunc function
)
357 if (self
->loader_func_id
== 0) {
358 self
->loader_func_id
= g_idle_add((GSourceFunc
)function
, self
);
365 * Stop and cleanup loader if a loader is running.
367 static void _loader_stop(IrrecoThemeCreatorDlg
*self
)
370 /*_hide_banner(self);*/
371 if (self
->loader_func_id
!= 0) {
372 g_source_remove(self
->loader_func_id
);
373 self
->loader_func_id
= 0;
374 self
->loader_state
= 0;
380 irreco_theme_creator_dlg_display_theme_detail(IrrecoThemeCreatorDlg
*self
,
385 IRRECO_PRINTF("Page_nro %d\n", page
);
386 IRRECO_RETURN_BOOL(TRUE
);
391 * Sets the theme details
394 void _set_theme_details(IrrecoThemeCreatorDlg
*self
, IrrecoTheme
*irreco_theme
)
399 gtk_entry_set_text(GTK_ENTRY(self
->entry_name
),
400 self
->theme
->name
->str
);
401 gtk_entry_set_text(GTK_ENTRY(self
->entry_author
),
402 self
->theme
->author
->str
);
404 self
->buffer_comments
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(
405 self
->textview_comments
));
406 gtk_text_buffer_set_text(GTK_TEXT_BUFFER(self
->buffer_comments
),
407 self
->theme
->comment
->str
,
409 self
->backgrounds
= irreco_theme_creator_backgrounds_new(
413 self
->buttons
= irreco_theme_creator_buttons_new(GTK_WINDOW(self
),
416 /* Set window title */
417 gtk_window_set_title(GTK_WINDOW(self
), _("Theme Editor "));
422 gtk_container_add(GTK_CONTAINER(self
->hbox_buttons
), self
->buttons
);
423 gtk_container_add(GTK_CONTAINER(self
->hbox_backgrounds
),
430 void _create_bg_and_button_widgets(IrrecoThemeCreatorDlg
*self
)
434 self
->backgrounds
= irreco_theme_creator_backgrounds_new(
438 self
->buttons
= irreco_theme_creator_buttons_new(GTK_WINDOW(self
),
442 gtk_container_add(GTK_CONTAINER(self
->hbox_buttons
), self
->buttons
);
443 gtk_container_add(GTK_CONTAINER(self
->hbox_backgrounds
),
449 * Update shown preview image
451 static void _set_preview(IrrecoThemeCreatorDlg
*self
)
455 /* if theme contains preview image, use it, else get first button */
456 if(self
->preview_name
) {
457 IRRECO_DEBUG("Preview set in dlg, using it\n");
458 } else if(strlen(self
->theme
->preview_button_name
->str
) != 0) {
460 IRRECO_DEBUG("Preview set to theme, using it\n");
461 strtblkey
= g_strdup_printf("%s/%s", self
->theme
->name
->str
,
462 self
->theme
->preview_button_name
->str
);
463 IRRECO_DEBUG("STRTBKEY: %s\n", strtblkey
);
464 if(irreco_string_table_get(self
->theme
->buttons
, strtblkey
,
465 (gpointer
*) &self
->preview_button
)) {
466 self
->preview_name
= self
->preview_button
->image_up
->str
;
468 IRRECO_DEBUG("Theme preview set wrong\n");
472 IRRECO_DEBUG("No preview set, using first button of theme\n");
473 irreco_string_table_index(self
->theme
->buttons
, 0, &key
,
474 (gpointer
*) &self
->preview_button
);
475 if(self
->preview_button
) {
476 self
->preview_name
= self
->preview_button
->image_up
->str
;
479 gtk_image_set_from_file(GTK_IMAGE(self
->preview_image
),
484 void _set_edited_theme_details(IrrecoThemeCreatorDlg
*self
)
486 GtkTextIter startiter
;
488 const gchar
*name
= NULL
;
489 const gchar
*author
= NULL
;
490 gchar
*comment
= NULL
;
494 name
= gtk_entry_get_text(GTK_ENTRY(self
->entry_name
));
495 author
= gtk_entry_get_text(GTK_ENTRY(self
->entry_author
));
498 self
->buffer_comments
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(
499 self
->textview_comments
));
501 gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(self
->buffer_comments
),
503 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(self
->buffer_comments
),
505 comment
= gtk_text_buffer_get_text(GTK_TEXT_BUFFER(
506 self
->buffer_comments
),
510 /* Check whether preview button set */
511 if (!self
->preview_name
) {
514 irreco_theme_set(self
->theme
,
528 irreco_theme_creator_dlg_check_details(IrrecoThemeCreatorDlg
*self
)
531 gboolean rvalue
= TRUE
;
533 /* check that there is at least one button */
534 if (!irreco_string_table_lenght(self
->theme
->buttons
)) {
535 irreco_error_dlg(GTK_WINDOW(self
),
536 "must be at least one button");
538 } else if (strlen(gtk_entry_get_text(GTK_ENTRY(self
->entry_name
))) == 0) {
539 irreco_error_dlg(GTK_WINDOW(self
),
542 } else if (strlen(gtk_entry_get_text(GTK_ENTRY(self
->entry_author
))) == 0) {
543 irreco_error_dlg(GTK_WINDOW(self
),
544 "Author is missing");
548 IRRECO_RETURN_BOOL(rvalue
);
552 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
554 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
557 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
558 /* Public Functions */
559 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
561 irreco_theme_creator_dlg_run(GtkWindow
*parent_window
, IrrecoData
*irreco_data
,
562 IrrecoTheme
*irreco_theme
)
564 IrrecoThemeCreatorDlg
*self
;
566 gboolean loop
= TRUE
;
567 gboolean rvalue
= FALSE
;
568 /*GtkTextIter startiter;
569 GtkTextIter enditer;*/
572 self
= (IrrecoThemeCreatorDlg
*)irreco_theme_creator_dlg_new(irreco_data
,
574 self
->parent_window
= GTK_WINDOW(self
);
575 self
->loader_func_id
= 0;
576 self
->irreco_data
= irreco_data
;
577 self
->preview_name
= NULL
;
578 irreco_theme_print(irreco_theme
);
579 self
->theme
= irreco_theme
;
580 IRRECO_DEBUG("Pointer: %p \n", (void*) self
->theme
);
581 IRRECO_DEBUG("Pointer: %p \n", (void*) irreco_theme
);
583 /* Check whether the theme of a blank*/
584 if (irreco_string_table_lenght(irreco_theme
->buttons
) != 0) {
585 /* Sets the theme details */
586 _set_theme_details(self
, irreco_theme
);
588 /* create blank bg:s and buttons widgets */
589 _create_bg_and_button_widgets(self
);
593 response
= gtk_dialog_run(GTK_DIALOG(self
));
595 case GTK_RESPONSE_OK
:
597 self
->loader_state
= LOADER_STATE_INIT
;
598 _loader_start(self
, NULL
);
599 /* Check theme details */
600 if (irreco_theme_creator_dlg_check_details(self
)) {
601 /* Call set edited_theme_details functio */
602 _set_edited_theme_details(self
);
604 /* Call ThemeSaveDlg */
605 if (irreco_theme_save_dlg_run(self
->irreco_data
,
606 irreco_theme
, GTK_WINDOW(self
))) {
619 case GTK_RESPONSE_CANCEL
:
620 IRRECO_DEBUG("GTK_RESPONSE_CANCEL\n");
627 IRRECO_DEBUG("default\n");
633 gtk_widget_destroy(GTK_WIDGET(self
));
635 IRRECO_RETURN_BOOL(rvalue
);
639 irreco_theme_creator_dlg_notebook_changed(GtkNotebook
*notebook
,
640 GtkNotebookPage
*page
,
642 IrrecoThemeCreatorDlg
*self
)
650 gtk_widget_show(self
->cancel_button
);
651 gtk_widget_show(self
->save_button
);
652 gtk_widget_hide(self
->add_button
);
653 gtk_widget_hide(self
->edit_button
);
654 gtk_widget_hide(self
->delete_button
);
656 irreco_theme_creator_dlg_display_theme_detail(self
, page_num
);
660 gtk_widget_hide(self
->cancel_button
);
661 gtk_widget_hide(self
->save_button
);
662 gtk_widget_show(self
->add_button
);
663 gtk_widget_show(self
->edit_button
);
664 gtk_widget_show(self
->delete_button
);
666 irreco_theme_creator_dlg_display_theme_detail(self
, page_num
);
667 gtk_widget_show_all(GTK_WIDGET(self
->buttons
));
671 gtk_widget_hide(self
->cancel_button
);
672 gtk_widget_hide(self
->save_button
);
673 gtk_widget_show(self
->add_button
);
674 gtk_widget_show(self
->edit_button
);
675 gtk_widget_show(self
->delete_button
);
677 irreco_theme_creator_dlg_display_theme_detail(self
, page_num
);
678 gtk_widget_show_all(GTK_WIDGET(self
->backgrounds
));
683 IRRECO_DEBUG("default\n");
689 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
690 /* Events and Callbacks */
691 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
694 * @name Events and Callbacks
698 static void irreco_theme_creator_dlg_preview_image(GtkWidget
*widget
,
699 GdkEventButton
*event
,
700 IrrecoThemeCreatorDlg
*self
)
703 IrrecoThemeButton
*preview_theme_button
= NULL
;
706 if (self
->theme
!= NULL
) {
707 preview_theme_button
= irreco_button_browser_dlg_run(
712 if(preview_theme_button
) {
713 IRRECO_DEBUG("Set preview button to theme and self->\n");
715 self
->preview_name
= preview_theme_button
->image_up
->str
;
716 self
->preview_button
= preview_theme_button
;
726 *Create new background or button
729 static void irreco_theme_creator_dlg_new_bg_button(GtkButton
*button
,
730 IrrecoThemeCreatorDlg
*self
)
734 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(
735 self
->notebook
))==BACKGROUNDS
) {
737 IrrecoThemeBg
*new_bg
= NULL
;
738 new_bg
= irreco_theme_bg_new();
740 if (irreco_background_creator_dlg_run(self
->irreco_data
,
742 GTK_WINDOW(self
), new_bg
)) {
743 irreco_string_table_add(self
->theme
->backgrounds
,
744 new_bg
->image_name
->str
,
746 irreco_theme_creator_backgrounds_refresh(
747 IRRECO_THEME_CREATOR_BACKGROUNDS(
750 /*irreco_theme_bg_free(new_bg);*/
753 IrrecoThemeButton
*new_button
= NULL
;
754 new_button
= irreco_theme_button_new(NULL
);
756 if (irreco_button_creator_dlg_run(self
->irreco_data
, self
->theme
,
757 GTK_WINDOW(self
), new_button
)) {
758 irreco_string_table_add(self
->theme
->buttons
,
759 new_button
->name
->str
,
761 irreco_theme_creator_buttons_refresh(
762 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
));
764 /*irreco_theme_button_free(new_button);*/
772 *Create edit background or button
775 static void irreco_theme_creator_dlg_edit_bg_button(GtkButton
*button
,
776 IrrecoThemeCreatorDlg
*self
)
779 /* Check which page */
781 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(
782 self
->notebook
)) == BACKGROUNDS
) {
784 IrrecoThemeBg
*bg
= NULL
;
785 IrrecoThemeBg
*new_bg
= NULL
;
786 IrrecoThemeBg
*old_bg
= NULL
;
788 bg
= irreco_theme_creator_backgrounds_get_selected_bg(
789 IRRECO_THEME_CREATOR_BACKGROUNDS(self
->backgrounds
));
790 /* check whether the background image of the selected */
792 new_bg
= irreco_theme_bg_copy(bg
);
794 IRRECO_PRINTF("Pointer: %p \n", (void*) self
->theme
);
796 if (irreco_background_creator_dlg_run(self
->irreco_data
,
800 old_bg
= irreco_theme_bg_copy(bg
);
801 irreco_theme_bg_set(bg
, new_bg
->image_name
->str
,
802 new_bg
->image_path
->str
);
804 irreco_theme_creator_backgrounds_refresh(
805 IRRECO_THEME_CREATOR_BACKGROUNDS(
808 irreco_theme_bg_free(new_bg
);
812 IRRECO_DEBUG("the background is not selected\n");
816 IrrecoThemeButton
*button
= NULL
;
817 IrrecoThemeButton
*new_button
= NULL
;
818 IrrecoThemeButton
*old_button
= NULL
;
820 button
= irreco_theme_creator_buttons_get_selected_button(
821 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
));
822 /* check whether the button image of the selected */
824 new_button
= irreco_theme_button_copy(button
);
826 if (irreco_button_creator_dlg_run(self
->irreco_data
,
830 old_button
= irreco_theme_button_copy(button
);
831 irreco_theme_button_print(new_button
);
832 irreco_theme_button_set_from_button(button
,
835 irreco_theme_button_print(old_button
);
836 irreco_theme_button_print(button
);
838 irreco_theme_creator_buttons_refresh(
839 IRRECO_THEME_CREATOR_BUTTONS(
844 irreco_theme_button_free(new_button
);
846 IRRECO_DEBUG("the button is not selected\n");
852 static void irreco_theme_creator_dlg_delete_bg_button(GtkButton
*button
,
853 IrrecoThemeCreatorDlg
*self
)
859 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(
860 self
->notebook
)) == BACKGROUNDS
) {
862 bg
= irreco_theme_creator_backgrounds_get_selected_bg(
863 IRRECO_THEME_CREATOR_BACKGROUNDS(self
->backgrounds
));
864 if (irreco_theme_creator_backgrounds_remove_selected(
865 IRRECO_THEME_CREATOR_BACKGROUNDS(self
->backgrounds
))) {
866 irreco_string_table_remove((self
->theme
)->backgrounds
,
867 bg
->image_name
->str
);
870 IrrecoThemeButton
*button
;
871 button
= irreco_theme_creator_buttons_get_selected_button(
872 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
));
873 if (irreco_theme_creator_buttons_remove_selected(
874 IRRECO_THEME_CREATOR_BUTTONS(self
->buttons
))) {
875 irreco_string_table_remove((self
->theme
)->buttons
,