I am not sure if this is the best Title, but I will try to explain.
I am creating a LinkButton with the following:
gtk_link_button_new_with_label ( "Gnome", "https://www.discourse.gnome.org/" );
And the Label “Gnome” does not get set on the LinkButton.
It has the same effect as I create the LinkButton with:
gtk_link_button_new ( "https://www.discourse.gnome.org/" );
The only difference is that, if I create the LinkButton with Label the Tooltip does set to"Gnome" but the Label not.
The only thing which seems to work is if I set its Propertie:
g_object_set( linkButton, "label", "GTK", NULL );
Linux Mint 19.2 Tina
GCC 9.2.1
GTK 3.22.30
Here is the Code I use:
#include <gtk/gtk.h>
void load_css ( void );
GtkWidget *createWindow ( const gint width, const gint height, const gchar *const title );
GtkWidget *createGrid ( gboolean row, gboolean col );
int main ( void )
{
GtkWidget *window;
GtkWidget *grid;
GtkWidget *linkButton;
/// ***
gtk_init ( NULL, NULL );
load_css();
/// ***
window = createWindow ( 300, 300, "My App" );
/// ***
grid = createGrid ( FALSE, TRUE );
gtk_container_add ( GTK_CONTAINER ( window ), grid );
/// ***
linkButton = gtk_link_button_new_with_label ( "Gnome", "https://www.discourse.gnome.org/" );
///g_object_set( linkButton, "label", "GTK", NULL );
/// ***
gtk_container_add ( GTK_CONTAINER ( grid ), linkButton );
/// ***
gtk_widget_show_all ( window );
gtk_main ();
}
void load_css ( void )
{
GtkCssProvider *provider;
GdkDisplay *display;
GdkScreen *screen;
/// ***
const gchar *css_style_file = "style.css";
GFile *css_fp = g_file_new_for_path ( css_style_file );
GError *error = 0;
/// ***
provider = gtk_css_provider_new ();
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen ( display );
/// ***
gtk_style_context_add_provider_for_screen ( screen, GTK_STYLE_PROVIDER ( provider ), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION );
gtk_css_provider_load_from_file ( provider, css_fp, &error );
/// ***
}
GtkWidget *createWindow ( const gint width, const gint height, const gchar *const title )
{
GtkWidget *window;
window = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
gtk_window_set_title ( GTK_WINDOW ( window ), title );
g_signal_connect ( window, "destroy", gtk_main_quit, window );
gtk_window_set_default_size ( GTK_WINDOW ( window ), width, height );
gtk_container_set_border_width ( GTK_CONTAINER ( window ), 25 );
return window;
}
GtkWidget *createGrid ( gboolean row, gboolean col )
{
GtkWidget *grid = gtk_grid_new ();
/// ***
gtk_grid_set_row_homogeneous ( GTK_GRID ( grid ), row );
gtk_grid_set_column_homogeneous ( GTK_GRID ( grid ), col );
/// ***
return grid;
}
Based of its properies the GtkLinkButton does not have the Label properties, this means if I understand right that There is no Label for this LinkButton.
I thought there is something like Setting the “uri” and settings the “uri label” as well.
This means that the following call:
g_object_set( linkButton, "label", "GTK", NULL );
Changes the Link of the button.
I was thinkong that the LinkButton behaves like : s
gtk_link_button_set_uri()
and:
gtk_link_button_set_uri_label()
But it does not.