0

Is there a way to right align the secondary text on the welcome widget. I have a rather longish secondary text (attached screenshot) and the text will look better if the left margin is aligned rather then the centering of the text.

Also is there a way to break the text into two paragraphs. Here is the code snippet, I use - standard way to create the welcome widget.

Granite.Widgets.Welcome welcome = new Granite.Widgets.Welcome (
    NuttyApp.Constants.PRIMARY_TEXT_FOR_DISCLAIMER,   
    NuttyApp.Constants.SECONDARY_TEXT_FOR_DISCLAIMER
);

The complete code is here on GitHub.

Thanks in advance for the help.

enter image description here

2

You might be out of luck here. Granite.Widgets.Welcome does not have an API for that.

Here's an approach that might still work: Granite.Widgets.Welcome is a subclass of Gtk.Bin containing a Gtk.Grid. To get at the label you should first get the grid using Granite.Widgets.Welcome.get_child () and then search for the label inside that grid using Gtk.Grid.get_children () which returns a list of all children. In that list you should find your desired label. To align the text to the left, just set that_label.justify = Gtk.Justification.LEFT.

However, you really should not do this. Granite.Widgets.Welcome is not meant for this purpose. It should contain short headings and everything that goes further should not be included here.

I would suggest using a Gtk.Dialog with a "Do not show again" tick box that pops up on startup instead.

  • Thanks for the workaround, will try that. It seems logical. I did have a dialogue before with “remember the decision” but the welcome looks a better experience since I have a URL as part of the text and granite link urls with the icon looks so much better... – Siddhartha Das Apr 28 '18 at 7:07
  • Just in case someone else needs this, here is the code snippet: //Format welcome secondary text Grid welcome_grid = (Grid) welcome.get_child (); GLib.List<weak Gtk.Widget> welcome_widgets = welcome_grid.get_children (); foreach(Widget aWelcomeWidget in welcome_widgets){ debug(aWelcomeWidget.get_path().to_string()); //grab the secondary text label if(aWelcomeWidget.get_path().to_string().contains("GtkLabel") && aWelcomeWidget.get_path().to_string().contains("h2")) { ((Label)aWelcomeWidget).justify = Gtk.Justification.LEFT; break; } } – Siddhartha Das Apr 28 '18 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.