Skip to content

Commit

Permalink
Brought Cinnamon's GVC on par with CCC's (should fix sound applet not…
Browse files Browse the repository at this point in the history
… detecting added/removed devices). We should also factorize GVC across all Cinnamon subprojects (right now it's still duplicated) and rebase it from upstream libgnome-volume-control.
  • Loading branch information
clefebvre committed Mar 7, 2015
1 parent abcbb67 commit 47c9223
Show file tree
Hide file tree
Showing 15 changed files with 2,091 additions and 95 deletions.
3 changes: 3 additions & 0 deletions src/Makefile-gvc.am
Expand Up @@ -29,6 +29,9 @@ libgvc_la_gir_sources = \
gvc/gvc-mixer-source-output.c \
gvc/gvc-mixer-event-role.h \
gvc/gvc-mixer-event-role.c \
gvc/gvc-mixer-ui-device.h \
gvc/gvc-mixer-ui-device.c \
gvc/gvc-mixer-control.h \
gvc/gvc-mixer-control.h \
gvc/gvc-mixer-control.c

Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Expand Up @@ -10,7 +10,7 @@ service_in_files =

-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --warn-all --warn-error --add-include-path=$(srcdir)
INTROSPECTION_SCANNER_ARGS = --warn-all --add-include-path=$(srcdir)
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --includedir=$(MUFFIN_TYPELIB_DIR)

typelibdir = $(pkglibdir)
Expand Down
62 changes: 58 additions & 4 deletions src/gvc/gvc-mixer-card.c
Expand Up @@ -2,6 +2,7 @@
*
* Copyright (C) 2008 William Jon McCann
* Copyright (C) 2009 Bastien Nocera
* Copyright (C) Conor Curran 2011 <conor.curran@canonical.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
Expand Down Expand Up @@ -49,6 +50,7 @@ struct GvcMixerCardPrivate
char *human_profile;
GList *profiles;
pa_operation *profile_op;
GList *ports;
};

enum
Expand Down Expand Up @@ -274,9 +276,28 @@ gvc_mixer_card_get_profiles (GvcMixerCard *card)
return card->priv->profiles;
}

static int
sort_profiles (GvcMixerCardProfile *a,
GvcMixerCardProfile *b)

/**
* gvc_mixer_card_get_ports:
*
* Return value: (transfer none) (element-type GvcMixerCardPort):
*/
const GList *
gvc_mixer_card_get_ports (GvcMixerCard *card)
{
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);
return card->priv->ports;
}

/**
* gvc_mixer_card_profile_compare:
*
* Return value: 1 if @a has a higher priority, -1 if @b has a higher
* priority, 0 if @a and @b have the same priority.
*/
int
gvc_mixer_card_profile_compare (GvcMixerCardProfile *a,
GvcMixerCardProfile *b)
{
if (a->priority == b->priority)
return 0;
Expand All @@ -296,7 +317,40 @@ gvc_mixer_card_set_profiles (GvcMixerCard *card,
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
g_return_val_if_fail (card->priv->profiles == NULL, FALSE);

card->priv->profiles = g_list_sort (profiles, (GCompareFunc) sort_profiles);
card->priv->profiles = g_list_sort (profiles, (GCompareFunc) gvc_mixer_card_profile_compare);

return TRUE;
}

/**
* gvc_mixer_card_get_gicon:
* @card:
*
* Return value: (transfer full) (element-type GIcon):
*/
GIcon *
gvc_mixer_card_get_gicon (GvcMixerCard *card)
{
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);

if (card->priv->icon_name == NULL)
return NULL;

return g_themed_icon_new_with_default_fallbacks (card->priv->icon_name);
}

/**
* gvc_mixer_card_set_ports:
* @profiles: (transfer full) (element-type GvcMixerCardPort):
*/
gboolean
gvc_mixer_card_set_ports (GvcMixerCard *card,
GList *ports)
{
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
g_return_val_if_fail (card->priv->ports == NULL, FALSE);

card->priv->ports = ports;

return TRUE;
}
Expand Down
30 changes: 24 additions & 6 deletions src/gvc/gvc-mixer-card.h
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2008-2009 Red Hat, Inc.
* Copyright (C) Conor Curran 2011 <conor.curran@canonical.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
Expand All @@ -22,6 +23,7 @@
#define __GVC_MIXER_CARD_H

#include <glib-object.h>
#include <gio/gio.h>

G_BEGIN_DECLS

Expand Down Expand Up @@ -49,13 +51,23 @@ typedef struct

typedef struct
{
char *profile;
char *human_profile;
char *status;
guint priority;
guint n_sinks, n_sources;
char *profile;
char *human_profile;
char *status;
guint priority;
guint n_sinks, n_sources;
} GvcMixerCardProfile;

typedef struct
{
char *port;
char *human_port;
guint priority;
gint available;
gint direction;
GList *profiles;
} GvcMixerCardPort;

GType gvc_mixer_card_get_type (void);

guint gvc_mixer_card_get_id (GvcMixerCard *card);
Expand All @@ -64,9 +76,13 @@ const char * gvc_mixer_card_get_name (GvcMixerCard *card);
const char * gvc_mixer_card_get_icon_name (GvcMixerCard *card);
GvcMixerCardProfile * gvc_mixer_card_get_profile (GvcMixerCard *card);
const GList * gvc_mixer_card_get_profiles (GvcMixerCard *card);

const GList * gvc_mixer_card_get_ports (GvcMixerCard *card);
gboolean gvc_mixer_card_change_profile (GvcMixerCard *card,
const char *profile);
GIcon * gvc_mixer_card_get_gicon (GvcMixerCard *card);

int gvc_mixer_card_profile_compare (GvcMixerCardProfile *a,
GvcMixerCardProfile *b);

/* private */
gboolean gvc_mixer_card_set_name (GvcMixerCard *card,
Expand All @@ -77,6 +93,8 @@ gboolean gvc_mixer_card_set_profile (GvcMixerCard *card,
const char *profile);
gboolean gvc_mixer_card_set_profiles (GvcMixerCard *card,
GList *profiles);
gboolean gvc_mixer_card_set_ports (GvcMixerCard *stream,
GList *ports);

G_END_DECLS

Expand Down

0 comments on commit 47c9223

Please sign in to comment.