chdkptp GTK gui (was Re: chdkptp - alternative ptp client) - General Discussion and Assistance - CHDK Forum

chdkptp GTK gui (was Re: chdkptp - alternative ptp client)

  • 11 Replies
  • 853 Views
*

Offline philmoz

  • *****
  • 3332
    • Photos
chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« on: 01 / October / 2020, 17:18:54 »
Advertisements
Out of curiosity, did you run into something that requires to you use 5.3? The current recommended process using misc/setup-ext-libs.bash should be completely self contained without dependency on system installed Lua.


IUP/CD have not worked on MacOS for a long time and I have not been able to get them to build from source.
I was going to see if I could create an alternative GUI using GTK3 and LGI; but I could not get LGI to work with Lua 5.2 on MacOS.
Since LGI works with 5.3 it seemed easier to fix chdkptp first.

Edit: some progress - basic UI conversion is not too difficult.

Phil.

« Last Edit: 02 / October / 2020, 03:15:11 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #1 on: 05 / October / 2020, 01:14:53 »
Patch for chdkptp GTK GUI.

Also includes a fix for what I believe is a typo in gui_live.lua (line 394).

I think everything works except file drag and drop onto the file list (haven't figured that one out yet).

Tested on:
- MacOS 10.15.7 with Lua 5.3.5 and LGI 0.9.2-1
- LMDE4 with Lua 5.3.3 and LGI 0.9.2-1

I implemented this by creating copies of the gui Lua files with different names and then loading the appropriate files as needed. There may be a better way to do this. There may also be some common code that could be re-factored out to simplify things between the versions.

To enable, add GTK_SUPPORT=1 to config.mk (and set IUP_SUPPORT and CD_SUPPORT to 0), then rebuild.

I really did this so I could have the chdkptp GUI in MacOS, if you don't think this should be part of the main chdkptp distribution that's fine.

Phil.
« Last Edit: 05 / October / 2020, 02:06:40 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #2 on: 05 / October / 2020, 21:23:54 »
Updated patch to remove Lua 5.3 changes already in trunk, and some minor bug fixes.


Phil.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #3 on: 06 / October / 2020, 23:47:15 »
Nearly half of the gui_live.lua / gtk_gui_live.lua code does not depend on the GUI system being used.

This new patch splits out that code to a new file gui_live_common.lua which the other files can use.

There is probably a better way to do this - let me know if you prefer some other method.

Should I create a branch in SVN for this?

Phil.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline reyalp

  • ******
  • 13353
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #4 on: 07 / October / 2020, 00:36:35 »
Nearly half of the gui_live.lua / gtk_gui_live.lua code does not depend on the GUI system being used.

This new patch splits out that code to a new file gui_live_common.lua which the other files can use.

There is probably a better way to do this - let me know if you prefer some other method.
Having only skimmed it, I would be tempted to treat gui_live_common more like a base class, so you don't have to keep track of what's in m vs l.

The simplest way would be to just do
Code: [Select]
m=require'gui_live_common'
and then add your additional fields / functions to m. This would also give the option of making more things generic, so for example the logic of redraw_canvas could be common, calling implementation specific functions to do the drawing.

(there are more OOPish ways you could do this, but we really only expect one implementation to run in a given chdkptp instance)

Quote
Should I create a branch in SVN for this?
If you want. I invited you to the chdkptp project.

edit:
I should mention an alternative to making the code common: The current GUI is, essentially, a proof of concept I massaged to be usable. It's not particularly well organized or designed. So rather than re-implementing the existing tabs, controls etc you could just make an entirely separate GUI.
« Last Edit: 07 / October / 2020, 00:56:28 by reyalp »
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #5 on: 07 / October / 2020, 17:52:52 »
The simplest way would be to just do
Code: [Select]
m=require'gui_live_common'
and then add your additional fields / functions to m. This would also give the option of making more things generic, so for example the logic of redraw_canvas could be common, calling implementation specific functions to do the drawing.


Thanks, that's a much better way.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline reyalp

  • ******
  • 13353
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #6 on: 07 / October / 2020, 23:09:15 »
One thing I wondered about is whether you're using package manager provided packages for Lua and LGI, or building them?

My current recommended approach has been get or build everything from upstream sources, using setup-ext-libs.sh. This was required IUP/CD, but also keeps all the versions consistent, avoids having to deal with peculiarities of how different distros configure Lua, and results in fairly self contained package that has a decent chance of running of different distros.

I managed to build and run the LGI gui on the Debian 8 VM I've been using for linux snapshot builds (yes, I know that's ancient). In that case, I ended up downloading LGI from source, since the the distro provided version was old and didn't support Lua 5.3. However, configuring it to use the Lua built by setup-ext-libs and getting the LGI files into the right lua paths was somewhat annoying.

One nice thing about the LGI build is that the chdkptp can just load it in Lua with require, where on IUP needs a bunch of stuff linked into the chdkptp executable, because liveimage.c needs to call into CD (or at least, I never figured out how to not do it that way, presumably it could be done with dynamic linking functions)
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #7 on: 07 / October / 2020, 23:33:42 »
So far I've only tested using package manager installed stuff (homebrew on MacOS and apt on Debian).


LGI hasn't been updated for a few years; but it was the only other Lua -> GTK library I could get working on MacOS.


There are a bunch of other packages that are required (cairo, pango, gobject-introspection, etc).
The dependency list is quite long - I am not sure it would be good to download/build all of that as well.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline reyalp

  • ******
  • 13353
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #8 on: 08 / October / 2020, 00:05:35 »
There are a bunch of other packages that are required (cairo, pango, gobject-introspection, etc).
The dependency list is quite long - I am not sure it would be good to download/build all of that as well.
Yeah, for IUP, I assume the relevant GTK dependencies are installed. Building them all would definitely be problematic.

There's probably a lot of overlap with the LGI dependencies, I ended up only needing to install gobject-introspection on my existing build VM (Debian weirdly calls the dev package libgirepository1.0-dev)
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 13353
Re: chdkptp GTK gui (was Re: chdkptp - alternative ptp client)
« Reply #9 on: 23 / November / 2020, 01:33:26 »
I merged this into the chdkptp trunk.

A couple additional changes in r966
Startup logic is now the same for IUP and GTK gui: A GUI-capable executable tries to start the GUI if there are no command line options.
The 'ver -l' command now shows the LGI version, if present

On Debian 10 and raspberry pi, I used the following to configure / build the GTK GUI

apt-get install liblua5.3-dev lua-lgi

lua-lgi-dev is available, but not required since our code just uses the module form lua.

The systems already had all the normal chdkptp and IUP GUI prerequisites installed

in config.mk
USE_LUA_VER=53
GTK_SUPPORT=1

LUA_INCLUDE_DIR=/usr/include/lua5.3
LUA_LIB=lua5.3


In this configuration, setup-ext-libs is not used, since trying to use a locally built Lua with system provided LGI is not convenient. If this executable was used for binary distribution, the end user would just need to install the lua and lgi pacakges.

This is pretty nice on raspberry pi, because it removes the need to build IUP and CD.

I don't think the LGI GUI should actually require Lua 5.3: Debian installs LGI files for Lua 5.2. However, when I tried to run a Lua 5.2 build, it showed the GUI but got an error when I tried to use commands that print to the console, like
Code: [Select]
(chdkptp:6193): Lgi-WARNING **: 22:12:32.923: Error raised while calling 'lgi.cbk (function: 0x560c78df39f0): GObject': /home/reyalp/chdkptp/lua/gtk_gui.lua:232: attempt to index upvalue 'console_view' (a nil value)
Don't forget what the H stands for.