Compare commits
8 Commits
v.2.0-beta
...
v.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| fe1cea9e2b | |||
| 0bf78c54d0 | |||
| 8a58e66c20 | |||
| f9a84b18e8 | |||
| c53c149d31 | |||
| 17348f7acf | |||
| e1b464e36c | |||
| d97ec091c5 |
@@ -1,4 +1,8 @@
|
|||||||
# Version 2.0 (upcoming)
|
# Version 2.1
|
||||||
|
- Bugfixes
|
||||||
|
- Smaller UI for displays with reduced resolution (< 1000px height)
|
||||||
|
|
||||||
|
# Version 2.0
|
||||||
- New App icon
|
- New App icon
|
||||||
- Preferences window redesign - All settings are now in one window accessable!
|
- Preferences window redesign - All settings are now in one window accessable!
|
||||||
- Graphic visualizing of the time periods of a day with a bar chart
|
- Graphic visualizing of the time periods of a day with a bar chart
|
||||||
|
|||||||
17
README.md
@@ -7,7 +7,7 @@
|
|||||||
This extension switches the background image of your Cinnamon desktop multiple times in a day, based on a location or custom time periods. You can choose between included image-sets, your own HEIC-file or a source folder with single images. Configuration through a user-friendly configuration window.
|
This extension switches the background image of your Cinnamon desktop multiple times in a day, based on a location or custom time periods. You can choose between included image-sets, your own HEIC-file or a source folder with single images. Configuration through a user-friendly configuration window.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
- 8 included image sets
|
- 9 included image sets
|
||||||
- 10 day periods
|
- 10 day periods
|
||||||
- HEIF converter
|
- HEIF converter
|
||||||
- Image configuration assistent with simple one-click setup for image choices
|
- Image configuration assistent with simple one-click setup for image choices
|
||||||
@@ -23,11 +23,6 @@ This extension switches the background image of your Cinnamon desktop multiple t
|
|||||||
- 5.8 (Mint 21.2)
|
- 5.8 (Mint 21.2)
|
||||||
- 6.0 (Mint 21.3)
|
- 6.0 (Mint 21.3)
|
||||||
|
|
||||||
#### Only supported with version 1.x
|
|
||||||
- 4.8 (Mint 20.1)
|
|
||||||
- 5.0 (Mint 20.2)
|
|
||||||
- 5.2 (Mint 20.3)
|
|
||||||
|
|
||||||
### Technology
|
### Technology
|
||||||
- `JavaScript`
|
- `JavaScript`
|
||||||
- Display desktop notifications
|
- Display desktop notifications
|
||||||
@@ -73,10 +68,10 @@ The image sets are from https://github.com/adi1090x/dynamic-wallpaper
|
|||||||
| ------ | ----- | ------ |
|
| ------ | ----- | ------ |
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|
|
||||||
| Cliffs | Gradient | Lakeside |
|
| Cliffs | Earth | Gradient |
|
||||||
| -------- | --------- | ------ |
|
| -------- | --------- | ------ |
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|
|
||||||
| Mountains | Sahara |
|
| Lakeside | Mountains | Sahara |
|
||||||
| --------- | ------ |
|
| --------- | ------ | ------ |
|
||||||
|  |  |
|
|  |  |  |
|
||||||
@@ -33,9 +33,6 @@ const PATH = DIRECTORY.path;
|
|||||||
// The extension object
|
// The extension object
|
||||||
let extension;
|
let extension;
|
||||||
|
|
||||||
// Time and date of the last location update
|
|
||||||
let lastLocationUpdate = -1
|
|
||||||
|
|
||||||
// Loop state
|
// Loop state
|
||||||
let looping = true
|
let looping = true
|
||||||
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 233 KiB |
|
Before Width: | Height: | Size: 454 KiB After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 488 KiB After Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 436 KiB After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 436 KiB After Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 470 KiB After Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 435 KiB After Width: | Height: | Size: 229 KiB |
|
Before Width: | Height: | Size: 426 KiB After Width: | Height: | Size: 216 KiB |
|
Before Width: | Height: | Size: 420 KiB After Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 485 KiB After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 371 KiB |
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 491 KiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 513 KiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 527 KiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 526 KiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 495 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 455 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 450 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 5 B |
@@ -0,0 +1 @@
|
|||||||
|
0.jpg
|
||||||
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 5 B |
|
Before Width: | Height: | Size: 352 KiB After Width: | Height: | Size: 352 KiB |
|
After Width: | Height: | Size: 856 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 5 B |
@@ -0,0 +1 @@
|
|||||||
|
0.jpg
|
||||||
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 5 B |
|
After Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 254 KiB |
|
After Width: | Height: | Size: 634 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 759 KiB |
|
After Width: | Height: | Size: 528 KiB |
|
After Width: | Height: | Size: 335 KiB |
|
After Width: | Height: | Size: 195 KiB |
|
After Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 163 KiB After Width: | Height: | Size: 163 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 351 KiB |
|
Before Width: | Height: | Size: 449 KiB After Width: | Height: | Size: 358 KiB |
|
Before Width: | Height: | Size: 558 KiB After Width: | Height: | Size: 374 KiB |
|
Before Width: | Height: | Size: 681 KiB After Width: | Height: | Size: 419 KiB |
|
Before Width: | Height: | Size: 654 KiB After Width: | Height: | Size: 388 KiB |
|
Before Width: | Height: | Size: 631 KiB After Width: | Height: | Size: 382 KiB |
|
Before Width: | Height: | Size: 548 KiB After Width: | Height: | Size: 366 KiB |
|
Before Width: | Height: | Size: 540 KiB After Width: | Height: | Size: 356 KiB |
|
Before Width: | Height: | Size: 465 KiB After Width: | Height: | Size: 351 KiB |
|
Before Width: | Height: | Size: 392 KiB After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 184 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 186 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 5 B |
@@ -0,0 +1 @@
|
|||||||
|
0.jpg
|
||||||
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 5 B |
|
After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 118 KiB |
@@ -19,7 +19,7 @@ class Loop():
|
|||||||
|
|
||||||
# Position should estimate by network
|
# Position should estimate by network
|
||||||
if self.prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
|
if self.prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
|
||||||
current_location = self.location.run()
|
current_location = self.location.get_location()
|
||||||
|
|
||||||
self.suntimes.calc_suntimes(float(current_location["latitude"]), float(current_location["longitude"]))
|
self.suntimes.calc_suntimes(float(current_location["latitude"]), float(current_location["longitude"]))
|
||||||
self.start_times = self.suntimes.day_periods
|
self.start_times = self.suntimes.day_periods
|
||||||
@@ -79,23 +79,27 @@ class Loop():
|
|||||||
""" Setting a gradient background to hide images, which are not high enough
|
""" Setting a gradient background to hide images, which are not high enough
|
||||||
"""
|
"""
|
||||||
# Load the image
|
# Load the image
|
||||||
im = Image.open(self.current_image_uri)
|
try:
|
||||||
pix = im.load()
|
im = Image.open(self.current_image_uri)
|
||||||
|
pix = im.load()
|
||||||
|
|
||||||
# Width and height of the current setted image
|
# Width and height of the current setted image
|
||||||
width, height = im.size
|
width, height = im.size
|
||||||
|
|
||||||
# Color of the top and bottom pixel in the middle of the image
|
# Color of the top and bottom pixel in the middle of the image
|
||||||
top_color = pix[width / 2,0]
|
top_color = pix[width / 2,0]
|
||||||
bottom_color = pix[width / 2, height - 1]
|
bottom_color = pix[width / 2, height - 1]
|
||||||
|
|
||||||
# Create the gradient
|
# Create the gradient
|
||||||
self.background_settings['color-shading-type'] = "vertical"
|
self.background_settings['color-shading-type'] = "vertical"
|
||||||
|
|
||||||
if self.prefs.dynamic_background_color:
|
if self.prefs.dynamic_background_color:
|
||||||
self.background_settings['primary-color'] = f"#{top_color[0]:x}{top_color[1]:x}{top_color[2]:x}"
|
self.background_settings['primary-color'] = f"#{top_color[0]:x}{top_color[1]:x}{top_color[2]:x}"
|
||||||
self.background_settings['secondary-color'] = f"#{bottom_color[0]:x}{bottom_color[1]:x}{bottom_color[2]:x}"
|
self.background_settings['secondary-color'] = f"#{bottom_color[0]:x}{bottom_color[1]:x}{bottom_color[2]:x}"
|
||||||
else:
|
else:
|
||||||
|
self.background_settings['primary-color'] = "#000000"
|
||||||
|
self.background_settings['secondary-color'] = "#000000"
|
||||||
|
except:
|
||||||
self.background_settings['primary-color'] = "#000000"
|
self.background_settings['primary-color'] = "#000000"
|
||||||
self.background_settings['secondary-color'] = "#000000"
|
self.background_settings['secondary-color'] = "#000000"
|
||||||
|
|
||||||
|
|||||||
@@ -107,8 +107,8 @@
|
|||||||
<object class="GtkWindow" id="window_main">
|
<object class="GtkWindow" id="window_main">
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="window-position">center</property>
|
<property name="window-position">center</property>
|
||||||
<property name="default-width">1024</property>
|
<property name="default-width">800</property>
|
||||||
<property name="default-height">400</property>
|
<property name="default-height">600</property>
|
||||||
<property name="icon">../icon.svg</property>
|
<property name="icon">../icon.svg</property>
|
||||||
<property name="gravity">center</property>
|
<property name="gravity">center</property>
|
||||||
<signal name="destroy" handler="on_destroy" swapped="no"/>
|
<signal name="destroy" handler="on_destroy" swapped="no"/>
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="img_tb_image_set">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="icon-name">applications-graphics</property>
|
<property name="icon-name">applications-graphics</property>
|
||||||
@@ -217,7 +217,7 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="img_tb_heic_file">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="icon-name">preferences-desktop-wallpaper</property>
|
<property name="icon-name">preferences-desktop-wallpaper</property>
|
||||||
@@ -267,7 +267,7 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="img_tb_source_folder">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="icon-name">folder-open</property>
|
<property name="icon-name">folder-open</property>
|
||||||
@@ -414,14 +414,41 @@
|
|||||||
<property name="margin-end">12</property>
|
<property name="margin-end">12</property>
|
||||||
<property name="margin-top">12</property>
|
<property name="margin-top">12</property>
|
||||||
<property name="margin-bottom">12</property>
|
<property name="margin-bottom">12</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="homogeneous">True</property>
|
||||||
<property name="hexpand">True</property>
|
<child>
|
||||||
<property name="label" translatable="yes">Select a source folder</property>
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="label" translatable="yes">Select a source folder</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btn_source_folder">
|
||||||
|
<property name="label" translatable="yes">Open file selection dialog</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
<signal name="clicked" handler="on_btn_source_folder_clicked" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -430,13 +457,14 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFileChooserButton" id="fc_source_folder">
|
<object class="GtkLabel" id="lbl_source_folder">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="action">select-folder</property>
|
<property name="margin-top">16</property>
|
||||||
<property name="title" translatable="yes"/>
|
<property name="label" translatable="yes">label</property>
|
||||||
<signal name="file-set" handler="on_fc_source_folder_file_set" swapped="no"/>
|
<attributes>
|
||||||
<signal name="selection-changed" handler="on_fc_source_folder_file_set" swapped="no"/>
|
<attribute name="style" value="italic"/>
|
||||||
|
</attributes>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -557,7 +585,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_0">
|
<object class="GtkImage" id="img_period_0">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -570,7 +597,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_2">
|
<object class="GtkImage" id="img_period_2">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -583,7 +609,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_4">
|
<object class="GtkImage" id="img_period_4">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -596,7 +621,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_6">
|
<object class="GtkImage" id="img_period_6">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -609,7 +633,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_8">
|
<object class="GtkImage" id="img_period_8">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -704,7 +727,6 @@
|
|||||||
<property name="column-homogeneous">True</property>
|
<property name="column-homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_1">
|
<object class="GtkImage" id="img_period_1">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -717,7 +739,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_9">
|
<object class="GtkImage" id="img_period_9">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -730,7 +751,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_7">
|
<object class="GtkImage" id="img_period_7">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -743,7 +763,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_5">
|
<object class="GtkImage" id="img_period_5">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -756,7 +775,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="img_period_3">
|
<object class="GtkImage" id="img_period_3">
|
||||||
<property name="width-request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="stock">gtk-missing-image</property>
|
<property name="stock">gtk-missing-image</property>
|
||||||
@@ -916,8 +934,8 @@
|
|||||||
<object class="GtkBox" id="gtkbox_location_time">
|
<object class="GtkBox" id="gtkbox_location_time">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-start">24</property>
|
<property name="margin-start">16</property>
|
||||||
<property name="margin-end">24</property>
|
<property name="margin-end">16</property>
|
||||||
<property name="margin-top">8</property>
|
<property name="margin-top">8</property>
|
||||||
<property name="margin-bottom">8</property>
|
<property name="margin-bottom">8</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
@@ -927,7 +945,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="label" translatable="yes">Period estimation</property>
|
<property name="label" translatable="yes">Period estimation</property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="weight" value="bold"/>
|
<attribute name="weight" value="bold"/>
|
||||||
@@ -965,7 +982,7 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="img_tb_network_location">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="icon-name">network-wireless</property>
|
<property name="icon-name">network-wireless</property>
|
||||||
@@ -1015,7 +1032,7 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="img_tb_custom_location">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="icon-name">preferences-desktop-keyboard</property>
|
<property name="icon-name">preferences-desktop-keyboard</property>
|
||||||
@@ -1067,7 +1084,7 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage" id="img_tb_time_periods">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="icon-name">document-open-recent</property>
|
<property name="icon-name">document-open-recent</property>
|
||||||
@@ -1112,7 +1129,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="label" translatable="yes">Location estimation</property>
|
<property name="label" translatable="yes">Location estimation</property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="weight" value="bold"/>
|
<attribute name="weight" value="bold"/>
|
||||||
@@ -1128,8 +1144,6 @@
|
|||||||
<object class="GtkListBox">
|
<object class="GtkListBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="margin-end">64</property>
|
|
||||||
<property name="selection-mode">none</property>
|
<property name="selection-mode">none</property>
|
||||||
<property name="activate-on-single-click">False</property>
|
<property name="activate-on-single-click">False</property>
|
||||||
<child>
|
<child>
|
||||||
@@ -2408,8 +2422,8 @@
|
|||||||
<object class="GtkBox" id="gtkbox_behaviour">
|
<object class="GtkBox" id="gtkbox_behaviour">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-start">8</property>
|
<property name="margin-start">16</property>
|
||||||
<property name="margin-end">8</property>
|
<property name="margin-end">16</property>
|
||||||
<property name="margin-top">8</property>
|
<property name="margin-top">8</property>
|
||||||
<property name="margin-bottom">8</property>
|
<property name="margin-bottom">8</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
@@ -2417,10 +2431,6 @@
|
|||||||
<object class="GtkListBox">
|
<object class="GtkListBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-left">64</property>
|
|
||||||
<property name="margin-right">64</property>
|
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="margin-end">64</property>
|
|
||||||
<property name="selection-mode">none</property>
|
<property name="selection-mode">none</property>
|
||||||
<property name="activate-on-single-click">False</property>
|
<property name="activate-on-single-click">False</property>
|
||||||
<child>
|
<child>
|
||||||
@@ -2531,8 +2541,8 @@
|
|||||||
<object class="GtkBox" id="gtkbox_about">
|
<object class="GtkBox" id="gtkbox_about">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-start">24</property>
|
<property name="margin-start">16</property>
|
||||||
<property name="margin-end">24</property>
|
<property name="margin-end">16</property>
|
||||||
<property name="margin-top">8</property>
|
<property name="margin-top">8</property>
|
||||||
<property name="margin-bottom">8</property>
|
<property name="margin-bottom">8</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
@@ -2542,7 +2552,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="label" translatable="yes">About the project</property>
|
<property name="label" translatable="yes">About the project</property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="weight" value="bold"/>
|
<attribute name="weight" value="bold"/>
|
||||||
@@ -2558,8 +2567,6 @@
|
|||||||
<object class="GtkListBox">
|
<object class="GtkListBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="margin-end">64</property>
|
|
||||||
<property name="selection-mode">none</property>
|
<property name="selection-mode">none</property>
|
||||||
<property name="activate-on-single-click">False</property>
|
<property name="activate-on-single-click">False</property>
|
||||||
<child>
|
<child>
|
||||||
@@ -2646,7 +2653,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="label" translatable="yes">Source Code</property>
|
<property name="label" translatable="yes">Source Code</property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="weight" value="bold"/>
|
<attribute name="weight" value="bold"/>
|
||||||
@@ -2662,8 +2668,6 @@
|
|||||||
<object class="GtkListBox">
|
<object class="GtkListBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="margin-end">64</property>
|
|
||||||
<property name="selection-mode">none</property>
|
<property name="selection-mode">none</property>
|
||||||
<property name="activate-on-single-click">False</property>
|
<property name="activate-on-single-click">False</property>
|
||||||
<child>
|
<child>
|
||||||
@@ -2714,7 +2718,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="label" translatable="yes">Issues and Enhancements</property>
|
<property name="label" translatable="yes">Issues and Enhancements</property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="weight" value="bold"/>
|
<attribute name="weight" value="bold"/>
|
||||||
@@ -2730,8 +2733,6 @@
|
|||||||
<object class="GtkListBox">
|
<object class="GtkListBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-start">64</property>
|
|
||||||
<property name="margin-end">64</property>
|
|
||||||
<property name="selection-mode">none</property>
|
<property name="selection-mode">none</property>
|
||||||
<property name="activate-on-single-click">False</property>
|
<property name="activate-on-single-click">False</property>
|
||||||
<child>
|
<child>
|
||||||
@@ -2810,6 +2811,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Apply and close this window</property>
|
||||||
<property name="use-stock">True</property>
|
<property name="use-stock">True</property>
|
||||||
<property name="always-show-image">True</property>
|
<property name="always-show-image">True</property>
|
||||||
<signal name="clicked" handler="on_ok" swapped="no"/>
|
<signal name="clicked" handler="on_ok" swapped="no"/>
|
||||||
@@ -2821,6 +2823,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Apply the settings without closing this window</property>
|
||||||
<property name="double-buffered">False</property>
|
<property name="double-buffered">False</property>
|
||||||
<property name="use-stock">True</property>
|
<property name="use-stock">True</property>
|
||||||
<property name="always-show-image">True</property>
|
<property name="always-show-image">True</property>
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# Imports
|
############################################################
|
||||||
|
# Imports #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# Packages
|
||||||
import gi, os, subprocess, time
|
import gi, os, subprocess, time
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from scripts.time_bar_chart import Time_Bar_Chart
|
|
||||||
from scripts.cinnamon_pref_handler import *
|
# Local scripts
|
||||||
from scripts.suntimes import *
|
from scripts import cinnamon_pref_handler, dialogs, display, images, location, suntimes, time_bar_chart, ui
|
||||||
from scripts.location import *
|
from loop import *
|
||||||
from scripts.images import *
|
|
||||||
from enums.ImageSourceEnum import ImageSourceEnum
|
from enums.ImageSourceEnum import ImageSourceEnum
|
||||||
from enums.PeriodSourceEnum import PeriodSourceEnum
|
from enums.PeriodSourceEnum import PeriodSourceEnum
|
||||||
from loop import *
|
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk, GdkPixbuf
|
from gi.repository import Gtk, GdkPixbuf
|
||||||
@@ -31,111 +33,24 @@ class Preferences:
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
# Objects from external scripts
|
# Objects from external scripts
|
||||||
self.time_bar_chart = Time_Bar_Chart()
|
self.prefs = cinnamon_pref_handler.Cinnamon_Pref_Handler()
|
||||||
self.c_prefs = Cinnamon_Pref_Handler()
|
self.dialogs = dialogs.Dialogs()
|
||||||
self.suntimes = Suntimes()
|
self.display = display.Display()
|
||||||
self.images = Images()
|
self.images = images.Images()
|
||||||
self.location = Location()
|
self.location = location.Location()
|
||||||
|
self.suntimes = suntimes.Suntimes()
|
||||||
|
self.time_bar_chart = time_bar_chart.Time_Bar_Chart()
|
||||||
|
|
||||||
# Glade
|
# Glade
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.builder.add_from_file(GLADE_URI)
|
self.builder.add_from_file(GLADE_URI)
|
||||||
self.builder.connect_signals(self)
|
self.builder.connect_signals(self)
|
||||||
|
|
||||||
########## UI objects ##########
|
|
||||||
|
|
||||||
#### Page 1: Image Configuration
|
|
||||||
self.tb_image_set: Gtk.ToggleButton = self.builder.get_object("tb_image_set")
|
|
||||||
self.tb_heic_file: Gtk.ToggleButton = self.builder.get_object("tb_heic_file")
|
|
||||||
self.tb_source_folder: Gtk.ToggleButton = self.builder.get_object("tb_source_folder")
|
|
||||||
|
|
||||||
# Image set
|
self.ui = ui.UI(self.builder)
|
||||||
self.lbr_image_set: Gtk.ListBoxRow = self.builder.get_object("lbr_image_set")
|
|
||||||
self.cb_image_set: Gtk.ComboBox = self.builder.get_object("cb_image_set")
|
|
||||||
|
|
||||||
# HEIC file
|
|
||||||
self.lbr_heic_file: Gtk.ListBoxRow = self.builder.get_object("lbr_heic_file")
|
|
||||||
|
|
||||||
# Source folder
|
|
||||||
self.lbr_source_folder: Gtk.ListBoxRow = self.builder.get_object("lbr_source_folder")
|
|
||||||
self.fc_source_folder: Gtk.FileChooser = self.builder.get_object("fc_source_folder")
|
|
||||||
|
|
||||||
# Time bar chart
|
|
||||||
self.img_bar_images: Gtk.Image = self.builder.get_object("img_bar_images")
|
|
||||||
self.etr_periods: list[Gtk.Entry] = [
|
|
||||||
self.builder.get_object("etr_period_1"), self.builder.get_object("etr_period_2"),
|
|
||||||
self.builder.get_object("etr_period_3"), self.builder.get_object("etr_period_4"),
|
|
||||||
self.builder.get_object("etr_period_5"), self.builder.get_object("etr_period_6"),
|
|
||||||
self.builder.get_object("etr_period_7"), self.builder.get_object("etr_period_8"),
|
|
||||||
self.builder.get_object("etr_period_9"), self.builder.get_object("etr_period_10"),
|
|
||||||
]
|
|
||||||
|
|
||||||
self.img_periods: list[Gtk.Image] = [
|
|
||||||
self.builder.get_object("img_period_0"), self.builder.get_object("img_period_1"),
|
|
||||||
self.builder.get_object("img_period_2"), self.builder.get_object("img_period_3"),
|
|
||||||
self.builder.get_object("img_period_4"), self.builder.get_object("img_period_5"),
|
|
||||||
self.builder.get_object("img_period_6"), self.builder.get_object("img_period_7"),
|
|
||||||
self.builder.get_object("img_period_8"), self.builder.get_object("img_period_9"),
|
|
||||||
]
|
|
||||||
|
|
||||||
self.cb_periods: list[Gtk.ComboBox] = [
|
|
||||||
self.builder.get_object("cb_period_0"), self.builder.get_object("cb_period_1"),
|
|
||||||
self.builder.get_object("cb_period_2"), self.builder.get_object("cb_period_3"),
|
|
||||||
self.builder.get_object("cb_period_4"), self.builder.get_object("cb_period_5"),
|
|
||||||
self.builder.get_object("cb_period_6"), self.builder.get_object("cb_period_7"),
|
|
||||||
self.builder.get_object("cb_period_8"), self.builder.get_object("cb_period_9"),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
|
# Local Config
|
||||||
#### Page 2: Location & Times
|
self.smaller_ui_height = 1000
|
||||||
self.tb_network_location: Gtk.ToggleButton = self.builder.get_object("tb_network_location")
|
|
||||||
self.lb_current_location: Gtk.Label = self.builder.get_object("lb_current_location")
|
|
||||||
self.lbr_current_location: Gtk.ListBoxRow = self.builder.get_object("lbr_current_location")
|
|
||||||
self.tb_custom_location: Gtk.ToggleButton = self.builder.get_object("tb_custom_location")
|
|
||||||
self.tb_time_periods: Gtk.ToggleButton = self.builder.get_object("tb_time_periods")
|
|
||||||
self.lbr_network_location: Gtk.ListBoxRow = self.builder.get_object("lbr_network_location")
|
|
||||||
self.spb_network_location_refresh_time: Gtk.SpinButton = self.builder.get_object("spb_network_location_refresh_time")
|
|
||||||
self.lbr_custom_location_longitude: Gtk.ListBoxRow = self.builder.get_object("lbr_custom_location_longitude")
|
|
||||||
self.lbr_custom_location_latitude: Gtk.ListBoxRow = self.builder.get_object("lbr_custom_location_latitude")
|
|
||||||
self.lbr_time_periods: Gtk.ListBoxRow = self.builder.get_object("lbr_time_periods")
|
|
||||||
self.etr_longitude: Gtk.Entry = self.builder.get_object("etr_longitude")
|
|
||||||
self.etr_latitude: Gtk.Entry = self.builder.get_object("etr_latitude")
|
|
||||||
self.img_bar_times: Gtk.Image = self.builder.get_object("img_bar_times")
|
|
||||||
self.spb_periods_hour: list[Gtk.SpinButton] = [
|
|
||||||
self.builder.get_object("spb_period_1_hour"),
|
|
||||||
self.builder.get_object("spb_period_2_hour"),
|
|
||||||
self.builder.get_object("spb_period_3_hour"),
|
|
||||||
self.builder.get_object("spb_period_4_hour"),
|
|
||||||
self.builder.get_object("spb_period_5_hour"),
|
|
||||||
self.builder.get_object("spb_period_6_hour"),
|
|
||||||
self.builder.get_object("spb_period_7_hour"),
|
|
||||||
self.builder.get_object("spb_period_8_hour"),
|
|
||||||
self.builder.get_object("spb_period_9_hour"),
|
|
||||||
]
|
|
||||||
self.spb_periods_minute: list[Gtk.SpinButton] = [
|
|
||||||
self.builder.get_object("spb_period_1_minute"),
|
|
||||||
self.builder.get_object("spb_period_2_minute"),
|
|
||||||
self.builder.get_object("spb_period_3_minute"),
|
|
||||||
self.builder.get_object("spb_period_4_minute"),
|
|
||||||
self.builder.get_object("spb_period_5_minute"),
|
|
||||||
self.builder.get_object("spb_period_6_minute"),
|
|
||||||
self.builder.get_object("spb_period_7_minute"),
|
|
||||||
self.builder.get_object("spb_period_8_minute"),
|
|
||||||
self.builder.get_object("spb_period_9_minute")
|
|
||||||
]
|
|
||||||
self.lb_period_end: list[Gtk.Label] = [
|
|
||||||
self.builder.get_object("lb_period_0_end"), self.builder.get_object("lb_period_1_end"),
|
|
||||||
self.builder.get_object("lb_period_2_end"), self.builder.get_object("lb_period_3_end"),
|
|
||||||
self.builder.get_object("lb_period_4_end"), self.builder.get_object("lb_period_5_end"),
|
|
||||||
self.builder.get_object("lb_period_6_end"), self.builder.get_object("lb_period_7_end"),
|
|
||||||
self.builder.get_object("lb_period_8_end"), self.builder.get_object("lb_period_9_end"),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Page 3: Behaviour
|
|
||||||
self.cb_picture_aspect: Gtk.ComboBox = self.builder.get_object("cb_picture_aspect")
|
|
||||||
self.sw_dynamic_background_color: Gtk.Switch = self.builder.get_object("sw_dynamic_background_color")
|
|
||||||
|
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
@@ -144,31 +59,38 @@ class Preferences:
|
|||||||
window = self.builder.get_object("window_main")
|
window = self.builder.get_object("window_main")
|
||||||
window.show_all()
|
window.show_all()
|
||||||
|
|
||||||
# todo: Remove after HEIC implementation
|
|
||||||
self.tb_heic_file.set_visible(False)
|
|
||||||
|
|
||||||
# Load from preferences
|
# Load from preferences
|
||||||
if self.c_prefs.image_source == ImageSourceEnum.IMAGESET:
|
if self.prefs.image_source == ImageSourceEnum.IMAGESET:
|
||||||
self.tb_image_set.set_active(True)
|
self.ui.tb_image_set.set_active(True)
|
||||||
elif self.c_prefs.image_source == ImageSourceEnum.HEICFILE:
|
elif self.prefs.image_source == ImageSourceEnum.HEICFILE:
|
||||||
self.tb_heic_file.set_active(True)
|
self.ui.tb_heic_file.set_active(True)
|
||||||
elif self.c_prefs.image_source == ImageSourceEnum.SOURCEFOLDER:
|
elif self.prefs.image_source == ImageSourceEnum.SOURCEFOLDER:
|
||||||
self.tb_source_folder.set_active(True)
|
self.ui.tb_source_folder.set_active(True)
|
||||||
|
|
||||||
|
|
||||||
|
# Remove icons in the ToggleButtons if the screen height resolution < 1000 px
|
||||||
|
if self.display.get_screen_height() < self.smaller_ui_height:
|
||||||
|
self.ui.img_tb_image_set.clear()
|
||||||
|
self.ui.img_tb_heic_file.clear()
|
||||||
|
self.ui.img_tb_source_folder.clear()
|
||||||
|
self.ui.img_tb_network_location.clear()
|
||||||
|
self.ui.img_tb_custom_location.clear()
|
||||||
|
self.ui.img_tb_time_periods.clear()
|
||||||
|
|
||||||
|
|
||||||
picture_aspects = ["mosaic", "centered", "scaled", "stretched", "zoom", "spanned"]
|
picture_aspects = ["centered", "scaled", "stretched", "zoom", "spanned"]
|
||||||
self.add_items_to_combo_box(self.cb_picture_aspect, picture_aspects)
|
self.ui.add_items_to_combo_box(self.ui.cb_picture_aspect, picture_aspects)
|
||||||
self.set_active_combobox_item(self.cb_picture_aspect, self.c_prefs.picture_aspect)
|
self.ui.set_active_combobox_item(self.ui.cb_picture_aspect, self.prefs.picture_aspect)
|
||||||
|
|
||||||
self.sw_dynamic_background_color.set_active(self.c_prefs.dynamic_background_color)
|
self.ui.sw_dynamic_background_color.set_active(self.prefs.dynamic_background_color)
|
||||||
|
|
||||||
|
|
||||||
if self.c_prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
|
if self.prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
|
||||||
self.tb_network_location.set_active(True)
|
self.ui.tb_network_location.set_active(True)
|
||||||
elif self.c_prefs.period_source == PeriodSourceEnum.CUSTOMLOCATION:
|
elif self.prefs.period_source == PeriodSourceEnum.CUSTOMLOCATION:
|
||||||
self.tb_custom_location.set_active(True)
|
self.ui.tb_custom_location.set_active(True)
|
||||||
elif self.c_prefs.period_source == PeriodSourceEnum.CUSTOMTIMEPERIODS:
|
elif self.prefs.period_source == PeriodSourceEnum.CUSTOMTIMEPERIODS:
|
||||||
self.tb_time_periods.set_active(True)
|
self.ui.tb_time_periods.set_active(True)
|
||||||
|
|
||||||
|
|
||||||
# Time diagram
|
# Time diagram
|
||||||
@@ -198,17 +120,16 @@ class Preferences:
|
|||||||
# Stores the start times of the periods in minutes since midnight
|
# Stores the start times of the periods in minutes since midnight
|
||||||
time_periods_min = []
|
time_periods_min = []
|
||||||
|
|
||||||
if self.c_prefs.period_source == PeriodSourceEnum.CUSTOMTIMEPERIODS:
|
if self.prefs.period_source == PeriodSourceEnum.CUSTOMTIMEPERIODS:
|
||||||
for i in range(0, 10):
|
for i in range(0, 10):
|
||||||
time_str = self.c_prefs.period_custom_start_time[i]
|
time_str = self.prefs.period_custom_start_time[i]
|
||||||
|
|
||||||
time_periods_min.append(int(time_str[0:2]) * 60 + int(time_str[3:5]))
|
time_periods_min.append(int(time_str[0:2]) * 60 + int(time_str[3:5]))
|
||||||
else:
|
else:
|
||||||
if self.c_prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
|
if self.prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
|
||||||
self.suntimes.calc_suntimes(float(self.c_prefs.latitude_auto),
|
self.suntimes.calc_suntimes(float(self.prefs.latitude_auto), float(self.prefs.longitude_auto))
|
||||||
float(self.c_prefs.longitude_auto))
|
|
||||||
else:
|
else:
|
||||||
self.suntimes.calc_suntimes(float(self.etr_latitude.get_text()), float(self.etr_longitude.get_text()))
|
self.suntimes.calc_suntimes(float(self.ui.etr_latitude.get_text()), float(self.ui.etr_longitude.get_text()))
|
||||||
|
|
||||||
|
|
||||||
# Get all time periods. Store the minutes to the list and print the values to the text views
|
# Get all time periods. Store the minutes to the list and print the values to the text views
|
||||||
@@ -220,22 +141,30 @@ class Preferences:
|
|||||||
else:
|
else:
|
||||||
time_range_next = time(hour=23, minute=59)
|
time_range_next = time(hour=23, minute=59)
|
||||||
|
|
||||||
self.etr_periods[i].set_text(
|
self.ui.etr_periods[i].set_text(
|
||||||
str(time_range_now.hour).rjust(2, '0') + ":" + str(time_range_now.minute).rjust(2, '0') +\
|
str(time_range_now.hour).rjust(2, '0') + ":" + str(time_range_now.minute).rjust(2, '0') + \
|
||||||
" - " + str(time_range_next.hour).rjust(2, '0') + ":" + str(time_range_next.minute).rjust(2, '0'))
|
" - " + str(time_range_next.hour).rjust(2, '0') + ":" + str(time_range_next.minute).rjust(2, '0'))
|
||||||
|
|
||||||
time_periods_min.append(time_range_now.hour * 60 + time_range_now.minute)
|
time_periods_min.append(time_range_now.hour * 60 + time_range_now.minute)
|
||||||
|
|
||||||
# Create time bar
|
# Create time bar
|
||||||
self.time_bar_chart.create_bar_chart_with_polylines(PREFERENCES_URI, 1300, 150, time_periods_min)
|
# Reduce size for small displays
|
||||||
self.time_bar_chart.create_bar_chart(PREFERENCES_URI, 1300, 150, time_periods_min)
|
if self.display.get_screen_height() < self.smaller_ui_height:
|
||||||
|
bar_width = 1150
|
||||||
|
bar_height = 110
|
||||||
|
else:
|
||||||
|
bar_width = 1300
|
||||||
|
bar_height = 150
|
||||||
|
|
||||||
|
self.time_bar_chart.create_bar_chart_with_polylines(PREFERENCES_URI, bar_width, bar_height, time_periods_min)
|
||||||
|
self.time_bar_chart.create_bar_chart(PREFERENCES_URI, bar_width, bar_height, time_periods_min)
|
||||||
|
|
||||||
# Load to the views
|
# Load to the views
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(PREFERENCES_URI + "/time_bar_polylines.svg")
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file(PREFERENCES_URI + "/time_bar_polylines.svg")
|
||||||
self.img_bar_images.set_from_pixbuf(pixbuf)
|
self.ui.img_bar_images.set_from_pixbuf(pixbuf)
|
||||||
|
|
||||||
pixbuf2 = GdkPixbuf.Pixbuf.new_from_file(PREFERENCES_URI + "/time_bar.svg")
|
pixbuf2 = GdkPixbuf.Pixbuf.new_from_file(PREFERENCES_URI + "/time_bar.svg")
|
||||||
self.img_bar_times.set_from_pixbuf(pixbuf2)
|
self.ui.img_bar_times.set_from_pixbuf(pixbuf2)
|
||||||
|
|
||||||
|
|
||||||
def load_image_options_to_combo_boxes(self, options: list):
|
def load_image_options_to_combo_boxes(self, options: list):
|
||||||
@@ -244,61 +173,35 @@ class Preferences:
|
|||||||
Args:
|
Args:
|
||||||
options (list): All possible options
|
options (list): All possible options
|
||||||
"""
|
"""
|
||||||
for combobox in self.cb_periods:
|
options.insert(0, "")
|
||||||
self.add_items_to_combo_box(combobox, options)
|
|
||||||
|
for combobox in self.ui.cb_periods:
|
||||||
|
self.ui.add_items_to_combo_box(combobox, options)
|
||||||
|
|
||||||
|
|
||||||
def load_image_to_preview(self, image_preview: Gtk.Image, image_src: list):
|
def load_image_to_preview(self, image_preview: Gtk.Image, image_src: str):
|
||||||
|
""" Scales the image to a lower resoultion and put them into the time bar chart
|
||||||
|
|
||||||
|
Args:
|
||||||
|
image_preview (Gtk.Image): Gtk Image where it will be displayed
|
||||||
|
image_src (str): Absolute path to the image
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_src)
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_src)
|
||||||
pixbuf = pixbuf.scale_simple(250, 175, GdkPixbuf.InterpType.BILINEAR)
|
|
||||||
|
screen_height = self.display.get_screen_height()
|
||||||
|
|
||||||
|
# Scaling the images smaller for screens
|
||||||
|
if screen_height < self.smaller_ui_height:
|
||||||
|
pixbuf = pixbuf.scale_simple(221, 128, GdkPixbuf.InterpType.BILINEAR)
|
||||||
|
else:
|
||||||
|
pixbuf = pixbuf.scale_simple(260, 150, GdkPixbuf.InterpType.BILINEAR)
|
||||||
|
|
||||||
image_preview.set_from_pixbuf(pixbuf)
|
image_preview.set_from_pixbuf(pixbuf)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
############################################################
|
|
||||||
# UI helper methods #
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
def set_active_combobox_item(self, combobox: Gtk.ComboBoxText, active_item: str):
|
|
||||||
""" Change active item in combobox by String value
|
|
||||||
|
|
||||||
Args:
|
|
||||||
combobox (Gtk.ComboBoxText): ComboBox to set active
|
|
||||||
active_item (str): String item to set active
|
|
||||||
"""
|
|
||||||
list_store = combobox.get_model()
|
|
||||||
|
|
||||||
for i in range(0, len(list_store)):
|
|
||||||
row = list_store[i]
|
|
||||||
if row[0] == active_item:
|
|
||||||
combobox.set_active(i)
|
|
||||||
|
|
||||||
|
|
||||||
def add_items_to_combo_box(self, combobox: Gtk.ComboBox, items: list):
|
|
||||||
""" Add items to a combo box
|
|
||||||
|
|
||||||
Args:
|
|
||||||
combobox (Gtk.ComboBox): ComboBox where to add the options
|
|
||||||
items (list): Possible options
|
|
||||||
"""
|
|
||||||
model = combobox.get_model()
|
|
||||||
store = Gtk.ListStore(str)
|
|
||||||
|
|
||||||
for image_set in items:
|
|
||||||
store.append([image_set])
|
|
||||||
|
|
||||||
combobox.set_model(store)
|
|
||||||
|
|
||||||
if model == None:
|
|
||||||
renderer_text = Gtk.CellRendererText()
|
|
||||||
combobox.pack_start(renderer_text, True)
|
|
||||||
combobox.add_attribute(renderer_text, "text", 0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Callbacks #
|
# Callbacks #
|
||||||
############################################################
|
############################################################
|
||||||
@@ -309,80 +212,134 @@ class Preferences:
|
|||||||
# | Image Set | HEIC file | Source Folder |
|
# | Image Set | HEIC file | Source Folder |
|
||||||
# +-----------+-----------+---------------+
|
# +-----------+-----------+---------------+
|
||||||
|
|
||||||
def on_toggle_button_image_set_clicked(self, button: Gtk.Button):
|
def on_toggle_button_image_set_clicked(self, button: Gtk.ToggleButton):
|
||||||
|
""" Clicked on ToggleButton "Image Set"
|
||||||
|
|
||||||
|
Args:
|
||||||
|
button (Gtk.ToggleButton): Clicked ToggleButton
|
||||||
|
"""
|
||||||
if button.get_active():
|
if button.get_active():
|
||||||
self.c_prefs.image_source = ImageSourceEnum.IMAGESET
|
self.prefs.image_source = ImageSourceEnum.IMAGESET
|
||||||
self.tb_heic_file.set_active(False)
|
self.ui.tb_heic_file.set_active(False)
|
||||||
self.tb_source_folder.set_active(False)
|
self.ui.tb_source_folder.set_active(False)
|
||||||
|
|
||||||
self.lbr_image_set.set_visible(True)
|
self.ui.lbr_image_set.set_visible(True)
|
||||||
self.lbr_heic_file.set_visible(False)
|
self.ui.lbr_heic_file.set_visible(False)
|
||||||
self.lbr_source_folder.set_visible(False)
|
self.ui.lbr_source_folder.set_visible(False)
|
||||||
|
|
||||||
image_set_choices = ["aurora", "beach", "bitday", "cliffs", "gradient", "lakeside", "mountains", "sahara"]
|
image_set_choices = [
|
||||||
self.add_items_to_combo_box(self.cb_image_set, image_set_choices)
|
"aurora", "beach",
|
||||||
|
"bitday", "cliffs",
|
||||||
|
"earth", "gradient",
|
||||||
|
"lakeside", "mountains",
|
||||||
|
"sahara"
|
||||||
|
]
|
||||||
|
self.ui.add_items_to_combo_box(self.ui.cb_image_set, image_set_choices)
|
||||||
|
|
||||||
self.set_active_combobox_item(self.cb_image_set, self.c_prefs.selected_image_set)
|
self.ui.set_active_combobox_item(self.ui.cb_image_set, self.prefs.selected_image_set)
|
||||||
|
|
||||||
for i, combobox in enumerate(self.cb_periods):
|
for i, combobox in enumerate(self.ui.cb_periods):
|
||||||
selected_image_name = self.c_prefs.period_images[i]
|
selected_image_name = self.prefs.period_images[i]
|
||||||
self.set_active_combobox_item(combobox, selected_image_name)
|
self.ui.set_active_combobox_item(combobox, selected_image_name)
|
||||||
|
|
||||||
# Make the comboboxes invisible
|
# Make the comboboxes invisible
|
||||||
for combobox in self.cb_periods:
|
for combobox in self.ui.cb_periods:
|
||||||
combobox.set_visible(False)
|
combobox.set_visible(False)
|
||||||
|
|
||||||
|
|
||||||
def on_toggle_button_heic_file_clicked(self, button: Gtk.Button):
|
def on_toggle_button_heic_file_clicked(self, button: Gtk.ToggleButton):
|
||||||
if button.get_active():
|
""" Clicked on ToggleButton "Heic file"
|
||||||
self.c_prefs.image_source = ImageSourceEnum.HEICFILE
|
|
||||||
self.tb_image_set.set_active(False)
|
|
||||||
self.tb_source_folder.set_active(False)
|
|
||||||
|
|
||||||
self.lbr_image_set.set_visible(False)
|
Args:
|
||||||
self.lbr_heic_file.set_visible(True)
|
button (Gtk.ToggleButton): Clicked ToggleButton
|
||||||
self.lbr_source_folder.set_visible(False)
|
"""
|
||||||
|
if button.get_active():
|
||||||
|
self.prefs.image_source = ImageSourceEnum.HEICFILE
|
||||||
|
self.ui.tb_image_set.set_active(False)
|
||||||
|
self.ui.tb_source_folder.set_active(False)
|
||||||
|
|
||||||
|
self.ui.lbr_image_set.set_visible(False)
|
||||||
|
self.ui.lbr_heic_file.set_visible(True)
|
||||||
|
self.ui.lbr_source_folder.set_visible(False)
|
||||||
|
|
||||||
# Make the comboboxes visible
|
# Make the comboboxes visible
|
||||||
for combobox in self.cb_periods:
|
for combobox in self.ui.cb_periods:
|
||||||
combobox.set_visible(True)
|
combobox.set_visible(True)
|
||||||
|
|
||||||
|
# Load images from source folder
|
||||||
|
files = self.images.get_images_from_folder(self.prefs.source_folder)
|
||||||
|
|
||||||
def on_toggle_button_source_folder_clicked(self, button: Gtk.Button):
|
if len(files) != 0:
|
||||||
|
self.load_image_options_to_combo_boxes(files)
|
||||||
|
|
||||||
|
# Load the values for the images from the preferences
|
||||||
|
for i in range(0, 10):
|
||||||
|
self.ui.set_active_combobox_item(self.ui.cb_periods[i], self.prefs.period_images[i])
|
||||||
|
else:
|
||||||
|
print("No image files!")
|
||||||
|
|
||||||
|
|
||||||
|
def on_toggle_button_source_folder_clicked(self, button: Gtk.ToggleButton):
|
||||||
|
""" Clicked on ToggleButton "Source Folder"
|
||||||
|
|
||||||
|
Args:
|
||||||
|
button (Gtk.ToggleButton): Clicked ToggleButton
|
||||||
|
"""
|
||||||
if button.get_active():
|
if button.get_active():
|
||||||
self.c_prefs.image_source = ImageSourceEnum.SOURCEFOLDER
|
self.prefs.image_source = ImageSourceEnum.SOURCEFOLDER
|
||||||
self.tb_image_set.set_active(False)
|
self.ui.tb_image_set.set_active(False)
|
||||||
self.tb_heic_file.set_active(False)
|
self.ui.tb_heic_file.set_active(False)
|
||||||
|
|
||||||
self.lbr_image_set.set_visible(False)
|
self.ui.lbr_image_set.set_visible(False)
|
||||||
self.lbr_heic_file.set_visible(False)
|
self.ui.lbr_heic_file.set_visible(False)
|
||||||
self.lbr_source_folder.set_visible(True)
|
self.ui.lbr_source_folder.set_visible(True)
|
||||||
|
|
||||||
# Make the comboboxes visible
|
# Make the comboboxes visible
|
||||||
for combobox in self.cb_periods:
|
for combobox in self.ui.cb_periods:
|
||||||
combobox.set_visible(True)
|
combobox.set_visible(True)
|
||||||
|
|
||||||
# Load the source folder to the view
|
# Load the source folder to the view
|
||||||
# This will update the comboboxes in the preview to contain the right items
|
# This will update the comboboxes in the preview to contain the right items
|
||||||
self.fc_source_folder.set_filename(self.c_prefs.source_folder)
|
self.ui.lbl_source_folder.set_label(self.prefs.source_folder)
|
||||||
|
|
||||||
|
# Load files from saved source folder
|
||||||
|
files = self.images.get_images_from_folder(self.prefs.source_folder)
|
||||||
|
|
||||||
|
if len(files) != 0:
|
||||||
|
self.load_image_options_to_combo_boxes(files)
|
||||||
|
|
||||||
|
# Load the values for the images from the preferences
|
||||||
|
for i in range(0, 10):
|
||||||
|
self.ui.set_active_combobox_item(self.ui.cb_periods[i], self.prefs.period_images[i])
|
||||||
|
else:
|
||||||
|
print("No image files!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# +------------------------------------+
|
||||||
|
# | Select an image set | aurora ▼ |
|
||||||
|
# +------------------------------------+
|
||||||
|
|
||||||
def on_cb_image_set_changed(self, combobox: Gtk.ComboBox):
|
def on_cb_image_set_changed(self, combobox: Gtk.ComboBox):
|
||||||
|
""" User select on of the included image sets
|
||||||
|
|
||||||
|
Args:
|
||||||
|
combobox (Gtk.ComboBox): The used ComboBox
|
||||||
|
"""
|
||||||
tree_iter = combobox.get_active_iter()
|
tree_iter = combobox.get_active_iter()
|
||||||
|
|
||||||
if tree_iter is not None and self.c_prefs.image_source == ImageSourceEnum.IMAGESET:
|
if tree_iter is not None and self.prefs.image_source == ImageSourceEnum.IMAGESET:
|
||||||
# Get the selected value
|
# Get the selected value
|
||||||
model = combobox.get_model()
|
model = combobox.get_model()
|
||||||
selected_image_set = model[tree_iter][0]
|
selected_image_set = model[tree_iter][0]
|
||||||
|
|
||||||
# Store to the preferences
|
# Store to the preferences
|
||||||
self.c_prefs.selected_image_set = selected_image_set
|
self.prefs.selected_image_set = selected_image_set
|
||||||
self.c_prefs.source_folder = os.path.abspath(os.path.join(PREFERENCES_URI, os.pardir)) + \
|
self.prefs.source_folder = os.path.abspath(os.path.join(PREFERENCES_URI, os.pardir)) + \
|
||||||
"/5.4/images/included_image_sets/" + selected_image_set + "/"
|
"/5.4/images/included_image_sets/" + selected_image_set + "/"
|
||||||
|
|
||||||
# Load all possible options to the comboboxes
|
# Load all possible options to the comboboxes
|
||||||
image_names = self.images.get_images_from_folder(self.c_prefs.source_folder)
|
image_names = self.images.get_images_from_folder(self.prefs.source_folder)
|
||||||
self.load_image_options_to_combo_boxes(image_names)
|
self.load_image_options_to_combo_boxes(image_names)
|
||||||
|
|
||||||
# Image sets have the same names for the images:
|
# Image sets have the same names for the images:
|
||||||
@@ -390,59 +347,77 @@ class Preferences:
|
|||||||
# 1.jpg = Period 1
|
# 1.jpg = Period 1
|
||||||
# 2.jpg = Period 2
|
# 2.jpg = Period 2
|
||||||
# and so on....
|
# and so on....
|
||||||
self.cb_periods[0].set_active(8)
|
for i in range(0, 10):
|
||||||
for i in range(1, 10):
|
self.ui.cb_periods[i].set_active(i + 1)
|
||||||
self.cb_periods[i].set_active(i - 1)
|
|
||||||
|
|
||||||
|
|
||||||
|
# +----------------------------------------------+
|
||||||
|
# | Select a heic file to import | (None) 📄 |
|
||||||
|
# +----------------------------------------------+
|
||||||
|
|
||||||
def on_fc_heic_file_file_set(self, fc_button: Gtk.FileChooser):
|
def on_fc_heic_file_file_set(self, fc_button: Gtk.FileChooser):
|
||||||
file_path = fc_button.get_filename()
|
""" User has a heic file selected with the FileChooserDialog
|
||||||
extract_folder = os.path.abspath(os.path.join(PREFERENCES_URI, os.pardir)) + \
|
|
||||||
"/images/extracted_images/"
|
|
||||||
|
|
||||||
file_name = file_path[file_path.rfind("/") + 1:]
|
Args:
|
||||||
file_name = file_name[:file_name.rfind(".")]
|
fc_button (Gtk.FileChooser): Parameter about the selected file
|
||||||
|
"""
|
||||||
|
# The the absolute path to the heic file
|
||||||
|
file_path: str = fc_button.get_filename()
|
||||||
|
|
||||||
|
# Extract the heic file
|
||||||
|
result = self.images.extract_heic_file(file_path)
|
||||||
|
|
||||||
# Update the preferences
|
# Update the preferences
|
||||||
self.c_prefs.selected_image_set = ""
|
self.prefs.selected_image_set = ""
|
||||||
self.c_prefs.source_folder = extract_folder
|
self.prefs.source_folder = PREFERENCES_URI + "/images/extracted_images/"
|
||||||
|
|
||||||
# Create the buffer folder
|
# Load images only if the extraction was successfully
|
||||||
try:
|
if result:
|
||||||
os.mkdir(extract_folder)
|
# Collect all extracted images and push them to the comboboxes
|
||||||
except:
|
image_names = self.images.get_images_from_folder(self.prefs.source_folder)
|
||||||
pass
|
self.load_image_options_to_combo_boxes(image_names)
|
||||||
|
|
||||||
# Extract the HEIC file
|
|
||||||
for file in self.images.get_images_from_folder(extract_folder):
|
|
||||||
os.remove(extract_folder + file)
|
|
||||||
|
|
||||||
os.system("heif-convert " + file_path + " " + extract_folder + file_name + ".jpg")
|
|
||||||
|
|
||||||
# Collect all extracted images and push them to the comboboxes
|
|
||||||
image_names = self.images.get_images_from_folder(self.c_prefs.source_folder)
|
|
||||||
self.load_image_options_to_combo_boxes(image_names)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_fc_source_folder_file_set(self, fc_button: Gtk.FileChooser):
|
|
||||||
files = self.images.get_images_from_folder(fc_button.get_filename())
|
|
||||||
|
|
||||||
# Update the preferences
|
|
||||||
self.c_prefs.selected_image_set = ""
|
|
||||||
self.c_prefs.source_folder = fc_button.get_filename() + "/"
|
|
||||||
|
|
||||||
if len(files) != 0:
|
|
||||||
self.load_image_options_to_combo_boxes(files)
|
|
||||||
|
|
||||||
# Load the values for the images from the preferences
|
|
||||||
for i in range(0, 10):
|
|
||||||
self.set_active_combobox_item(self.cb_periods[i], self.c_prefs.period_images[i])
|
|
||||||
else:
|
else:
|
||||||
pass
|
self.dialogs.message_dialog("Error during extraction")
|
||||||
|
|
||||||
|
|
||||||
|
# +------------------------------------------------------------+
|
||||||
|
# | Select a source folder | 📂 Open file selection dialog |
|
||||||
|
# | /home/developer/Downloads/
|
||||||
|
# +------------------------------------------------------------+
|
||||||
|
|
||||||
|
def on_btn_source_folder_clicked(self, button: Gtk.Button):
|
||||||
|
""" Button to choose an image source folder was clicked
|
||||||
|
|
||||||
|
Args:
|
||||||
|
button (Gtk.Button): The clicked button
|
||||||
|
"""
|
||||||
|
folder = self.dialogs.source_folder_dialog()
|
||||||
|
files = self.images.get_images_from_folder(folder)
|
||||||
|
|
||||||
|
# Update the preferences
|
||||||
|
self.prefs.selected_image_set = ""
|
||||||
|
self.prefs.source_folder = folder + "/"
|
||||||
|
|
||||||
|
# Update the label
|
||||||
|
self.ui.lbl_source_folder.set_label(folder)
|
||||||
|
|
||||||
|
# Update the image comboboxes
|
||||||
|
self.load_image_options_to_combo_boxes(files)
|
||||||
|
|
||||||
|
# Load the values for the images from the preferences
|
||||||
|
for i in range(0, 10):
|
||||||
|
self.ui.cb_periods[i].set_active(0)
|
||||||
|
|
||||||
|
if len(files) == 1:
|
||||||
|
self.dialogs.message_dialog("No image files found!")
|
||||||
|
|
||||||
|
|
||||||
def on_cb_period_preview_changed(self, combobox: Gtk.ComboBox):
|
def on_cb_period_preview_changed(self, combobox: Gtk.ComboBox):
|
||||||
|
""" User select an image from the ComboBox for the time period
|
||||||
|
|
||||||
|
Args:
|
||||||
|
combobox (Gtk.ComboBox): The used ComboBox
|
||||||
|
"""
|
||||||
tree_iter = combobox.get_active_iter()
|
tree_iter = combobox.get_active_iter()
|
||||||
|
|
||||||
combobox_name = Gtk.Buildable.get_name(combobox)
|
combobox_name = Gtk.Buildable.get_name(combobox)
|
||||||
@@ -454,78 +429,83 @@ class Preferences:
|
|||||||
image_file_name = model[tree_iter][0]
|
image_file_name = model[tree_iter][0]
|
||||||
|
|
||||||
# Store selection to preferences
|
# Store selection to preferences
|
||||||
self.c_prefs.period_images[period_index] = image_file_name
|
self.prefs.period_images[period_index] = image_file_name
|
||||||
|
|
||||||
# Build up image path
|
# Build up image path
|
||||||
image_path = self.c_prefs.source_folder + image_file_name
|
image_path = self.prefs.source_folder + image_file_name
|
||||||
|
|
||||||
self.load_image_to_preview(self.img_periods[period_index], image_path)
|
self.load_image_to_preview(self.ui.img_periods[period_index], image_path)
|
||||||
|
|
||||||
|
|
||||||
## Location & Times
|
## Location & Times
|
||||||
|
|
||||||
def on_toggle_button_network_location_clicked(self, button: Gtk.Button):
|
def on_toggle_button_network_location_clicked(self, button: Gtk.ToggleButton):
|
||||||
|
""" User clicks on the ToggleButton for the network location
|
||||||
|
|
||||||
|
Args:
|
||||||
|
button (Gtk.ToggleButton): Clicked ToggleButton
|
||||||
|
"""
|
||||||
if button.get_active():
|
if button.get_active():
|
||||||
self.c_prefs.period_source = PeriodSourceEnum.NETWORKLOCATION
|
self.prefs.period_source = PeriodSourceEnum.NETWORKLOCATION
|
||||||
self.tb_custom_location.set_active(False)
|
self.ui.tb_custom_location.set_active(False)
|
||||||
self.tb_time_periods.set_active(False)
|
self.ui.tb_time_periods.set_active(False)
|
||||||
|
|
||||||
self.lbr_network_location.set_visible(True)
|
self.ui.lbr_network_location.set_visible(True)
|
||||||
self.lbr_current_location.set_visible(True)
|
self.ui.lbr_current_location.set_visible(True)
|
||||||
self.lbr_custom_location_longitude.set_visible(False)
|
self.ui.lbr_custom_location_longitude.set_visible(False)
|
||||||
self.lbr_custom_location_latitude.set_visible(False)
|
self.ui.lbr_custom_location_latitude.set_visible(False)
|
||||||
self.lbr_time_periods.set_visible(False)
|
self.ui.lbr_time_periods.set_visible(False)
|
||||||
|
|
||||||
self.spb_network_location_refresh_time.set_value(self.c_prefs.location_refresh_intervals)
|
self.ui.spb_network_location_refresh_time.set_value(self.prefs.location_refresh_intervals)
|
||||||
|
|
||||||
|
|
||||||
# Display the location in the UI
|
# Display the location in the UI
|
||||||
current_location = self.location.run()
|
current_location = self.location.get_location()
|
||||||
self.lb_current_location.set_text("Latitude: " + current_location["latitude"] + \
|
self.ui.lb_current_location.set_text("Latitude: " + current_location["latitude"] + \
|
||||||
", Longitude: " + current_location["longitude"])
|
", Longitude: " + current_location["longitude"])
|
||||||
|
|
||||||
# Store the location to the preferences
|
# Store the location to the preferences
|
||||||
self.c_prefs.latitude_auto = float(current_location["latitude"])
|
self.prefs.latitude_auto = float(current_location["latitude"])
|
||||||
self.c_prefs.longitude_auto = float(current_location["longitude"])
|
self.prefs.longitude_auto = float(current_location["longitude"])
|
||||||
|
|
||||||
self.refresh_chart()
|
self.refresh_chart()
|
||||||
|
|
||||||
|
|
||||||
def on_toggle_button_custom_location_clicked(self, button: Gtk.Button):
|
def on_toggle_button_custom_location_clicked(self, button: Gtk.ToggleButton):
|
||||||
if button.get_active():
|
if button.get_active():
|
||||||
self.c_prefs.period_source = PeriodSourceEnum.CUSTOMLOCATION
|
self.prefs.period_source = PeriodSourceEnum.CUSTOMLOCATION
|
||||||
self.tb_network_location.set_active(False)
|
self.ui.tb_network_location.set_active(False)
|
||||||
self.tb_time_periods.set_active(False)
|
self.ui.tb_time_periods.set_active(False)
|
||||||
|
|
||||||
self.lbr_network_location.set_visible(False)
|
self.ui.lbr_network_location.set_visible(False)
|
||||||
self.lbr_current_location.set_visible(False)
|
self.ui.lbr_current_location.set_visible(False)
|
||||||
self.lbr_custom_location_longitude.set_visible(True)
|
self.ui.lbr_custom_location_longitude.set_visible(True)
|
||||||
self.lbr_custom_location_latitude.set_visible(True)
|
self.ui.lbr_custom_location_latitude.set_visible(True)
|
||||||
self.lbr_time_periods.set_visible(False)
|
self.ui.lbr_time_periods.set_visible(False)
|
||||||
|
|
||||||
self.etr_latitude.set_text(str(self.c_prefs.latitude_custom))
|
self.ui.etr_latitude.set_text(str(self.prefs.latitude_custom))
|
||||||
self.etr_longitude.set_text(str(self.c_prefs.longitude_custom))
|
self.ui.etr_longitude.set_text(str(self.prefs.longitude_custom))
|
||||||
|
|
||||||
|
|
||||||
def on_toggle_button_time_periods_clicked(self, button: Gtk.Button):
|
def on_toggle_button_time_periods_clicked(self, button: Gtk.ToggleButton):
|
||||||
if button.get_active():
|
if button.get_active():
|
||||||
self.c_prefs.period_source = PeriodSourceEnum.CUSTOMTIMEPERIODS
|
self.prefs.period_source = PeriodSourceEnum.CUSTOMTIMEPERIODS
|
||||||
self.tb_network_location.set_active(False)
|
self.ui.tb_network_location.set_active(False)
|
||||||
self.tb_custom_location.set_active(False)
|
self.ui.tb_custom_location.set_active(False)
|
||||||
|
|
||||||
self.lbr_network_location.set_visible(False)
|
self.ui.lbr_network_location.set_visible(False)
|
||||||
self.lbr_current_location.set_visible(False)
|
self.ui.lbr_current_location.set_visible(False)
|
||||||
self.lbr_custom_location_longitude.set_visible(False)
|
self.ui.lbr_custom_location_longitude.set_visible(False)
|
||||||
self.lbr_custom_location_latitude.set_visible(False)
|
self.ui.lbr_custom_location_latitude.set_visible(False)
|
||||||
self.lbr_time_periods.set_visible(True)
|
self.ui.lbr_time_periods.set_visible(True)
|
||||||
|
|
||||||
|
|
||||||
for i in range(0, 9):
|
for i in range(0, 9):
|
||||||
pref_value = self.c_prefs.period_custom_start_time[i + 1]
|
pref_value = self.prefs.period_custom_start_time[i + 1]
|
||||||
time_parts = [int(pref_value[0:pref_value.find(":")]), int(pref_value[pref_value.find(":") + 1:])]
|
time_parts = [int(pref_value[0:pref_value.find(":")]), int(pref_value[pref_value.find(":") + 1:])]
|
||||||
|
|
||||||
self.spb_periods_hour[i].set_value(time_parts[0])
|
self.ui.spb_periods_hour[i].set_value(time_parts[0])
|
||||||
self.spb_periods_minute[i].set_value(time_parts[1])
|
self.ui.spb_periods_minute[i].set_value(time_parts[1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -545,34 +525,49 @@ class Preferences:
|
|||||||
index = int(spin_button_name[11:12]) - 1
|
index = int(spin_button_name[11:12]) - 1
|
||||||
|
|
||||||
# Determe time string and store to prefs
|
# Determe time string and store to prefs
|
||||||
time_current_start = datetime(2024,1,1, int(self.spb_periods_hour[index].get_value()), int(self.spb_periods_minute[index].get_value()))
|
time_current_start = datetime(2024,1,1, int(self.ui.spb_periods_hour[index].get_value()), int(self.ui.spb_periods_minute[index].get_value()))
|
||||||
time_current_start_str = str(time_current_start.hour).rjust(2, '0') + ":" + str(time_current_start.minute).rjust(2, '0')
|
time_current_start_str = str(time_current_start.hour).rjust(2, '0') + ":" + str(time_current_start.minute).rjust(2, '0')
|
||||||
|
|
||||||
self.c_prefs.period_custom_start_time[index + 1] = time_current_start_str
|
self.prefs.period_custom_start_time[index + 1] = time_current_start_str
|
||||||
|
|
||||||
|
|
||||||
time_previous_end = time_current_start - timedelta(minutes=1)
|
time_previous_end = time_current_start - timedelta(minutes=1)
|
||||||
self.lb_period_end[index].set_text(str(time_previous_end.hour).rjust(2, '0') + ":" + str(time_previous_end.minute).rjust(2, '0'))
|
self.ui.lb_period_end[index].set_text(str(time_previous_end.hour).rjust(2, '0') + ":" + str(time_previous_end.minute).rjust(2, '0'))
|
||||||
|
|
||||||
|
|
||||||
self.refresh_chart()
|
self.refresh_chart()
|
||||||
|
|
||||||
|
|
||||||
def on_spb_network_location_refresh_time_changed(self, spin_button):
|
def on_spb_network_location_refresh_time_changed(self, spin_button: Gtk.SpinButton):
|
||||||
self.c_prefs.location_refresh_intervals = spin_button.get_value()
|
""" User changed the refresh time of network location estimation
|
||||||
|
|
||||||
|
Args:
|
||||||
|
spin_button (Gtk.SpinButton): The used SpinButton
|
||||||
|
"""
|
||||||
|
self.prefs.location_refresh_intervals = spin_button.get_value()
|
||||||
|
|
||||||
|
|
||||||
def on_etr_longitude_changed(self, entry):
|
def on_etr_longitude_changed(self, entry: Gtk.Entry):
|
||||||
|
""" User changes the value of the longitude Entry
|
||||||
|
|
||||||
|
Args:
|
||||||
|
entry (Gtk.Entry): The manipulated Entry object
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
self.c_prefs.longitude_custom = float(entry.get_text())
|
self.prefs.longitude_custom = float(entry.get_text())
|
||||||
self.refresh_chart()
|
self.refresh_chart()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def on_etr_latitude_changed(self, entry):
|
def on_etr_latitude_changed(self, entry: Gtk.Entry):
|
||||||
|
""" User changes the value of the latitude Entry
|
||||||
|
|
||||||
|
Args:
|
||||||
|
entry (Gtk.Entry): The manipulated Entry object
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
self.c_prefs.latitude_custom = float(entry.get_text())
|
self.prefs.latitude_custom = float(entry.get_text())
|
||||||
self.refresh_chart()
|
self.refresh_chart()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -585,10 +580,10 @@ class Preferences:
|
|||||||
|
|
||||||
if tree_iter is not None:
|
if tree_iter is not None:
|
||||||
model = combobox.get_model()
|
model = combobox.get_model()
|
||||||
self.c_prefs.picture_aspect = model[tree_iter][0]
|
self.prefs.picture_aspect = model[tree_iter][0]
|
||||||
|
|
||||||
def on_sw_dynamic_background_color_state_set(self, switch: Gtk.Switch, state):
|
def on_sw_dynamic_background_color_state_set(self, switch: Gtk.Switch, state):
|
||||||
self.c_prefs.dynamic_background_color = state
|
self.prefs.dynamic_background_color = state
|
||||||
|
|
||||||
|
|
||||||
# About
|
# About
|
||||||
@@ -623,7 +618,10 @@ class Preferences:
|
|||||||
def on_ok(self, *args):
|
def on_ok(self, *args):
|
||||||
""" Callback for the OK button in the top bar
|
""" Callback for the OK button in the top bar
|
||||||
"""
|
"""
|
||||||
self.on_apply()
|
try:
|
||||||
|
self.on_apply()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# Close the window
|
# Close the window
|
||||||
self.on_destroy()
|
self.on_destroy()
|
||||||
@@ -633,7 +631,7 @@ class Preferences:
|
|||||||
""" Callback for the Apply button in the top bar
|
""" Callback for the Apply button in the top bar
|
||||||
"""
|
"""
|
||||||
# Store all values to the JSON file
|
# Store all values to the JSON file
|
||||||
self.c_prefs.store_preferences()
|
self.prefs.store_preferences()
|
||||||
|
|
||||||
# Use the new settings
|
# Use the new settings
|
||||||
loop = Loop()
|
loop = Loop()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import os, json
|
import os, json
|
||||||
|
|
||||||
class Cinnamon_Pref_Handler:
|
class Cinnamon_Pref_Handler:
|
||||||
|
""" Class to work with the Cinnamon Extension preference format
|
||||||
|
"""
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
# Location of the Cinnamon preference file since Cinnamon 5.4
|
# Location of the Cinnamon preference file since Cinnamon 5.4
|
||||||
self.pref_location = os.path.expanduser("~") + \
|
self.pref_location = os.path.expanduser("~") + \
|
||||||
@@ -54,6 +56,7 @@ class Cinnamon_Pref_Handler:
|
|||||||
pref_data['period_9_custom_start_time']['value']
|
pref_data['period_9_custom_start_time']['value']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def store_preferences(self):
|
def store_preferences(self):
|
||||||
""" Store the values of the Preference object to the JSON file
|
""" Store the values of the Preference object to the JSON file
|
||||||
"""
|
"""
|
||||||
|
|||||||
61
cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/dialogs.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
class Dialogs(Gtk.Window):
|
||||||
|
""" All used Gtk dialogs
|
||||||
|
|
||||||
|
Args:
|
||||||
|
Gtk (Gtk.Window): Window of Gtk application
|
||||||
|
"""
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
|
||||||
|
def source_folder_dialog(self) -> str:
|
||||||
|
""" Display a FileChooser dialog where the user choose a folder
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Absolute path to the selected folder
|
||||||
|
"""
|
||||||
|
dialog = Gtk.FileChooserDialog(
|
||||||
|
title= "Please choose a folder with images",
|
||||||
|
parent=self,
|
||||||
|
action=Gtk.FileChooserAction.SELECT_FOLDER
|
||||||
|
)
|
||||||
|
|
||||||
|
dialog.add_buttons(
|
||||||
|
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, "Select", Gtk.ResponseType.OK
|
||||||
|
)
|
||||||
|
|
||||||
|
dialog.set_default_size(800, 400)
|
||||||
|
|
||||||
|
response = dialog.run()
|
||||||
|
|
||||||
|
if response == Gtk.ResponseType.OK:
|
||||||
|
location = dialog.get_filename()
|
||||||
|
elif response == Gtk.ResponseType.CANCEL:
|
||||||
|
location = ""
|
||||||
|
|
||||||
|
dialog.destroy()
|
||||||
|
|
||||||
|
return location
|
||||||
|
|
||||||
|
|
||||||
|
def message_dialog(self, message: str):
|
||||||
|
""" Displaying a Gtk Message dialog to the user
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message (str): Message which appear in the dialog
|
||||||
|
"""
|
||||||
|
dialog = Gtk.MessageDialog(
|
||||||
|
transient_for=self,
|
||||||
|
flags=0,
|
||||||
|
message_type=Gtk.MessageType.INFO,
|
||||||
|
buttons=Gtk.ButtonsType.OK,
|
||||||
|
text=message
|
||||||
|
)
|
||||||
|
|
||||||
|
dialog.run()
|
||||||
|
dialog.destroy()
|
||||||
20
cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/display.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import gi
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gdk
|
||||||
|
|
||||||
|
class Display:
|
||||||
|
""" Handling display informations and actions
|
||||||
|
"""
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self.display = Gdk.Display.get_default()
|
||||||
|
|
||||||
|
|
||||||
|
def get_screen_height(self) -> int:
|
||||||
|
""" Estimate the height resolution of the primary display
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: Height in pixel
|
||||||
|
"""
|
||||||
|
geometry = self.display.get_monitor(0).get_geometry()
|
||||||
|
|
||||||
|
return geometry.height
|
||||||
@@ -1,10 +1,60 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
class Images:
|
class Images:
|
||||||
|
""" Class for image operations
|
||||||
|
"""
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_images_from_folder(self, URI: str) -> list:
|
def get_images_from_folder(self, URI: str) -> list:
|
||||||
items = os.listdir(URI)
|
""" List all images in a folder
|
||||||
|
|
||||||
|
Args:
|
||||||
|
URI (str): Absolute path of the folder
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: List of file names which are images
|
||||||
|
"""
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for file in os.listdir(URI):
|
||||||
|
if file.endswith(("jpg", "jpeg", "png", "bmp", "svg")):
|
||||||
|
items.append(file)
|
||||||
|
|
||||||
items.sort()
|
items.sort()
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
def extract_heic_file(self, file_uri: str) -> bool:
|
||||||
|
""" Extract a heic file to an internal folder
|
||||||
|
|
||||||
|
Args:
|
||||||
|
file_uri (str): Absolute path to the heic file
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: Extraction was successful
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
extract_folder = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)) + \
|
||||||
|
"/images/extracted_images/"
|
||||||
|
|
||||||
|
file_name: str = file_uri[file_uri.rfind("/") + 1:]
|
||||||
|
file_name = file_name[:file_name.rfind(".")]
|
||||||
|
|
||||||
|
# Create the buffer folder if its not existing
|
||||||
|
try:
|
||||||
|
os.mkdir(extract_folder)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Cleanup the folder
|
||||||
|
for file in self.get_images_from_folder(extract_folder):
|
||||||
|
os.remove(extract_folder + file)
|
||||||
|
|
||||||
|
# Extract the HEIC file
|
||||||
|
os.system("heif-convert '" + file_uri + "' '" + extract_folder + file_name + ".jpg'")
|
||||||
|
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
import urllib.request, json
|
import urllib.request, json
|
||||||
|
|
||||||
class Location():
|
class Location():
|
||||||
|
""" Class to handle location requests
|
||||||
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.GEO_URL = "https://get.geojs.io/v1/ip/geo.json"
|
self.GEO_URL = "https://get.geojs.io/v1/ip/geo.json"
|
||||||
|
|
||||||
def run(self) -> dict:
|
def get_location(self) -> dict:
|
||||||
|
""" Request the location via network
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: latitude and longitude
|
||||||
|
"""
|
||||||
request = urllib.request.urlopen(self.GEO_URL)
|
request = urllib.request.urlopen(self.GEO_URL)
|
||||||
|
|
||||||
data = json.load(request)
|
data = json.load(request)
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ class Suntimes:
|
|||||||
|
|
||||||
|
|
||||||
def calc_suntimes(self, latitude: float, longitude: float) -> None:
|
def calc_suntimes(self, latitude: float, longitude: float) -> None:
|
||||||
|
""" Start the calculation process
|
||||||
|
|
||||||
|
Args:
|
||||||
|
latitude (float): Current latitude
|
||||||
|
longitude (float): Current longitude
|
||||||
|
"""
|
||||||
self.latitude = latitude
|
self.latitude = latitude
|
||||||
self.longitude = longitude
|
self.longitude = longitude
|
||||||
self.calc_sun_events()
|
self.calc_sun_events()
|
||||||
@@ -43,6 +49,8 @@ class Suntimes:
|
|||||||
|
|
||||||
|
|
||||||
def calc_sun_events(self):
|
def calc_sun_events(self):
|
||||||
|
""" Parent sun event calculater. Calls calc_sunrise_sunset_time() for every time period
|
||||||
|
"""
|
||||||
civial_dawn_start = self.calc_sunrise_sunset_time(True, 96)
|
civial_dawn_start = self.calc_sunrise_sunset_time(True, 96)
|
||||||
sunrise_start = self.calc_sunrise_sunset_time(True)
|
sunrise_start = self.calc_sunrise_sunset_time(True)
|
||||||
morning_start = self.calc_sunrise_sunset_time(True, 89.167)
|
morning_start = self.calc_sunrise_sunset_time(True, 89.167)
|
||||||
@@ -71,8 +79,6 @@ class Suntimes:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def calc_sunrise_sunset_time(self, is_sunrise: bool, zenith=90.833) -> datetime:
|
def calc_sunrise_sunset_time(self, is_sunrise: bool, zenith=90.833) -> datetime:
|
||||||
""" Calculate all values to estimate the day periods
|
""" Calculate all values to estimate the day periods
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
class Time_Bar_Chart:
|
class Time_Bar_Chart:
|
||||||
|
""" Class to handle the creation of the day time period bar
|
||||||
|
"""
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.image_code = []
|
self.image_code = []
|
||||||
|
|
||||||
@@ -8,9 +10,9 @@ class Time_Bar_Chart:
|
|||||||
"00193d",
|
"00193d",
|
||||||
"05597f",
|
"05597f",
|
||||||
"54babf",
|
"54babf",
|
||||||
"bfe3c2",
|
"9ec3a1",
|
||||||
"ffbf6b",
|
"ffb95e",
|
||||||
"fdb55c",
|
"fcae4e",
|
||||||
"f37f73",
|
"f37f73",
|
||||||
"b45bbc",
|
"b45bbc",
|
||||||
"7e38ce",
|
"7e38ce",
|
||||||
@@ -21,9 +23,10 @@ class Time_Bar_Chart:
|
|||||||
|
|
||||||
|
|
||||||
def create_bar_chart_with_polylines(self, save_location: str, image_width: int, image_height: int, times: list):
|
def create_bar_chart_with_polylines(self, save_location: str, image_width: int, image_height: int, times: list):
|
||||||
""" Create a time bar chart
|
""" Create a time bar chart WITH polylines
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
save_location (str): Absolute path to store
|
||||||
image_width (int): Width of the image in pixel
|
image_width (int): Width of the image in pixel
|
||||||
image_height (int): Height of the image in pixel
|
image_height (int): Height of the image in pixel
|
||||||
times (list): List of start times of the periods in minutes since midnight
|
times (list): List of start times of the periods in minutes since midnight
|
||||||
@@ -45,6 +48,14 @@ class Time_Bar_Chart:
|
|||||||
|
|
||||||
|
|
||||||
def create_bar_chart(self, save_location: str, image_width: int, image_height: int, times: list):
|
def create_bar_chart(self, save_location: str, image_width: int, image_height: int, times: list):
|
||||||
|
""" Create a time bar chart WITHOUT polylines
|
||||||
|
|
||||||
|
Args:
|
||||||
|
save_location (str): Absolute path to store
|
||||||
|
image_width (int): Width of the image in pixel
|
||||||
|
image_height (int): Height of the image in pixel
|
||||||
|
times (list): List of start times of the periods in minutes since midnight
|
||||||
|
"""
|
||||||
self.create_bar(image_width, image_height, times)
|
self.create_bar(image_width, image_height, times)
|
||||||
self.create_time_markers(image_width, image_height)
|
self.create_time_markers(image_width, image_height)
|
||||||
|
|
||||||
@@ -96,13 +107,22 @@ class Time_Bar_Chart:
|
|||||||
image_height (int): Total height of the image
|
image_height (int): Total height of the image
|
||||||
"""
|
"""
|
||||||
for i in range(0, 8):
|
for i in range(0, 8):
|
||||||
|
# 3 hour vertical line
|
||||||
self.image_code.append(
|
self.image_code.append(
|
||||||
'<line x1="%s" y1="40" x2="%s" y2="%s" stroke="gray" stroke-width="2" />' %
|
'<line x1="%s" y1="40" x2="%s" y2="%s" stroke="white" stroke-width="2" />' %
|
||||||
(i * (image_width // 8), i * (image_width // 8), image_height - 40)
|
(i * (image_width // 8), i * (image_width // 8), image_height - 40)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The two hours between the 3 hour lines
|
||||||
|
for j in range(1, 3):
|
||||||
|
self.image_code.append(
|
||||||
|
'<line x1="%s" y1="40" x2="%s" y2="%s" stroke="white" stroke-width="0.5" />' %
|
||||||
|
(i * (image_width // 8) + image_width // 24 * j, i * (image_width // 8) + image_width // 24 * j, image_height - 40)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Time labels
|
||||||
self.image_code.append(
|
self.image_code.append(
|
||||||
'<text x="%s" y="%s" fill="gray" font-size="20" font-family="Liberation Sans">%s</text>' %
|
'<text x="%s" y="%s" fill="white" font-size="20" font-family="Liberation Sans">%s</text>' %
|
||||||
(i * (image_width // 8) + 5, image_height - 45, i * 3)
|
(i * (image_width // 8) + 5, image_height - 45, i * 3)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
147
cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/ui.py
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
import gi
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
class UI:
|
||||||
|
""" Class to handle UI components and actions
|
||||||
|
"""
|
||||||
|
def __init__(self, builder: Gtk.Builder) -> None:
|
||||||
|
# Page 1
|
||||||
|
self.tb_image_set: Gtk.ToggleButton = builder.get_object("tb_image_set")
|
||||||
|
self.tb_heic_file: Gtk.ToggleButton = builder.get_object("tb_heic_file")
|
||||||
|
self.tb_source_folder: Gtk.ToggleButton = builder.get_object("tb_source_folder")
|
||||||
|
self.img_tb_image_set: Gtk.Image = builder.get_object("img_tb_image_set")
|
||||||
|
self.img_tb_heic_file: Gtk.Image = builder.get_object("img_tb_heic_file")
|
||||||
|
self.img_tb_source_folder: Gtk.Image = builder.get_object("img_tb_source_folder")
|
||||||
|
|
||||||
|
# Image set
|
||||||
|
self.lbr_image_set: Gtk.ListBoxRow = builder.get_object("lbr_image_set")
|
||||||
|
self.cb_image_set: Gtk.ComboBox = builder.get_object("cb_image_set")
|
||||||
|
|
||||||
|
# HEIC file
|
||||||
|
self.lbr_heic_file: Gtk.ListBoxRow = builder.get_object("lbr_heic_file")
|
||||||
|
|
||||||
|
# Source folder
|
||||||
|
self.lbr_source_folder: Gtk.ListBoxRow = builder.get_object("lbr_source_folder")
|
||||||
|
self.btn_source_folder: Gtk.Button = builder.get_object("btn_source_folder")
|
||||||
|
self.lbl_source_folder: Gtk.Label = builder.get_object("lbl_source_folder")
|
||||||
|
|
||||||
|
# Time bar chart
|
||||||
|
self.img_bar_images: Gtk.Image = builder.get_object("img_bar_images")
|
||||||
|
self.etr_periods: list[Gtk.Entry] = [
|
||||||
|
builder.get_object("etr_period_1"), builder.get_object("etr_period_2"),
|
||||||
|
builder.get_object("etr_period_3"), builder.get_object("etr_period_4"),
|
||||||
|
builder.get_object("etr_period_5"), builder.get_object("etr_period_6"),
|
||||||
|
builder.get_object("etr_period_7"), builder.get_object("etr_period_8"),
|
||||||
|
builder.get_object("etr_period_9"), builder.get_object("etr_period_10"),
|
||||||
|
]
|
||||||
|
|
||||||
|
self.img_periods: list[Gtk.Image] = [
|
||||||
|
builder.get_object("img_period_0"), builder.get_object("img_period_1"),
|
||||||
|
builder.get_object("img_period_2"), builder.get_object("img_period_3"),
|
||||||
|
builder.get_object("img_period_4"), builder.get_object("img_period_5"),
|
||||||
|
builder.get_object("img_period_6"), builder.get_object("img_period_7"),
|
||||||
|
builder.get_object("img_period_8"), builder.get_object("img_period_9"),
|
||||||
|
]
|
||||||
|
|
||||||
|
self.cb_periods: list[Gtk.ComboBox] = [
|
||||||
|
builder.get_object("cb_period_0"), builder.get_object("cb_period_1"),
|
||||||
|
builder.get_object("cb_period_2"), builder.get_object("cb_period_3"),
|
||||||
|
builder.get_object("cb_period_4"), builder.get_object("cb_period_5"),
|
||||||
|
builder.get_object("cb_period_6"), builder.get_object("cb_period_7"),
|
||||||
|
builder.get_object("cb_period_8"), builder.get_object("cb_period_9"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Page 2: Location & Times
|
||||||
|
self.tb_network_location: Gtk.ToggleButton = builder.get_object("tb_network_location")
|
||||||
|
self.tb_custom_location: Gtk.ToggleButton = builder.get_object("tb_custom_location")
|
||||||
|
self.tb_time_periods: Gtk.ToggleButton = builder.get_object("tb_time_periods")
|
||||||
|
self.img_tb_network_location: Gtk.Image = builder.get_object("img_tb_network_location")
|
||||||
|
self.img_tb_custom_location: Gtk.Image = builder.get_object("img_tb_custom_location")
|
||||||
|
self.img_tb_time_periods: Gtk.Image = builder.get_object("img_tb_time_periods")
|
||||||
|
|
||||||
|
# Network Location
|
||||||
|
self.lb_current_location: Gtk.Label = builder.get_object("lb_current_location")
|
||||||
|
self.lbr_current_location: Gtk.ListBoxRow = builder.get_object("lbr_current_location")
|
||||||
|
self.lbr_network_location: Gtk.ListBoxRow = builder.get_object("lbr_network_location")
|
||||||
|
self.spb_network_location_refresh_time: Gtk.SpinButton = builder.get_object("spb_network_location_refresh_time")
|
||||||
|
|
||||||
|
# Custom location
|
||||||
|
self.lbr_custom_location_longitude: Gtk.ListBoxRow = builder.get_object("lbr_custom_location_longitude")
|
||||||
|
self.lbr_custom_location_latitude: Gtk.ListBoxRow = builder.get_object("lbr_custom_location_latitude")
|
||||||
|
self.lbr_time_periods: Gtk.ListBoxRow = builder.get_object("lbr_time_periods")
|
||||||
|
self.etr_longitude: Gtk.Entry = builder.get_object("etr_longitude")
|
||||||
|
self.etr_latitude: Gtk.Entry = builder.get_object("etr_latitude")
|
||||||
|
self.img_bar_times: Gtk.Image = builder.get_object("img_bar_times")
|
||||||
|
self.spb_periods_hour: list[Gtk.SpinButton] = [
|
||||||
|
builder.get_object("spb_period_1_hour"),
|
||||||
|
builder.get_object("spb_period_2_hour"),
|
||||||
|
builder.get_object("spb_period_3_hour"),
|
||||||
|
builder.get_object("spb_period_4_hour"),
|
||||||
|
builder.get_object("spb_period_5_hour"),
|
||||||
|
builder.get_object("spb_period_6_hour"),
|
||||||
|
builder.get_object("spb_period_7_hour"),
|
||||||
|
builder.get_object("spb_period_8_hour"),
|
||||||
|
builder.get_object("spb_period_9_hour"),
|
||||||
|
]
|
||||||
|
self.spb_periods_minute: list[Gtk.SpinButton] = [
|
||||||
|
builder.get_object("spb_period_1_minute"),
|
||||||
|
builder.get_object("spb_period_2_minute"),
|
||||||
|
builder.get_object("spb_period_3_minute"),
|
||||||
|
builder.get_object("spb_period_4_minute"),
|
||||||
|
builder.get_object("spb_period_5_minute"),
|
||||||
|
builder.get_object("spb_period_6_minute"),
|
||||||
|
builder.get_object("spb_period_7_minute"),
|
||||||
|
builder.get_object("spb_period_8_minute"),
|
||||||
|
builder.get_object("spb_period_9_minute")
|
||||||
|
]
|
||||||
|
self.lb_period_end: list[Gtk.Label] = [
|
||||||
|
builder.get_object("lb_period_0_end"), builder.get_object("lb_period_1_end"),
|
||||||
|
builder.get_object("lb_period_2_end"), builder.get_object("lb_period_3_end"),
|
||||||
|
builder.get_object("lb_period_4_end"), builder.get_object("lb_period_5_end"),
|
||||||
|
builder.get_object("lb_period_6_end"), builder.get_object("lb_period_7_end"),
|
||||||
|
builder.get_object("lb_period_8_end"), builder.get_object("lb_period_9_end"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Page 3: Behaviour
|
||||||
|
self.cb_picture_aspect: Gtk.ComboBox = builder.get_object("cb_picture_aspect")
|
||||||
|
self.sw_dynamic_background_color: Gtk.Switch = builder.get_object("sw_dynamic_background_color")
|
||||||
|
|
||||||
|
|
||||||
|
def set_active_combobox_item(self, combobox: Gtk.ComboBoxText, active_item: str):
|
||||||
|
""" Change active item in combobox by String value
|
||||||
|
|
||||||
|
Args:
|
||||||
|
combobox (Gtk.ComboBoxText): ComboBox to set active
|
||||||
|
active_item (str): String item to set active
|
||||||
|
"""
|
||||||
|
list_store = combobox.get_model()
|
||||||
|
|
||||||
|
for i in range(0, len(list_store)):
|
||||||
|
row = list_store[i]
|
||||||
|
if row[0] == active_item:
|
||||||
|
combobox.set_active(i)
|
||||||
|
|
||||||
|
|
||||||
|
def add_items_to_combo_box(self, combobox: Gtk.ComboBox, items: list):
|
||||||
|
""" Add items to a combo box
|
||||||
|
|
||||||
|
Args:
|
||||||
|
combobox (Gtk.ComboBox): ComboBox where to add the options
|
||||||
|
items (list): Possible options
|
||||||
|
"""
|
||||||
|
model = combobox.get_model()
|
||||||
|
store = Gtk.ListStore(str)
|
||||||
|
|
||||||
|
for image_set in items:
|
||||||
|
store.append([image_set])
|
||||||
|
|
||||||
|
combobox.set_model(store)
|
||||||
|
|
||||||
|
if model == None:
|
||||||
|
renderer_text = Gtk.CellRendererText()
|
||||||
|
combobox.pack_start(renderer_text, True)
|
||||||
|
combobox.add_attribute(renderer_text, "text", 0)
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
},
|
},
|
||||||
"picture_aspect": {
|
"picture_aspect": {
|
||||||
"type": "generic",
|
"type": "generic",
|
||||||
"default": "Scaled"
|
"default": "scaled"
|
||||||
},
|
},
|
||||||
"dynamic_background_color": {
|
"dynamic_background_color": {
|
||||||
"type": "generic",
|
"type": "generic",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"uuid": "cinnamon-dynamic-wallpaper@TobiZog",
|
"uuid": "cinnamon-dynamic-wallpaper@TobiZog",
|
||||||
"name": "Cinnamon Dynamic Wallpaper",
|
"name": "Cinnamon Dynamic Wallpaper",
|
||||||
"description": "Cinnamon extension for dynamic desktop backgrounds based on time and location",
|
"description": "Cinnamon extension for dynamic desktop backgrounds based on time and location",
|
||||||
"version": "2.0",
|
"version": "2.1",
|
||||||
"multiversion": true,
|
"multiversion": true,
|
||||||
"cinnamon-version": [
|
"cinnamon-version": [
|
||||||
"5.4",
|
"5.4",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 412 KiB After Width: | Height: | Size: 373 KiB |