grim/guifications3
Clone
Summary
Browse
Changes
Graph
moved gflib-gtk to the new cmake module
cmake
2010-12-15, Gary Kramlich
b6418db658c1
moved gflib-gtk to the new cmake module
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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/>.
*/
#if HAVE_CONFIG_H
#
include
<config.h>
#endif
/* HAVE_CONFIG_H */
#include
<gflib/gf_intl.h>
#include
<gflib/gf_preferences_proxy_entry.h>
#define GF_PREFERENCES_PROXY_ENTRY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GF_TYPE_PREFERENCES_PROXY_ENTRY, GfPreferencesProxyEntryPrivate))
/******************************************************************************
* Structs
*****************************************************************************/
typedef
struct
{
gchar
*
mount_point
;
GfPreferenceEngine
*
engine
;
}
GfPreferencesProxyEntryPrivate
;
/******************************************************************************
* Enums
*****************************************************************************/
enum
{
PROP_ZERO
=
0
,
PROP_MOUNT_POINT
,
PROP_ENGINE
,
PROP_LAST
};
/******************************************************************************
* Globals
*****************************************************************************/
static
GObjectClass
*
parent_class
=
NULL
;
/******************************************************************************
* Private API
*****************************************************************************/
static
void
gf_preferences_proxy_entry_set_mount_point
(
GfPreferencesProxyEntry
*
entry
,
const
gchar
*
mount_point
)
{
GfPreferencesProxyEntryPrivate
*
priv
=
GF_PREFERENCES_PROXY_ENTRY_GET_PRIVATE
(
entry
);
g_return_if_fail
(
GF_IS_PREFERENCES_PROXY_ENTRY
(
entry
));
g_return_if_fail
(
mount_point
);
g_free
(
priv
->
mount_point
);
priv
->
mount_point
=
(
mount_point
)
?
g_strdup
(
mount_point
)
:
NULL
;
}
static
void
gf_preferences_proxy_entry_set_engine
(
GfPreferencesProxyEntry
*
entry
,
GfPreferenceEngine
*
engine
)
{
GfPreferencesProxyEntryPrivate
*
priv
=
GF_PREFERENCES_PROXY_ENTRY_GET_PRIVATE
(
entry
);
g_return_if_fail
(
GF_IS_PREFERENCES_PROXY_ENTRY
(
entry
));
g_return_if_fail
(
GF_IS_PREFERENCE_ENGINE
(
engine
));
if
(
GF_IS_PREFERENCE_ENGINE
(
priv
->
engine
))
g_object_unref
(
G_OBJECT
(
priv
->
engine
));
priv
->
engine
=
(
GF_IS_PREFERENCE_ENGINE
(
engine
))
?
g_object_ref
(
engine
)
:
NULL
;
}
/******************************************************************************
* PreferencesProxyEntry API
*****************************************************************************/
static
const
gchar
*
gf_preferences_proxy_entry_real_get_mount_point
(
const
GfPreferencesProxyEntry
*
entry
)
{
GfPreferencesProxyEntryPrivate
*
priv
=
GF_PREFERENCES_PROXY_ENTRY_GET_PRIVATE
(
entry
);
g_return_val_if_fail
(
GF_IS_PREFERENCES_PROXY_ENTRY
(
entry
),
NULL
);
return
priv
->
mount_point
;
}
static
GfPreferenceEngine
*
gf_preferences_proxy_entry_real_get_engine
(
const
GfPreferencesProxyEntry
*
entry
)
{
GfPreferencesProxyEntryPrivate
*
priv
=
GF_PREFERENCES_PROXY_ENTRY_GET_PRIVATE
(
entry
);
g_return_val_if_fail
(
GF_IS_PREFERENCES_PROXY_ENTRY
(
entry
),
NULL
);
return
priv
->
engine
;
}
/******************************************************************************
* Object stuff
*****************************************************************************/
static
void
gf_preferences_proxy_entry_get_property
(
GObject
*
obj
,
guint
param_id
,
GValue
*
value
,
GParamSpec
*
psec
)
{
GfPreferencesProxyEntry
*
entry
=
GF_PREFERENCES_PROXY_ENTRY
(
obj
);
switch
(
param_id
)
{
case
PROP_MOUNT_POINT
:
g_value_set_string
(
value
,
gf_preferences_proxy_entry_get_mount_point
(
entry
));
break
;
case
PROP_ENGINE
:
g_value_set_object
(
value
,
gf_preferences_proxy_entry_get_engine
(
entry
));
break
;
default
:
G_OBJECT_WARN_INVALID_PROPERTY_ID
(
obj
,
param_id
,
psec
);
break
;
}
}
static
void
gf_preferences_proxy_entry_set_property
(
GObject
*
obj
,
guint
param_id
,
const
GValue
*
value
,
GParamSpec
*
psec
)
{
GfPreferencesProxyEntry
*
entry
=
GF_PREFERENCES_PROXY_ENTRY
(
obj
);
switch
(
param_id
)
{
case
PROP_MOUNT_POINT
:
gf_preferences_proxy_entry_set_mount_point
(
entry
,
g_value_get_string
(
value
));
break
;
case
PROP_ENGINE
:
gf_preferences_proxy_entry_set_engine
(
entry
,
g_value_get_object
(
value
));
break
;
default
:
G_OBJECT_WARN_INVALID_PROPERTY_ID
(
obj
,
param_id
,
psec
);
break
;
}
}
static
void
gf_preferences_proxy_entry_finalize
(
GObject
*
obj
)
{
GfPreferencesProxyEntryPrivate
*
priv
=
GF_PREFERENCES_PROXY_ENTRY_GET_PRIVATE
(
obj
);
g_free
(
priv
->
mount_point
);
g_object_unref
(
priv
->
engine
);
G_OBJECT_CLASS
(
parent_class
)
->
finalize
(
obj
);
}
static
void
gf_preferences_proxy_entry_class_init
(
GfPreferencesProxyEntryClass
*
klass
)
{
GObjectClass
*
obj_class
=
G_OBJECT_CLASS
(
klass
);
parent_class
=
g_type_class_peek_parent
(
klass
);
g_type_class_add_private
(
klass
,
sizeof
(
GfPreferencesProxyEntryPrivate
));
obj_class
->
finalize
=
gf_preferences_proxy_entry_finalize
;
obj_class
->
get_property
=
gf_preferences_proxy_entry_get_property
;
obj_class
->
set_property
=
gf_preferences_proxy_entry_set_property
;
klass
->
get_mount_point
=
gf_preferences_proxy_entry_real_get_mount_point
;
klass
->
get_engine
=
gf_preferences_proxy_entry_real_get_engine
;
g_object_class_install_property
(
obj_class
,
PROP_MOUNT_POINT
,
g_param_spec_string
(
"mount_point"
,
P_
(
"mount point"
),
P_
(
"The mount point for the engine"
),
NULL
,
G_PARAM_READWRITE
|
G_PARAM_CONSTRUCT_ONLY
));
g_object_class_install_property
(
obj_class
,
PROP_ENGINE
,
g_param_spec_object
(
"engine"
,
P_
(
"engine"
),
P_
(
"The engine to mount"
),
GF_TYPE_PREFERENCE_ENGINE
,
G_PARAM_READWRITE
|
G_PARAM_CONSTRUCT_ONLY
));
}
/******************************************************************************
* API
*****************************************************************************/
GType
gf_preferences_proxy_entry_get_type
(
void
)
{
static
GType
type
=
0
;
if
(
type
==
0
)
{
static
const
GTypeInfo
info
=
{
sizeof
(
GfPreferencesProxyEntryClass
),
NULL
,
NULL
,
(
GClassInitFunc
)
gf_preferences_proxy_entry_class_init
,
NULL
,
NULL
,
sizeof
(
GfPreferencesProxyEntry
),
0
,
NULL
,
NULL
};
type
=
g_type_register_static
(
GF_TYPE_OBJECT
,
"GfPreferencesProxyEntry"
,
&
info
,
0
);
}
return
type
;
}
/**
* gf_preferences_proxy_entry_new:
* @mount_point : The mount point of @engine.
* @engine : The #GfPreferenceEngine.
*
* Creates a #GfPreferencesProxyEntry for @engine.
*
* Return Value: The new #GfPreferencesProxyEntry or NULL.
*/
GfPreferencesProxyEntry
*
gf_preferences_proxy_entry_new
(
const
gchar
*
mount_point
,
GfPreferenceEngine
*
engine
)
{
g_return_val_if_fail
(
mount_point
,
NULL
);
g_return_val_if_fail
(
GF_IS_PREFERENCE_ENGINE
(
engine
),
NULL
);
return
g_object_new
(
GF_TYPE_PREFERENCES_PROXY_ENTRY
,
"mount_point"
,
mount_point
,
"engine"
,
engine
,
NULL
);
}
/**
* gf_preferences_proxy_entry_get_mount_point:
* @entry : The #GfPreferencesProxyEntry instance.
*
* Gets the mount point from @entry.
*
* Return Value: The mount point of @entry or NULL.
*/
const
gchar
*
gf_preferences_proxy_entry_get_mount_point
(
const
GfPreferencesProxyEntry
*
entry
)
{
GfPreferencesProxyEntryClass
*
klass
=
NULL
;
g_return_val_if_fail
(
GF_IS_PREFERENCES_PROXY_ENTRY
(
entry
),
NULL
);
klass
=
GF_PREFERENCES_PROXY_ENTRY_GET_CLASS
(
entry
);
if
(
klass
&&
klass
->
get_mount_point
)
return
klass
->
get_mount_point
(
entry
);
return
NULL
;
}
/**
* gf_preferences_proxy_entry_get_engine
* @entry : The #GfPreferencesProxyEntry instance.
*
* Gets the #GfPreferenceEngine from @entry.
*
* Return Value: The #GfPreferenceEngine from @entry or NULL.
*/
GfPreferenceEngine
*
gf_preferences_proxy_entry_get_engine
(
const
GfPreferencesProxyEntry
*
entry
)
{
GfPreferencesProxyEntryClass
*
klass
=
NULL
;
g_return_val_if_fail
(
GF_IS_PREFERENCES_PROXY_ENTRY
(
entry
),
NULL
);
klass
=
GF_PREFERENCES_PROXY_ENTRY_GET_CLASS
(
entry
);
if
(
klass
&&
klass
->
get_engine
)
return
klass
->
get_engine
(
entry
);
return
NULL
;
}