2006-08-30 Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
[hildon] / hildon-widgets / hildon-app.h
1 /*
2  * This file is part of hildon-libs
3  *
4  * Copyright (C) 2005, 2006 Nokia Corporation.
5  *
6  * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; version 2.1 of
11  * the License.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 #ifndef __HILDON_APP_H__
26 #define __HILDON_APP_H__
27
28 #include <gtk/gtkwindow.h>
29 #include <gtk/gtkuimanager.h>
30 #include "hildon-appview.h"
31
32 G_BEGIN_DECLS
33 /**
34  * HildonApp:
35  *
36  * Contains only private data not to be touched by outsiders. 
37  */
38 typedef struct _HildonApp HildonApp;
39 typedef struct _HildonAppClass HildonAppClass;
40
41 #define HILDON_TYPE_APP ( hildon_app_get_type() )
42
43 #define HILDON_APP(obj) (GTK_CHECK_CAST (obj, HILDON_TYPE_APP, \
44             HildonApp))
45
46 #define HILDON_APP_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), \
47             HILDON_TYPE_APP, HildonAppClass))
48
49 #define HILDON_IS_APP(obj) (GTK_CHECK_TYPE (obj, HILDON_TYPE_APP))
50
51 #define HILDON_IS_APP_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), \
52             HILDON_TYPE_APP))
53
54
55 struct _HildonApp {
56     GtkWindow parent;
57 };
58
59 struct _HildonAppClass {
60     GtkWindowClass parent_class;
61     void (*topmost_status_acquire) (HildonApp *self);
62     void (*topmost_status_lose) (HildonApp *self);
63     void (*switch_to) (HildonApp *self); /* FIXME: Possible browser hack?? */
64     void (*im_close) (HildonApp *self);
65     void (*clipboard_copy) (HildonApp *self, GtkWidget *widget);
66     void (*clipboard_cut) (HildonApp *self, GtkWidget *widget);
67     void (*clipboard_paste) (HildonApp *self, GtkWidget *widget);
68 };
69
70 #ifndef HILDON_DISABLE_DEPRECATED
71 /* Make these values >0 so that we can detect when someone sets SMALL-1
72  * zoom level (enum seems to be unsigned int)
73  */
74
75 /**
76  * HildonZoomLevel:
77  * @HILDON_ZOOM_SMALL: Smallest font.
78  * @HILDON_ZOOM_MEDIUM: Middle size font.
79  * @HILDON_ZOOM_LARGE: Largest font.
80  *
81  * The Hildon zoom levels. Small meaning small font. Large meaning
82  * large font. These font are specified in the gtkrc files.
83  * This enum is deprecated and should not be used. It's just
84  * lecagy stuff from ancient specs.
85  */
86 typedef enum /*< skip >*/
87 {
88     HILDON_ZOOM_SMALL = 1,
89     HILDON_ZOOM_MEDIUM = 2,
90     HILDON_ZOOM_LARGE = 3
91 } HildonZoomLevel;
92
93 #define HILDON_TYPE_ZOOM_LEVEL (hildon_zoom_level_get_type ())
94
95 GType hildon_zoom_level_get_type (void);
96 #endif /* deprecated */
97
98
99 /* You should use the correct ones from hildon-defines.h 
100  *
101  * FIXME: These should be removed when API changes are allowed, 
102  * they are not used in hildon code anymore (but might be in external). 
103  */ 
104 #define HILDON_MENU_KEY         GDK_F4
105 #define HILDON_HOME_KEY         GDK_F5
106 #define HILDON_TOOLBAR_KEY      GDK_T
107 #define HILDON_FULLSCREEN_KEY   GDK_F6
108 #define HILDON_INCREASE_KEY     GDK_F7
109 #define HILDON_DECREASE_KEY     GDK_F8
110 #define HILDON_TOOLBAR_MODIFIERS (GDK_SHIFT_MASK | GDK_CONTROL_MASK)
111
112 #define HILDON_KEYEVENT_IS_MENU_KEY(keyevent) (keyevent->keyval == HILDON_MENU_KEY)
113 #define HILDON_KEYEVENT_IS_HOME_KEY(keyevent) (keyevent->keyval == HILDON_HOME_KEY)
114 #define HILDON_KEYEVENT_IS_TOOLBAR_KEY(keyevent) ((keyevent->keyval == HILDON_TOOLBAR_KEY) && \
115                                                    (keyevent->state == HILDON_TOOLBAR_MODIFIERS))
116 #define HILDON_KEYEVENT_IS_FULLSCREEN_KEY(keyevent) (keyevent->keyval == HILDON_FULLSCREEN_KEY)
117 #define HILDON_KEYEVENT_IS_INCREASE_KEY(keyevent) (keyevent->keyval == HILDON_INCREASE_KEY)
118 #define HILDON_KEYEVENT_IS_DECREASE_KEY(keyevent) (keyevent->keyval == HILDON_DECREASE_KEY)
119
120 #define TRANSIENCY_MAXITER 50
121
122 GType hildon_app_get_type(void) G_GNUC_CONST;
123 GtkWidget *hildon_app_new(void);
124 GtkWidget *hildon_app_new_with_appview(HildonAppView * appview);
125 void hildon_app_set_appview(HildonApp * self, HildonAppView * appview);
126 HildonAppView *hildon_app_get_appview(HildonApp * self);
127 void hildon_app_set_title(HildonApp * self, const gchar * newtitle);
128 const gchar *hildon_app_get_title(HildonApp * self);
129
130 #ifndef HILDON_DISABLE_DEPRECATED
131 void hildon_app_set_zoom(HildonApp * self, HildonZoomLevel newzoom);
132 HildonZoomLevel hildon_app_get_zoom(HildonApp * self);
133 PangoFontDescription *hildon_app_get_default_font(HildonApp * self);
134 PangoFontDescription *hildon_app_get_zoom_font(HildonApp * self);
135 #endif
136
137 void hildon_app_set_two_part_title(HildonApp * self,
138                                    gboolean istwoparttitle);
139 gboolean hildon_app_get_two_part_title(HildonApp * self);
140
141 void hildon_app_set_autoregistration(HildonApp *self, gboolean auto_reg);
142 void hildon_app_register_view(HildonApp *self, gpointer view_ptr);
143 gboolean hildon_app_register_view_with_id(HildonApp *self,
144                                           gpointer view_ptr,
145                                           unsigned long view_id);
146 void hildon_app_unregister_view(HildonApp *self, gpointer view_ptr);
147 void hildon_app_unregister_view_with_id(HildonApp *self,
148                                         unsigned long view_id);
149 unsigned long hildon_app_find_view_id(HildonApp *self, gpointer view_ptr);
150 void hildon_app_notify_view_changed(HildonApp *self, gpointer view_ptr);
151
152 void hildon_app_set_killable(HildonApp *self, gboolean killability);
153
154 void hildon_app_set_ui_manager(HildonApp *self, GtkUIManager *uim);
155 GtkUIManager *hildon_app_get_ui_manager(HildonApp *self);
156
157 G_END_DECLS
158 #endif /* __HILDON_APP_H__ */