Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System Tray #363

Closed
ccoupe opened this issue Jul 29, 2017 · 11 comments
Closed

System Tray #363

ccoupe opened this issue Jul 29, 2017 · 11 comments
Labels
Milestone

Comments

@ccoupe
Copy link

ccoupe commented Jul 29, 2017

via shoes/shoes-deprecated#285

see https://docs.oracle.com/javase/tutorial/uiswing/misc/systemtray.html

Currently I have no idea if or how Shoes can do this cross platform.
For Gtk and note the deprecation in 3.14

This is a more Shoes Amenable gtk class

@ccoupe
Copy link
Author

ccoupe commented Jul 31, 2017

OSX - Start here . There will be an api somewhere.
Like
They seem similar enough so there could be a Shoes LCD way, there are Shoes design issues to think through. Shoes needs a widget/class to attach it's callback/blocks and configure manipulate and not be a Shoes GUI widget with a canvas.

For example, we could create a NotifyOS non gui class ( like SvgHandle is). Perhaps we could move some of those Shoes.app.methods like fullscreen or set_app_icon into that class (or ancestor class). I'm starting to really like this idea although it's huge amount of work.

@ccoupe
Copy link
Author

ccoupe commented Aug 1, 2017

As expected, unification of the two apis Cocoa and Gtk is going to result in a skinny set of features - No replies so there's no need to deal with buttons in notifications. Title, subtitle, icon/image would be the only arguments. Something like

  OsNotify.new("My Bot", "responded to a tweet",   "#{DIR}/images/done.png")

Is that useful? Could be, I guess. Opinions?

It could be paired with an alert or confirm to be more useful for some designs:

  OsNotify.new("Long Running Solver", "needs your attention")
  if confirm("continue solution generation"
     find_solution
  else
    clean_up
   Shoes.quit
end

That would be suspend the Shoes gui threads until you get it front and center and deal with the dialog. Is that sufficient?

FWIW, more advanced notification things require that Shoes implement/become a GApplication (linux, windows) which is a big deal and would probably require using Gtk3 on OSX. If possible.

@IanTrudel
Copy link
Collaborator

The proposed API doesn't feel Shoes-like, especially using it with new keyword. osnotify is descriptive but not great. Notification/Tray is actually considered a GUI component as it includes a visual representation of itself. Other than that, adding the feature seems like a good idea.

What do you think of systray ?

   systray("Long Running Solver", "needs your attention") # ordered parameters
   systray title: "Long Running Solver", notification: "needs your attention"

@ccoupe
Copy link
Author

ccoupe commented Aug 1, 2017

What do you think of systray ?

systray is fine with me and it is more Shoes like even though there will not be a Shoes visible GUI widget to back it - it's really just a message to the desktop manager - function call if you will. Thanks for the feedback. It's a good opportunity for me to really work with our/your refactoring of the C code.

ccoupe pushed a commit that referenced this issue Aug 1, 2017
* mostly a git branch initial commit thing.
  don't expect to to compile. It's a branch!
ccoupe pushed a commit that referenced this issue Aug 2, 2017
* have a test script
* gdb verified that shoes_systray_new is called and the c strings
  are extracted
* the icon_path will be tricky - ignore for now.
@ccoupe
Copy link
Author

ccoupe commented Aug 3, 2017

Sadly, I missed seeing. So, my simple scheme isn't going to work. GApplication (or GtkApplication) is not something Shoes is written to deal with. Implementing GtkApplication is a big deal. It affects main loop and command line handling, ruby init changes, quite possibly packaging changes. A lot of work. There's probably some other downsides I haven't thought of.

On the positive side of GtkApplication is systray, obviously, but also dbus compatiblty (for linux), better control of gtk resources (like themes). We also get something to hang menus on, if we had them. Because of the code changes to main.c.//world.c/app.c/shoes.rb then we might as well just use the Gtk3 for OSX and dump cocoa.m.

@ccoupe
Copy link
Author

ccoupe commented Aug 4, 2017

As I often the case, things could be a little easier that I expected. On branch systray, replace gtk_init () in shoes/native/gtk.c (shoe_native_init) with a call to gtk_application_new and setup a a call back for the 'activate' signal. systray is working (linux) and so far other Shoes things appear normal.

Windows however is complaing with a couple of gtk errors and a crash when running the systray test.

@ccoupe ccoupe removed the Enhancement label Aug 5, 2017
@ccoupe ccoupe added this to the 3.3.4 milestone Aug 5, 2017
@ccoupe
Copy link
Author

ccoupe commented Aug 5, 2017

The windows problem with calling 'gtk_application_new' is that it ignores the given argc/argv and and re-reads the windows command line args (from cshoes.exe) - documented. The proper fix requires work and understanding and should be done.

That said, there is a workaround for Windows - the deprecated in Gtk 3.14 GtkStatusIcon. It does work - Windows systray is not as clever as GNotification or Cocoa. but it works!

ccoupe pushed a commit that referenced this issue Aug 5, 2017
* replace gtk_init with gtk_new_application. Linux can run systray test
* xwin7 complains about the command line
* xwin7 systray crashes because app setup failed.
ccoupe pushed a commit that referenced this issue Aug 5, 2017
* uses older gtk_status_icon calls
* saves a copy for sequent calls (updates) which matches the
  linux GNotification behavior.
ccoupe pushed a commit that referenced this issue Aug 5, 2017
* type check the args
* add some Ruby garbage collection thinking.
* update the manual
* needs osx
ccoupe pushed a commit that referenced this issue Aug 5, 2017
@ccoupe
Copy link
Author

ccoupe commented Aug 5, 2017

Shoes Windows beta 3.3.4 with systray

@ccoupe ccoupe added Normal and removed Wishlist labels Aug 5, 2017
ccoupe pushed a commit that referenced this issue Aug 6, 2017
* OSX is working
* Will revisit the windows to see if I can use the newer code in GTK
ccoupe pushed a commit that referenced this issue Aug 7, 2017
* Shoes/Windows can use gtk_application_new. Linux is fine too.
  implement command-line signal-handler. Goodbye gtk_init.
* Windows/Gtk can not use the GNotifican code so it uses the status_icon.
* clean up code and comments and #ifdefs
@IanTrudel
Copy link
Collaborator

What do you think of the new approach for implementing types/native widgets so far?

@ccoupe
Copy link
Author

ccoupe commented Aug 23, 2017

What do you think of the new approach for implementing types/native widgets so far?

I like it now that rake file is more intelligent about what to compile.

@ccoupe
Copy link
Author

ccoupe commented Aug 24, 2017

There's a Shoes 3.3.4 beta

@ccoupe ccoupe closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants