0

I'm writing a vala GTK+ application and want to add a modal dialog like this:

var dialog = new Gtk.Dialog.with_buttons (_("My title"), this,
    Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
    _("Yes"),
    Gtk.ResponseType.OK,
    _("No"),
    Gtk.ResponseType.NO,
    null);

The dialog appears and behaves correctly, but the title is missing. Any idea why? Anything special about gala? I couldn't find any mention of this problem on the web so far.

I'm on a clean installation of elementary OS 5 Juno.

MCVE in Application.vala:

public void show_dialog(Gtk.Window window) {
  var dialog = new Gtk.Dialog.with_buttons ("My title", window,
      Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
      "Yes",
      Gtk.ResponseType.OK,
      "No",
      Gtk.ResponseType.NO,
      null);

  dialog.response.connect((response_id) => {
    dialog.close();
  });

  dialog.show_all ();
}

int main (string[] args) {
  Gtk.init (ref args);

  var window = new Gtk.Window ();
  window.title = "First GTK+ Program";
  window.border_width = 10;
  window.window_position = Gtk.WindowPosition.CENTER;
  window.set_default_size (350, 70);
  window.destroy.connect (Gtk.main_quit);

  var button = new Gtk.Button.with_label ("Click me!");
  button.clicked.connect (() => {
    show_dialog(window);
  });

  window.add (button);
  window.show_all ();

  Gtk.main ();
  return 0;
}

Compiled with valac --pkg gtk+-3.0 Application.vala results in this dialog displayed when I click the button:

enter image description here

5
  • I get the impression that this is not the best place to ask this, any recommendation welcome. – berliner Jul 12 '19 at 10:06
  • Could you post an MCVE? – theGtknerd Jul 14 '19 at 12:53
  • @theGtknerd Sure, I have updated my question. Let me know if this is sufficent. I am very new to both GTK and vala, so it is definitely possible that I missed something obvious. – berliner Jul 14 '19 at 16:21
  • In Linux Mint 19 Cinnamon edition, the dialog shows the title My title correctly, so I expect/assume your window manager is actually at fault. You could try changing your dialog flags so that the dialog is a separate window (or etc) to verify this. – theGtknerd Jul 15 '19 at 2:18
  • @theGtknerd Thanks for looking into it. I already tried different dialog flags, but it doesn't seem to affect the title at all. I kind of assumed it to be related to elementary OS and gala, which is why I was asking here instead of a more generic forum. – berliner Jul 15 '19 at 7:42

Your Answer

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

Browse other questions tagged or ask your own question.