1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#include "launcher-item.h"
static void foobar_launcher_item_default_init( FoobarLauncherItemInterface* iface );
G_DEFINE_INTERFACE( FoobarLauncherItem, foobar_launcher_item, G_TYPE_OBJECT )
//
// Static initialization for the launcher item interface.
//
void foobar_launcher_item_default_init( FoobarLauncherItemInterface* iface )
{
g_object_interface_install_property( iface, g_param_spec_string(
"title",
"Title",
"The title text displayed in the launcher.",
NULL,
G_PARAM_READABLE ) );
g_object_interface_install_property( iface, g_param_spec_string(
"description",
"Description",
"Text displayed below the title.",
NULL,
G_PARAM_READABLE ) );
g_object_interface_install_property( iface, g_param_spec_object(
"icon",
"Icon",
"Icon to show for the item.",
G_TYPE_ICON,
G_PARAM_READABLE ) );
}
//
// Get the title text displayed in the launcher.
//
gchar const* foobar_launcher_item_get_title( FoobarLauncherItem* self )
{
g_return_val_if_fail( FOOBAR_IS_LAUNCHER_ITEM( self ), NULL );
FoobarLauncherItemInterface* iface = FOOBAR_LAUNCHER_ITEM_GET_IFACE( self );
g_return_val_if_fail( iface->get_title != NULL, NULL );
return iface->get_title( self );
}
//
// Get the text displayed below the title.
//
gchar const* foobar_launcher_item_get_description( FoobarLauncherItem* self )
{
g_return_val_if_fail( FOOBAR_IS_LAUNCHER_ITEM( self ), NULL );
FoobarLauncherItemInterface* iface = FOOBAR_LAUNCHER_ITEM_GET_IFACE( self );
g_return_val_if_fail( iface->get_description != NULL, NULL );
return iface->get_description( self );
}
//
// Get the icon to show for the item.
//
GIcon* foobar_launcher_item_get_icon( FoobarLauncherItem* self )
{
g_return_val_if_fail( FOOBAR_IS_LAUNCHER_ITEM( self ), NULL );
FoobarLauncherItemInterface* iface = FOOBAR_LAUNCHER_ITEM_GET_IFACE( self );
g_return_val_if_fail( iface->get_icon != NULL, NULL );
return iface->get_icon( self );
}
//
// Activate the item, e.g. by launching the application.
//
void foobar_launcher_item_activate( FoobarLauncherItem* self )
{
g_return_if_fail( FOOBAR_IS_LAUNCHER_ITEM( self ) );
FoobarLauncherItemInterface* iface = FOOBAR_LAUNCHER_ITEM_GET_IFACE( self );
if ( iface->activate ) { iface->activate( self ); }
}
|