Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bb7b927
Showing
11 changed files
with
889 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Budgie Weather | ||
|
||
|
||
--- | ||
|
||
## Dependencies | ||
``` | ||
budgie-1.0 >= 2 | ||
gnome-desktop-3.0 | ||
gtk+-3.0 >= 3.18 | ||
glib-2.0 | ||
libpeas-1.0 >= 1.8.0 | ||
vala | ||
``` | ||
|
||
### Installing | ||
|
||
**From source** | ||
```bash | ||
mkdir build && cd build | ||
meson --prefix /usr --buildtype=plain .. | ||
ninja | ||
sudo ninja install | ||
``` | ||
|
||
### License | ||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or at your option) any later version. | ||
|
||
Workspaces applet of Budgie Desktop is used as a templete for this project. Spacer applet used as a templete in implementing settings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
project( | ||
'budgie_weather_applet', | ||
['c', 'vala'], | ||
version: '0.1.0', | ||
license: [ | ||
'GPL-2.0' | ||
], | ||
default_options: [ | ||
'c_std=c11', | ||
], | ||
) | ||
|
||
gnome = import('gnome') | ||
|
||
am_cflags = [ | ||
'-fstack-protector', | ||
'-pedantic', | ||
'-Wstrict-prototypes', | ||
'-Wundef', | ||
'-Werror-implicit-function-declaration', | ||
'-Wformat', | ||
'-Wformat-security', | ||
'-Werror=format-security', | ||
'-Wconversion', | ||
'-Wunused-variable', | ||
'-Wunreachable-code', | ||
'-Wall', | ||
'-W', | ||
] | ||
|
||
add_global_arguments(am_cflags, language: 'c') | ||
|
||
dep_gtk3 = dependency('gtk+-3.0', version: '>=3.18') | ||
dep_glib = dependency('glib-2.0', version: '>= 2.46.0') | ||
dep_peas = dependency('libpeas-1.0', version: '>= 1.8.0') | ||
dep_budgie = dependency('budgie-1.0', version: '>= 2') | ||
|
||
LIB_INSTALL_DIR = join_paths(get_option('prefix'), get_option('libdir'), 'budgie-desktop', 'plugins', meson.project_name()) | ||
|
||
subdir('src') | ||
|
||
meson.add_install_script('./meson_post_install.py') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import subprocess | ||
|
||
schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas') | ||
|
||
if not os.environ.get('DESTDIR'): | ||
print('Compiling gsettings schemas...') | ||
subprocess.call(['glib-compile-schemas', schemadir]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Plugin] | ||
Module=libbudgieweatherapplet.so | ||
Name=Budgie Weather | ||
Description=Weather | ||
Authors=Mehmet Ali İLGAR <mehmet.ali@milgar.net> | ||
Copyright=Copyright © 2017 Mehmet Ali İLGAR | ||
Website=https://github.com/ilgarmehmetali/budgie-weather-applet | ||
Icon=weather-overcast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
|
||
namespace Weather { | ||
|
||
public class Plugin : Budgie.Plugin, Peas.ExtensionBase | ||
{ | ||
public Budgie.Applet get_panel_widget(string uuid) | ||
{ | ||
return new Applet(uuid); | ||
} | ||
} | ||
|
||
public class Applet : Budgie.Applet | ||
{ | ||
Gtk.Label city_name; | ||
Gtk.Label temp; | ||
Gtk.Image weather_icon; | ||
|
||
public string uuid { public set; public get; } | ||
|
||
private Settings? settings; | ||
|
||
public Applet(string uuid) | ||
{ | ||
Object(uuid: uuid); | ||
|
||
this.weather_icon = new Gtk.Image.from_icon_name ("weather-overcast", Gtk.IconSize.MENU); | ||
|
||
this.city_name = new Gtk.Label ("-"); | ||
this.city_name.set_ellipsize (Pango.EllipsizeMode.END); | ||
this.city_name.set_alignment(0, 0.5f); | ||
this.temp = new Gtk.Label ("-"); | ||
this.temp.set_ellipsize (Pango.EllipsizeMode.END); | ||
this.temp.set_alignment(0, 0.5f); | ||
|
||
Gtk.Box box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); | ||
box.pack_start (this.weather_icon, false, false, 0); | ||
box.pack_start (this.temp, false, false, 0); | ||
box.pack_start (this.city_name, false, false, 0); | ||
this.add (box); | ||
|
||
settings_schema = "net.milgar.budgie-weather"; | ||
settings_prefix = "/net/milgar/budgie-weather"; | ||
|
||
this.settings = this.get_applet_settings(uuid); | ||
this.settings.changed.connect(on_settings_change); | ||
this.on_settings_change("longitude"); | ||
this.on_settings_change("latitude"); | ||
this.on_settings_change("show-icon"); | ||
this.on_settings_change("show-city-name"); | ||
this.on_settings_change("show-temp"); | ||
show_all(); | ||
} | ||
|
||
void on_settings_change(string key) { | ||
if (key == "longitude") { | ||
// update weather data | ||
} else if (key == "latitude") { | ||
// update weather data | ||
} else if (key == "show-icon") { | ||
if(this.settings.get_boolean("show-icon")) { | ||
this.weather_icon.show(); | ||
} else { | ||
this.weather_icon.hide(); | ||
} | ||
} else if (key == "show-city-name") { | ||
if(this.settings.get_boolean("show-city-name")) { | ||
this.city_name.show(); | ||
} else { | ||
this.city_name.hide(); | ||
} | ||
} else if (key == "show-temp") { | ||
if(this.settings.get_boolean("show-temp")) { | ||
this.temp.show(); | ||
} else { | ||
this.temp.hide(); | ||
} | ||
} else if (key == "update-now") { | ||
if(this.settings.get_boolean("update-now")) { | ||
this.city_name.label += "-"; | ||
} | ||
} | ||
queue_resize(); | ||
} | ||
|
||
public override bool supports_settings() { | ||
return true; | ||
} | ||
|
||
public override Gtk.Widget? get_settings_ui() | ||
{ | ||
return new AppletSettings(this.get_applet_settings(uuid)); | ||
} | ||
} | ||
|
||
[GtkTemplate (ui = "/net/milgar/budgie-weather/settings.ui")] | ||
public class AppletSettings : Gtk.Grid | ||
{ | ||
Settings? settings = null; | ||
|
||
[GtkChild] | ||
private Gtk.SpinButton? spinbutton_longitude; | ||
|
||
[GtkChild] | ||
private Gtk.SpinButton? spinbutton_latitude; | ||
|
||
[GtkChild] | ||
private Gtk.Switch? switch_icon; | ||
|
||
[GtkChild] | ||
private Gtk.Switch? switch_city_name; | ||
|
||
[GtkChild] | ||
private Gtk.Switch? switch_temp; | ||
|
||
[GtkChild] | ||
private Gtk.Button? button_update_now; | ||
|
||
[GtkChild] | ||
private Gtk.Entry? textentry_openweathermap_api_key; | ||
|
||
public AppletSettings(Settings? settings) | ||
{ | ||
this.settings = settings; | ||
|
||
this.settings.bind("longitude", spinbutton_longitude, "value", SettingsBindFlags.DEFAULT); | ||
this.settings.bind("latitude", spinbutton_latitude, "value", SettingsBindFlags.DEFAULT); | ||
this.settings.bind("openweathermap-api-key", textentry_openweathermap_api_key, "text", SettingsBindFlags.DEFAULT); | ||
this.settings.bind("show-icon", switch_icon, "active", SettingsBindFlags.DEFAULT); | ||
this.settings.bind("show-city-name", switch_city_name, "active", SettingsBindFlags.DEFAULT); | ||
this.settings.bind("show-temp", switch_temp, "active", SettingsBindFlags.DEFAULT); | ||
|
||
this.button_update_now.clicked.connect (() => { | ||
this.settings.set_boolean("update-now", true); | ||
this.settings.set_boolean("update-now", false); | ||
}); | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
[ModuleInit] | ||
public void peas_register_types(TypeModule module) | ||
{ | ||
// boilerplate - all modules need this | ||
var objmodule = module as Peas.ObjectModule; | ||
objmodule.register_extension_type(typeof(Budgie.Plugin), typeof(Weather.Plugin)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
custom_target('plugin-file-workspaces', | ||
input : 'BudgieWeatherApplet.plugin.in', | ||
output : 'BudgieWeatherApplet.plugin', | ||
command : ['cp', '@INPUT@', '@OUTPUT@'], | ||
install : true, | ||
install_dir: LIB_INSTALL_DIR, | ||
) | ||
|
||
gresource = join_paths(meson.current_source_dir(), 'plugin.gresource.xml') | ||
|
||
# Compile the assets into the binary | ||
applet_budgie_weather_resources = gnome.compile_resources( | ||
'budgie-weather-applet-resources', | ||
gresource, | ||
source_dir: meson.current_source_dir(), | ||
c_name: 'budgie_weather', | ||
) | ||
|
||
|
||
applet_budgie_weather_sources = [ | ||
'BudgieWeatherApplet.vala', | ||
applet_budgie_weather_resources, | ||
] | ||
|
||
applet_budgie_weather_deps = [ | ||
dep_gtk3, | ||
dep_glib, | ||
dep_peas, | ||
dep_budgie, | ||
] | ||
|
||
shared_library( | ||
'budgieweatherapplet', | ||
applet_budgie_weather_sources, | ||
dependencies: applet_budgie_weather_deps, | ||
install: true, | ||
install_dir: LIB_INSTALL_DIR, | ||
) | ||
|
||
install_data('net.milgar.budgie-weather.gschema.xml', | ||
install_dir: '/usr/share/glib-2.0/schemas' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<schemalist> | ||
<schema id="net.milgar.budgie-weather"> | ||
<key type="d" name="longitude"> | ||
<default>0</default> | ||
<summary>Longitude</summary> | ||
<description>Longitude</description> | ||
</key> | ||
<key type="d" name="latitude"> | ||
<default>0</default> | ||
<summary>Latitude</summary> | ||
<description>Latitude</description> | ||
</key> | ||
<key type="s" name="openweathermap-api-key"> | ||
<default>""</default> | ||
<summary>OpenWeatherMap API Key</summary> | ||
<description>OpenWeatherMap API Key</description> | ||
</key> | ||
<key type="b" name="show-icon"> | ||
<default>true</default> | ||
<summary>Show Icon</summary> | ||
<description>Whether to show icon about weather</description> | ||
</key> | ||
<key type="b" name="show-city-name"> | ||
<default>true</default> | ||
<summary>Show City Name</summary> | ||
<description>Whether to show city name</description> | ||
</key> | ||
<key type="b" name="show-temp"> | ||
<default>true</default> | ||
<summary>Show Temperature</summary> | ||
<description>Whether to show temperature</description> | ||
</key> | ||
<key type="b" name="update-now"> | ||
<default>false</default> | ||
<summary>Update Data Now</summary> | ||
<description>Whether to Update Data Now</description> | ||
</key> | ||
</schema> | ||
</schemalist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<gresources> | ||
<gresource prefix="/net/milgar/budgie-weather"> | ||
<file preprocess="xml-stripblanks">settings.ui</file> | ||
</gresource> | ||
</gresources> |
Oops, something went wrong.