2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef __GTKUTILS_H__
20 #define __GTKUTILS_H__
23 #include "claws-features.h"
34 #include "gtkcmctree.h"
36 #define GTK_EVENTS_FLUSH() \
38 while (gtk_events_pending()) \
39 gtk_main_iteration(); \
42 #define GTK_WIDGET_PTR(wid) (*(GtkWidget **)wid)
44 #define GTKUT_CTREE_NODE_SET_ROW_DATA(node, d) \
46 GTK_CMCTREE_ROW(node)->row.data = d; \
49 #define GTKUT_CTREE_NODE_GET_ROW_DATA(node) \
50 (GTK_CMCTREE_ROW(node)->row.data)
52 #define GTKUT_CTREE_REFRESH(clist) \
53 GTK_CMCLIST_GET_CLASS(clist)->refresh(clist)
55 #define GTKUT_COLOR_BUTTON() \
56 gtk_button_new_with_label("\x20\xE2\x80\x83\x20")
58 gboolean gtkut_get_font_size (GtkWidget *widget,
62 void gtkut_convert_int_to_gdk_color (gint rgbvalue,
64 gint gtkut_convert_gdk_color_to_int (GdkColor *color);
66 void gtkut_stock_button_add_help(GtkWidget *bbox, GtkWidget **help_btn);
68 void gtkut_stock_button_set_create_with_help(GtkWidget **bbox,
69 GtkWidget **help_button,
70 GtkWidget **button1, const gchar *label1,
71 GtkWidget **button2, const gchar *label2,
72 GtkWidget **button3, const gchar *label3);
74 void gtkut_stock_button_set_create (GtkWidget **bbox,
82 void gtkut_stock_with_text_button_set_create(GtkWidget **bbox,
83 GtkWidget **button1, const gchar *label1, const gchar *text1,
84 GtkWidget **button2, const gchar *label2, const gchar *text2,
85 GtkWidget **button3, const gchar *label3, const gchar *text3);
87 void gtkut_ctree_node_move_if_on_the_edge
91 gint gtkut_ctree_get_nth_from_node (GtkCMCTree *ctree,
92 GtkCMCTreeNode *node);
93 GtkCMCTreeNode *gtkut_ctree_node_next (GtkCMCTree *ctree,
94 GtkCMCTreeNode *node);
95 GtkCMCTreeNode *gtkut_ctree_node_prev (GtkCMCTree *ctree,
96 GtkCMCTreeNode *node);
97 gboolean gtkut_ctree_node_is_selected (GtkCMCTree *ctree,
98 GtkCMCTreeNode *node);
99 GtkCMCTreeNode *gtkut_ctree_find_collapsed_parent
101 GtkCMCTreeNode *node);
102 void gtkut_ctree_expand_parent_all (GtkCMCTree *ctree,
103 GtkCMCTreeNode *node);
104 gboolean gtkut_ctree_node_is_parent (GtkCMCTreeNode *parent,
105 GtkCMCTreeNode *node);
106 void gtkut_ctree_set_focus_row (GtkCMCTree *ctree,
107 GtkCMCTreeNode *node);
109 void gtkut_clist_set_focus_row (GtkCMCList *clist,
112 void gtkut_container_remove (GtkContainer *container,
115 gchar *gtkut_text_view_get_selection (GtkTextView *textview);
116 void gtkut_text_view_set_position (GtkTextView *text, gint pos);
117 gboolean gtkut_text_view_search_string (GtkTextView *text, const gchar *str,
119 gboolean gtkut_text_view_search_string_backward (GtkTextView *text, const gchar *str,
122 GtkWidget *label_window_create(const gchar *str);
123 void label_window_destroy(GtkWidget *widget);
125 void gtkut_window_popup (GtkWidget *window);
126 GtkWidget *gtkut_window_new (GtkWindowType type,
130 void gtkut_widget_get_uposition (GtkWidget *widget,
133 void gtkut_widget_draw_now (GtkWidget *widget);
134 void gtkut_widget_init (void);
136 void gtkut_widget_set_app_icon (GtkWidget *widget);
137 void gtkut_widget_set_composer_icon (GtkWidget *widget);
139 GtkWidget *gtkut_account_menu_new (GList *ac_list,
143 void gtkut_set_widget_bgcolor_rgb (GtkWidget *widget,
146 void gtkut_widget_set_small_font_size(GtkWidget *widget);
147 GtkWidget *gtkut_get_focused_child (GtkContainer *parent);
149 GtkWidget *gtkut_get_browse_file_btn(const gchar *label);
150 GtkWidget *gtkut_get_browse_directory_btn(const gchar *label);
151 GtkWidget *gtkut_get_replace_btn(const gchar *label);
152 GtkWidget *gtkut_get_options_frame(GtkWidget *box, GtkWidget **frame, const gchar *frame_label);
154 GtkWidget *xface_get_from_header(const gchar *o_xface);
156 gboolean get_tag_range(GtkTextIter *iter,
158 GtkTextIter *start_iter,
159 GtkTextIter *end_iter);
161 GtkWidget *face_get_from_header(const gchar *o_face);
162 GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *label);
164 GtkWidget *gtkut_sc_combobox_create(GtkWidget *eventbox, gboolean focus_on_click);
165 void gtkutils_scroll_one_line (GtkWidget *widget,
168 gboolean gtkutils_scroll_page (GtkWidget *widget,
172 gboolean gtkut_tree_model_text_iter_prev(GtkTreeModel *model,
175 gboolean gtkut_tree_model_get_iter_last(GtkTreeModel *model,
178 gint gtkut_list_view_get_selected_row(GtkWidget *list_view);
179 gboolean gtkut_list_view_select_row(GtkWidget *list, gint row);
181 GtkUIManager *gtkut_create_ui_manager(void);
182 GtkUIManager *gtkut_ui_manager(void);
184 GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *pixbuf, gboolean inline_img,
185 gboolean fit_img_height,
186 int box_width, int box_height);
188 GtkWidget *gtkut_time_select_combo_new();
189 void gtkut_time_select_select_by_time(GtkComboBox *combo, int hour, int minute);
190 gboolean gtkut_time_select_get_time(GtkComboBox *combo, int *hour, int *minute);
192 void gtk_calendar_select_today(GtkCalendar *calendar);
194 typedef void (*ClawsIOFunc)(gpointer data, gint source, GIOCondition condition);
196 claws_input_add (gint source,
197 GIOCondition condition,
198 ClawsIOFunc function,
202 #define CLAWS_SET_TIP(widget,tip) { \
203 if (widget != NULL) { \
205 gtk_widget_set_tooltip_text(GTK_WIDGET(widget), tip); \
207 gtk_widget_set_has_tooltip(GTK_WIDGET(widget), FALSE); \
211 #if defined USE_GNUTLS
212 typedef struct _AutoConfigureData {
213 const gchar *ssl_service;
214 const gchar *tls_service;
218 GtkEntry *hostname_entry;
219 GtkToggleButton *set_port;
222 gint default_ssl_port;
223 GtkToggleButton *tls_checkbtn;
224 GtkToggleButton *ssl_checkbtn;
225 GtkToggleButton *auth_checkbtn;
227 GtkLabel *info_label;
228 GtkButton *configure_button;
229 GtkButton *cancel_button;
230 GCancellable *cancel;
231 GMainLoop *main_loop;
234 void auto_configure_service(AutoConfigureData *data);
235 gboolean auto_configure_service_sync(const gchar *service, const gchar *domain, gchar **srvhost, guint16 *srvport);
238 /* Returns pointer stored in selected row of a tree view's model
239 * in a given column. The column has to be of type G_TYPE_POINTER
240 * or G_TYPE_STRING (in this case, the returned value has to be
241 * freed by the caller.
242 * _model, _selection and _iter parameters are optional, and if
243 * not NULL, they will be set to point to corresponding GtkTreeModel,
244 * GtkTreeSelection, and GtkTreeIter of the selected row. */
245 gpointer gtkut_tree_view_get_selected_pointer(GtkTreeView *view,
246 gint column, GtkTreeModel **_model, GtkTreeSelection **_selection,
249 #if GTK_CHECK_VERSION (3, 2, 0)
250 #define GTK_TYPE_VBOX GTK_TYPE_BOX
251 #define GtkVBox GtkBox
252 #define GtkVBoxClass GtkBoxClass
253 #define gtk_vbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
254 "homogeneous", hmg, "spacing", spc, \
255 "orientation", GTK_ORIENTATION_VERTICAL, NULL)
256 #define GTK_TYPE_HBOX GTK_TYPE_BOX
257 #define GtkHBox GtkBox
258 #define GtkHBoxClass GtkBoxClass
259 #define gtk_hbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
260 "homogeneous", hmg, "spacing", spc, \
261 "orientation", GTK_ORIENTATION_HORIZONTAL, NULL)
262 #define gtk_hseparator_new() g_object_new (GTK_TYPE_SEPARATOR, NULL)
263 #define gtk_hpaned_new() g_object_new (GTK_TYPE_PANED, NULL)
264 #define gtk_vpaned_new() g_object_new (GTK_TYPE_PANED, \
265 "orientation", GTK_ORIENTATION_VERTICAL, NULL)
268 #endif /* __GTKUTILS_H__ */