1 #ifndef __GLADE_UTILS_H__
2 #define __GLADE_UTILS_H__
3 
4 #include <glib.h>
5 #include "glade-project.h"
6 
7 G_BEGIN_DECLS
8 
9 #define GLADE_DEVHELP_ICON_NAME           "devhelp"
10 #define GLADE_DEVHELP_FALLBACK_ICON_FILE  "devhelp.png"
11 
12 typedef enum _GladeUtilFileDialogType
13 {
14   GLADE_FILE_DIALOG_ACTION_OPEN,
15   GLADE_FILE_DIALOG_ACTION_SAVE
16 } GladeUtilFileDialogType;
17 
18 typedef enum
19 {
20   GLADE_UI_INFO,
21   GLADE_UI_WARN,
22   GLADE_UI_ERROR,
23   GLADE_UI_ARE_YOU_SURE,
24   GLADE_UI_YES_OR_NO
25 } GladeUIMessageType;
26 
27 /* UI interaction */
28 gboolean          glade_util_ui_message           (GtkWidget *parent,
29 						   GladeUIMessageType type,
30 						   GtkWidget *widget,
31 						   const gchar *format,
32                                                    ...) G_GNUC_PRINTF (4, 5);
33 
34 void		  glade_util_flash_message	(GtkWidget *statusbar,
35 						 guint context_id,
36 						 gchar *format,
37                                                  ...) G_GNUC_PRINTF (3, 4);
38 gboolean          glade_util_url_show              (const gchar *url);
39 GtkWidget        *glade_util_file_dialog_new (const gchar *title,
40 					      GladeProject *project,
41 					      GtkWindow *parent,
42 					      GladeUtilFileDialogType action);
43 
44 /* Strings */
45 gint              glade_util_compare_stock_labels (gconstpointer a, gconstpointer b);
46 void              glade_util_replace (gchar *str, gchar a, gchar b);
47 gchar            *glade_util_read_prop_name (const gchar *str);
48 gchar            *glade_util_duplicate_underscores (const gchar *name);
49 
50 
51 
52 
53 /* GModule stuff */
54 GType	          glade_util_get_type_from_name (const gchar *name, gboolean have_func);
55 GParamSpec       *glade_utils_get_pspec_from_funcname (const gchar *funcname);
56 GModule          *glade_util_load_library          (const gchar  *library_name);
57 
58 
59 /* String/Value utilities */
60 gint              glade_utils_enum_value_from_string  (GType enum_type, const gchar *strval);
61 gchar            *glade_utils_enum_string_from_value  (GType enum_type, gint value);
62 gint              glade_utils_flags_value_from_string (GType enum_type, const gchar *strval);
63 gchar            *glade_utils_flags_string_from_value (GType enum_type, gint value);
64 gchar            *glade_utils_flags_string_from_value_displayable (GType flags_type, gint value);
65 gchar            *glade_utils_enum_string_from_value_displayable (GType flags_type, gint value);
66 GValue           *glade_utils_value_from_string   (GType               type,
67 						   const gchar        *string,
68 						   GladeProject       *project);
69 gchar            *glade_utils_string_from_value   (const GValue       *value);
70 gboolean          glade_utils_boolean_from_string (const gchar *string,
71 						   gboolean *value);
72 
73 /* Devhelp */
74 gboolean          glade_util_have_devhelp          (void);
75 GtkWidget        *glade_util_get_devhelp_icon      (GtkIconSize size);
76 void              glade_util_search_devhelp        (const gchar *book,
77 						    const gchar *page,
78 						    const gchar *search);
79 
80 /* Files/Filenames*/
81 gchar            *glade_utils_replace_home_dir_with_tilde (const gchar *path);
82 gchar            *glade_util_canonical_path        (const gchar  *path);
83 time_t            glade_util_get_file_mtime        (const gchar *filename, GError **error);
84 gboolean          glade_util_file_is_writeable     (const gchar *path);
85 gchar            *glade_util_filename_to_icon_name (const gchar *value);
86 gchar            *glade_util_icon_name_to_filename (const gchar *value);
87 
88 /* Cairo utilities */
89 void              glade_utils_cairo_draw_line (cairo_t  *cr,
90 					       GdkColor *color,
91 					       gint      x1,
92 					       gint      y1,
93 					       gint      x2,
94 					       gint      y2);
95 
96 
97 void              glade_utils_cairo_draw_rectangle (cairo_t *cr,
98 						    GdkColor *color,
99 						    gboolean filled,
100 						    gint x,
101 						    gint y,
102 						    gint width,
103 						    gint height);
104 
105 /* Lists */
106 GList            *glade_util_purify_list           (GList        *list);
107 GList            *glade_util_added_in_list         (GList        *old_list,
108 						    GList        *new_list);
109 GList            *glade_util_removed_from_list     (GList        *old_list,
110 						    GList        *new_list);
111 
112 /* Other utilities */
113 GtkListStore     *glade_utils_liststore_from_enum_type  (GType enum_type, gboolean include_empty);
114 gint              glade_utils_hijack_key_press (GtkWindow          *win,
115 						GdkEventKey        *event,
116 						gpointer            user_data);
117 gboolean          glade_util_check_and_warn_scrollable (GladeWidget        *parent,
118 							GladeWidgetAdaptor *child_adaptor,
119 							GtkWidget          *parent_widget);
120 GList            *glade_util_container_get_all_children (GtkContainer *container);
121 gint              glade_util_count_placeholders    (GladeWidget *parent);
122 GtkTreeIter      *glade_util_find_iter_by_widget   (GtkTreeModel *model,
123 						    GladeWidget  *findme,
124 						    gint          column);
125 GtkWidget        *glade_util_get_placeholder_from_pointer (GtkContainer *container);
126 gboolean          glade_util_object_is_loading     (GObject *object);
127 
128 GdkPixbuf        *glade_utils_pointer_mode_render_icon (GladePointerMode mode, GtkIconSize size);
129 
130 void              glade_utils_get_pointer (GtkWidget *widget,
131 					   GdkWindow *window,
132 					   GdkDevice *device,
133 					   gint      *x,
134 					   gint      *y);
135 
136 
137 void glade_util_remove_scroll_events (GtkWidget *widget);
138 
139 G_END_DECLS
140 
141 #endif /* __GLADE_UTILS_H__ */
142