Installing a (minimal) calendar plug-in for Mailer

This commit is contained in:
Pierre Pronchery 2012-11-01 19:37:10 +01:00
parent 70ab204a40
commit cc5b9cfdb4
4 changed files with 164 additions and 1 deletions

View File

@ -1,6 +1,6 @@
PACKAGE = Calendar
VERSION = 0.0.0
SUBDIRS = data src
SUBDIRS = data src tools
RM ?= rm -f
LN ?= ln -f
TAR ?= tar -czvf
@ -29,6 +29,9 @@ dist:
$(PACKAGE)-$(VERSION)/src/Makefile \
$(PACKAGE)-$(VERSION)/src/calendar.h \
$(PACKAGE)-$(VERSION)/src/project.conf \
$(PACKAGE)-$(VERSION)/tools/calendar.c \
$(PACKAGE)-$(VERSION)/tools/Makefile \
$(PACKAGE)-$(VERSION)/tools/project.conf \
$(PACKAGE)-$(VERSION)/Makefile \
$(PACKAGE)-$(VERSION)/COPYING \
$(PACKAGE)-$(VERSION)/project.conf

45
tools/Makefile Normal file
View File

@ -0,0 +1,45 @@
TARGETS = calendar.so
PREFIX = /usr/local
DESTDIR =
LIBDIR = $(PREFIX)/lib
CC ?= cc
CPPFLAGSF?=
CPPFLAGS?=
CFLAGSF = -W -fPIC `pkg-config --cflags libDesktop Mailer`
CFLAGS = -Wall -g -O2 -pedantic
LDFLAGSF= `pkg-config --libs libDesktop`
AR ?= ar
RANLIB ?= ranlib
CCSHARED?= $(CC) -shared
RM ?= rm -f
LN ?= ln -f
MKDIR ?= mkdir -p
INSTALL ?= install
all: $(TARGETS)
calendar_OBJS = calendar.o
calendar_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
calendar_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
calendar.so: $(calendar_OBJS)
$(CCSHARED) -o calendar.so $(calendar_OBJS) $(calendar_LDFLAGS)
calendar.o: calendar.c
$(CC) $(calendar_CFLAGS) -c calendar.c
clean:
$(RM) -- $(calendar_OBJS)
distclean: clean
$(RM) -- $(TARGETS)
install: $(TARGETS)
$(MKDIR) $(DESTDIR)$(LIBDIR)/Mailer/plugins
$(INSTALL) -m 0644 -- calendar.so $(DESTDIR)$(LIBDIR)/Mailer/plugins/calendar.so
uninstall:
$(RM) -- $(DESTDIR)$(LIBDIR)/Mailer/plugins/calendar.so
.PHONY: all clean distclean install uninstall

105
tools/calendar.c Normal file
View File

@ -0,0 +1,105 @@
/* $Id$ */
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */
/* 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, version 3 of the License.
*
* 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/>. */
#include <stdlib.h>
#include <Desktop/Mailer/plugin.h>
/* Mailing-lists */
/* private */
/* types */
typedef struct _MailerPlugin Calendar;
struct _MailerPlugin
{
MailerPluginHelper * helper;
/* widgets */
GtkWidget * widget;
GtkWidget * calendar;
};
/* protected */
/* prototypes */
/* plug-in */
static MailerPlugin * _calendar_init(MailerPluginHelper * helper);
static void _calendar_destroy(Calendar * calendar);
static GtkWidget * _calendar_get_widget(Calendar * calendar);
/* public */
/* variables */
/* plug-in */
MailerPluginDefinition plugin =
{
"Calendar",
NULL,
NULL,
_calendar_init,
_calendar_destroy,
_calendar_get_widget,
NULL
};
/* protected */
/* functions */
/* plug-in */
/* calendar_init */
static MailerPlugin * _calendar_init(MailerPluginHelper * helper)
{
Calendar * calendar;
if((calendar = malloc(sizeof(*calendar))) == NULL)
return NULL;
calendar->helper = helper;
calendar->widget = gtk_vbox_new(FALSE, 4);
/* XXX code duplicated from the Calendar class */
calendar->calendar = gtk_calendar_new();
gtk_calendar_set_display_options(GTK_CALENDAR(calendar->calendar),
GTK_CALENDAR_SHOW_HEADING
| GTK_CALENDAR_SHOW_DAY_NAMES
| GTK_CALENDAR_SHOW_WEEK_NUMBERS);
#if GTK_CHECK_VERSION(2, 14, 0)
gtk_calendar_set_detail_height_rows(GTK_CALENDAR(calendar->calendar),
1);
# if 0 /* XXX allow callbacks to be re-used from the Calendar class */
gtk_calendar_set_detail_func(GTK_CALENDAR(calendar->calendar),
(GtkCalendarDetailFunc)_calendar_on_detail, calendar,
NULL);
# endif
#endif
gtk_box_pack_start(GTK_BOX(calendar->widget), calendar->calendar, TRUE,
TRUE, 0);
gtk_widget_show_all(calendar->widget);
return calendar;
}
/* calendar_destroy */
static void _calendar_destroy(Calendar * calendar)
{
free(calendar);
}
/* calendar_get_widget */
static GtkWidget * _calendar_get_widget(Calendar * calendar)
{
return calendar->widget;
}

10
tools/project.conf Normal file
View File

@ -0,0 +1,10 @@
targets=calendar
cflags_force=-W -fPIC `pkg-config --cflags libDesktop Mailer`
cflags=-Wall -g -O2 -pedantic
ldflags_force=`pkg-config --libs libDesktop`
dist=Makefile
[calendar]
type=plugin
sources=calendar.c
install=$(LIBDIR)/Mailer/plugins