1 /*
2  * @file liferea_shell.h  UI layout handling
3  *
4  * Copyright (C) 2004-2005 Nathan J. Conrad <t98502@users.sourceforge.net>
5  * Copyright (C) 2007-2018 Lars Windolf <lars.windolf@gmx.de>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
23 #ifndef _LIFEREA_SHELL_H
24 #define _LIFEREA_SHELL_H
25 
26 #include <glib-object.h>
27 #include <glib.h>
28 #include <gtk/gtk.h>
29 
30 #include "node.h"
31 
32 /* possible main window states */
33 enum mainwindowState {
34 	MAINWINDOW_SHOWN,	/*<< main window is visible */
35 	MAINWINDOW_MAXIMIZED,	/*<< main window is visible and maximized */
36 	MAINWINDOW_ICONIFIED,	/*<< main window is iconified */
37 	MAINWINDOW_HIDDEN	/*<< main window is not visible at all */
38 };
39 
40 G_BEGIN_DECLS
41 
42 #define LIFEREA_SHELL_TYPE		(liferea_shell_get_type ())
43 #define LIFEREA_SHELL(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), LIFEREA_SHELL_TYPE, LifereaShell))
44 #define LIFEREA_SHELL_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), LIFEREA_SHELL_TYPE, LifereaShellClass))
45 #define IS_LIFEREA_SHELL(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LIFEREA_SHELL_TYPE))
46 #define IS_LIFEREA_SHELL_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), LIFEREA_SHELL_TYPE))
47 
48 typedef struct LifereaShell		LifereaShell;
49 typedef struct LifereaShellClass	LifereaShellClass;
50 typedef struct LifereaShellPrivate	LifereaShellPrivate;
51 
52 extern LifereaShell *liferea_shell;
53 
54 struct LifereaShell
55 {
56 	GObject		parent;
57 
58 	/*< private >*/
59 	LifereaShellPrivate	*priv;
60 };
61 
62 struct LifereaShellClass
63 {
64 	GObjectClass parent_class;
65 };
66 
67 GType liferea_shell_get_type	(void);
68 
69 /**
70  * liferea_shell_lookup:
71  * @name: the widget name
72  *
73  * Searches the glade XML UI tree for the given widget
74  * name and returns the found widget.
75  *
76  * Returns: (transfer none) (nullable): the widget found or NULL
77  */
78 GtkWidget * liferea_shell_lookup (const gchar *name);
79 
80 /**
81  * liferea_shell_create: (skip)
82  * @app:	                the GtkApplication to attach the main window to
83  * @overrideWindowState:	optional parameter for window state (or NULL)
84  * @pluginsDisabled		1 if plugins are not to be loaded
85  *
86  * Set up the Liferea main window.
87  */
88 void liferea_shell_create (GtkApplication *app, const gchar *overrideWindowState, gint pluginsDisabled);
89 
90 /**
91  * liferea_shell_destroy: (skip)
92  *
93  * Destroys the global liferea_shell object.
94  */
95 void liferea_shell_destroy (void);
96 
97 /**
98  * liferea_shell_present:
99  *
100  * Presents the main window if it is hidden.
101  */
102 void liferea_shell_present (void);
103 
104 /**
105  * liferea_shell_toggle_visibility:
106  *
107  * Toggles main window visibility.
108  */
109 void liferea_shell_toggle_visibility (void);
110 
111 /**
112  * liferea_shell_set_toolbar_style:
113  * @toolbar_style: text string containing the type of style to use
114  *
115  * Sets the toolbar to a particular style
116  */
117 void liferea_shell_set_toolbar_style (const gchar *toolbar_style);
118 
119 /**
120  * liferea_shell_update_toolbar: (skip)
121  *
122  * According to the preferences this function enables/disables the toolbar.
123  *
124  * TODO: use signal instead
125  */
126 void liferea_shell_update_toolbar (void);
127 
128 /**
129  * liferea_shell_update_history_actions: (skip)
130  *
131  * Update item history menu actions and toolbar buttons.
132  *
133  * TODO: use signal instead
134  */
135 void liferea_shell_update_history_actions (void);
136 
137 /**
138  * liferea_shell_update_feed_menu: (skip)
139  * @add:                TRUE if subscribing is to be enabled
140  * @enabled:    	TRUE if feed actions are to be enabled
141  * @readWrite:  	TRUE if feed list modifying actions are enabled
142  *
143  * Update the sensitivity of options affecting single feeds.
144  *
145  * TODO: use signal instead
146  */
147 void liferea_shell_update_feed_menu (gboolean add, gboolean enabled, gboolean readWrite);
148 
149 /**
150  * liferea_shell_update_item_menu: (skip)
151  * @enabled:	TRUE if item actions are to be enabled
152  *
153  * Update the sensitivity of options affecting single items.
154  *
155  * TODO: use signal instead
156  */
157 void liferea_shell_update_item_menu (gboolean enabled);
158 
159 /**
160  * liferea_shell_update_allitems_actions: (skip)
161  * @isNotEmpty: 	TRUE if there is a non-empty item set active
162  * @isRead:     	TRUE if there are no unread items in the item set
163  *
164  * Update the sensitivity of options affecting item sets.
165  *
166  * TODO: use signal instead
167  */
168 void liferea_shell_update_allitems_actions (gboolean isNotEmpty, gboolean isRead);
169 
170 /**
171  * liferea_shell_update_update_menu: (skip)
172  * @enabled:	TRUE if menu options are to be enabled
173  *
174  * Set the sensitivity of items in the update menu.
175  *
176  * TODO: use signal instead
177  */
178 void liferea_shell_update_update_menu (gboolean enabled);
179 
180 /**
181  * liferea_shell_set_status_bar:
182  *
183  * Sets the status bar text. Takes printf() like parameters.
184  */
185 void liferea_shell_set_status_bar (const char *format, ...);
186 
187 /**
188  * liferea_shell_set_important_status_bar:
189  *
190  * Similar to liferea_shell_set_status_message(), but ensures
191  * that messages stay visible and avoids that those messages
192  * are overwritten by unimportant ones.
193  */
194 void liferea_shell_set_important_status_bar (const char *format, ...);
195 
196 /**
197  * liferea_shell_get_window:
198  *
199  * Returns the Liferea main window.
200  *
201  * Returns: (transfer none): the main window widget found or NULL
202  */
203 GtkWidget * liferea_shell_get_window (void);
204 
205 void liferea_shutdown (void);
206 
207 G_END_DECLS
208 
209 #endif
210