gui: Add a function for determining the height of widgets
It's eaiser to do it in the builder code, rather than repeating this code in several places. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
1e59968154
commit
cbb9631877
|
@ -31,8 +31,7 @@ static inline void __audio_set_time_label(const gchar *label, unsigned int time)
|
||||||
static void __audio_set_cover(gchar *path)
|
static void __audio_set_cover(gchar *path)
|
||||||
{
|
{
|
||||||
GtkImage *image = GTK_IMAGE(gui_builder_widget("o_cover"));
|
GtkImage *image = GTK_IMAGE(gui_builder_widget("o_cover"));
|
||||||
GtkWidget *tags = gui_builder_widget("o_tags");
|
int height = gui_builder_widget_height("o_tags");
|
||||||
int height = gtk_widget_get_allocated_height(tags);
|
|
||||||
GdkPixbuf *pix = gdk_pixbuf_new_from_file_at_size(path, height,
|
GdkPixbuf *pix = gdk_pixbuf_new_from_file_at_size(path, height,
|
||||||
height, NULL);
|
height, NULL);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,11 @@ GtkWidget *gui_builder_widget(const char *name)
|
||||||
return GTK_WIDGET(gui_builder_object(name));
|
return GTK_WIDGET(gui_builder_object(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gui_builder_widget_height(const char *name)
|
||||||
|
{
|
||||||
|
return gtk_widget_get_allocated_height(gui_builder_widget(name));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_TESTING
|
#ifdef CONFIG_TESTING
|
||||||
GtkBuilder *test_get_gui_builder()
|
GtkBuilder *test_get_gui_builder()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,9 @@ GObject *gui_builder_object(const char *);
|
||||||
/* Called to get a widget from the GTK builder. */
|
/* Called to get a widget from the GTK builder. */
|
||||||
GtkWidget *gui_builder_widget(const char *);
|
GtkWidget *gui_builder_widget(const char *);
|
||||||
|
|
||||||
|
/* Called to find the height of a GTK builder widget. */
|
||||||
|
int gui_builder_widget_height(const char *);
|
||||||
|
|
||||||
#ifdef CONFIG_TESTING
|
#ifdef CONFIG_TESTING
|
||||||
GtkBuilder *test_get_gui_builder();
|
GtkBuilder *test_get_gui_builder();
|
||||||
#endif /* CONFIG_TESTING */
|
#endif /* CONFIG_TESTING */
|
||||||
|
|
|
@ -33,9 +33,11 @@ static void test_builder()
|
||||||
test_not_equal((void *)widget, NULL);
|
test_not_equal((void *)widget, NULL);
|
||||||
test_equal(GTK_IS_WIDGET(widget), true);
|
test_equal(GTK_IS_WIDGET(widget), true);
|
||||||
test_equal(GTK_IS_BUTTON(widget), true);
|
test_equal(GTK_IS_BUTTON(widget), true);
|
||||||
|
test_equal(gui_builder_widget_height("button1") > 0, true);
|
||||||
gtk_button_clicked(GTK_BUTTON(widget));
|
gtk_button_clicked(GTK_BUTTON(widget));
|
||||||
test_equal(gui_clicked, 1);
|
test_equal(gui_clicked, 1);
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_destroy(gui_builder_widget("window1"));
|
gtk_widget_destroy(gui_builder_widget("window1"));
|
||||||
gui_builder_deinit();
|
gui_builder_deinit();
|
||||||
test_equal((void *)test_get_gui_builder(), NULL);
|
test_equal((void *)test_get_gui_builder(), NULL);
|
||||||
|
|
Loading…
Reference in New Issue