Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add messengers as plugins #9

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ foreach i : icon_sizes
)
endforeach

shared_icons = [
'com.messenger',
'com.slack',
'com.whatsapp.web',
'org.telegram.web'
]

foreach icon : shared_icons
install_data(
join_paths('icons', 'share', icon + '.svg'),
install_dir: join_paths(get_option('datadir'), meson.project_name(), 'icons')
)
endforeach

i18n.merge_file(
input: meson.project_name() + '.desktop.in',
output: meson.project_name() + '.desktop',
Expand Down
9 changes: 9 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ gtk_plus_3_dep = dependency('gtk+-3.0')
granite_dep = dependency('granite')
webkit2gtk_4_dep = dependency('webkit2gtk-4.0')

dependencies = [
gtk_plus_3_dep,
granite_dep,
webkit2gtk_4_dep,
]

sources = []

subdir('data')
subdir('plugins')
subdir('po')
subdir('src')

Expand Down
30 changes: 30 additions & 0 deletions plugins/com.messenger/com.messenger.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 Manexim (https://github.com/manexim)
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class ComMessenger : Models.Plugin {
public ComMessenger () {
Object (
id: "com.messenger",
name: "Messenger",
url: "https://www.messenger.com/"
);
}
}
10 changes: 10 additions & 0 deletions plugins/com.messenger/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = 'com.messenger'

sources += [
join_paths(meson.source_root(), meson.current_source_dir(), name + '.vala')
]

install_data(
name + '.svg',
install_dir: join_paths(get_option('datadir'), meson.project_name(), 'icons')
)
File renamed without changes
30 changes: 30 additions & 0 deletions plugins/com.slack/com.slack.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 Manexim (https://github.com/manexim)
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class ComSlack : Models.Plugin {
public ComSlack () {
Object (
id: "com.slack",
name: "Slack",
url: "https://slack.com/signin/"
);
}
}
10 changes: 10 additions & 0 deletions plugins/com.slack/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = 'com.slack'

sources += [
join_paths(meson.source_root(), meson.current_source_dir(), name + '.vala')
]

install_data(
name + '.svg',
install_dir: join_paths(get_option('datadir'), meson.project_name(), 'icons')
)
30 changes: 30 additions & 0 deletions plugins/com.whatsapp.web/com.whatsapp.web.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 Manexim (https://github.com/manexim)
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class ComWhatsappWeb : Models.Plugin {
public ComWhatsappWeb () {
Object (
id: "com.whatsapp.web",
name: "WhatsApp",
url: "https://web.whatsapp.com/"
);
}
}
10 changes: 10 additions & 0 deletions plugins/com.whatsapp.web/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = 'com.whatsapp.web'

sources += [
join_paths(meson.source_root(), meson.current_source_dir(), name + '.vala')
]

install_data(
name + '.svg',
install_dir: join_paths(get_option('datadir'), meson.project_name(), 'icons')
)
4 changes: 4 additions & 0 deletions plugins/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
subdir('com.messenger')
subdir('com.slack')
subdir('com.whatsapp.web')
subdir('org.telegram.web')
10 changes: 10 additions & 0 deletions plugins/org.telegram.web/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = 'org.telegram.web'

sources += [
join_paths(meson.source_root(), meson.current_source_dir(), name + '.vala')
]

install_data(
name + '.svg',
install_dir: join_paths(get_option('datadir'), meson.project_name(), 'icons')
)
30 changes: 30 additions & 0 deletions plugins/org.telegram.web/org.telegram.web.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 Manexim (https://github.com/manexim)
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class OrgTelegramWeb : Models.Plugin {
public OrgTelegramWeb () {
Object (
id: "org.telegram.web",
name: "Telegram",
url: "https://web.telegram.org/"
);
}
}
12 changes: 10 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public class Application : Granite.Application {
}

construct {
var action = new SimpleAction ("show-messenger", VariantType.STRING);
var action = new SimpleAction ("show-tab", VariantType.STRING);
action.activate.connect ((parameter) => {
this.hold ();
string id = parameter.get_string ();
Services.Messengers.get_default ().visible = id;
Services.PluginManager.get_default ().visible = id;
this.release ();
});

Expand All @@ -35,6 +35,14 @@ public class Application : Granite.Application {
window = new MainWindow (this);

window.show_all ();

var action_quit = new SimpleAction ("quit", null);
add_action (action_quit);
set_accels_for_action ("app.quit", {"<Ctrl>Q"});

action_quit.activate.connect (() => {
quit ();
});
}

public static int main (string[] args) {
Expand Down
12 changes: 11 additions & 1 deletion src/Models/Messenger.vala → src/Models/Plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class Models.Messenger : Object {
public class Models.Plugin : Object {
private string _id;
private string _name;
private string _url;
private bool _enabled = true;
private uint _unread_notifications = 0;

public string id {
Expand Down Expand Up @@ -52,6 +53,15 @@ public class Models.Messenger : Object {
}
}

public bool enabled {
get {
return _enabled;
}
set {
_enabled = value;
}
}

public uint unread_notifications {
get {
return _unread_notifications;
Expand Down
55 changes: 25 additions & 30 deletions src/Services/Messengers.vala → src/Services/PluginManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,29 @@
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class Services.Messengers : Object {
private static Messengers instance;
private Array<Models.Messenger> _data;
public class Services.PluginManager : Object {
private static PluginManager instance;
private Array<Models.Plugin> _data;
private string _visible;

public static Messengers get_default () {
public static PluginManager get_default () {
if (instance == null) {
instance = new Messengers ();
instance = new PluginManager ();
}

return instance;
}

public Array<Models.Messenger> data {
get {
return _data;
public Array<Models.Plugin> enabled {
owned get {
var array = new Array<Models.Plugin> ();
for (var i = 0; i < _data.length; i++) {
if (_data.index (i).enabled) {
array.append_val (_data.index (i));
}
}

return array;
}
}

Expand All @@ -52,39 +59,27 @@ public class Services.Messengers : Object {
}
}

private Messengers () {
_data = new Array<Models.Messenger> ();
private PluginManager () {
_data = new Array<Models.Plugin> ();

{
var messenger = new Models.Messenger ();
messenger.id = "com.messenger";
messenger.name = "Messenger";
messenger.url = "https://www.messenger.com/";
_data.append_val (messenger);
var plugin = new ComMessenger ();
_data.append_val (plugin);
}

{
var messenger = new Models.Messenger ();
messenger.id = "com.slack";
messenger.name = "Slack";
messenger.url = "https://slack.com/signin/";
_data.append_val (messenger);
var plugin = new ComSlack ();
_data.append_val (plugin);
}

{
var messenger = new Models.Messenger ();
messenger.id = "org.telegram.web";
messenger.name = "Telegram";
messenger.url = "https://web.telegram.org/";
_data.append_val (messenger);
var plugin = new OrgTelegramWeb ();
_data.append_val (plugin);
}

{
var messenger = new Models.Messenger ();
messenger.id = "com.whatsapp.web";
messenger.name = "WhatsApp";
messenger.url = "https://web.whatsapp.com/";
_data.append_val (messenger);
var plugin = new ComWhatsappWeb ();
_data.append_val (plugin);
}
}
}
Loading