summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2018-02-12 18:24:02 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2018-02-13 20:11:28 +0100
commit67fadd12dd0739ac97a0342a50654b6c4de23f8b (patch)
treed85411b938dfbcadbe7268d99600c26c551ade89
parent78a1627745290392e17840171292ae5dd60b9b66 (diff)
downloadgnome-contacts-wip/nielsdg/extract-im-service.tar.gz
WIP: extract ImService as a separate class.wip/nielsdg/extract-im-service
-rw-r--r--po/POTFILES.in1
-rw-r--r--po/POTFILES.skip1
-rw-r--r--src/contacts-contact-sheet.vala2
-rw-r--r--src/contacts-contact.vala45
-rw-r--r--src/contacts-im-service.vala67
-rw-r--r--src/meson.build1
6 files changed, 73 insertions, 44 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f710868..e684c88 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,6 +23,7 @@ src/contacts-contact-pane.vala
src/contacts-contact-sheet.vala
src/contacts-contact.vala
src/contacts-esd-setup.vala
+src/contacts-im-service.vala
src/contacts-linked-personas-dialog.vala
src/contacts-link-suggestion-grid.vala
src/contacts-settings.vala
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index a69be8a..3125cfd 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -12,6 +12,7 @@ src/contacts-contact-list.c
src/contacts-contact-pane.c
src/contacts-contact-sheet.c
src/contacts-esd-setup.c
+src/contacts-im-service.c
src/contacts-linked-personas-dialog.c
src/contacts-link-suggestion-grid.c
src/contacts-settings.c
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index 8467f46..ce9ce7c 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -169,7 +169,7 @@ public class Contacts.ContactSheet : Grid {
foreach (var protocol in im_details.im_addresses.get_keys ()) {
foreach (var id in im_details.im_addresses[protocol]) {
if (p is Tpf.Persona) {
- var button = add_row_with_button (ref i, Contact.format_im_service (protocol), id.value);
+ var button = add_row_with_button (ref i, ImService.get_display_name (protocol), id.value);
button.clicked.connect (() => {
var im_persona = c.find_im_persona (protocol, id.value);
if (im_persona != null) {
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 12e9a6c..8036803 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -276,47 +276,6 @@ public class Contacts.Contact : GLib.Object {
}
#endif
- private struct ImData {
- unowned string service;
- unowned string display_name;
- }
-
- public static string format_im_service (string service) {
- const ImData[] data = {
- { "google-talk", N_("Google Talk") },
- { "ovi-chat", N_("Ovi Chat") },
- { "facebook", N_("Facebook") },
- { "lj-talk", N_("Livejournal") },
- { "aim", N_("AOL Instant Messenger") },
- { "gadugadu", N_("Gadu-Gadu") },
- { "groupwise", N_("Novell Groupwise") },
- { "icq", N_("ICQ")},
- { "irc", N_("IRC")},
- { "jabber", N_("Jabber")},
- { "local-xmpp", N_("Local network")},
- { "msn", N_("Windows Live Messenger")},
- { "myspace", N_("MySpace")},
- { "mxit", N_("MXit")},
- { "napster", N_("Napster")},
- { "qq", N_("Tencent QQ")},
- { "sametime", N_("IBM Lotus Sametime")},
- { "silc", N_("SILC")},
- { "sip", N_("sip")},
- { "skype", N_("Skype")},
- { "tel", N_("Telephony")},
- { "trepia", N_("Trepia")},
- { "yahoo", N_("Yahoo! Messenger")},
- { "yahoojp", N_("Yahoo! Messenger")},
- { "zephyr", N_("Zephyr")}
- };
-
- foreach (var d in data)
- if (d.service == service)
- return dgettext (Config.GETTEXT_PACKAGE, d.display_name);
-
- return service;
- }
-
private bool changed_cb () {
changed_id = 0;
var changed_personas = this.changed_personas;
@@ -518,7 +477,7 @@ public class Contacts.Contact : GLib.Object {
#if HAVE_TELEPATHY
if (store.type_id == "telepathy") {
var account = (store as Tpf.PersonaStore).account;
- return format_im_service (account.service);
+ return Contacts.ImService.get_display_name (account.service);
}
#endif
@@ -613,7 +572,7 @@ public class Contacts.Contact : GLib.Object {
#if HAVE_TELEPATHY
if (store.type_id == "telepathy") {
var account = (store as Tpf.PersonaStore).account;
- return format_im_service (account.service);
+ return Contacts.ImService.get_display_name (account.service);
}
#endif
diff --git a/src/contacts-im-service.vala b/src/contacts-im-service.vala
new file mode 100644
index 0000000..05a360b
--- /dev/null
+++ b/src/contacts-im-service.vala
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+using Gtk;
+using Folks;
+using Gee;
+
+namespace Contacts.ImService {
+
+ private struct ImData {
+ unowned string service_name;
+ unowned string display_name;
+ }
+
+ private const ImData[] data = {
+ { "aim", N_("AOL Instant Messenger") },
+ { "facebook", N_("Facebook") },
+ { "gadugadu", N_("Gadu-Gadu") },
+ { "google-talk", N_("Google Talk") },
+ { "groupwise", N_("Novell Groupwise") },
+ { "icq", N_("ICQ") },
+ { "irc", N_("IRC") },
+ { "jabber", N_("Jabber") },
+ { "lj-talk", N_("Livejournal") },
+ { "local-xmpp", N_("Local network") },
+ { "msn", N_("Windows Live Messenger") },
+ { "myspace", N_("MySpace") },
+ { "mxit", N_("MXit") },
+ { "napster", N_("Napster") },
+ { "ovi-chat", N_("Ovi Chat") },
+ { "qq", N_("Tencent QQ") },
+ { "sametime", N_("IBM Lotus Sametime") },
+ { "silc", N_("SILC") },
+ { "sip", N_("sip") },
+ { "skype", N_("Skype") },
+ { "tel", N_("Telephony") },
+ { "trepia", N_("Trepia") },
+ { "yahoo", N_("Yahoo! Messenger") },
+ { "yahoojp", N_("Yahoo! Messenger") },
+ { "zephyr", N_("Zephyr") }
+ };
+
+ /**
+ * Returns the name for the given ImService in a nicely presented way.
+ */
+ public string get_display_name (string service_name) {
+ foreach (var d in data)
+ if (d.service_name == service_name)
+ return dgettext (Config.GETTEXT_PACKAGE, d.display_name);
+
+ return service_name;
+ }
+}
diff --git a/src/meson.build b/src/meson.build
index fc20c72..cc13e4f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -72,6 +72,7 @@ endif
if telepathy_enabled
contacts_deps += [ folks_telepathy, telepathy_glib ]
contacts_vala_args += [ '-D', 'HAVE_TELEPATHY' ]
+ contacts_vala_sources += [ 'contacts-im-service.vala' ]
endif
contacts_sources = [