summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Makefile.am4
-rw-r--r--cdplayer/Makefile.am29
-rw-r--r--cdplayer/cdplayer.c442
-rw-r--r--cdplayer/cdplayer.h26
-rw-r--r--cdplayer/cdplayer_applet.desktop7
-rw-r--r--cdplayer/cdrom-interface.h78
-rw-r--r--cdplayer/cdrom-linux.c441
-rw-r--r--cdplayer/cdrom-solaris.c441
-rw-r--r--cdplayer/led.c202
-rw-r--r--cdplayer/led.h13
-rw-r--r--clock/clock.c142
-rw-r--r--mailcheck/ChangeLog7
-rw-r--r--mailcheck/mailcheck_applet.desktop9
14 files changed, 914 insertions, 934 deletions
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 000000000..b050fc202
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,7 @@
+Fri Mar 20 00:08:43 1998 George Lebl <jirka@5z.com>
+
+ * cdplayer/*: ported to corba, indented to kernel
+ conding style to be compatible with rest of gnome
+
+ * mailcheck/*: ported to corba
+
diff --git a/Makefile.am b/Makefile.am
index 07135493e..27e93ed4e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
SUBDIRS = applet-dirs \
- clock #mailcheck batmon netwatch \
-# @PROGRAMS_PANEL_CDPLAYER@
+ clock mailcheck \
+ @PROGRAMS_PANEL_CDPLAYER@
diff --git a/cdplayer/Makefile.am b/cdplayer/Makefile.am
index 6f7f5cc11..2e4974b14 100644
--- a/cdplayer/Makefile.am
+++ b/cdplayer/Makefile.am
@@ -1,27 +1,26 @@
-INCLUDES = \
- -I.. \
- -I../libapplet \
- -I$(srcdir)/../libapplet \
- -I../../.. \
- -I$(srcdir)/../../.. \
- -I$(includedir)
+INCLUDES = -I. -I$(srcdir) \
+ -I$(srcdir)/../../panel \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ -I$(includedir) $(GNOME_INCLUDEDIR)
bin_PROGRAMS = cdplayer_applet
-cdplayer_applet_SOURCES = \
- cdplayer.c \
- led.c \
+cdplayer_applet_SOURCES = \
+ cdplayer.c \
+ led.c \
cdrom-$(CDROM_HOST).c
MICO_VERS = 2.0.3
MICO_LIBS = -lmicocoss$(MICO_VERS) -lmicoaux$(MICO_VERS) -lmico$(MICO_VERS)
-#cdplayer_applet_LDADD = ../libapplet/libapplet.a \
-cdplayer_applet_LDADD = ../libpanel_applet.a \
- $(GNOME_LIBDIR) $(MICO_LIBS) -lXt \
- $(GNOMEUI_LIBS) $(INTLLIBS) -lstdc++
+cdplayer_applet_LDADD = ../../panel/libpanel_applet.la \
+ $(GNOME_LIBDIR) $(MICO_LIBS) -lXt \
+ $(GNOMEUI_LIBS) $(INTLLIBS) -lstdc++
-EXTRA_DIST = cdrom-linux.c cdrom-solaris.c
+EXTRA_DIST = cdplayer_applet.desktop cdrom-linux.c cdrom-solaris.c
+
+sysdir = $(datadir)/applets/Multimedia
+sys_DATA = cdplayer_applet.desktop
dist-hook:
mkdir $(distdir)/images
diff --git a/cdplayer/cdplayer.c b/cdplayer/cdplayer.c
index 94c34bcfc..51072da9f 100644
--- a/cdplayer/cdplayer.c
+++ b/cdplayer/cdplayer.c
@@ -1,4 +1,6 @@
/*
+ * FIXME: who wrote this ... this is the header from clock .... this isn't
+ * clock :)
* GNOME time/date display module.
* (C) 1997 The Free Software Foundation
*
@@ -20,8 +22,7 @@
#include <gnome.h>
#include <gdk/gdkx.h>
#include <applet-lib.h>
-#include <applet-widget.h>
-#include "../panel.h"
+#include "panel.h"
#include "mico-parse.h"
#include "led.h"
@@ -34,203 +35,232 @@
#include "images/cdplayer-next.xpm"
#include "images/cdplayer-eject.xpm"
-#define APPLET_ID "Cdplayer"
#define TIMEOUT_VALUE 500
-GtkWidget *aw;
+GtkWidget *plug = NULL;
-int applet_id=-1; /*this is our id we use to comunicate with the panel*/
+int applet_id = -1;/*this is our id we use to comunicate with the panel */
-static void
-cd_panel_update(GtkWidget *cdplayer, CDPlayerData *cd)
+static void
+cd_panel_update(GtkWidget * cdplayer, CDPlayerData * cd)
{
- cdrom_device_status_t stat;
- int retval;
-
- if (cdrom_get_status(cd->cdrom_device, &stat) == DISC_NO_ERROR)
- {
- switch(stat.audio_status)
- {
- case DISC_PLAY:
- led_time(cd->panel.time,
- stat.relative_address.minute,
- stat.relative_address.second,
- cd->panel.track,
- stat.track);
- break;
- case DISC_PAUSED:
- led_paused(cd->panel.time,
- stat.relative_address.minute,
- stat.relative_address.second,
- cd->panel.track,
- stat.track);
- break;
- case DISC_COMPLETED:
- /* check for looping or ? */
- break;
- case DISC_STOP:
- case DISC_ERROR:
- led_stop(cd->panel.time, cd->panel.track);
- default:
-
- }
- }
- else
- led_nodisc(cd->panel.time, cd->panel.track);
+ cdrom_device_status_t stat;
+ int retval;
+
+ if (cdrom_get_status(cd->cdrom_device, &stat) == DISC_NO_ERROR) {
+ switch (stat.audio_status) {
+ case DISC_PLAY:
+ led_time(cd->panel.time,
+ stat.relative_address.minute,
+ stat.relative_address.second,
+ cd->panel.track,
+ stat.track);
+ break;
+ case DISC_PAUSED:
+ led_paused(cd->panel.time,
+ stat.relative_address.minute,
+ stat.relative_address.second,
+ cd->panel.track,
+ stat.track);
+ break;
+ case DISC_COMPLETED:
+ /* check for looping or ? */
+ break;
+ case DISC_STOP:
+ case DISC_ERROR:
+ led_stop(cd->panel.time, cd->panel.track);
+ default:
+
+ }
+ } else
+ led_nodisc(cd->panel.time, cd->panel.track);
}
-static int
-cdplayer_play_pause(GtkWidget *w, gpointer data)
+static int
+cdplayer_play_pause(GtkWidget * w, gpointer data)
{
- CDPlayerData *cd = data;
- cdrom_device_status_t stat;
-
- if (cdrom_get_status(cd->cdrom_device, &stat) == DISC_NO_ERROR)
- {
- switch(stat.audio_status)
- {
- case DISC_PLAY:
- cdrom_pause(cd->cdrom_device);
- break;
- case DISC_PAUSED:
- cdrom_resume(cd->cdrom_device);
- break;
- case DISC_COMPLETED:
- case DISC_STOP:
- case DISC_ERROR:
- cdrom_read_track_info(cd->cdrom_device);
- cdrom_play(cd->cdrom_device, cd->cdrom_device->track0,
- cd->cdrom_device->track1);
- break;
+ CDPlayerData *cd = data;
+ cdrom_device_status_t stat;
+
+ if (cdrom_get_status(cd->cdrom_device, &stat) == DISC_NO_ERROR) {
+ switch (stat.audio_status) {
+ case DISC_PLAY:
+ cdrom_pause(cd->cdrom_device);
+ break;
+ case DISC_PAUSED:
+ cdrom_resume(cd->cdrom_device);
+ break;
+ case DISC_COMPLETED:
+ case DISC_STOP:
+ case DISC_ERROR:
+ cdrom_read_track_info(cd->cdrom_device);
+ cdrom_play(cd->cdrom_device, cd->cdrom_device->track0,
+ cd->cdrom_device->track1);
+ break;
+ }
}
- }
}
static int
-cdplayer_stop(GtkWidget *w, gpointer data)
+cdplayer_stop(GtkWidget * w, gpointer data)
{
- CDPlayerData *cd = data;
- cdrom_stop(cd->cdrom_device);
- return 0;
+ CDPlayerData *cd = data;
+ cdrom_stop(cd->cdrom_device);
+ return 0;
}
static int
-cdplayer_prev(GtkWidget *w, gpointer data)
+cdplayer_prev(GtkWidget * w, gpointer data)
{
- CDPlayerData *cd = data;
- cdrom_prev(cd->cdrom_device);
- return 0;
+ CDPlayerData *cd = data;
+ cdrom_prev(cd->cdrom_device);
+ return 0;
}
static int
-cdplayer_next(GtkWidget *w, gpointer data)
+cdplayer_next(GtkWidget * w, gpointer data)
{
- CDPlayerData *cd = data;
- cdrom_next(cd->cdrom_device);
- return 0;
+ CDPlayerData *cd = data;
+ cdrom_next(cd->cdrom_device);
+ return 0;
}
static int
-cdplayer_eject(GtkWidget *w, gpointer data)
+cdplayer_eject(GtkWidget * w, gpointer data)
{
- CDPlayerData *cd = data;
- cdrom_eject(cd->cdrom_device);
- return 0;
+ CDPlayerData *cd = data;
+ cdrom_eject(cd->cdrom_device);
+ return 0;
}
-static int
-cdplayer_timeout_callback (gpointer data)
+static int
+cdplayer_timeout_callback(gpointer data)
{
- GtkWidget *cdplayer;
- CDPlayerData *cd;
+ GtkWidget *cdplayer;
+ CDPlayerData *cd;
- cdplayer = data;
- cd = gtk_object_get_user_data(GTK_OBJECT(cdplayer));
+ cdplayer = data;
+ cd = gtk_object_get_user_data(GTK_OBJECT(cdplayer));
- cd_panel_update (cdplayer, cd);
- return 1;
+ cd_panel_update(cdplayer, cd);
+ return 1;
}
static GtkWidget *
-control_button_factory(GtkWidget *window, GtkWidget *box_container,
- gchar *pixmap_data[],
- int (*func)(GtkWidget *, gpointer data),
- CDPlayerData *cd)
+control_button_factory(GtkWidget * box_container,
+ gchar * pixmap_data[],
+ int (*func) (GtkWidget *, gpointer data),
+ CDPlayerData * cd)
{
- GtkWidget *w, *pixmap;
-
- w = gtk_button_new();
- GTK_WIDGET_UNSET_FLAGS(w, GTK_CAN_DEFAULT);
- GTK_WIDGET_UNSET_FLAGS(w, GTK_CAN_FOCUS);
- pixmap = gnome_create_pixmap_widget_d (window, w, pixmap_data);
- gtk_box_pack_start(GTK_BOX(box_container), w, FALSE, TRUE, 0);
- gtk_widget_show(pixmap);
- gtk_container_add (GTK_CONTAINER(w), pixmap);
- gtk_signal_connect(GTK_OBJECT(w), "clicked",
- GTK_SIGNAL_FUNC(func),
- (gpointer) cd);
- gtk_widget_show(w);
- return w;
+ GtkWidget *w, *pixmap;
+
+ w = gtk_button_new();
+ GTK_WIDGET_UNSET_FLAGS(w, GTK_CAN_DEFAULT);
+ GTK_WIDGET_UNSET_FLAGS(w, GTK_CAN_FOCUS);
+ pixmap = gnome_pixmap_new_from_xpm_d (pixmap_data);
+ gtk_box_pack_start(GTK_BOX(box_container), w, FALSE, TRUE, 0);
+ gtk_widget_show(pixmap);
+ gtk_container_add(GTK_CONTAINER(w), pixmap);
+ gtk_signal_connect(GTK_OBJECT(w), "clicked",
+ GTK_SIGNAL_FUNC(func),
+ (gpointer) cd);
+ gtk_widget_show(w);
+ return w;
}
static GtkWidget *
-create_cdpanel_widget(GtkWidget *window, CDPlayerData *cd)
+create_cdpanel_widget(GtkWidget *window, CDPlayerData * cd)
{
- GtkWidget *frame;
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *pixmap;
-
- frame = gtk_frame_new(NULL);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
- gtk_widget_show(frame);
-
- vbox = gtk_vbox_new(FALSE, FALSE);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_widget_show(vbox);
-
- led_create_widget(window, &cd->panel.time, &cd->panel.track);
- gtk_box_pack_start_defaults(GTK_BOX(vbox), cd->panel.time);
- gtk_widget_show(cd->panel.time);
-
- /* */
- hbox = gtk_hbox_new(FALSE, FALSE);
- gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);
- gtk_widget_show(hbox);
-
- cd->panel.stop = control_button_factory(window, hbox, stop_xpm,
- cdplayer_stop, cd);
- cd->panel.play_pause = control_button_factory(window, hbox, play_pause_xpm,
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+
+ frame = gtk_frame_new(NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_widget_show(frame);
+
+ vbox = gtk_vbox_new(FALSE, FALSE);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
+ gtk_widget_show(vbox);
+
+ led_create_widget(window,&cd->panel.time, &cd->panel.track);
+ gtk_box_pack_start_defaults(GTK_BOX(vbox), cd->panel.time);
+ gtk_widget_show(cd->panel.time);
+
+ /* */
+ hbox = gtk_hbox_new(FALSE, FALSE);
+ gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);
+ gtk_widget_show(hbox);
+
+ cd->panel.stop = control_button_factory(hbox, stop_xpm,
+ cdplayer_stop, cd);
+ cd->panel.play_pause = control_button_factory(hbox, play_pause_xpm,
cdplayer_play_pause, cd);
- cd->panel.eject = control_button_factory(window, hbox, eject_xpm,
- cdplayer_eject, cd);
-
- /* */
- hbox = gtk_hbox_new(FALSE, FALSE);
- gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);
- gtk_widget_show(hbox);
+ cd->panel.eject = control_button_factory(hbox, eject_xpm,
+ cdplayer_eject, cd);
- cd->panel.prev = control_button_factory(window, hbox, prev_xpm,
- cdplayer_prev, cd);
+ /* */
+ hbox = gtk_hbox_new(FALSE, FALSE);
+ gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);
+ gtk_widget_show(hbox);
- gtk_box_pack_start(GTK_BOX(hbox), cd->panel.track, TRUE, TRUE, 0);
- gtk_widget_show(cd->panel.track);
+ cd->panel.prev = control_button_factory(hbox, prev_xpm,
+ cdplayer_prev, cd);
- cd->panel.next = control_button_factory(window, hbox, next_xpm,
- cdplayer_next, cd);
+ gtk_box_pack_start(GTK_BOX(hbox), cd->panel.track, TRUE, TRUE, 0);
+ gtk_widget_show(cd->panel.track);
- return frame;
+ cd->panel.next = control_button_factory(hbox, next_xpm,
+ cdplayer_next, cd);
+
+ return frame;
+}
+
+static void
+destroy_cdplayer(GtkWidget * widget, void *data)
+{
+ CDPlayerData *cd;
+
+ cd = gtk_object_get_user_data(GTK_OBJECT(widget));
+ gtk_timeout_remove(cd->timeout);
+ cdrom_close(cd->cdrom_device);
+ g_free(cd);
}
-static void
-destroy_cdplayer (GtkWidget *widget, void *data)
+
+static GtkWidget *
+create_cdplayer_widget(GtkWidget *window)
{
- CDPlayerData *cd;
+ gchar *devpath;
+ CDPlayerData *cd;
+ GtkWidget *cdpanel;
+ time_t current_time;
+ int err;
+
+ cd = g_new(CDPlayerData, 1);
+
+ devpath = gnome_config_get_string("/panel/cdplayer/devpath=/dev/cdrom");
+ cd->cdrom_device = cdrom_open(devpath, &err);
+ g_free(devpath);
+ if (cd->cdrom_device == NULL) {
+ printf("Error: Can't open cdrom(%s)\n", strerror(err));
+ g_free(cd);
+ return NULL;
+ }
+ cdpanel = create_cdpanel_widget(window,cd);
- cd = gtk_object_get_user_data(GTK_OBJECT(widget));
- gtk_timeout_remove (cd->timeout);
- cdrom_close(cd->cdrom_device);
- g_free(cd);
+ /* Install timeout handler */
+
+ cd->timeout = gtk_timeout_add(TIMEOUT_VALUE, cdplayer_timeout_callback,
+ cdpanel);
+
+ gtk_object_set_user_data(GTK_OBJECT(cdpanel), cd);
+ gtk_signal_connect(GTK_OBJECT(cdpanel), "destroy",
+ (GtkSignalFunc) destroy_cdplayer,
+ NULL);
+ cd_panel_update(cdpanel, cd);
+
+ return cdpanel;
}
/*these are commands sent over corba:*/
@@ -238,18 +268,16 @@ void
change_orient(int id, int orient)
{
PanelOrientType o = (PanelOrientType)orient;
- puts("CHANGE_ORIENT");
}
void
-session_save(int id, int panel, int pos)
+session_save(int id, const char *cfgpath, const char *globcfgpath)
{
- /*FIXME: save the position*/
- puts("SESSION_SAVE");
+ /*save the session here*/
}
static gint
-applet_die(gpointer data)
+quit_applet(gpointer data)
{
exit(0);
}
@@ -257,83 +285,59 @@ applet_die(gpointer data)
void
shutdown_applet(int id)
{
- puts("SHUTDOWN_APPLET");
- /*kill our window*/
- gtk_widget_unref(aw);
- gtk_timeout_add(100,applet_die,NULL);
- led_done();
+ /*kill our plug using destroy to avoid warnings we need to
+ kill the plug but we also need to return from this call*/
+ if(plug) gtk_widget_destroy(plug);
+ gtk_idle_add(quit_applet,NULL);
}
-static GtkWidget *
-create_cdplayer_widget (GtkWidget *window)
-{
- gchar *devpath;
- CDPlayerData *cd;
- GtkWidget *cdpanel;
- time_t current_time;
- int err;
-
- cd = g_new(CDPlayerData, 1);
-
- devpath = gnome_config_get_string("/panel/cdplayer/devpath=/dev/cdrom");
- cd->cdrom_device = cdrom_open(devpath, &err);
- g_free(devpath);
- if (cd->cdrom_device == NULL)
- {
- printf("Error: Can't open cdrom(%s)\n", strerror(err));
- g_free(cd);
- return NULL;
- }
-
- cdpanel = create_cdpanel_widget(window, cd);
-
- /* Install timeout handler */
-
- cd->timeout = gtk_timeout_add(TIMEOUT_VALUE, cdplayer_timeout_callback,
- cdpanel);
-
- gtk_object_set_user_data(GTK_OBJECT(cdpanel), cd);
- gtk_signal_connect(GTK_OBJECT(cdpanel), "destroy",
- (GtkSignalFunc) destroy_cdplayer,
- NULL);
- cd_panel_update(cdpanel, cd);
-
- return cdpanel;
-}
+
int
main(int argc, char **argv)
{
GtkWidget *cdplayer;
char *result;
-
+ char *cfgpath;
+ char *globcfgpath;
+
+ char *myinvoc;
+ guint32 winid;
+
+ myinvoc = get_which_output(argv[0]);
+ if(!myinvoc)
+ return 1;
+
panel_corba_register_arguments ();
gnome_init("cdplayer_applet", NULL, argc, argv, 0, NULL);
- if (!gnome_panel_applet_init_corba ()){
- fprintf (stderr, "Could not comunicate with the panel\n");
- exit (1);
- }
+ if (!gnome_panel_applet_init_corba ())
+ g_error ("Could not comunicate with the panel\n");
+
+ result = gnome_panel_applet_request_id(myinvoc,&applet_id,
+ &cfgpath,&globcfgpath,
+ &winid);
+
+ g_free(myinvoc);
+ if (result)
+ g_error ("Could not talk to the Panel: %s\n", result);
- aw = applet_widget_new ();
+ /*use cfg path for loading up data!*/
- /* FIXME */
- led_init(aw);
+ g_free(globcfgpath);
+ g_free(cfgpath);
- /* FIXME */
- cdplayer = create_cdplayer_widget (GTK_WIDGET(aw));
+ plug = gtk_plug_new (winid);
+
+ cdplayer = create_cdplayer_widget (plug);
gtk_widget_show(cdplayer);
- applet_widget_add (APPLET_WIDGET (aw), cdplayer);
- gtk_widget_show (aw);
-
- /*FIXME: do session saving, find out panel and pos from the panel
- so we can restore them on the next startup*/
- result = gnome_panel_prepare_and_transfer(aw,argv[0],&applet_id,0,0);
- printf ("Done\n");
- if (result){
- printf ("Could not talk to the Panel: %s\n", result);
- exit (1);
- }
+ gtk_container_add (GTK_CONTAINER (plug), cdplayer);
+ gtk_widget_show (plug);
+
+
+ result = gnome_panel_applet_register(plug,applet_id);
+ if (result)
+ g_error ("Could not talk to the Panel: %s\n", result);
applet_corba_gtk_main ("IDL:GNOME/Applet:1.0");
diff --git a/cdplayer/cdplayer.h b/cdplayer/cdplayer.h
index d485b73f8..73c70a07f 100644
--- a/cdplayer/cdplayer.h
+++ b/cdplayer/cdplayer.h
@@ -2,22 +2,20 @@
#define __CDPLAYER_H__
typedef struct {
- int timeout;
- cdrom_device_t cdrom_device;
+ int timeout;
+ cdrom_device_t cdrom_device;
- struct {
- GtkWidget *time;
- GtkWidget *track;
+ struct {
+ GtkWidget *time;
+ GtkWidget *track;
- /* control button */
- GtkWidget *play_pause;
- GtkWidget *stop;
- GtkWidget *prev;
- GtkWidget *next;
- GtkWidget *eject;
- } panel;
+ /* control button */
+ GtkWidget *play_pause;
+ GtkWidget *stop;
+ GtkWidget *prev;
+ GtkWidget *next;
+ GtkWidget *eject;
+ } panel;
} CDPlayerData;
-
-
#endif
diff --git a/cdplayer/cdplayer_applet.desktop b/cdplayer/cdplayer_applet.desktop
new file mode 100644
index 000000000..de6f49268
--- /dev/null
+++ b/cdplayer/cdplayer_applet.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=CD Player
+Comment=CD Player
+Exec=cdplayer_applet
+Icon=
+Terminal=0
+Type=Application
diff --git a/cdplayer/cdrom-interface.h b/cdplayer/cdrom-interface.h
index fdcc7c524..a7ea30a11 100644
--- a/cdplayer/cdrom-interface.h
+++ b/cdplayer/cdrom-interface.h
@@ -4,57 +4,51 @@
#include <errno.h>
-enum
-{
- DISC_NO_ERROR = 0,
- DISC_IO_ERROR,
- DISC_INDEX_OUT_OF_RANGE
+enum {
+ DISC_NO_ERROR = 0,
+ DISC_IO_ERROR,
+ DISC_INDEX_OUT_OF_RANGE
};
-enum
-{
- DISC_PLAY,
- DISC_PAUSED,
- DISC_STOP,
- DISC_COMPLETED,
- DISC_ERROR
+enum {
+ DISC_PLAY,
+ DISC_PAUSED,
+ DISC_STOP,
+ DISC_COMPLETED,
+ DISC_ERROR
};
-typedef struct
-{
- int minute;
- int second;
- int frame;
+typedef struct {
+ int minute;
+ int second;
+ int frame;
} cdrom_msf_t;
-typedef struct
-{
- char *name;
- unsigned char track;
- unsigned int audio_track:1;
- cdrom_msf_t address;
- cdrom_msf_t length;
+typedef struct {
+ char *name;
+ unsigned char track;
+ unsigned int audio_track:1;
+ cdrom_msf_t address;
+ cdrom_msf_t length;
} track_info_t;
-typedef struct
-{
- int audio_status;
- unsigned char track;
- cdrom_msf_t relative_address;
- cdrom_msf_t absolute_address;
+typedef struct {
+ int audio_status;
+ unsigned char track;
+ cdrom_msf_t relative_address;
+ cdrom_msf_t absolute_address;
} cdrom_device_status_t;
-typedef struct cdrom_device
-{
- int device;
- int nr_track;
- unsigned char track0, track1;
- track_info_t *track_info;
+typedef struct cdrom_device {
+ int device;
+ int nr_track;
+ unsigned char track0, track1;
+ track_info_t *track_info;
#if 0
- cdrom_msf_t leadout;
+ cdrom_msf_t leadout;
#endif
-
- int my_errno;
+
+ int my_errno;
} *cdrom_device_t;
cdrom_device_t cdrom_open(char *path, /* out */ int *errcode);
@@ -63,7 +57,7 @@ void cdrom_close(cdrom_device_t cdp);
int cdrom_eject(cdrom_device_t cdp);
int cdrom_read_track_info(cdrom_device_t cdp);
int cdrom_play(cdrom_device_t cdp, int start, int stop);
-int cdrom_play_msf(cdrom_device_t cdp, cdrom_msf_t *start);
+int cdrom_play_msf(cdrom_device_t cdp, cdrom_msf_t * start);
int cdrom_pause(cdrom_device_t cdp);
int cdrom_resume(cdrom_device_t cdp);
int cdrom_stop(cdrom_device_t cdp);
@@ -72,6 +66,6 @@ int cdrom_prev(cdrom_device_t cdp);
int cdrom_ff(cdrom_device_t cdp);
int cdrom_rewind(cdrom_device_t cdp);
-int cdrom_track_length(cdrom_device_t cdp, int track,
- /* out */ cdrom_msf_t *length);
+int cdrom_track_length(cdrom_device_t cdp, int track,
+ /* out */ cdrom_msf_t * length);
#endif
diff --git a/cdplayer/cdrom-linux.c b/cdplayer/cdrom-linux.c
index e66115a98..bf2c0629d 100644
--- a/cdplayer/cdrom-linux.c
+++ b/cdplayer/cdrom-linux.c
@@ -17,297 +17,278 @@
int
cdrom_play(cdrom_device_t cdp, int start, int stop)
{
- struct cdrom_ti ti;
-
- ti.cdti_trk0 = start;
- ti.cdti_ind0 = 1;
- ti.cdti_trk1 = stop;
- ti.cdti_ind1 = 1;
- if (ioctl(cdp->device, CDROMPLAYTRKIND, &ti) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ struct cdrom_ti ti;
+
+ ti.cdti_trk0 = start;
+ ti.cdti_ind0 = 1;
+ ti.cdti_trk1 = stop;
+ ti.cdti_ind1 = 1;
+ if (ioctl(cdp->device, CDROMPLAYTRKIND, &ti) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
int
-cdrom_play_msf(cdrom_device_t cdp, cdrom_msf_t *start)
+cdrom_play_msf(cdrom_device_t cdp, cdrom_msf_t * start)
{
- struct cdrom_msf msf;
-
- if (cdrom_read_track_info(cdp) == DISC_IO_ERROR)
- return DISC_IO_ERROR;
- msf.cdmsf_min0 = start->minute;
- msf.cdmsf_sec0 = start->second;
- msf.cdmsf_frame0 = start->frame;
-
- msf.cdmsf_min1 = cdp->track_info[cdp->nr_track].address.minute;
- msf.cdmsf_sec1 = cdp->track_info[cdp->nr_track].address.second;
- msf.cdmsf_frame1 = cdp->track_info[cdp->nr_track].address.frame;
-
- if (ioctl(cdp->device, CDROMPLAYMSF, &msf) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ struct cdrom_msf msf;
+
+ if (cdrom_read_track_info(cdp) == DISC_IO_ERROR)
+ return DISC_IO_ERROR;
+ msf.cdmsf_min0 = start->minute;
+ msf.cdmsf_sec0 = start->second;
+ msf.cdmsf_frame0 = start->frame;
+
+ msf.cdmsf_min1 = cdp->track_info[cdp->nr_track].address.minute;
+ msf.cdmsf_sec1 = cdp->track_info[cdp->nr_track].address.second;
+ msf.cdmsf_frame1 = cdp->track_info[cdp->nr_track].address.frame;
+
+ if (ioctl(cdp->device, CDROMPLAYMSF, &msf) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
-int
+int
cdrom_pause(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMPAUSE, 0) == -1)
- {
- return DISC_IO_ERROR;
- cdp->my_errno = errno;
- }
- return DISC_IO_ERROR;
+ if (ioctl(cdp->device, CDROMPAUSE, 0) == -1) {
+ return DISC_IO_ERROR;
+ cdp->my_errno = errno;
+ }
+ return DISC_IO_ERROR;
}
-int
+int
cdrom_resume(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMRESUME, 0) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ if (ioctl(cdp->device, CDROMRESUME, 0) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
int
cdrom_stop(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMSTOP, 0) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ if (ioctl(cdp->device, CDROMSTOP, 0) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
int
cdrom_read_track_info(cdrom_device_t cdp)
{
- struct cdrom_tochdr toc;
- struct cdrom_tocentry tocentry;
-
- int i, j, nr_track;
-
- if (ioctl(cdp->device, CDROMREADTOCHDR, &toc) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- cdp->track0 = toc.cdth_trk0;
- cdp->track1 = toc.cdth_trk1;
- nr_track = toc.cdth_trk1 - toc.cdth_trk0 + 1;
- if (nr_track <= 0)
- return DISC_IO_ERROR;
-
- if (nr_track != cdp->nr_track)
- {
- if (cdp->track_info)
- g_free(cdp->track_info);
- cdp->nr_track = nr_track;
- cdp->track_info = g_malloc((cdp->nr_track + 1) * sizeof(track_info_t));
- }
-
-
- for (i = 0, j = cdp->track0; i < cdp->nr_track; i++, j++)
- {
- tocentry.cdte_track = j;
- tocentry.cdte_format = CDROM_MSF;
-
- if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
+ struct cdrom_tochdr toc;
+ struct cdrom_tocentry tocentry;
+
+ int i, j, nr_track;
+
+ if (ioctl(cdp->device, CDROMREADTOCHDR, &toc) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ cdp->track0 = toc.cdth_trk0;
+ cdp->track1 = toc.cdth_trk1;
+ nr_track = toc.cdth_trk1 - toc.cdth_trk0 + 1;
+ if (nr_track <= 0)
+ return DISC_IO_ERROR;
+
+ if (nr_track != cdp->nr_track) {
+ if (cdp->track_info)
+ g_free(cdp->track_info);
+ cdp->nr_track = nr_track;
+ cdp->track_info = g_malloc((cdp->nr_track + 1) * sizeof(track_info_t));
}
-
- /* fill the trackinfo field */
- cdp->track_info[i].track = j;
- cdp->track_info[i].audio_track = tocentry.cdte_ctrl !=
- CDROM_DATA_TRACK ? 1 : 0;
- ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
- }
-
- tocentry.cdte_track = CDROM_LEADOUT;
- tocentry.cdte_format = CDROM_MSF;
- if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- cdp->track_info[i].track = j;
- cdp->track_info[i].audio_track = 0;
- ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
-
- return DISC_NO_ERROR;
+ for (i = 0, j = cdp->track0; i < cdp->nr_track; i++, j++) {
+ tocentry.cdte_track = j;
+ tocentry.cdte_format = CDROM_MSF;
+
+ if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ /* fill the trackinfo field */
+ cdp->track_info[i].track = j;
+ cdp->track_info[i].audio_track = tocentry.cdte_ctrl !=
+ CDROM_DATA_TRACK ? 1 : 0;
+ ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
+ }
+
+ tocentry.cdte_track = CDROM_LEADOUT;
+ tocentry.cdte_format = CDROM_MSF;
+ if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ cdp->track_info[i].track = j;
+ cdp->track_info[i].audio_track = 0;
+ ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
+
+ return DISC_NO_ERROR;
}
int
-cdrom_get_status(cdrom_device_t cdp, cdrom_device_status_t *stat)
+cdrom_get_status(cdrom_device_t cdp, cdrom_device_status_t * stat)
{
- struct cdrom_subchnl subchnl;
-
- subchnl.cdsc_format = CDROM_MSF;
- if (ioctl(cdp->device, CDROMSUBCHNL, &subchnl) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- switch(subchnl.cdsc_audiostatus)
- {
- case CDROM_AUDIO_PLAY:
- stat->audio_status = DISC_PLAY;
- break;
- case CDROM_AUDIO_PAUSED:
- stat->audio_status = DISC_PAUSED;
- break;
- case CDROM_AUDIO_COMPLETED:
- stat->audio_status = DISC_COMPLETED;
- break;
- case CDROM_AUDIO_INVALID:
- case CDROM_AUDIO_NO_STATUS:
- case CDROM_AUDIO_ERROR:
- stat->audio_status = DISC_STOP;
- break;
- default:
- stat->audio_status = DISC_ERROR;
- }
- stat->track = subchnl.cdsc_trk;
- ASSIGN_MSF(stat->relative_address, subchnl.cdsc_reladdr.msf);
- ASSIGN_MSF(stat->absolute_address, subchnl.cdsc_absaddr.msf);
- return DISC_NO_ERROR;
+ struct cdrom_subchnl subchnl;
+
+ subchnl.cdsc_format = CDROM_MSF;
+ if (ioctl(cdp->device, CDROMSUBCHNL, &subchnl) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ switch (subchnl.cdsc_audiostatus) {
+ case CDROM_AUDIO_PLAY:
+ stat->audio_status = DISC_PLAY;
+ break;
+ case CDROM_AUDIO_PAUSED:
+ stat->audio_status = DISC_PAUSED;
+ break;
+ case CDROM_AUDIO_COMPLETED:
+ stat->audio_status = DISC_COMPLETED;
+ break;
+ case CDROM_AUDIO_INVALID:
+ case CDROM_AUDIO_NO_STATUS:
+ case CDROM_AUDIO_ERROR:
+ stat->audio_status = DISC_STOP;
+ break;
+ default:
+ stat->audio_status = DISC_ERROR;
+ }
+ stat->track = subchnl.cdsc_trk;
+ ASSIGN_MSF(stat->relative_address, subchnl.cdsc_reladdr.msf);
+ ASSIGN_MSF(stat->absolute_address, subchnl.cdsc_absaddr.msf);
+ return DISC_NO_ERROR;
}
-cdrom_device_t
+cdrom_device_t
cdrom_open(char *device, int *errcode)
{
- cdrom_device_t cdp;
-
- cdp = g_malloc(sizeof(struct cdrom_device));
-
- cdp->device = open(device, O_RDONLY);
- if (cdp->device == -1)
- {
- *errcode = errno;
- g_free(cdp);
- return NULL;
- }
- cdp->nr_track = 0;
- cdp->track_info = NULL;
- return cdp;
+ cdrom_device_t cdp;
+
+ cdp = g_malloc(sizeof(struct cdrom_device));
+
+ cdp->device = open(device, O_RDONLY);
+ if (cdp->device == -1) {
+ *errcode = errno;
+ g_free(cdp);
+ return NULL;
+ }
+ cdp->nr_track = 0;
+ cdp->track_info = NULL;
+ return cdp;
}
void
cdrom_close(cdrom_device_t cdp)
{
- if (cdp->nr_track)
- g_free(cdp->track_info);
- close(cdp->device);
- g_free(cdp);
+ if (cdp->nr_track)
+ g_free(cdp->track_info);
+ close(cdp->device);
+ g_free(cdp);
}
int
cdrom_eject(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMEJECT, 0) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- };
- return DISC_NO_ERROR;
+ if (ioctl(cdp->device, CDROMEJECT, 0) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ };
+ return DISC_NO_ERROR;
}
-int cdrom_next(cdrom_device_t cdp)
+int
+cdrom_next(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- track = stat.track + 1;
- return cdrom_play(cdp, stat.track + 1, cdp->track1);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ track = stat.track + 1;
+ return cdrom_play(cdp, stat.track + 1, cdp->track1);
}
-int cdrom_prev(cdrom_device_t cdp)
+int
+cdrom_prev(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- track = stat.track - 1;
- return cdrom_play(cdp, stat.track - 1, cdp->track1);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ track = stat.track - 1;
+ return cdrom_play(cdp, stat.track - 1, cdp->track1);
}
int
cdrom_rewind(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- if (stat.absolute_address.second != 0)
- stat.absolute_address.second--;
- else
- {
- stat.absolute_address.second = 0;
- if (stat.absolute_address.minute > 0)
- stat.absolute_address.minute--;
- }
- stat.absolute_address.frame = 0;
- return cdrom_play_msf(cdp, &stat.absolute_address);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ if (stat.absolute_address.second != 0)
+ stat.absolute_address.second--;
+ else {
+ stat.absolute_address.second = 0;
+ if (stat.absolute_address.minute > 0)
+ stat.absolute_address.minute--;
+ }
+ stat.absolute_address.frame = 0;
+ return cdrom_play_msf(cdp, &stat.absolute_address);
}
int
cdrom_ff(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- stat.absolute_address.second++;
- if (stat.absolute_address.second >= 60)
- {
- stat.absolute_address.minute++;
- stat.absolute_address.second = 0;
- }
- stat.absolute_address.frame = 0;
- return cdrom_play_msf(cdp, &stat.absolute_address);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ stat.absolute_address.second++;
+ if (stat.absolute_address.second >= 60) {
+ stat.absolute_address.minute++;
+ stat.absolute_address.second = 0;
+ }
+ stat.absolute_address.frame = 0;
+ return cdrom_play_msf(cdp, &stat.absolute_address);
}
int
-cdrom_track_length(cdrom_device_t cdp, int track, cdrom_msf_t *length)
+cdrom_track_length(cdrom_device_t cdp, int track, cdrom_msf_t * length)
{
- int index, s1, s2, i;
-
- if ((track < cdp->track0) || (track > cdp->track1))
- return DISC_INDEX_OUT_OF_RANGE;
- index = track - cdp->track0;
-
- s1 = cdp->track_info[index + 1].address.second;
- s2 = cdp->track_info[index].address.second;
- length->second = s1 = s1 - s2;
- if (s1 < 0)
- {
- i = 1;
- length->second = s1 + 60;
- }
- else
- i = 0;
-
- length->minute = cdp->track_info[index + 1].address.minute -
- cdp->track_info[index].address.minute - i;
+ int index, s1, s2, i;
+
+ if ((track < cdp->track0) || (track > cdp->track1))
+ return DISC_INDEX_OUT_OF_RANGE;
+ index = track - cdp->track0;
+
+ s1 = cdp->track_info[index + 1].address.second;
+ s2 = cdp->track_info[index].address.second;
+ length->second = s1 = s1 - s2;
+ if (s1 < 0) {
+ i = 1;
+ length->second = s1 + 60;
+ } else
+ i = 0;
+
+ length->minute = cdp->track_info[index + 1].address.minute -
+ cdp->track_info[index].address.minute - i;
}
diff --git a/cdplayer/cdrom-solaris.c b/cdplayer/cdrom-solaris.c
index db44c80fa..3f646fc98 100644
--- a/cdplayer/cdrom-solaris.c
+++ b/cdplayer/cdrom-solaris.c
@@ -17,297 +17,278 @@
int
cdrom_play(cdrom_device_t cdp, int start, int stop)
{
- struct cdrom_ti ti;
-
- ti.cdti_trk0 = start;
- ti.cdti_ind0 = 1;
- ti.cdti_trk1 = stop;
- ti.cdti_ind1 = 1;
- if (ioctl(cdp->device, CDROMPLAYTRKIND, &ti) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ struct cdrom_ti ti;
+
+ ti.cdti_trk0 = start;
+ ti.cdti_ind0 = 1;
+ ti.cdti_trk1 = stop;
+ ti.cdti_ind1 = 1;
+ if (ioctl(cdp->device, CDROMPLAYTRKIND, &ti) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
int
-cdrom_play_msf(cdrom_device_t cdp, cdrom_msf_t *start)
+cdrom_play_msf(cdrom_device_t cdp, cdrom_msf_t * start)
{
- struct cdrom_msf msf;
-
- if (cdrom_read_track_info(cdp) == DISC_IO_ERROR)
- return DISC_IO_ERROR;
- msf.cdmsf_min0 = start->minute;
- msf.cdmsf_sec0 = start->second;
- msf.cdmsf_frame0 = start->frame;
-
- msf.cdmsf_min1 = cdp->track_info[cdp->nr_track].address.minute;
- msf.cdmsf_sec1 = cdp->track_info[cdp->nr_track].address.second;
- msf.cdmsf_frame1 = cdp->track_info[cdp->nr_track].address.frame;
-
- if (ioctl(cdp->device, CDROMPLAYMSF, &msf) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ struct cdrom_msf msf;
+
+ if (cdrom_read_track_info(cdp) == DISC_IO_ERROR)
+ return DISC_IO_ERROR;
+ msf.cdmsf_min0 = start->minute;
+ msf.cdmsf_sec0 = start->second;
+ msf.cdmsf_frame0 = start->frame;
+
+ msf.cdmsf_min1 = cdp->track_info[cdp->nr_track].address.minute;
+ msf.cdmsf_sec1 = cdp->track_info[cdp->nr_track].address.second;
+ msf.cdmsf_frame1 = cdp->track_info[cdp->nr_track].address.frame;
+
+ if (ioctl(cdp->device, CDROMPLAYMSF, &msf) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
-int
+int
cdrom_pause(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMPAUSE, 0) == -1)
- {
- return DISC_IO_ERROR;
- cdp->my_errno = errno;
- }
- return DISC_IO_ERROR;
+ if (ioctl(cdp->device, CDROMPAUSE, 0) == -1) {
+ return DISC_IO_ERROR;
+ cdp->my_errno = errno;
+ }
+ return DISC_IO_ERROR;
}
-int
+int
cdrom_resume(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMRESUME, 0) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ if (ioctl(cdp->device, CDROMRESUME, 0) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
int
cdrom_stop(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMSTOP, 0) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- return DISC_NO_ERROR;
+ if (ioctl(cdp->device, CDROMSTOP, 0) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ return DISC_NO_ERROR;
}
int
cdrom_read_track_info(cdrom_device_t cdp)
{
- struct cdrom_tochdr toc;
- struct cdrom_tocentry tocentry;
-
- int i, j, nr_track;
-
- if (ioctl(cdp->device, CDROMREADTOCHDR, &toc) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- cdp->track0 = toc.cdth_trk0;
- cdp->track1 = toc.cdth_trk1;
- nr_track = toc.cdth_trk1 - toc.cdth_trk0 + 1;
- if (nr_track <= 0)
- return DISC_IO_ERROR;
-
- if (nr_track != cdp->nr_track)
- {
- if (cdp->track_info)
- g_free(cdp->track_info);
- cdp->nr_track = nr_track;
- cdp->track_info = g_malloc((cdp->nr_track + 1) * sizeof(track_info_t));
- }
-
-
- for (i = 0, j = cdp->track0; i < cdp->nr_track; i++, j++)
- {
- tocentry.cdte_track = j;
- tocentry.cdte_format = CDROM_MSF;
-
- if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
+ struct cdrom_tochdr toc;
+ struct cdrom_tocentry tocentry;
+
+ int i, j, nr_track;
+
+ if (ioctl(cdp->device, CDROMREADTOCHDR, &toc) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ cdp->track0 = toc.cdth_trk0;
+ cdp->track1 = toc.cdth_trk1;
+ nr_track = toc.cdth_trk1 - toc.cdth_trk0 + 1;
+ if (nr_track <= 0)
+ return DISC_IO_ERROR;
+
+ if (nr_track != cdp->nr_track) {
+ if (cdp->track_info)
+ g_free(cdp->track_info);
+ cdp->nr_track = nr_track;
+ cdp->track_info = g_malloc((cdp->nr_track + 1) * sizeof(track_info_t));
}
-
- /* fill the trackinfo field */
- cdp->track_info[i].track = j;
- cdp->track_info[i].audio_track = tocentry.cdte_ctrl !=
- CDROM_DATA_TRACK ? 1 : 0;
- ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
- }
-
- tocentry.cdte_track = CDROM_LEADOUT;
- tocentry.cdte_format = CDROM_MSF;
- if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- cdp->track_info[i].track = j;
- cdp->track_info[i].audio_track = 0;
- ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
-
- return DISC_NO_ERROR;
+ for (i = 0, j = cdp->track0; i < cdp->nr_track; i++, j++) {
+ tocentry.cdte_track = j;
+ tocentry.cdte_format = CDROM_MSF;
+
+ if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ /* fill the trackinfo field */
+ cdp->track_info[i].track = j;
+ cdp->track_info[i].audio_track = tocentry.cdte_ctrl !=
+ CDROM_DATA_TRACK ? 1 : 0;
+ ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
+ }
+
+ tocentry.cdte_track = CDROM_LEADOUT;
+ tocentry.cdte_format = CDROM_MSF;
+ if (ioctl(cdp->device, CDROMREADTOCENTRY, &tocentry) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ cdp->track_info[i].track = j;
+ cdp->track_info[i].audio_track = 0;
+ ASSIGN_MSF(cdp->track_info[i].address, tocentry.cdte_addr.msf);
+
+ return DISC_NO_ERROR;
}
int
-cdrom_get_status(cdrom_device_t cdp, cdrom_device_status_t *stat)
+cdrom_get_status(cdrom_device_t cdp, cdrom_device_status_t * stat)
{
- struct cdrom_subchnl subchnl;
-
- subchnl.cdsc_format = CDROM_MSF;
- if (ioctl(cdp->device, CDROMSUBCHNL, &subchnl) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- }
- switch(subchnl.cdsc_audiostatus)
- {
- case CDROM_AUDIO_PLAY:
- stat->audio_status = DISC_PLAY;
- break;
- case CDROM_AUDIO_PAUSED:
- stat->audio_status = DISC_PAUSED;
- break;
- case CDROM_AUDIO_COMPLETED:
- stat->audio_status = DISC_COMPLETED;
- break;
- case CDROM_AUDIO_INVALID:
- case CDROM_AUDIO_NO_STATUS:
- case CDROM_AUDIO_ERROR:
- stat->audio_status = DISC_STOP;
- break;
- default:
- stat->audio_status = DISC_ERROR;
- }
- stat->track = subchnl.cdsc_trk;
- ASSIGN_MSF(stat->relative_address, subchnl.cdsc_reladdr.msf);
- ASSIGN_MSF(stat->absolute_address, subchnl.cdsc_absaddr.msf);
- return DISC_NO_ERROR;
+ struct cdrom_subchnl subchnl;
+
+ subchnl.cdsc_format = CDROM_MSF;
+ if (ioctl(cdp->device, CDROMSUBCHNL, &subchnl) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ }
+ switch (subchnl.cdsc_audiostatus) {
+ case CDROM_AUDIO_PLAY:
+ stat->audio_status = DISC_PLAY;
+ break;
+ case CDROM_AUDIO_PAUSED:
+ stat->audio_status = DISC_PAUSED;
+ break;
+ case CDROM_AUDIO_COMPLETED:
+ stat->audio_status = DISC_COMPLETED;
+ break;
+ case CDROM_AUDIO_INVALID:
+ case CDROM_AUDIO_NO_STATUS:
+ case CDROM_AUDIO_ERROR:
+ stat->audio_status = DISC_STOP;
+ break;
+ default:
+ stat->audio_status = DISC_ERROR;
+ }
+ stat->track = subchnl.cdsc_trk;
+ ASSIGN_MSF(stat->relative_address, subchnl.cdsc_reladdr.msf);
+ ASSIGN_MSF(stat->absolute_address, subchnl.cdsc_absaddr.msf);
+ return DISC_NO_ERROR;
}
-cdrom_device_t
+cdrom_device_t
cdrom_open(char *device, int *errcode)
{
- cdrom_device_t cdp;
-
- cdp = g_malloc(sizeof(struct cdrom_device));
-
- cdp->device = open(device, O_RDONLY);
- if (cdp->device == -1)
- {
- *errcode = errno;
- g_free(cdp);
- return NULL;
- }
- cdp->nr_track = 0;
- cdp->track_info = NULL;
- return cdp;
+ cdrom_device_t cdp;
+
+ cdp = g_malloc(sizeof(struct cdrom_device));
+
+ cdp->device = open(device, O_RDONLY);
+ if (cdp->device == -1) {
+ *errcode = errno;
+ g_free(cdp);
+ return NULL;
+ }
+ cdp->nr_track = 0;
+ cdp->track_info = NULL;
+ return cdp;
}
void
cdrom_close(cdrom_device_t cdp)
{
- if (cdp->nr_track)
- g_free(cdp->track_info);
- close(cdp->device);
- g_free(cdp);
+ if (cdp->nr_track)
+ g_free(cdp->track_info);
+ close(cdp->device);
+ g_free(cdp);
}
int
cdrom_eject(cdrom_device_t cdp)
{
- if (ioctl(cdp->device, CDROMEJECT, 0) == -1)
- {
- cdp->my_errno = errno;
- return DISC_IO_ERROR;
- };
- return DISC_NO_ERROR;
+ if (ioctl(cdp->device, CDROMEJECT, 0) == -1) {
+ cdp->my_errno = errno;
+ return DISC_IO_ERROR;
+ };
+ return DISC_NO_ERROR;
}
-int cdrom_next(cdrom_device_t cdp)
+int
+cdrom_next(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- track = stat.track + 1;
- return cdrom_play(cdp, stat.track + 1, cdp->track1);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ track = stat.track + 1;
+ return cdrom_play(cdp, stat.track + 1, cdp->track1);
}
-int cdrom_prev(cdrom_device_t cdp)
+int
+cdrom_prev(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- track = stat.track - 1;
- return cdrom_play(cdp, stat.track - 1, cdp->track1);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ track = stat.track - 1;
+ return cdrom_play(cdp, stat.track - 1, cdp->track1);
}
int
cdrom_rewind(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- if (stat.absolute_address.second != 0)
- stat.absolute_address.second--;
- else
- {
- stat.absolute_address.second = 0;
- if (stat.absolute_address.minute > 0)
- stat.absolute_address.minute--;
- }
- stat.absolute_address.frame = 0;
- return cdrom_play_msf(cdp, &stat.absolute_address);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ if (stat.absolute_address.second != 0)
+ stat.absolute_address.second--;
+ else {
+ stat.absolute_address.second = 0;
+ if (stat.absolute_address.minute > 0)
+ stat.absolute_address.minute--;
+ }
+ stat.absolute_address.frame = 0;
+ return cdrom_play_msf(cdp, &stat.absolute_address);
}
int
cdrom_ff(cdrom_device_t cdp)
{
- cdrom_device_status_t stat;
- int track;
-
- if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
- (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
- return DISC_IO_ERROR;
- stat.absolute_address.second++;
- if (stat.absolute_address.second >= 60)
- {
- stat.absolute_address.minute++;
- stat.absolute_address.second = 0;
- }
- stat.absolute_address.frame = 0;
- return cdrom_play_msf(cdp, &stat.absolute_address);
+ cdrom_device_status_t stat;
+ int track;
+
+ if ((cdrom_read_track_info(cdp) == DISC_IO_ERROR) ||
+ (cdrom_get_status(cdp, &stat) == DISC_IO_ERROR))
+ return DISC_IO_ERROR;
+ stat.absolute_address.second++;
+ if (stat.absolute_address.second >= 60) {
+ stat.absolute_address.minute++;
+ stat.absolute_address.second = 0;
+ }
+ stat.absolute_address.frame = 0;
+ return cdrom_play_msf(cdp, &stat.absolute_address);
}
int
-cdrom_track_length(cdrom_device_t cdp, int track, cdrom_msf_t *length)
+cdrom_track_length(cdrom_device_t cdp, int track, cdrom_msf_t * length)
{
- int index, s1, s2, i;
-
- if ((track < cdp->track0) || (track > cdp->track1))
- return DISC_INDEX_OUT_OF_RANGE;
- index = track - cdp->track0;
-
- s1 = cdp->track_info[index + 1].address.second;
- s2 = cdp->track_info[index].address.second;
- length->second = s1 = s1 - s2;
- if (s1 < 0)
- {
- i = 1;
- length->second = s1 + 60;
- }
- else
- i = 0;
-
- length->minute = cdp->track_info[index + 1].address.minute -
- cdp->track_info[index].address.minute - i;
+ int index, s1, s2, i;
+
+ if ((track < cdp->track0) || (track > cdp->track1))
+ return DISC_INDEX_OUT_OF_RANGE;
+ index = track - cdp->track0;
+
+ s1 = cdp->track_info[index + 1].address.second;
+ s2 = cdp->track_info[index].address.second;
+ length->second = s1 = s1 - s2;
+ if (s1 < 0) {
+ i = 1;
+ length->second = s1 + 60;
+ } else
+ i = 0;
+
+ length->minute = cdp->track_info[index + 1].address.minute -
+ cdp->track_info[index].address.minute - i;
}
diff --git a/cdplayer/led.c b/cdplayer/led.c
index e7880b4c4..1f6c7d696 100644
--- a/cdplayer/led.c
+++ b/cdplayer/led.c
@@ -5,138 +5,136 @@
static GdkPixmap *led_pixmap;
void
-led_init(GtkWidget *w)
+led_init(GtkWidget * w)
{
- GdkColor black;
+ GdkColor black;
- gdk_color_black(gtk_widget_get_colormap(w), &black);
- led_pixmap = gdk_pixmap_create_from_xpm_d(w->window, NULL,
- &black, led);
+ gdk_color_black(gtk_widget_get_colormap(w), &black);
+ led_pixmap = gdk_pixmap_create_from_xpm_d(w->window, NULL,
+ &black, led);
}
void
led_done()
{
- gdk_pixmap_unref(led_pixmap);
+ gdk_pixmap_unref(led_pixmap);
}
void
-led_create_widget(GtkWidget *window, GtkWidget **time, GtkWidget **track)
+led_create_widget(GtkWidget * window, GtkWidget ** time, GtkWidget ** track)
{
- GtkWidget *w;
- *time = gtk_pixmap_new(gdk_pixmap_new(window->window,
- LED_WIDTH, LED_HEIGHT + 2,
- -1), NULL);
- *track = gtk_pixmap_new(gdk_pixmap_new(window->window,
- DIGIT_WIDTH * 2 + 2, LED_HEIGHT + 2,
- -1), NULL);
+ GtkWidget *w;
+ *time = gtk_pixmap_new(gdk_pixmap_new(window->window,
+ LED_WIDTH, LED_HEIGHT + 2,
+ -1), NULL);
+ *track = gtk_pixmap_new(gdk_pixmap_new(window->window,
+ DIGIT_WIDTH * 2 + 2,
+ LED_HEIGHT + 2,
+ -1), NULL);
}
void
-led_stop(GtkWidget *time, GtkWidget *track)
+led_stop(GtkWidget * time, GtkWidget * track)
{
- GdkPixmap *p;
- GtkStyle *style;
- int retval;
-
- style = gtk_widget_get_style(time);
- gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
- gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
- 0, 1, 1, DIGIT_WIDTH, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
- 0, DIGIT_WIDTH + 1, 1, DIGIT_WIDTH, -1);
- /* : */
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH,
- 0, 2 * DIGIT_WIDTH + 2, 1, DIGIT_WIDTH, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
- 0, 3 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
- 0, 4 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
- gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
- gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
-
+ GdkPixmap *p;
+ GtkStyle *style;
+ int retval;
+
+ style = gtk_widget_get_style(time);
+ gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
+ gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
+ 0, 1, 1, DIGIT_WIDTH, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
+ 0, DIGIT_WIDTH + 1, 1, DIGIT_WIDTH, -1);
+ /* : */
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH,
+ 0, 2 * DIGIT_WIDTH + 2, 1, DIGIT_WIDTH, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
+ 0, 3 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH + 7,
+ 0, 4 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
+ gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
+ gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
+
}
static void
-led_draw_track(GtkStyle *style, GtkWidget *track, int trackno)
+led_draw_track(GtkStyle * style, GtkWidget * track, int trackno)
{
- GdkPixmap *p;
- gtk_pixmap_get(GTK_PIXMAP(track), &p, NULL);
- gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, (trackno / 10) * DIGIT_WIDTH,
- 0, 1, 1, DIGIT_WIDTH, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, (trackno % 10) * DIGIT_WIDTH,
- 0, DIGIT_WIDTH + 1, 1, DIGIT_WIDTH, -1);
+ GdkPixmap *p;
+ gtk_pixmap_get(GTK_PIXMAP(track), &p, NULL);
+ gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, (trackno / 10) * DIGIT_WIDTH,
+ 0, 1, 1, DIGIT_WIDTH, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, (trackno % 10) * DIGIT_WIDTH,
+ 0, DIGIT_WIDTH + 1, 1, DIGIT_WIDTH, -1);
}
void
-led_time(GtkWidget *time, int min, int sec, GtkWidget *track, int trackno)
+led_time(GtkWidget * time, int min, int sec, GtkWidget * track, int trackno)
{
- GdkPixmap *p;
- GtkStyle *style;
- int retval;
-
- style = gtk_widget_get_style(time);
- gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
- gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
- /* minute */
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, (min / 10) * DIGIT_WIDTH,
- 0, 1, 1, DIGIT_WIDTH, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, (min % 10) * DIGIT_WIDTH,
- 0, DIGIT_WIDTH + 1, 1, DIGIT_WIDTH, -1);
- /* : */
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH,
- 0, 2 * DIGIT_WIDTH + 2, 1, DIGIT_WIDTH, -1);
- /* second */
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, (sec / 10) * DIGIT_WIDTH,
- 0, 3 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
- gdk_draw_pixmap(p, style->white_gc, led_pixmap, (sec % 10) * DIGIT_WIDTH,
- 0, 4 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
-
- led_draw_track(style, track, trackno);
- gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
- gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
+ GdkPixmap *p;
+ GtkStyle *style;
+ int retval;
+
+ style = gtk_widget_get_style(time);
+ gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
+ gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
+ /* minute */
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, (min / 10) * DIGIT_WIDTH,
+ 0, 1, 1, DIGIT_WIDTH, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, (min % 10) * DIGIT_WIDTH,
+ 0, DIGIT_WIDTH + 1, 1, DIGIT_WIDTH, -1);
+ /* : */
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, 10 * DIGIT_WIDTH,
+ 0, 2 * DIGIT_WIDTH + 2, 1, DIGIT_WIDTH, -1);
+ /* second */
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, (sec / 10) * DIGIT_WIDTH,
+ 0, 3 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
+ gdk_draw_pixmap(p, style->white_gc, led_pixmap, (sec % 10) * DIGIT_WIDTH,
+ 0, 4 * DIGIT_WIDTH - 1, 1, DIGIT_WIDTH, -1);
+
+ led_draw_track(style, track, trackno);
+ gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
+ gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
}
void
-led_paused(GtkWidget *time, int min, int sec, GtkWidget *track, int trackno)
+led_paused(GtkWidget * time, int min, int sec, GtkWidget * track, int trackno)
{
- static int visible = 1;
- if (visible == 1)
- {
- led_time(time, min, sec, track, trackno);
- visible = 0;
- }
- else
- {
- GdkPixmap *p;
- GtkStyle *style;
- int retval;
-
- style = gtk_widget_get_style(time);
- gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
- gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
- led_draw_track(style, track, trackno);
- visible = 1;
- gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
- gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
- }
+ static int visible = 1;
+ if (visible == 1) {
+ led_time(time, min, sec, track, trackno);
+ visible = 0;
+ } else {
+ GdkPixmap *p;
+ GtkStyle *style;
+ int retval;
+
+ style = gtk_widget_get_style(time);
+ gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
+ gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
+ led_draw_track(style, track, trackno);
+ visible = 1;
+ gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
+ gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
+ }
}
void
-led_nodisc(GtkWidget *time, GtkWidget *track)
+led_nodisc(GtkWidget * time, GtkWidget * track)
{
- GdkPixmap *p;
- GtkStyle *style;
- int retval;
-
- style = gtk_widget_get_style(time);
- gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
- gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
- gtk_pixmap_get(GTK_PIXMAP(track), &p, NULL);
- gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
- gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
- gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
+ GdkPixmap *p;
+ GtkStyle *style;
+ int retval;
+
+ style = gtk_widget_get_style(time);
+ gtk_pixmap_get(GTK_PIXMAP(time), &p, NULL);
+ gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
+ gtk_pixmap_get(GTK_PIXMAP(track), &p, NULL);
+ gdk_draw_rectangle(p, style->black_gc, 1, 0, 0, -1, -1);
+ gtk_signal_emit_by_name(GTK_OBJECT(time), "draw", &retval);
+ gtk_signal_emit_by_name(GTK_OBJECT(track), "draw", &retval);
}
diff --git a/cdplayer/led.h b/cdplayer/led.h
index a59aaee3d..97918215f 100644
--- a/cdplayer/led.h
+++ b/cdplayer/led.h
@@ -5,14 +5,15 @@
#define LED_HEIGHT 11
#define LED_WIDTH (DIGIT_WIDTH * 5)
-void led_init(GtkWidget *window);
+void led_init(GtkWidget * window);
void led_done(void);
-void led_create_widget(GtkWidget *window,GtkWidget **time, GtkWidget **track);
-void led_time(GtkWidget *time, int min, int sec, GtkWidget *track,
+void led_create_widget(GtkWidget * window, GtkWidget ** time,
+ GtkWidget ** track);
+void led_time(GtkWidget * time, int min, int sec, GtkWidget * track,
int trackno);
-void led_stop(GtkWidget *time, GtkWidget *track);
-void led_pause(GtkWidget *time, int min, int sec, GtkWidget *track,
+void led_stop(GtkWidget * time, GtkWidget * track);
+void led_pause(GtkWidget * time, int min, int sec, GtkWidget * track,
int trackno);
-void led_nodisc(GtkWidget *time, GtkWidget *track);
+void led_nodisc(GtkWidget * time, GtkWidget * track);
#endif
diff --git a/clock/clock.c b/clock/clock.c
index 59f266a90..ffebc2c53 100644
--- a/clock/clock.c
+++ b/clock/clock.c
@@ -25,11 +25,11 @@
#define CLOCK_DATA "clock_data"
-typedef void (*ClockUpdateFunc) (GtkWidget *clock, time_t current_time);
+typedef void (*ClockUpdateFunc) (GtkWidget * clock, time_t current_time);
GtkWidget *plug = NULL;
-int applet_id=-1; /*this is our id we use to comunicate with the panel*/
+int applet_id = (-1); /*this is our id we use to comunicate with the panel */
typedef struct {
@@ -44,19 +44,19 @@ typedef struct {
static void
-free_data(GtkWidget *widget, gpointer data)
+free_data(GtkWidget * widget, gpointer data)
{
g_free(data);
}
static int
-clock_timeout_callback (gpointer data)
+clock_timeout_callback(gpointer data)
{
- time_t current_time;
+ time_t current_time;
GtkWidget *clock;
ClockData *cd;
-
- time (&current_time);
+
+ time(&current_time);
clock = data;
cd = gtk_object_get_data(GTK_OBJECT(clock), CLOCK_DATA);
@@ -67,32 +67,32 @@ clock_timeout_callback (gpointer data)
}
static void
-computer_clock_update_func(GtkWidget *clock, time_t current_time)
+computer_clock_update_func(GtkWidget * clock, time_t current_time)
{
ComputerClock *cc;
- char *strtime;
- char date[20], hour[20];
+ char *strtime;
+ char date[20], hour[20];
cc = gtk_object_get_user_data(GTK_OBJECT(clock));
- strtime = ctime (&current_time);
+ strtime = ctime(&current_time);
- strncpy (date, strtime, 10);
+ strncpy(date, strtime, 10);
date[10] = '\0';
- gtk_label_set (GTK_LABEL (cc->date), date);
+ gtk_label_set(GTK_LABEL(cc->date), date);
strtime += 11;
- strncpy (hour, strtime, 5);
+ strncpy(hour, strtime, 5);
hour[5] = '\0';
- gtk_label_set (GTK_LABEL (cc->time), hour);
+ gtk_label_set(GTK_LABEL(cc->time), hour);
}
static void
-create_computer_clock_widget(GtkWidget **clock, ClockUpdateFunc *update_func)
+create_computer_clock_widget(GtkWidget ** clock, ClockUpdateFunc * update_func)
{
- GtkWidget *frame;
- GtkWidget *align;
- GtkWidget *vbox;
+ GtkWidget *frame;
+ GtkWidget *align;
+ GtkWidget *vbox;
ComputerClock *cc;
frame = gtk_frame_new(NULL);
@@ -127,27 +127,27 @@ create_computer_clock_widget(GtkWidget **clock, ClockUpdateFunc *update_func)
}
static void
-destroy_clock (GtkWidget *widget, void *data)
+destroy_clock(GtkWidget * widget, void *data)
{
ClockData *cd;
cd = gtk_object_get_data(GTK_OBJECT(widget), CLOCK_DATA);
-
- gtk_timeout_remove (cd->timeout);
+
+ gtk_timeout_remove(cd->timeout);
g_free(cd);
}
static GtkWidget *
-create_clock_widget (GtkWidget *window)
+create_clock_widget(void)
{
- ClockData *cd;
- GtkWidget *clock;
- time_t current_time;
+ ClockData *cd;
+ GtkWidget *clock;
+ time_t current_time;
cd = g_new(ClockData, 1);
- /*FIXME: different clock types here*/
+ /*FIXME: different clock types here */
create_computer_clock_widget(&clock, &cd->update_func);
/* Install timeout handler */
@@ -162,23 +162,23 @@ create_clock_widget (GtkWidget *window)
/* Call the clock's update function so that it paints its first state */
time(&current_time);
-
+
(*cd->update_func) (clock, current_time);
return clock;
}
-/*these are commands sent over corba:*/
+/*these are commands sent over corba: */
void
change_orient(int id, int orient)
{
- PanelOrientType o = (PanelOrientType)orient;
+ PanelOrientType o = (PanelOrientType) orient;
}
void
session_save(int id, const char *cfgpath, const char *globcfgpath)
{
- /*save the session here*/
+ /*save the session here */
}
static gint
@@ -190,17 +190,21 @@ quit_clock(gpointer data)
void
shutdown_applet(int id)
{
- /*kill our window using destroy to avoid warnings we need to
- kill the plug but we also need to return from this call*/
- if(plug) gtk_widget_destroy(plug);
- gtk_idle_add(quit_clock,NULL);
+ /*kill our plug using destroy to avoid warnings we need to
+ kill the plug but we also need to return from this call */
+ if (plug)
+ gtk_widget_destroy(plug);
+ gtk_idle_add(quit_clock, NULL);
}
+
+/*
void
test_callback(int id, gpointer data)
{
puts("TEST");
}
+*/
int
@@ -211,62 +215,52 @@ main(int argc, char **argv)
char *cfgpath;
char *globcfgpath;
- char *mypath;
char *myinvoc;
guint32 winid;
- panel_corba_register_arguments ();
+ myinvoc = get_which_output(argv[0]);
+ if(!myinvoc)
+ return 1;
+
+ panel_corba_register_arguments();
gnome_init("clock_applet", NULL, argc, argv, 0, NULL);
- if (!gnome_panel_applet_init_corba ()){
- g_error ("Could not comunicate with the panel\n");
- /*fprintf (stderr, "Could not comunicate with the panel\n");*/
- /*exit (1);*/
- }
-
- if(argv[0][0] == '/')
- myinvoc = g_strdup(argv[0]);
- else {
- mypath = getcwd(NULL,0);
- myinvoc = g_copy_strings(mypath,"/",argv[0],NULL);
- free(mypath);
- }
- result = gnome_panel_applet_request_id(myinvoc,&applet_id,
- &cfgpath,&globcfgpath,
+ if (!gnome_panel_applet_init_corba())
+ g_error("Could not comunicate with the panel\n");
+
+ result = gnome_panel_applet_request_id(myinvoc, &applet_id,
+ &cfgpath, &globcfgpath,
&winid);
g_free(myinvoc);
- if (result){
- g_error ("Could not talk to the Panel: %s\n", result);
- /*exit (1);*/
- }
-
- /*use cfg path for loading up data!*/
+ if (result)
+ g_error("Could not talk to the Panel: %s\n", result);
+ /*use cfg path for loading up data! */
g_free(globcfgpath);
g_free(cfgpath);
- plug = gtk_plug_new (winid);
+ plug = gtk_plug_new(winid);
- clock = create_clock_widget (plug);
+ clock = create_clock_widget();
gtk_widget_show(clock);
- gtk_container_add (GTK_CONTAINER (plug), clock);
- gtk_widget_show (plug);
+ gtk_container_add(GTK_CONTAINER(plug), clock);
+ gtk_widget_show(plug);
- result = gnome_panel_applet_register(plug,applet_id);
- if (result){
- g_error ("Could not talk to the Panel: %s\n", result);
- }
+ result = gnome_panel_applet_register(plug, applet_id);
+ if (result)
+ g_error("Could not talk to the Panel: %s\n", result);
-
- gnome_panel_applet_register_callback (applet_id,
- "test",
- "TEST CALLBACK",
- test_callback,
- NULL);
-
- applet_corba_gtk_main ("IDL:GNOME/Applet:1.0");
+/*
+ gnome_panel_applet_register_callback(applet_id,
+ "test",
+ "TEST CALLBACK",
+ test_callback,
+ NULL);
+*/
+
+ applet_corba_gtk_main("IDL:GNOME/Applet:1.0");
return 0;
}
diff --git a/mailcheck/ChangeLog b/mailcheck/ChangeLog
new file mode 100644
index 000000000..b050fc202
--- /dev/null
+++ b/mailcheck/ChangeLog
@@ -0,0 +1,7 @@
+Fri Mar 20 00:08:43 1998 George Lebl <jirka@5z.com>
+
+ * cdplayer/*: ported to corba, indented to kernel
+ conding style to be compatible with rest of gnome
+
+ * mailcheck/*: ported to corba
+
diff --git a/mailcheck/mailcheck_applet.desktop b/mailcheck/mailcheck_applet.desktop
new file mode 100644
index 000000000..184f852b7
--- /dev/null
+++ b/mailcheck/mailcheck_applet.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Clock
+Name[cs]=Hodiny
+Comment=Clock
+Comment[cs]=Hodiny
+Exec=clock_applet
+Icon=
+Terminal=0
+Type=Application