From 2025dea7b834f123832d8678343067f920c94ff2 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 31 Jul 2024 18:06:30 +0600 Subject: [PATCH] Test fix for RAM --- source/ubinstall-gtk.c | 94 ++++++------ source/ubinstall-gtk.h | 2 +- ubinstall-gtk.glade | 316 ++++++++++++----------------------------- 3 files changed, 143 insertions(+), 269 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 205ef12..00012c7 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -778,31 +778,37 @@ void on_configuration_mode_switch(GtkWidget *self){ main_config.configure_mode = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(self)); } +int cur_slide=0; + int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled); -int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled){ - - int width = gtk_widget_get_allocated_width(gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(target)))); - int height = gtk_widget_get_allocated_height(gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(target)))); - yon_debug_output("width: %s\n",yon_char_from_int(width)); - yon_debug_output("height: %s\n\n",yon_char_from_int(height)); - int newImgWidthDef = (width <= 217) ? width : width - 30; - int newImgHeightDef = (height <= 120) ? height : height - 217; - GdkPixbuf *pixBuf = pixbuf_unscaled; - int newImgHeight = (int)(gdk_pixbuf_get_height(pixBuf) / ((double) gdk_pixbuf_get_width(pixBuf) / newImgWidthDef)); - if (newImgHeight > newImgHeightDef) { - newImgHeight = newImgHeightDef; - newImgWidthDef = newImgWidthDef; - } - int newImageWidth = (int)(gdk_pixbuf_get_width(pixBuf) / ((double) gdk_pixbuf_get_height(pixBuf) / newImgHeight)); - GdkPixbuf *scaledPixBuf = gdk_pixbuf_scale_simple(pixBuf, abs(newImageWidth), abs(newImgHeight), GDK_INTERP_BILINEAR); - gtk_image_set_from_pixbuf(target, scaledPixBuf); +int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled) { + int width = gtk_widget_get_allocated_width(gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(target)))); + int height = gtk_widget_get_allocated_height(gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(target)))); + + int newImgWidthDef = (width <= 217) ? width : width - 30; + int newImgHeightDef = (height <= 120) ? height : height - 217; + + int originalWidth = gdk_pixbuf_get_width(pixbuf_unscaled); + int originalHeight = gdk_pixbuf_get_height(pixbuf_unscaled); + int newImgHeight = (int)(originalHeight / ((double) originalWidth / newImgWidthDef)); + + if (newImgHeight > newImgHeightDef) { + newImgHeight = newImgHeightDef; + newImgWidthDef = (int)(originalWidth / ((double) originalHeight / newImgHeight)); + } + int newImageWidth = (int)(originalWidth / ((double) originalHeight / newImgHeight)); + + GdkPixbuf *scaledPixBuf = gdk_pixbuf_scale_simple(pixbuf_unscaled, newImageWidth, newImgHeight, GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(target, scaledPixBuf); + + g_object_unref(scaledPixBuf); // Освобождаем память, занятую скалированным изображением return 1; } void on_region_resized(GtkWidget *,main_window *widgets); void on_region_resized(GtkWidget *,main_window *widgets){ - yon_image_resize_from_container(GTK_IMAGE(widgets->SlidesImage), widgets->slides_original); + yon_image_resize_from_container(GTK_IMAGE(widgets->SlidesImage), widgets->slides_original[cur_slide]); yon_image_resize_from_container(GTK_IMAGE(widgets->RegionImage), widgets->regions_original); yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); } @@ -821,35 +827,32 @@ void yon_switch_page_render(main_window *widgets, int page){ GList *list = gtk_container_get_children(parent); for (guint i=0;islides_original); - widgets->slides_original = gdk_pixbuf_new_from_resource_at_scale(target[cur_slide],600,400,1,NULL); if (size) yon_char_parsed_free(target,size); - GtkWidget *parent = gtk_widget_get_parent(widgets->SlidesImage); - gtk_widget_destroy(widgets->SlidesImage); - widgets->SlidesImage = gtk_image_new(); - gtk_container_add(GTK_CONTAINER(parent),widgets->SlidesImage); - gtk_widget_show(widgets->SlidesImage); - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),widgets->slides_original); + // GtkWidget *parent = gtk_widget_get_parent(widgets->SlidesImage); + // gtk_widget_destroy(widgets->SlidesImage); + // widgets->SlidesImage = gtk_image_new(); + // gtk_container_add(GTK_CONTAINER(parent),widgets->SlidesImage); + // gtk_widget_show(widgets->SlidesImage); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),widgets->slides_original[cur_slide]); gtk_widget_queue_draw(widgets->SlidesImage); if (cur_slideHostnameSensitiveCheck),"toggled",G_CALLBACK(on_autohostname_sensitiveness_check),widgets); g_signal_connect(G_OBJECT(widgets->AutoHostnameCheck),"toggled",G_CALLBACK(on_autohostname_check),widgets); g_signal_connect(G_OBJECT(widgets->HotnameEntry),"changed",G_CALLBACK(on_hostname_entry_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->InstallationToggle),"toggled",G_CALLBACK(on_toggle_block),widgets); + g_signal_connect(G_OBJECT(widgets->InstallationToggle),"toggled",G_CALLBACK(on_toggle_block),widgets); gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter),0); @@ -2217,15 +2221,21 @@ main_window *yon_main_window_complete(){ yon_char_parsed_free(parsed,size); } + config_str slides = yon_char_parsed_new(&size,slide_repeat_path); widgets->regions_original = gdk_pixbuf_new_from_resource(regions_path,NULL); widgets->keyboard_original = gdk_pixbuf_new_from_resource(keyboard_path,NULL); - widgets->slides_original = gdk_pixbuf_new_from_resource(slide_0_path,NULL); + widgets->slides_original = malloc(sizeof(GdkPixbuf*)*size); + widgets->slides_original[0] = gdk_pixbuf_new_from_resource(slide_0_path,NULL); + for (int i=1;islides_original[i] = gdk_pixbuf_new_from_resource(slides[i-1],NULL); + } + yon_char_parsed_free(slides,size); int width = gdk_pixbuf_get_width(widgets->regions_original); int height = gdk_pixbuf_get_height(widgets->regions_original); widgets->region_height_mult = (float)height/width; gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->RegionImage),gdk_pixbuf_scale_simple(widgets->regions_original,600,400,GDK_INTERP_BILINEAR)); gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->KeyboardImage),gdk_pixbuf_scale_simple(widgets->keyboard_original,600,400,GDK_INTERP_BILINEAR)); - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),gdk_pixbuf_scale_simple(widgets->slides_original,600,400,GDK_INTERP_BILINEAR)); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),gdk_pixbuf_scale_simple(widgets->slides_original[0],600,400,GDK_INTERP_BILINEAR)); GtkTreeIter iter; gtk_list_store_clear(widgets->LanguagesList); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 9ae3adb..cade5bc 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -352,7 +352,7 @@ typedef struct { GdkPixbuf *regions_original; GdkPixbuf *keyboard_original; - GdkPixbuf *slides_original; + GdkPixbuf **slides_original; float region_height_mult; GtkWidget *RegionSensitiveCheck; diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index efdf931..cf85e90 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -1601,7 +1601,11 @@ and help you install UBLinux on your computer - + + True + False + Region: + @@ -1621,18 +1625,6 @@ and help you install UBLinux on your computer False 15 5 - - - True - False - Region: - - - False - True - 0 - - True @@ -1730,7 +1722,11 @@ and help you install UBLinux on your computer - + + True + False + Available languages in the system: + @@ -1739,18 +1735,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Available languages in the system: - - - False - True - 1 - - True @@ -1801,7 +1785,11 @@ and help you install UBLinux on your computer True - + + True + False + Language: + @@ -1810,18 +1798,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Language: - - - False - True - 1 - - True @@ -1938,7 +1914,11 @@ and help you install UBLinux on your computer True - + + True + False + Keyboard model: + @@ -1947,18 +1927,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Keyboard model: - - - False - True - 1 - - True @@ -1996,7 +1964,11 @@ and help you install UBLinux on your computer True - + + True + False + Layout changing: + @@ -2005,18 +1977,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Layout changing: - - - False - True - 1 - - True @@ -2351,7 +2311,12 @@ and help you install UBLinux on your computer True - + + True + False + Your account name: + 0 + @@ -2360,19 +2325,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Your account name: - 0 - - - False - True - 1 - - True @@ -2407,7 +2359,12 @@ and help you install UBLinux on your computer True - + + True + False + Login: + 0 + @@ -2416,19 +2373,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Login: - 0 - - - False - True - 1 - - True @@ -2463,7 +2407,12 @@ and help you install UBLinux on your computer True - + + True + False + Password + 0 + @@ -2472,19 +2421,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Password - 0 - - - False - True - 1 - - True @@ -2584,7 +2520,12 @@ and help you install UBLinux on your computer True - + + True + False + Administrator password (root): + 0 + @@ -2593,19 +2534,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Administrator password (root): - 0 - - - False - True - 1 - - True @@ -2670,7 +2598,12 @@ and help you install UBLinux on your computer False True - + + True + False + Computer name: + 0 + @@ -2679,19 +2612,6 @@ and help you install UBLinux on your computer 0 - - - True - False - Computer name: - 0 - - - False - True - 1 - - True @@ -3172,7 +3092,11 @@ or continue working in the UBLinux Live environment. True - + + True + False + Choose file system type for the section: + @@ -3181,18 +3105,6 @@ or continue working in the UBLinux Live environment. 0 - - - True - False - Choose file system type for the section: - - - False - True - 1 - - True @@ -3238,7 +3150,11 @@ or continue working in the UBLinux Live environment. True - + + True + False + Section name: + @@ -3247,18 +3163,6 @@ or continue working in the UBLinux Live environment. 0 - - - True - False - Section name: - - - False - True - 1 - - True @@ -3696,7 +3600,11 @@ installed. - + + True + False + Specify the size of the new partition for UBLinux OS: + @@ -3705,18 +3613,6 @@ installed. 0 - - - True - False - Specify the size of the new partition for UBLinux OS: - - - False - True - 1 - - True @@ -3779,7 +3675,11 @@ installed. True - + + True + False + Choose file system type for the section: + @@ -3788,18 +3688,6 @@ installed. 0 - - - True - False - Choose file system type for the section: - - - False - True - 1 - - True @@ -3861,7 +3749,11 @@ installed. True - + + True + False + Section name: + @@ -3870,18 +3762,6 @@ installed. 0 - - - True - False - Section name: - - - False - True - 1 - - True @@ -4313,7 +4193,11 @@ installed. True - + + True + False + Choose file system type for the section: + @@ -4322,18 +4206,6 @@ installed. 0 - - - True - False - Choose file system type for the section: - - - False - True - 1 - - True @@ -4395,7 +4267,11 @@ installed. True - + + True + False + Section name: + @@ -4404,18 +4280,6 @@ installed. 0 - - - True - False - Section name: - - - False - True - 1 - - True