Display brightness / Adding new settings to the GUI

Hi all,



I’ve only recently started experimenting with the Plex source code. My background’s in .NET/Java & I mainly do web development now, but I started learning Cocoa & Obj-C around the start of the year. I’ve had very little C/C++ experience but I’m starting to find my way around (still getting tripped up by pointers & memory allocation occasionally), although I’m still a long way off understanding the full Plex source.



I’ve added a couple of functions to Plex to allow getting/setting the brightness level of the Mac’s main display (on an iMac or MacBook - haven’t been able to test on anything else). Nothing groundbreaking, but I’ve got to start somewhere! I was wondering if there’s any information out there on how to add new GUI items (to the Settings window, specifically). I know how to add new controls to the skin, but can’t work out how to use these to display & set values. I could probably find the right place in the code eventually, but could do with being pointed in the right direction.



For now, I’ve added both functions to the Python module so they can be called from scripts. If anyone else thinks they’d find this useful, get in touch & I’ll send the changes (or let me know how to make a patch with git).

Ok, I’ve made a bit more progress now. Many thanks to Jonathan Marshall for his help.



The panel brightness can now be set under Settings / System. The Python functions are extensions to the regular xbmc module and are pretty straightforward to use, for example:



xbmc.setPanelBrightness(x);<br />
x = xbmc.getPanelBrightness();


where x is between 0 (backlight off) and 1 (full brightness). The Python function & the item in the settings window retrieve the brightness value from the OS, so they'll still be correct if the brightness is changed from the keyboard.

I think I've made a patch correctly (if 'git diff -p' is the right command to use), so if anyone fancies checking it out I'd appreciate the feedback. One thing I still need help with is how to check whether the display supports the brightness being set by the OS, although this is more of an OS X question than a Plex one. We're still saving for a Mac Mini, and the only Macs I have access to have integrated displays, so I can't reliably test this myself.

Nice, thanks for the patch! Send me a pull request on GitHub and I’ll incorporate it (or if that’s too much trouble I’ll just use the patch you attached).

Okay, how do I do that? Sorry, I haven’t used git before, still getting used to it.

Welcome to the drinking… I mean coding team!

Hey Jam, check out this page, should provide everything you need!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.