4f6f1b6caae00ccc1547af4c75ed74a697b52de8
[claws.git] / src / gtkutils.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2001 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/gtkctree.h>
32 #include <gtk/gtkcombo.h>
33 #include <gtk/gtktext.h>
34 #include <stdlib.h>
35 #if HAVE_WCHAR_H
36 #  include <wchar.h>
37 #endif
38
39 #define GTK_EVENTS_FLUSH() \
40 { \
41         while (gtk_events_pending()) \
42                 gtk_main_iteration(); \
43 }
44
45 #define PIXMAP_CREATE(widget, pixmap, mask, xpm_d) \
46 { \
47         if (!pixmap) { \
48                 GtkStyle *style = gtk_widget_get_style(widget); \
49                 pixmap = gdk_pixmap_create_from_xpm_d \
50                         (widget->window, &mask, \
51                          &style->bg[GTK_STATE_NORMAL], xpm_d); \
52         } \
53 }
54
55 #define GTK_WIDGET_PTR(wid)     (*(GtkWidget **)wid)
56
57 #define GTKUT_CTREE_NODE_SET_ROW_DATA(node, d) \
58 { \
59         GTK_CTREE_ROW(node)->row.data = d; \
60 }
61
62 #define GTKUT_CTREE_NODE_GET_ROW_DATA(node) \
63         (GTK_CTREE_ROW(node)->row.data)
64
65 #define GTKUT_CTREE_REFRESH(clist) \
66         GTK_CLIST_CLASS(GTK_OBJECT(clist)->klass)->refresh(clist)
67
68 gint gtkut_get_font_width               (GdkFont        *font);
69 gint gtkut_get_font_height              (GdkFont        *font);
70
71 void gtkut_convert_int_to_gdk_color     (gint            rgbvalue,
72                                          GdkColor       *color);
73
74 void gtkut_button_set_create            (GtkWidget      **bbox,
75                                          GtkWidget      **button1,
76                                          const gchar     *label1,
77                                          GtkWidget      **button2,
78                                          const gchar     *label2,
79                                          GtkWidget      **button3,
80                                          const gchar     *label3);
81
82 void gtkut_ctree_node_move_if_on_the_edge
83                                         (GtkCTree       *ctree,
84                                          GtkCTreeNode   *node);
85 gint gtkut_ctree_get_nth_from_node      (GtkCTree       *ctree,
86                                          GtkCTreeNode   *node);
87 GtkCTreeNode *gtkut_ctree_node_next     (GtkCTree       *ctree,
88                                          GtkCTreeNode   *node);
89 GtkCTreeNode *gtkut_ctree_find_collapsed_parent
90                                         (GtkCTree       *ctree,
91                                          GtkCTreeNode   *node);
92 void gtkut_ctree_expand_parent_all      (GtkCTree       *ctree,
93                                          GtkCTreeNode   *node);
94 void gtkut_ctree_set_focus_row          (GtkCTree       *ctree,
95                                          GtkCTreeNode   *node);
96
97 void gtkut_clist_set_focus_row          (GtkCList       *clist,
98                                          gint            row);
99
100 void gtkut_combo_set_items              (GtkCombo       *combo,
101                                          const gchar    *str1, ...);
102
103 gboolean gtkut_text_match_string        (GtkText        *text,
104                                          gint            pos,
105                                          wchar_t        *wcs,
106                                          gint            len,
107                                          gboolean        case_sens);
108 guint gtkut_text_str_compare_n          (GtkText        *text,
109                                          guint           pos1,
110                                          guint           pos2,
111                                          guint           len,
112                                          guint           text_len);
113 guint gtkut_text_str_compare            (GtkText        *text,
114                                          guint           start_pos,
115                                          guint           text_len,
116                                          const gchar    *str);
117 gboolean gtkut_text_is_uri_string       (GtkText        *text,
118                                          guint           start_pos,
119                                          guint           text_len);
120
121 void gtkut_widget_disable_theme_engine  (GtkWidget      *widget);
122 void gtkut_widget_wait_for_draw         (GtkWidget      *widget);
123 void gtkut_widget_get_uposition         (GtkWidget      *widget,
124                                          gint           *px,
125                                          gint           *py);
126 void gtkut_widget_init                  (void);
127
128 void gtkut_widget_set_app_icon          (GtkWidget      *widget);
129 void gtkut_widget_set_composer_icon     (GtkWidget      *widget);
130
131 #endif /* __GTKUTILS_H__ */