1 /*
2  * view: Abstract class for views, optional with scrollbars
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_VIEW__
25 #define __LIBXFDASHBOARD_VIEW__
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/actor.h>
34 #include <libxfdashboard/types.h>
35 #include <libxfdashboard/focusable.h>
36 
37 G_BEGIN_DECLS
38 
39 /* Public definitions */
40 /**
41  * XfdashboardViewFitMode:
42  * @XFDASHBOARD_VIEW_FIT_MODE_NONE: Do not try to fit view into viewpad.
43  * @XFDASHBOARD_VIEW_FIT_MODE_HORIZONTAL: Try to fit view into viewpad horizontally.
44  * @XFDASHBOARD_VIEW_FIT_MODE_VERTICAL: Try to fit view into viewpad vertically.
45  * @XFDASHBOARD_VIEW_FIT_MODE_BOTH: Try to fit view into viewpad horizontally and vertically.
46  *
47  * Determines how a view should fit into a viewpad.
48  */
49 typedef enum /*< prefix=XFDASHBOARD_VIEW_FIT_MODE >*/
50 {
51 	XFDASHBOARD_VIEW_FIT_MODE_NONE=0,
52 	XFDASHBOARD_VIEW_FIT_MODE_HORIZONTAL,
53 	XFDASHBOARD_VIEW_FIT_MODE_VERTICAL,
54 	XFDASHBOARD_VIEW_FIT_MODE_BOTH
55 } XfdashboardViewFitMode;
56 
57 
58 /* Object declaration */
59 #define XFDASHBOARD_TYPE_VIEW				(xfdashboard_view_get_type())
60 #define XFDASHBOARD_VIEW(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_VIEW, XfdashboardView))
61 #define XFDASHBOARD_IS_VIEW(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_VIEW))
62 #define XFDASHBOARD_VIEW_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST((klass), XFDASHBOARD_TYPE_VIEW, XfdashboardViewClass))
63 #define XFDASHBOARD_IS_VIEW_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), XFDASHBOARD_TYPE_VIEW))
64 #define XFDASHBOARD_VIEW_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS((obj), XFDASHBOARD_TYPE_VIEW, XfdashboardViewClass))
65 
66 typedef struct _XfdashboardView				XfdashboardView;
67 typedef struct _XfdashboardViewPrivate		XfdashboardViewPrivate;
68 typedef struct _XfdashboardViewClass		XfdashboardViewClass;
69 
70 struct _XfdashboardView
71 {
72 	/*< private >*/
73 	/* Parent instance */
74 	XfdashboardActor			parent_instance;
75 
76 	/* Private structure */
77 	XfdashboardViewPrivate		*priv;
78 };
79 
80 struct _XfdashboardViewClass
81 {
82 	/*< private >*/
83 	/* Parent class */
84 	XfdashboardActorClass		parent_class;
85 
86 	/*< public >*/
87 	/* Virtual functions */
88 	void (*set_view_fit_mode)(XfdashboardView *self, XfdashboardViewFitMode inFitMode);
89 
90 	void (*activating)(XfdashboardView *self);
91 	void (*activated)(XfdashboardView *self);
92 	void (*deactivating)(XfdashboardView *self);
93 	void (*deactivated)(XfdashboardView *self);
94 
95 	void (*enabling)(XfdashboardView *self);
96 	void (*enabled)(XfdashboardView *self);
97 	void (*disabling)(XfdashboardView *self);
98 	void (*disabled)(XfdashboardView *self);
99 
100 	void (*name_changed)(XfdashboardView *self, gchar *inName);
101 	void (*icon_changed)(XfdashboardView *self, ClutterImage *inIcon);
102 
103 	void (*scroll_to)(XfdashboardView *self, gfloat inX, gfloat inY);
104 	gboolean (*child_needs_scroll)(XfdashboardView *self, ClutterActor *inActor);
105 	void (*child_ensure_visible)(XfdashboardView *self, ClutterActor *inActor);
106 
107 	/* Binding actions */
108 	gboolean (*view_activate)(XfdashboardView *self,
109 								XfdashboardFocusable *inSource,
110 								const gchar *inAction,
111 								ClutterEvent *inEvent);
112 };
113 
114 
115 /* Public API */
116 GType xfdashboard_view_get_type(void) G_GNUC_CONST;
117 
118 const gchar* xfdashboard_view_get_id(XfdashboardView *self);
119 gboolean xfdashboard_view_has_id(XfdashboardView *self, const gchar *inID);
120 
121 const gchar* xfdashboard_view_get_name(XfdashboardView *self);
122 void xfdashboard_view_set_name(XfdashboardView *self, const gchar *inName);
123 
124 const gchar* xfdashboard_view_get_icon(XfdashboardView *self);
125 void xfdashboard_view_set_icon(XfdashboardView *self, const gchar *inIcon);
126 
127 XfdashboardViewFitMode xfdashboard_view_get_view_fit_mode(XfdashboardView *self);
128 void xfdashboard_view_set_view_fit_mode(XfdashboardView *self, XfdashboardViewFitMode inFitMode);
129 
130 gboolean xfdashboard_view_get_enabled(XfdashboardView *self);
131 void xfdashboard_view_set_enabled(XfdashboardView *self, gboolean inIsEnabled);
132 
133 void xfdashboard_view_scroll_to(XfdashboardView *self, gfloat inX, gfloat inY);
134 gboolean xfdashboard_view_child_needs_scroll(XfdashboardView *self, ClutterActor *inActor);
135 void xfdashboard_view_child_ensure_visible(XfdashboardView *self, ClutterActor *inActor);
136 
137 gboolean xfdashboard_view_has_focus(XfdashboardView *self);
138 
139 G_END_DECLS
140 
141 #endif	/* __LIBXFDASHBOARD_VIEW__ */
142