Re: Missing Gtk3::MessageDialog's format_secondary_text method?



hi;

the gtk_message_dialog_format_secondary_text() function is not
introspectable, because it takes a variadic arguments list.

not that you'd need it in Perl, tho, since it's just a wrapper around
g_strdup_printf(), and Perl has its own string formatting tools.

if you want to set the secondary-text property, you can pass the
secondary text as a constructor property:

  $primary = sprintf $primary_format, @primary_args;
  $secondary = sprintf $secondary_format, @secondary_args;
  $message_dialog = Glib::Object::new('Gtk3::MessageDialog', text =>
$primary, secondary_text => $secondary);

or you can use the Glib::Object::tie_property() function function to
automatically tie properties to values keys in the instance hash,
e.g.:

  $message_dialog->tie_properties;
  $message_dialog->{secondary_text} = sprintf 'foo %d', $value; #
shows the secondary text label
  $message_dialog->{secondary_text} = undef; # hides the secondary text label

as a side note: I'm a bit sad that we still need the overrides for the
constructors in Gtk3 just for porting reasons; I would actually make
them opt-in, and do what Python and JavaScript do for constructors —
i.e. just call Glib::Object::new with a bunch of property key/value
pairs. I understand that it makes porting from Gtk2 to Gtk3 mildly
easier, but it creates a disconnect with the other high level
languages, and it makes some functionality harder to implement.

ciao,
 Emmanuele.


On 12 August 2014 09:40, intrigeri <intrigeri debian org> wrote:
Hi,

intrigeri wrote (07 Jun 2014 12:45:17 GMT) :
(Gtk3 is 0.016, Glib::Object::Introspection is 0.023-1)

FTR, I can still reproduce this with Gtk3 0.017 and G::O::I 0.024.

I get this error:

    Can't locate object method "format_secondary_text" via package "Gtk3::MessageDialog"

... with that program:

    use strict;
    use warnings FATAL => 'all';

    use Gtk3 qw{-init};

    my $main_window = Gtk3::Window->new('toplevel');

    my $dialog = Gtk3::MessageDialog->new(
        $main_window, 'destroy-with-parent', 'error', 'ok', "title"
    );

    $dialog->format_secondary_text("bla");

Am I doing anything wrong, or are there some bits missing somewhere?
Note that it works just fine if I replace the call to the
format_secondary_text method with:

    $dialog->set('secondary_text' => "bla");

Thanks in advance!

Cheers,
--
intrigeri
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list



-- 
http://www.bassi.io
[ ] ebassi [ gmail com]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]