Skip to content

Commit

Permalink
libaudgui: Make label in dialog selectable
Browse files Browse the repository at this point in the history
Especially useful for error dialogs. Audacious' scrobbler plugin for example
includes a long Last.fm URL in the text which nobody wants to type by hand.
  • Loading branch information
radioactiveman committed Jan 13, 2024
1 parent c67afc5 commit 6741ccc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libaudgui/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,13 @@ EXPORT void audgui_file_entry_set_uri (GtkWidget * entry, const char * uri)
gtk_editable_set_position ((GtkEditable *) entry, -1);
}

static void set_label_wrap (GtkWidget * label, void *)
static void set_label_properties (GtkWidget * label, void *)
{
if (GTK_IS_LABEL (label))
{
gtk_label_set_selectable ((GtkLabel *) label, true);
gtk_label_set_line_wrap_mode ((GtkLabel *) label, PANGO_WRAP_WORD_CHAR);
}
}

#ifdef USE_GTK3
Expand Down Expand Up @@ -287,7 +290,7 @@ EXPORT GtkWidget * audgui_dialog_new (GtkMessageType type, const char * title,
gtk_window_set_role ((GtkWindow *) dialog, "message");

GtkWidget * box = gtk_message_dialog_get_message_area ((GtkMessageDialog *) dialog);
gtk_container_foreach ((GtkContainer *) box, set_label_wrap, nullptr);
gtk_container_foreach ((GtkContainer *) box, set_label_properties, nullptr);

#ifdef USE_GTK3
const char * icon = icon_for_message_type (type);
Expand Down

0 comments on commit 6741ccc

Please sign in to comment.