1 /*
2  * label: An actor representing a label and an icon (both optional)
3  *
4  * Copyright 2012-2020 Stephan Haller <nomad@froevel.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  *
21  *
22  */
23 
24 #ifndef __LIBXFDASHBOARD_LABEL__
25 #define __LIBXFDASHBOARD_LABEL__
26 
27 #if !defined(__LIBXFDASHBOARD_H_INSIDE__) && !defined(LIBXFDASHBOARD_COMPILATION)
28 #error "Only <libxfdashboard/libxfdashboard.h> can be included directly."
29 #endif
30 
31 #include <clutter/clutter.h>
32 
33 #include <libxfdashboard/background.h>
34 #include <libxfdashboard/types.h>
35 
36 G_BEGIN_DECLS
37 
38 /* Public definitions */
39 /**
40  * XfdashboardLabelStyle:
41  * @XFDASHBOARD_LABEL_STYLE_TEXT: The actor will show only text labels.
42  * @XFDASHBOARD_LABEL_STYLE_ICON: The actor will show only icons.
43  * @XFDASHBOARD_LABEL_STYLE_BOTH: The actor will show both, text labels and icons.
44  *
45  * Determines the style of an actor, e.g. text labels and icons at labels.
46  */
47 typedef enum /*< prefix=XFDASHBOARD_LABEL_STYLE >*/
48 {
49 	XFDASHBOARD_LABEL_STYLE_TEXT=0,
50 	XFDASHBOARD_LABEL_STYLE_ICON,
51 	XFDASHBOARD_LABEL_STYLE_BOTH
52 } XfdashboardLabelStyle;
53 
54 
55 /* Object declaration */
56 #define XFDASHBOARD_TYPE_LABEL					(xfdashboard_label_get_type())
57 #define XFDASHBOARD_LABEL(obj)					(G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_LABEL, XfdashboardLabel))
58 #define XFDASHBOARD_IS_LABEL(obj)				(G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_LABEL))
59 #define XFDASHBOARD_LABEL_CLASS(klass)			(G_TYPE_CHECK_CLASS_CAST((klass), XFDASHBOARD_TYPE_LABEL, XfdashboardLabelClass))
60 #define XFDASHBOARD_IS_LABEL_CLASS(klass)		(G_TYPE_CHECK_CLASS_TYPE((klass), XFDASHBOARD_TYPE_LABEL))
61 #define XFDASHBOARD_LABEL_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS((obj), XFDASHBOARD_TYPE_LABEL, XfdashboardLabelClass))
62 
63 typedef struct _XfdashboardLabel				XfdashboardLabel;
64 typedef struct _XfdashboardLabelClass			XfdashboardLabelClass;
65 typedef struct _XfdashboardLabelPrivate			XfdashboardLabelPrivate;
66 
67 struct _XfdashboardLabel
68 {
69 	/*< private >*/
70 	/* Parent instance */
71 	XfdashboardBackground		parent_instance;
72 
73 	/* Private structure */
74 	XfdashboardLabelPrivate	*priv;
75 };
76 
77 struct _XfdashboardLabelClass
78 {
79 	/*< private >*/
80 	/* Parent class */
81 	XfdashboardBackgroundClass	parent_class;
82 
83 	/*< public >*/
84 	/* Virtual functions */
85 	void (*clicked)(XfdashboardLabel *self);
86 };
87 
88 /* Public API */
89 GType xfdashboard_label_get_type(void) G_GNUC_CONST;
90 
91 ClutterActor* xfdashboard_label_new(void);
92 ClutterActor* xfdashboard_label_new_with_text(const gchar *inText);
93 ClutterActor* xfdashboard_label_new_with_icon_name(const gchar *inIconName);
94 ClutterActor* xfdashboard_label_new_with_gicon(GIcon *inIcon);
95 ClutterActor* xfdashboard_label_new_full_with_icon_name(const gchar *inIconName, const gchar *inText);
96 ClutterActor* xfdashboard_label_new_full_with_gicon(GIcon *inIcon, const gchar *inText);
97 
98 /* General functions */
99 gfloat xfdashboard_label_get_padding(XfdashboardLabel *self);
100 void xfdashboard_label_set_padding(XfdashboardLabel *self, const gfloat inPadding);
101 
102 gfloat xfdashboard_label_get_spacing(XfdashboardLabel *self);
103 void xfdashboard_label_set_spacing(XfdashboardLabel *self, const gfloat inSpacing);
104 
105 XfdashboardLabelStyle xfdashboard_label_get_style(XfdashboardLabel *self);
106 void xfdashboard_label_set_style(XfdashboardLabel *self, const XfdashboardLabelStyle inStyle);
107 
108 /* Icon functions */
109 const gchar* xfdashboard_label_get_icon_name(XfdashboardLabel *self);
110 void xfdashboard_label_set_icon_name(XfdashboardLabel *self, const gchar *inIconName);
111 
112 GIcon* xfdashboard_label_get_gicon(XfdashboardLabel *self);
113 void xfdashboard_label_set_gicon(XfdashboardLabel *self, GIcon *inIcon);
114 
115 ClutterImage* xfdashboard_label_get_icon_image(XfdashboardLabel *self);
116 void xfdashboard_label_set_icon_image(XfdashboardLabel *self, ClutterImage *inIconImage);
117 
118 gint xfdashboard_label_get_icon_size(XfdashboardLabel *self);
119 void xfdashboard_label_set_icon_size(XfdashboardLabel *self, gint inSize);
120 
121 gboolean xfdashboard_label_get_sync_icon_size(XfdashboardLabel *self);
122 void xfdashboard_label_set_sync_icon_size(XfdashboardLabel *self, gboolean inSync);
123 
124 XfdashboardOrientation xfdashboard_label_get_icon_orientation(XfdashboardLabel *self);
125 void xfdashboard_label_set_icon_orientation(XfdashboardLabel *self, const XfdashboardOrientation inOrientation);
126 
127 /* Label functions */
128 const gchar* xfdashboard_label_get_text(XfdashboardLabel *self);
129 void xfdashboard_label_set_text(XfdashboardLabel *self, const gchar *inMarkupText);
130 
131 const gchar* xfdashboard_label_get_font(XfdashboardLabel *self);
132 void xfdashboard_label_set_font(XfdashboardLabel *self, const gchar *inFont);
133 
134 const ClutterColor* xfdashboard_label_get_color(XfdashboardLabel *self);
135 void xfdashboard_label_set_color(XfdashboardLabel *self, const ClutterColor *inColor);
136 
137 PangoEllipsizeMode xfdashboard_label_get_ellipsize_mode(XfdashboardLabel *self);
138 void xfdashboard_label_set_ellipsize_mode(XfdashboardLabel *self, const PangoEllipsizeMode inMode);
139 
140 gboolean xfdashboard_label_get_single_line_mode(XfdashboardLabel *self);
141 void xfdashboard_label_set_single_line_mode(XfdashboardLabel *self, const gboolean inSingleLine);
142 
143 PangoAlignment xfdashboard_label_get_text_justification(XfdashboardLabel *self);
144 void xfdashboard_label_set_text_justification(XfdashboardLabel *self, const PangoAlignment inJustification);
145 
146 G_END_DECLS
147 
148 #endif	/* __LIBXFDASHBOARD_LABEL__ */
149