Skip to content

Commit a43ff4b

Browse files
committed
[Fix] - Image Horizontal
Changed the way images are placed within the application. Issues ----------- The images are displayed in the bottom with buttons, and not in the centre of view.
1 parent 571222f commit a43ff4b

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/gtk_gui.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,29 @@ static void activate(GtkApplication *app, gpointer user_data)
151151
// include box container in window
152152
gtk_window_set_child(GTK_WINDOW(window), box);
153153

154-
// create new horizontal box container for user image
155-
user_image_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
156-
gtk_widget_set_halign(user_image_box, GTK_ALIGN_CENTER);
157-
gtk_widget_set_valign(user_image_box, GTK_ALIGN_CENTER);
158-
gtk_widget_set_margin_bottom(user_image_box, 20);
159-
// append user image box to vertical box
160-
gtk_box_append(GTK_BOX(box), user_image_box);
161-
// create image widget
154+
// create new horizontal box container for both user and filtered images
155+
GtkWidget *image_container = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
156+
gtk_widget_set_halign(image_container, GTK_ALIGN_CENTER);
157+
gtk_widget_set_valign(image_container, GTK_ALIGN_CENTER);
158+
gtk_widget_set_margin_bottom(image_container, 20);
159+
// append image container to vertical box
160+
gtk_box_append(GTK_BOX(box), image_container);
161+
162+
// create image widget for user image
162163
image = gtk_image_new_from_file("assets/images/test_image.bmp");
163164
gtk_image_set_pixel_size(GTK_IMAGE(image), 250);
164-
// append user image widget to user image box
165-
gtk_box_append(GTK_BOX(user_image_box), image);
166-
167-
// create new horizontal box container for filtered image
168-
filtered_image_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
169-
gtk_widget_set_halign(filtered_image_box, GTK_ALIGN_CENTER);
170-
gtk_widget_set_valign(filtered_image_box, GTK_ALIGN_CENTER);
171-
gtk_widget_set_margin_bottom(filtered_image_box, 20);
172-
// append filtered image box to vertical box
173-
gtk_box_append(GTK_BOX(box), filtered_image_box);
174-
// create image widget
165+
// Set horizontal alignment to center
166+
gtk_widget_set_halign(image, GTK_ALIGN_CENTER);
167+
// append user image widget to image container
168+
gtk_box_append(GTK_BOX(image_container), image);
169+
170+
// create image widget for filtered image
175171
image = gtk_image_new_from_file("assets/images/test_image.bmp");
176172
gtk_image_set_pixel_size(GTK_IMAGE(image), 250);
177-
// append user image widget to filtered image box
178-
gtk_box_append(GTK_BOX(filtered_image_box), image);
173+
// Set horizontal alignment to center
174+
gtk_widget_set_halign(image, GTK_ALIGN_CENTER);
175+
// append filtered image widget to image container
176+
gtk_box_append(GTK_BOX(image_container), image);
179177

180178
// create new horizontal box container for buttons
181179
button_box0 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);

0 commit comments

Comments
 (0)