From 7cb260b4aca95ab0c02b7a08823fa645db21c392 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pekka=20Geh=C3=B6r?= Date: Fri, 12 Dec 2008 08:26:38 +0200 Subject: [PATCH] fixed bg images adding a table. --- irreco/src/core/irreco_background_creator_dlg.c | 18 ++++--- irreco/src/core/irreco_theme.c | 10 ++-- irreco/src/core/irreco_theme_creator_backgrounds.c | 27 ++++++----- irreco/src/core/irreco_theme_creator_backgrounds.h | 5 -- irreco/src/core/irreco_theme_creator_dlg.c | 56 ++++++++++++++-------- irreco/src/core/irreco_theme_manager_dlg.c | 6 ++- 6 files changed, 68 insertions(+), 54 deletions(-) diff --git a/irreco/src/core/irreco_background_creator_dlg.c b/irreco/src/core/irreco_background_creator_dlg.c index 28d28d66..4b8e5561 100644 --- a/irreco/src/core/irreco_background_creator_dlg.c +++ b/irreco/src/core/irreco_background_creator_dlg.c @@ -341,8 +341,6 @@ gboolean irreco_background_creator_dlg_run(IrrecoData *irreco_data, irreco_theme_bg_print(bg); - /*if (irreco_theme != NULL) { - if (irreco_string_table_lenght(irreco_theme->buttons) > 0) {*/ if (g_utf8_strlen(bg->image_name->str, 1) >0) { temp_bg = irreco_theme_bg_copy(bg); irreco_theme_bg_print(temp_bg); @@ -365,19 +363,19 @@ gboolean irreco_background_creator_dlg_run(IrrecoData *irreco_data, IRRECO_PRINTF("Filepath: %s\n", self->filename->str); IRRECO_PRINTF("BgName: %s\n", gtk_entry_get_text(GTK_ENTRY( self->entry_name))); - irreco_theme_bg_set(bg, gtk_entry_get_text(GTK_ENTRY( self->entry_name)), self->filename->str); - - irreco_theme_update_keyfile(self->theme); - - irreco_theme = irreco_theme_copy(self->theme); - + irreco_theme_bg_print(bg); + /*irreco_theme_update_keyfile(self->theme); + irreco_theme = irreco_theme_copy(self->theme);*/ + irreco_theme = self->theme; + /* IRRECO_PRINTF("Pointer: %p \n", (void*) self->theme); + IRRECO_PAUSE + IRRECO_PRINTF("Pointer: %p \n", (void*) irreco_theme); + IRRECO_PAUSE*/ rvalue = TRUE; - - if (temp_bg !=NULL) irreco_theme_bg_free(temp_bg); loop = FALSE; break; diff --git a/irreco/src/core/irreco_theme.c b/irreco/src/core/irreco_theme.c index ee76e4fc..76b227ca 100644 --- a/irreco/src/core/irreco_theme.c +++ b/irreco/src/core/irreco_theme.c @@ -270,14 +270,14 @@ void irreco_theme_read_button_keyfile_foreach(IrrecoDirForeachData * dir_data) button = irreco_theme_button_new_from_dir(dir_data->directory); - if (irreco_string_table_exists(self->buttons, button->style_name->str)) { + if (irreco_string_table_exists(self->buttons, button->name->str)) { IRRECO_ERROR("Error: Button %s has already been read. " "You cannot have two buttons with the same name.\n", - button->style_name->str); + button->name->str); irreco_theme_button_free(button); } else { irreco_string_table_add(self->buttons, - button->style_name->str, button); + button->name->str, button); } @@ -554,7 +554,7 @@ IrrecoTheme *irreco_theme_copy(IrrecoTheme *self) self->version->str); - IRRECO_STRING_TABLE_FOREACH(self->backgrounds, key, IrrecoThemeBg *, +/* IRRECO_STRING_TABLE_FOREACH(self->backgrounds, key, IrrecoThemeBg *, theme_bg) irreco_string_table_add(new->backgrounds, key, irreco_theme_bg_copy(theme_bg)); @@ -569,7 +569,7 @@ IrrecoTheme *irreco_theme_copy(IrrecoTheme *self) IRRECO_STRING_TABLE_FOREACH_END - + */ IRRECO_RETURN_PTR(new); } diff --git a/irreco/src/core/irreco_theme_creator_backgrounds.c b/irreco/src/core/irreco_theme_creator_backgrounds.c index c9e66d84..fccea4a8 100644 --- a/irreco/src/core/irreco_theme_creator_backgrounds.c +++ b/irreco/src/core/irreco_theme_creator_backgrounds.c @@ -197,12 +197,11 @@ irreco_theme_creator_backgrounds_new(GtkWindow *parent, IrrecoData *irreco_data, self->parent_window = GTK_WINDOW(parent); self->irreco_data = irreco_data; self->theme = irreco_theme; - if (irreco_theme !=NULL) { - irreco_theme_creator_backgrounds_refresh(self); - } - /*if (irreco_string_table_lenght(irreco_theme->buttons) != 0) { - irreco_theme_creator_backgrounds_image_append_with_size(self); - }*/ + /*IRRECO_PRINTF("Pointer: %p \n", (void*) self->theme); + IRRECO_PAUSE*/ + + irreco_theme_creator_backgrounds_refresh(self); + IRRECO_RETURN_PTR(GTK_WIDGET(self)); } @@ -262,34 +261,36 @@ irreco_theme_creator_backgrounds_refresh( gint i=0; IRRECO_ENTER - gtk_list_store_clear(self->store_backgrounds); - irreco_data = self->irreco_data; manager = irreco_data->theme_manager; theme = self->theme; + IRRECO_PRINTF("Pointer: %p \n", (void*) theme); + IRRECO_PRINTF("Pointer: %p \n", (void*) theme->backgrounds); + theme_bg_count = irreco_string_table_lenght(theme->backgrounds); - + + IRRECO_PAUSE if (theme_bg_count > 0) { while(theme_bg_count > 0) { IrrecoThemeBg *background_image; - + irreco_string_table_index(theme->backgrounds, i, &image_name, (gpointer *) &background_image); + irreco_theme_bg_print(background_image); - pixbuf = gdk_pixbuf_new_from_file_at_scale( background_image->image_path->str, IRRECO_BACKGROUNDS_PREVIEW_WIDHT, IRRECO_BACKGROUNDS_PREVIEW_HEIGHT, GDK_INTERP_NEAREST, &error); + if (irreco_gerror_check_print(&error)) { IRRECO_RETURN } - gtk_list_store_append(self->store_backgrounds, &iter); @@ -298,7 +299,7 @@ irreco_theme_creator_backgrounds_refresh( background_image, PIXBUF_COL, pixbuf, TEXT_COL, image_name, -1); - + gtk_tree_view_columns_autosize(GTK_TREE_VIEW( self->view_backgrounds)); diff --git a/irreco/src/core/irreco_theme_creator_backgrounds.h b/irreco/src/core/irreco_theme_creator_backgrounds.h index 02b4d70a..40064df3 100644 --- a/irreco/src/core/irreco_theme_creator_backgrounds.h +++ b/irreco/src/core/irreco_theme_creator_backgrounds.h @@ -115,17 +115,12 @@ GType irreco_theme_creator_backgrounds_get_type (void); GtkWidget* irreco_theme_creator_backgrounds_new(GtkWindow *parent, IrrecoData *irreco_data, IrrecoTheme * irreco_theme); -/*GtkWidget* irreco_theme_creator_backgrounds_new(IrrecoData *irreco_data);*/ - void irreco_theme_creator_backgrounds_set_parent_window( IrrecoThemeCreatorBackgrounds *self, GtkWindow *parent); IrrecoThemeBg *irreco_theme_creator_backgrounds_get_selected_bg(IrrecoThemeCreatorBackgrounds *self); -void -irreco_theme_creator_backgrounds_refresh_list(GtkWindow *parent, IrrecoData *irreco_data, - IrrecoTheme * irreco_theme); gboolean irreco_theme_creator_backgrounds_remove_selected(IrrecoThemeCreatorBackgrounds *self); diff --git a/irreco/src/core/irreco_theme_creator_dlg.c b/irreco/src/core/irreco_theme_creator_dlg.c index 0f566fc8..07128b2e 100644 --- a/irreco/src/core/irreco_theme_creator_dlg.c +++ b/irreco/src/core/irreco_theme_creator_dlg.c @@ -199,11 +199,11 @@ static void irreco_theme_creator_dlg_constructed(GObject *object) "Preview button", 0, 0, 0, 0, 0, 0)); - self->backgrounds = irreco_theme_creator_backgrounds_new( + /*self->backgrounds = irreco_theme_creator_backgrounds_new( GTK_WINDOW(self), irreco_data, NULL); - + */ /* Create Notebook tabs. */ gtk_notebook_append_page(GTK_NOTEBOOK(self->notebook), @@ -454,6 +454,10 @@ irreco_theme_creator_dlg_run(GtkWindow *parent_window, IrrecoData *irreco_data, self->preview_name = NULL; irreco_theme_print(irreco_theme); self->theme = irreco_theme; + /* IRRECO_PRINTF("Pointer: %p \n", (void*) self->theme); + IRRECO_PAUSE + IRRECO_PRINTF("Pointer: %p \n", (void*) irreco_theme); + IRRECO_PAUSE */ /* Check whether the theme of a blank*/ if (irreco_string_table_lenght(irreco_theme->buttons) != 0) { @@ -545,8 +549,8 @@ void _set_theme_details(IrrecoThemeCreatorDlg *self, IrrecoTheme *irreco_theme) gtk_entry_set_text(GTK_ENTRY(self->entry_author), self->theme->author->str); - self->buffer_comments = gtk_text_view_get_buffer( - GTK_TEXT_VIEW(self->textview_comments)); + self->buffer_comments = gtk_text_view_get_buffer(GTK_TEXT_VIEW( + self->textview_comments)); gtk_text_buffer_set_text(GTK_TEXT_BUFFER(self->buffer_comments), self->theme->comment->str, -1); @@ -564,10 +568,9 @@ void _set_theme_details(IrrecoThemeCreatorDlg *self, IrrecoTheme *irreco_theme) _set_preview(self); - gtk_container_add(GTK_CONTAINER(self->hbox_buttons), - self->buttons); + gtk_container_add(GTK_CONTAINER(self->hbox_buttons), self->buttons); gtk_container_add(GTK_CONTAINER(self->hbox_backgrounds), - self->backgrounds); + self->backgrounds); IRRECO_RETURN @@ -580,13 +583,12 @@ void _create_bg_and_button_widgets(IrrecoThemeCreatorDlg *self) self->backgrounds = irreco_theme_creator_backgrounds_new( GTK_WINDOW(self), self->irreco_data, - NULL); + self->theme); self->buttons = irreco_theme_creator_buttons_new(GTK_WINDOW(self), - self->irreco_data, NULL); + self->irreco_data, + self->theme); - - gtk_container_add(GTK_CONTAINER(self->hbox_buttons), - self->buttons); + gtk_container_add(GTK_CONTAINER(self->hbox_buttons), self->buttons); gtk_container_add(GTK_CONTAINER(self->hbox_backgrounds), self->backgrounds); IRRECO_RETURN @@ -739,12 +741,15 @@ static void irreco_theme_creator_dlg_new_bg_button(GtkButton *button, irreco_background_creator_dlg_run(self->irreco_data, self->theme, GTK_WINDOW(self), new_bg); - irreco_theme_bg_print(new_bg); + /* IRRECO_PRINTF("Pointer: %p \n", (void*) self->theme); + IRRECO_PAUSE + + irreco_theme_bg_print(new_bg);*/ irreco_string_table_add(self->theme->backgrounds, new_bg->image_name->str, new_bg); - - /* Delete backgrounds widget and create it again */ + + irreco_theme_update_keyfile(self->theme); irreco_theme_creator_backgrounds_refresh( IRRECO_THEME_CREATOR_BACKGROUNDS( self->backgrounds)); @@ -754,7 +759,15 @@ static void irreco_theme_creator_dlg_new_bg_button(GtkButton *button, new_button = irreco_theme_button_new(NULL); irreco_button_creator_dlg_run(self->irreco_data, self->theme, - GTK_WINDOW(self), new_button); + GTK_WINDOW(self), new_button); + irreco_string_table_add(self->theme->buttons, + new_button->name->str, + new_button); + + irreco_theme_button_free(new_button); + irreco_theme_creator_buttons_refresh( + IRRECO_THEME_CREATOR_BUTTONS(self->buttons)); + } IRRECO_RETURN @@ -786,12 +799,15 @@ static void irreco_theme_creator_dlg_edit_bg_button(GtkButton *button, self->theme, GTK_WINDOW(self), new_bg)) { - irreco_theme_bg_set(bg, new_bg->image_name->str, + irreco_theme_bg_print(new_bg); + irreco_theme_bg_set(bg, new_bg->image_name->str, new_bg->image_path->str); - irreco_theme_creator_backgrounds_refresh( + /* irreco_theme_creator_backgrounds_refresh( IRRECO_THEME_CREATOR_BACKGROUNDS( self->backgrounds)); - + */ + irreco_theme_bg_print(new_bg); + irreco_theme_bg_free(new_bg); } else { @@ -817,7 +833,7 @@ static void irreco_theme_creator_dlg_edit_bg_button(GtkButton *button, if (button) { new_button = irreco_theme_button_copy(button); - new_button = irreco_button_creator_dlg_run(self->irreco_data, + irreco_button_creator_dlg_run(self->irreco_data, self->theme, GTK_WINDOW(self), new_button); diff --git a/irreco/src/core/irreco_theme_manager_dlg.c b/irreco/src/core/irreco_theme_manager_dlg.c index f207a068..438614dc 100644 --- a/irreco/src/core/irreco_theme_manager_dlg.c +++ b/irreco/src/core/irreco_theme_manager_dlg.c @@ -909,7 +909,8 @@ static void irreco_theme_manager_dlg_new_theme(GtkButton *button, IrrecoTheme *new_theme = NULL; new_theme = irreco_theme_new(); - + /*IRRECO_PRINTF("Pointer: %p \n", (void*) new_theme); + IRRECO_PAUSE*/ irreco_theme_creator_dlg_run(GTK_WINDOW(self), self->irreco_data, new_theme); @@ -920,6 +921,9 @@ static void irreco_theme_manager_dlg_new_theme(GtkButton *button, IrrecoTheme *new_theme = NULL; new_theme = irreco_theme_copy(self->theme); + + /*IRRECO_PRINTF("Pointer: %p \n", (void*) new_theme); + IRRECO_PAUSE*/ if (irreco_theme_creator_dlg_run(GTK_WINDOW(self), self->irreco_data, new_theme)) { -- 2.11.4.GIT