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



On 20 August 2012 17:07, Jasper St. Pierre <jstpierre mecheye net> wrote:
> 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.
>
Oh, I see. The main reason is that on GNOME 3.4 I'm happy for all
configuring to be done via gnome-shell-extension-prefs but on GNOME
3.2 would like configuring to be done via the drop down menu from the
status icon (since it'll have one anyway). However I'm after a few
more complex widgets that won't work in PopupMenu (like Gtk TreeView),
so have to work out how to get the TreeView happening from the
PopupMenu for the GNOME 3.2 folk (I know 3.2 is going out of fashion
pretty quickly due to 3.5 coming out, but I personally am going to be
stuck on 3.2 for at least another year at work so it's important for
me that extensions work on the computer I spend the most time on!)

So the options for getting (e.g.) Gtk.TreeView from a PopupMenu/GNOME
3.2 (I mainly want to use it as a list box where each item is
editable; the add/remove functions are not important), what I've
thought of so far:

* a PopupMenuItem ("Prefs") launches a GTK widget with the TreeView in
it - I now know it will have to spawn an external process to do so.
* make a PopupMenuItem for *each* of the entires that I wanted in my
TreeView, and say clicking them brings up a modalDialog with a
St.Entry for the user to enter in a new name
* a PopupMenuItem ("Prefs") brings up a modal dialog where there's one
non-editable St.Entry for each of the entries and perhaps a St.Button
next to each ("Edit") that allows me to edit each entry

Are these basically my only options? (I think the
St.Entry/PopupMenuItem-per-entry solution feels pretty cludgy).

> 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]