0

I need to resize a GtkMessageDialog in php to have enough space for long string (dont want a new line)!

Create it:

$dialog = new GtkMessageDialog($this->window, Gtk::DIALOG_MODAL, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, "");

Set the message output:

$message = "I NEED A LONG STRING TO DISPLAY IN THE DIALOG\n"
$dialog->set_markup($message);

How its possible to adjust the dialog size? (the string should fit in one line)

Thanks and greets

leon22

leon22
  • 5,280
  • 19
  • 62
  • 100

1 Answers1

0

If I am correct you do not want to use new lines in order to increase the height of the dialog window.

There is no difference how to do it, it is the same as with all other widgets, just use the set_size_request method. Also whenever you have such problem just tell php to get what methods are there avaiable.

So for this example you would use this to get all methods:

file_put_contents("out.txt",print_r(get_class_methods($dialog),true));

This is a full example that set the size as you want it:

<?php
$window = new GtkWindow();
$window->set_size_request(400, 600);
$window->connect_simple('destroy', array('Gtk','main_quit'));

$message = '<b>DO I NEED</b> A LONG STRING TO <b><span foreground="blue"> '.
"DISPLAY IN THE DIALOG?</span></b>\n";

$dialog = new GtkMessageDialog($window, Gtk::DIALOG_MODAL, 
Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, null); 

$dialog->set_size_request(600,400);
$dialog->set_markup($message);

$answer = $dialog->run();
$dialog->destroy(); 

if ($answer == Gtk::RESPONSE_YES) 
    echo "So I need it.";
else if ($answer == Gtk::RESPONSE_NO) 
    echo "I see, I don't need it.";
else 
    echo "Choose something.";

$window->show_all();
Gtk::main();
?>
Melsi
  • 1,462
  • 1
  • 15
  • 21