aboutsummaryrefslogtreecommitdiff
path: root/dragon.c
diff options
context:
space:
mode:
authorFichteFoll <fichtefoll2@googlemail.com>2019-05-08 06:01:01 +0200
committerFichteFoll <fichtefoll2@googlemail.com>2019-05-08 14:49:01 +0200
commitd254f693f5da34b8e0493c99999efa0d55494a20 (patch)
treeb40e8de2d6fa45bd787c5df92ed5ddd61ffb3ca1 /dragon.c
parentUnify whitespace (to spaces) (diff)
downloaddragon-d254f693f5da34b8e0493c99999efa0d55494a20.tar.gz
dragon-d254f693f5da34b8e0493c99999efa0d55494a20.tar.bz2
dragon-d254f693f5da34b8e0493c99999efa0d55494a20.zip
Remove deprecated gtk_button_set_alignment call
The recommended method is to set the child's `halign` property. However, because our button has two children that automatically get wrapped in a GtkAlignment container, we need to set the alignment of that child after the image and the label have been added. Also fix an assertion failure when no icon could be found for a file.
Diffstat (limited to 'dragon.c')
-rw-r--r--dragon.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/dragon.c b/dragon.c
index 869c118..f66fb46 100644
--- a/dragon.c
+++ b/dragon.c
@@ -107,8 +107,8 @@ void drag_data_get(GtkWidget *widget,
}
GtkButton *add_button(char *label, struct draggable_thing *dragdata, int type) {
- GtkWidget *button = gtk_button_new();
- gtk_button_set_label(GTK_BUTTON(button), label);
+ GtkWidget *button = gtk_button_new_with_label(label);
+
GtkTargetList *targetlist = gtk_drag_source_get_target_list(GTK_WIDGET(button));
if (targetlist)
gtk_target_list_ref(targetlist);
@@ -152,13 +152,18 @@ void add_file_button(char *filename) {
GIcon *icon = g_file_info_get_icon(fileinfo);
GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon(icon_theme,
icon, 48, 0);
- gtk_button_set_image(button,
- gtk_image_new_from_pixbuf(
- gtk_icon_info_load_icon(icon_info, NULL)
- ));
- gtk_button_set_alignment(button, 0, 0);
- gtk_button_set_always_show_image(button, true);
+ if (icon_info) {
+ GtkWidget *image = gtk_image_new_from_pixbuf(
+ gtk_icon_info_load_icon(icon_info, NULL));
+ gtk_button_set_image(button, image);
+ gtk_button_set_always_show_image(button, true);
+ }
+
+ GList *child = g_list_first(
+ gtk_container_get_children(GTK_CONTAINER(button)));
+ if (child)
+ gtk_widget_set_halign(GTK_WIDGET(child->data), GTK_ALIGN_START);
}
void add_uri_button(char *uri) {
bgstack15