Re: Launching a Gtk.Dialog from a gnome shell extension (not prefs.js)?



Due to the way the window manager works, it's not possible to pop up a
GTK+ window in-process. You can spawn the gnome-shell-extension-prefs
tool yourself, but I don't see why you would do that.

On Mon, Aug 20, 2012 at 3:00 AM, Amy C <mathematical coffee gmail com> wrote:
> Hi all,
>
> I'm writing an extension that is a port of another program which comes
> with a Gtk  .ui file defining a preferences dialog.
>
> Since the dialog is all already nicely defined for me in the .ui file,
> I'd like to use it for:
>
> * prefs.js (GNOME 3.4 version)
> * I click a menu item and the dialog gets launched (from extension.js
> in GNOME 3.2).
>
> Now I have succeeded in the first case (launching from prefs.js) but
> am having trouble with the second, because if I just do
> `dialog.show_all()` from `extension.js` on my loaded dialog, nothing
> happens.
>
> This is what I'm doing to load all the widgets in the UI
>
>     // load the UI - this is fine
>     let builder = new Gtk.Builder()
>     builder.add_from_file(GLib.build_filenamev([extensionPath,
> 'preferences.ui']));
>
> Now for prefs.js since this doesn't want a dialog but a widget to
> embed, I can query for the vbox that is the first child of the dialog
> in the UI file - it's called 'dialog-vbox1':
>
>     let widg = builder.get_object('dialog-vbox1');
>     widg.unparent();
>     widg.show_all();
>
> If I return `widg` from `buildPrefsWidget` in `prefs.js`, that shows
> up in gnome-shell-extension-prefs nicely.
>
> Now on to the second problem - in my extension there is a PopupMenu
> and clicking on one the items should launch the widget.
>
>     item.connect('activate', function () {
>         let dialog = builder.get_object('pager_properties_dialog'); //
> the top-level widget in the UI file
>          // TODO: ... connect up various events here ...
>         dialog.show_all();
>     });
>
> However, this doesn't work - nothing at all happens.
>
> Question - what do I do to get this dialog showing when launched from
> extension.js?
>
> I could re-implement the dialog into the PopupMenu but it seems like I
> could save a lot of work by just using the same UI file for
> everything.
>
> cheers!
> _______________________________________________
> gnome-shell-list mailing list
> gnome-shell-list gnome org
> https://mail.gnome.org/mailman/listinfo/gnome-shell-list



-- 
  Jasper


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