diff --git a/src/main.c b/src/main.c index cf0d227..93ba0b4 100644 --- a/src/main.c +++ b/src/main.c @@ -20,7 +20,7 @@ #include #include #include -#include "mixer.h" +#include "window.h" #include "../config.h" #define _(string) gettext(string) @@ -51,12 +51,12 @@ static int _usage(void); /* mixer */ static int _mixer(char const * device, MixerLayout layout, gboolean embedded) { - Mixer * mixer; + MixerWindow * mixer; - if((mixer = mixer_new(device, layout, embedded)) == NULL) + if((mixer = mixerwindow_new(device, layout, embedded)) == NULL) return 2; gtk_main(); - mixer_delete(mixer); + mixerwindow_delete(mixer); return 0; } diff --git a/src/mixer.c b/src/mixer.c index 23ea76c..542774f 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -237,7 +237,8 @@ static GtkWidget * _new_set(Mixer * mixer, int dev, struct audio_mixer_set * s); #endif static GtkWidget * _new_value(Mixer * mixer, int index, GtkWidget ** bbox); -Mixer * mixer_new(char const * device, MixerLayout layout, gboolean embedded) +Mixer * mixer_new(GtkWidget * window, char const * device, MixerLayout layout, + gboolean embedded) { Mixer * mixer; MixerProperties properties; diff --git a/src/mixer.h b/src/mixer.h index 2164f45..8c1eb0a 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -34,7 +34,8 @@ typedef struct _Mixer Mixer; /* functions */ -Mixer * mixer_new(char const * device, MixerLayout layout, gboolean embedded); +Mixer * mixer_new(GtkWidget * window, char const * device, MixerLayout layout, + gboolean embedded); void mixer_delete(Mixer * mixer); /* accessors */ diff --git a/src/project.conf b/src/project.conf index db37056..9779da0 100644 --- a/src/project.conf +++ b/src/project.conf @@ -4,18 +4,21 @@ cflags_force=-W `pkg-config --cflags libDesktop` cflags=-Wall -g -O2 -pedantic ldflags_force=`pkg-config --libs libDesktop` -lintl ldflags= -dist=Makefile,mixer.h,callbacks.h +dist=Makefile,mixer.h,window.h,callbacks.h [mixer] type=binary -sources=mixer.c,callbacks.c,main.c +sources=mixer.c,window.c,callbacks.c,main.c install=$(BINDIR) [mixer.c] depends=callbacks.h,mixer.h,../config.h +[window.c] +depends=mixer.h,window.h + [callbacks.c] depends=mixer.h,callbacks.h,../config.h [main.c] -depends=mixer.h,../config.h +depends=mixer.h,window.h,../config.h diff --git a/src/window.c b/src/window.c new file mode 100644 index 0000000..77be445 --- /dev/null +++ b/src/window.c @@ -0,0 +1,114 @@ +/* $Id$ */ +/* Copyright (c) 2015 Pierre Pronchery */ +/* This file is part of DeforaOS Desktop Mixer */ +/* 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 . */ + + + +#include +#include "window.h" + + +/* MixerWindow */ +/* private */ +/* types */ +struct _MixerWindow +{ + Mixer * mixer; + + /* widgets */ + GtkWidget * window; +#ifndef EMBEDDED + GtkWidget * menubar; +#endif +}; + + +/* prototypes */ +/* callbacks */ + + +/* public */ +/* functions */ +/* mixerwindow_new */ +MixerWindow * mixerwindow_new(char const * device, MixerLayout layout, + gboolean embedded) +{ + MixerWindow * mixer; + GtkAccelGroup * group; + + if((mixer = object_new(sizeof(*mixer))) == NULL) + return NULL; + group = gtk_accel_group_new(); + mixer->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + mixer->mixer = NULL; + if(mixer->window != NULL) + { + gtk_widget_realize(mixer->window); + mixer->mixer = mixer_new(mixer->window, device, layout, + embedded); + } + if(mixer->mixer == NULL) + { + mixerwindow_delete(mixer); + return NULL; + } + return mixer; +} + + +/* mixerwindow_delete */ +void mixerwindow_delete(MixerWindow * mixer) +{ + if(mixer->mixer != NULL) + mixer_delete(mixer->mixer); + if(mixer->window != NULL) + gtk_widget_destroy(mixer->window); + object_delete(mixer); +} + + +/* useful */ +/* mixerwindow_about */ +void mixerwindow_about(MixerWindow * mixer) +{ + mixer_about(mixer->mixer); +} + + +/* mixerwindow_properties */ +void mixerwindow_properties(MixerWindow * mixer) +{ + mixer_properties(mixer->mixer); +} + + +/* mixerwindow_show */ +void mixerwindow_show(MixerWindow * mixer) +{ + mixer_show(mixer->mixer); +} + + +/* mixerwindow_show_all */ +void mixerwindow_show_all(MixerWindow * mixer) +{ + mixer_show_all(mixer->mixer); +} + + +/* mixerwindow_show_class */ +void mixerwindow_show_class(MixerWindow * mixer, char const * name) +{ + mixer_show_class(mixer->mixer, name); +} diff --git a/src/window.h b/src/window.h new file mode 100644 index 0000000..0a42df6 --- /dev/null +++ b/src/window.h @@ -0,0 +1,43 @@ +/* $Id$ */ +/* Copyright (c) 2015 Pierre Pronchery */ +/* This file is part of DeforaOS Desktop Mixer */ +/* 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 . */ + + + +#ifndef MIXER_WINDOW_H +# define MIXER_WINDOW_H + +# include "mixer.h" + + +/* MixerWindow */ +/* public */ +/* types */ +typedef struct _MixerWindow MixerWindow; + + +/* functions */ +MixerWindow * mixerwindow_new(char const * device, MixerLayout layout, + gboolean embedded); +void mixerwindow_delete(MixerWindow * mixer); + +/* useful */ +void mixerwindow_about(MixerWindow * mixer); +void mixerwindow_properties(MixerWindow * mixer); + +void mixerwindow_show(MixerWindow * mixer); +void mixerwindow_show_all(MixerWindow * mixer); +void mixerwindow_show_class(MixerWindow * mixer, char const * name); + +#endif /* !MIXER_WINDOW_H */