enable storing of GnuPG passphrase
[claws.git] / src / gtkutils.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2002 Hiroyuki Yamamoto
4  *
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 2 of the License, or
8  * (at your option) any later version.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GTKUTILS_H__
21 #define __GTKUTILS_H__
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #endif
26
27 #include <glib.h>
28 #include <gdk/gdk.h>
29 #include <gtk/gtkmain.h>
30 #include <gtk/gtkwidget.h>
31 #include <gtk/gtkcontainer.h>
32 #include <gtk/gtkeditable.h>
33 #include <gtk/gtkctree.h>
34 #include <gtk/gtkcombo.h>
35 #include "gtkstext.h"
36 #include <stdlib.h>
37 #if HAVE_WCHAR_H
38 #  include <wchar.h>
39 #endif
40
41 #define GTK_EVENTS_FLUSH() \
42 { \
43         while (gtk_events_pending()) \
44                 gtk_main_iteration(); \
45 }
46
47 #define PIXMAP_CREATE(widget, pixmap, mask, xpm_d) \
48 { \
49         if (!pixmap) { \
50                 GtkStyle *style = gtk_widget_get_style(widget); \
51                 pixmap = gdk_pixmap_create_from_xpm_d \
52                         (widget->window, &mask, \
53                          &style->bg[GTK_STATE_NORMAL], xpm_d); \
54         } \
55 }
56
57 #define PIXMAP_CREATE_FROM_FILE(widget, pixmap, mask, filename) \
58 { \
59         if (!pixmap) { \
60                 GtkStyle *style = gtk_widget_get_style(widget); \
61                 pixmap = gdk_pixmap_create_from_xpm \
62                         (widget->window, &mask, \
63                          &style->bg[GTK_STATE_NORMAL], filename); \
64         } \
65 }
66
67 #define GTK_WIDGET_PTR(wid)     (*(GtkWidget **)wid)
68
69 #define GTKUT_CTREE_NODE_SET_ROW_DATA(node, d) \
70 { \
71         GTK_CTREE_ROW(node)->row.data = d; \
72 }
73
74 #define GTKUT_CTREE_NODE_GET_ROW_DATA(node) \
75         (GTK_CTREE_ROW(node)->row.data)
76
77 #define GTKUT_CTREE_REFRESH(clist) \
78         GTK_CLIST_CLASS(GTK_OBJECT(clist)->klass)->refresh(clist)
79
80 gint gtkut_get_font_width               (GdkFont        *font);
81 gint gtkut_get_font_height              (GdkFont        *font);
82
83 void gtkut_convert_int_to_gdk_color     (gint            rgbvalue,
84                                          GdkColor       *color);
85
86 void gtkut_button_set_create            (GtkWidget      **bbox,
87                                          GtkWidget      **button1,
88                                          const gchar     *label1,
89                                          GtkWidget      **button2,
90                                          const gchar     *label2,
91                                          GtkWidget      **button3,
92                                          const gchar     *label3);
93
94 void gtkut_ctree_node_move_if_on_the_edge
95                                         (GtkCTree       *ctree,
96                                          GtkCTreeNode   *node);
97 gint gtkut_ctree_get_nth_from_node      (GtkCTree       *ctree,
98                                          GtkCTreeNode   *node);
99 GtkCTreeNode *gtkut_ctree_node_next     (GtkCTree       *ctree,
100                                          GtkCTreeNode   *node);
101 GtkCTreeNode *gtkut_ctree_find_collapsed_parent
102                                         (GtkCTree       *ctree,
103                                          GtkCTreeNode   *node);
104 void gtkut_ctree_expand_parent_all      (GtkCTree       *ctree,
105                                          GtkCTreeNode   *node);
106 void gtkut_ctree_set_focus_row          (GtkCTree       *ctree,
107                                          GtkCTreeNode   *node);
108
109 void gtkut_clist_set_focus_row          (GtkCList       *clist,
110                                          gint            row);
111
112 void gtkut_combo_set_items              (GtkCombo       *combo,
113                                          const gchar    *str1, ...);
114
115 gchar *gtkut_editable_get_selection     (GtkEditable    *editable);
116
117 void gtkut_container_remove             (GtkContainer   *container,
118                                          GtkWidget      *widget);
119
120 gboolean gtkut_stext_match_string       (GtkSText       *text,
121                                          gint            pos,
122                                          wchar_t        *wcs,
123                                          gint            len,
124                                          gboolean        case_sens);
125 guint gtkut_stext_str_compare_n         (GtkSText       *text,
126                                          guint           pos1,
127                                          guint           pos2,
128                                          guint           len,
129                                          guint           text_len);
130 guint gtkut_stext_str_compare           (GtkSText       *text,
131                                          guint           start_pos,
132                                          guint           text_len,
133                                          const gchar    *str);
134 gboolean gtkut_stext_is_uri_string      (GtkSText       *text,
135                                          guint           start_pos,
136                                          guint           text_len);
137 void gtk_stext_clear                    (GtkSText       *text);
138
139 void gtkut_widget_disable_theme_engine  (GtkWidget      *widget);
140 void gtkut_widget_wait_for_draw         (GtkWidget      *widget);
141 void gtkut_widget_get_uposition         (GtkWidget      *widget,
142                                          gint           *px,
143                                          gint           *py);
144 void gtkut_widget_init                  (void);
145
146 void gtkut_widget_set_app_icon          (GtkWidget      *widget);
147 void gtkut_widget_set_composer_icon     (GtkWidget      *widget);
148 #endif /* __GTKUTILS_H__ */