Added a plug-in to confirm the presence of the application in the system tray

This commit is contained in:
Pierre Pronchery 2011-08-20 14:43:12 +00:00
parent 5a176cd359
commit 99302b8242
4 changed files with 175 additions and 5 deletions

View File

@ -81,7 +81,6 @@ dist:
$(PACKAGE)-$(VERSION)/src/callbacks.h \ $(PACKAGE)-$(VERSION)/src/callbacks.h \
$(PACKAGE)-$(VERSION)/src/modem.h \ $(PACKAGE)-$(VERSION)/src/modem.h \
$(PACKAGE)-$(VERSION)/src/phone.h \ $(PACKAGE)-$(VERSION)/src/phone.h \
$(PACKAGE)-$(VERSION)/src/common.c \
$(PACKAGE)-$(VERSION)/src/project.conf \ $(PACKAGE)-$(VERSION)/src/project.conf \
$(PACKAGE)-$(VERSION)/src/modems/debug.c \ $(PACKAGE)-$(VERSION)/src/modems/debug.c \
$(PACKAGE)-$(VERSION)/src/modems/hayes.c \ $(PACKAGE)-$(VERSION)/src/modems/hayes.c \
@ -100,6 +99,7 @@ dist:
$(PACKAGE)-$(VERSION)/src/plugins/panel.c \ $(PACKAGE)-$(VERSION)/src/plugins/panel.c \
$(PACKAGE)-$(VERSION)/src/plugins/profiles.c \ $(PACKAGE)-$(VERSION)/src/plugins/profiles.c \
$(PACKAGE)-$(VERSION)/src/plugins/smscrypt.c \ $(PACKAGE)-$(VERSION)/src/plugins/smscrypt.c \
$(PACKAGE)-$(VERSION)/src/plugins/systray.c \
$(PACKAGE)-$(VERSION)/src/plugins/Makefile \ $(PACKAGE)-$(VERSION)/src/plugins/Makefile \
$(PACKAGE)-$(VERSION)/src/plugins/project.conf \ $(PACKAGE)-$(VERSION)/src/plugins/project.conf \
$(PACKAGE)-$(VERSION)/src/plugins/16x16/Makefile \ $(PACKAGE)-$(VERSION)/src/plugins/16x16/Makefile \

View File

@ -1,5 +1,5 @@
SUBDIRS = 16x16 24x24 32x32 48x48 SUBDIRS = 16x16 24x24 32x32 48x48
TARGETS = blacklist.so debug.so engineering.so gprs.so locker.so n900.so openmoko.so oss.so panel.so profiles.so smscrypt.so TARGETS = blacklist.so debug.so engineering.so gprs.so locker.so n900.so openmoko.so oss.so panel.so profiles.so smscrypt.so systray.so
PREFIX = /usr/local PREFIX = /usr/local
DESTDIR = DESTDIR =
LIBDIR = $(PREFIX)/lib LIBDIR = $(PREFIX)/lib
@ -99,6 +99,13 @@ smscrypt_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
smscrypt.so: $(smscrypt_OBJS) smscrypt.so: $(smscrypt_OBJS)
$(LD) -o smscrypt.so $(smscrypt_OBJS) $(smscrypt_LDFLAGS) $(LD) -o smscrypt.so $(smscrypt_OBJS) $(smscrypt_LDFLAGS)
systray_OBJS = systray.o
systray_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) `pkg-config --cflags libDesktop`
systray_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) `pkg-config --libs libDesktop`
systray.so: $(systray_OBJS)
$(LD) -o systray.so $(systray_OBJS) $(systray_LDFLAGS)
blacklist.o: blacklist.c ../../include/Phone.h blacklist.o: blacklist.c ../../include/Phone.h
$(CC) $(blacklist_CFLAGS) -c blacklist.c $(CC) $(blacklist_CFLAGS) -c blacklist.c
@ -132,13 +139,16 @@ profiles.o: profiles.c ../../include/Phone.h
smscrypt.o: smscrypt.c ../../include/Phone.h smscrypt.o: smscrypt.c ../../include/Phone.h
$(CC) $(smscrypt_CFLAGS) -c smscrypt.c $(CC) $(smscrypt_CFLAGS) -c smscrypt.c
systray.o: systray.c ../../include/Phone.h ../../config.h
$(CC) $(systray_CFLAGS) -c systray.c
clean: clean:
@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done
$(RM) -- $(blacklist_OBJS) $(debug_OBJS) $(engineering_OBJS) $(gprs_OBJS) $(locker_OBJS) $(n900_OBJS) $(openmoko_OBJS) $(oss_OBJS) $(panel_OBJS) $(profiles_OBJS) $(smscrypt_OBJS) $(RM) -- $(blacklist_OBJS) $(debug_OBJS) $(engineering_OBJS) $(gprs_OBJS) $(locker_OBJS) $(n900_OBJS) $(openmoko_OBJS) $(oss_OBJS) $(panel_OBJS) $(profiles_OBJS) $(smscrypt_OBJS) $(systray_OBJS)
distclean: distclean:
@for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done @for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done
$(RM) -- $(blacklist_OBJS) $(debug_OBJS) $(engineering_OBJS) $(gprs_OBJS) $(locker_OBJS) $(n900_OBJS) $(openmoko_OBJS) $(oss_OBJS) $(panel_OBJS) $(profiles_OBJS) $(smscrypt_OBJS) $(RM) -- $(blacklist_OBJS) $(debug_OBJS) $(engineering_OBJS) $(gprs_OBJS) $(locker_OBJS) $(n900_OBJS) $(openmoko_OBJS) $(oss_OBJS) $(panel_OBJS) $(profiles_OBJS) $(smscrypt_OBJS) $(systray_OBJS)
$(RM) -- $(TARGETS) $(RM) -- $(TARGETS)
install: $(TARGETS) install: $(TARGETS)
@ -163,6 +173,8 @@ install: $(TARGETS)
$(INSTALL) -m 0644 -- profiles.so $(DESTDIR)$(LIBDIR)/Phone/plugins/profiles.so $(INSTALL) -m 0644 -- profiles.so $(DESTDIR)$(LIBDIR)/Phone/plugins/profiles.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins $(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins
$(INSTALL) -m 0644 -- smscrypt.so $(DESTDIR)$(LIBDIR)/Phone/plugins/smscrypt.so $(INSTALL) -m 0644 -- smscrypt.so $(DESTDIR)$(LIBDIR)/Phone/plugins/smscrypt.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins
$(INSTALL) -m 0644 -- systray.so $(DESTDIR)$(LIBDIR)/Phone/plugins/systray.so
uninstall: uninstall:
@for i in $(SUBDIRS); do (cd $$i && $(MAKE) uninstall) || exit; done @for i in $(SUBDIRS); do (cd $$i && $(MAKE) uninstall) || exit; done
@ -176,5 +188,6 @@ uninstall:
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/panel.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/panel.so
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/profiles.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/profiles.so
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/smscrypt.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/smscrypt.so
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/systray.so
.PHONY: all subdirs clean distclean install uninstall .PHONY: all subdirs clean distclean install uninstall

View File

@ -1,5 +1,5 @@
subdirs=16x16,24x24,32x32,48x48 subdirs=16x16,24x24,32x32,48x48
targets=blacklist,debug,engineering,gprs,locker,n900,openmoko,oss,panel,profiles,smscrypt targets=blacklist,debug,engineering,gprs,locker,n900,openmoko,oss,panel,profiles,smscrypt,systray
cppflags_force=-I ../../include cppflags_force=-I ../../include
cppflags= cppflags=
cflags_force=-W `pkg-config --cflags libSystem gtk+-2.0` cflags_force=-W `pkg-config --cflags libSystem gtk+-2.0`
@ -98,3 +98,13 @@ install=$(LIBDIR)/Phone/plugins
[smscrypt.c] [smscrypt.c]
depends=../../include/Phone.h depends=../../include/Phone.h
[systray]
type=plugin
sources=systray.c
cflags=`pkg-config --cflags libDesktop`
ldflags=`pkg-config --libs libDesktop`
install=$(LIBDIR)/Phone/plugins
[systray.c]
depends=../../include/Phone.h,../../config.h

147
src/plugins/systray.c Normal file
View File

@ -0,0 +1,147 @@
/* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Phone */
static char const _license[] =
"This program is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, version 3 of the License.\n"
"\n"
"This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with this program. If not, see <http://www.gnu.org/licenses/>.";
#include <System.h>
#include <Desktop.h>
#ifdef DEBUG
# include <stdio.h>
#endif
#include <gtk/gtk.h>
#include "Phone.h"
#include "../../config.h"
/* Systray */
/* private */
/* types */
typedef struct _Systray
{
GtkStatusIcon * icon;
GtkWidget * ab_window;
} Systray;
/* prototypes */
/* plug-in */
static int _systray_init(PhonePlugin * plugin);
static int _systray_destroy(PhonePlugin * plugin);
/* callbacks */
#if GTK_CHECK_VERSION(2, 10, 0)
static void _systray_on_activate(gpointer data);
#endif
/* variables */
static char const * _authors[] =
{
"Pierre Pronchery <khorben@defora.org>",
NULL
};
static char _copyright[] =
"Copyright (c) 2011 DeforaOS Project <contact@defora.org>";
/* public */
/* variables */
PhonePlugin plugin =
{
NULL,
"System tray",
"gnome-monitor",
_systray_init,
_systray_destroy,
NULL,
NULL,
NULL
};
/* private */
/* functions */
/* systray_init */
static int _systray_init(PhonePlugin * plugin)
{
Systray * systray;
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
#if GTK_CHECK_VERSION(2, 10, 0)
if((systray = object_new(sizeof(*systray))) == NULL)
return 1;
plugin->priv = systray;
systray->icon = gtk_status_icon_new_from_icon_name("phone-dialer");
g_signal_connect_swapped(systray->icon, "activate", G_CALLBACK(
_systray_on_activate), plugin);
systray->ab_window = NULL;
return 0;
#else
return 1;
#endif
}
/* systray_destroy */
static int _systray_destroy(PhonePlugin * plugin)
{
Systray * systray = plugin->priv;
g_object_unref(systray->icon);
return 0;
}
#if GTK_CHECK_VERSION(2, 10, 0)
/* callbacks */
/* systray_on_activate */
static gboolean _activate_on_closex(gpointer data);
static void _systray_on_activate(gpointer data)
{
PhonePlugin * plugin = data;
Systray * systray = plugin->priv;
if(systray->ab_window != NULL)
{
gtk_window_present(GTK_WINDOW(systray->ab_window));
return;
}
systray->ab_window = desktop_about_dialog_new();
desktop_about_dialog_set_authors(systray->ab_window, _authors);
desktop_about_dialog_set_copyright(systray->ab_window, _copyright);
desktop_about_dialog_set_license(systray->ab_window, _license);
desktop_about_dialog_set_logo_icon_name(systray->ab_window,
"phone-dialer");
desktop_about_dialog_set_name(systray->ab_window, PACKAGE);
desktop_about_dialog_set_version(systray->ab_window, VERSION);
g_signal_connect_swapped(systray->ab_window, "delete-event",
G_CALLBACK(_activate_on_closex), plugin);
gtk_widget_show(systray->ab_window);
}
static gboolean _activate_on_closex(gpointer data)
{
PhonePlugin * plugin = data;
Systray * systray = plugin->priv;
gtk_widget_hide(systray->ab_window);
return TRUE;
}
#endif