sync with sylpheed 0.4.99cvs1
[claws.git] / src / gtkutils.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999,2000 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 #include <glib.h>
24 #include <gdk/gdk.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtkctree.h>
28 #include <gtk/gtkcombo.h>
29
30 #define GTK_EVENTS_FLUSH() \
31 { \
32         while (gtk_events_pending()) \
33                 gtk_main_iteration(); \
34 }
35
36 #define PIXMAP_CREATE(widget, pixmap, mask, xpm_d) \
37 { \
38         if (!pixmap) { \
39                 GtkStyle *style = gtk_widget_get_style(widget); \
40                 pixmap = gdk_pixmap_create_from_xpm_d \
41                         (widget->window, &mask, \
42                          &style->bg[GTK_STATE_NORMAL], xpm_d); \
43         } \
44 }
45
46 #define GTK_WIDGET_PTR(wid)     (*(GtkWidget **)wid)
47
48 #define GTKUT_CTREE_NODE_SET_ROW_DATA(node, d) \
49 { \
50         GTK_CTREE_ROW(node)->row.data = d; \
51 }
52
53 #define GTKUT_CTREE_NODE_GET_ROW_DATA(node) \
54         (GTK_CTREE_ROW(node)->row.data)
55
56 #define GTKUT_CTREE_REFRESH(clist) \
57         GTK_CLIST_CLASS(GTK_OBJECT(clist)->klass)->refresh(clist)
58
59 gint gtkut_get_font_width               (GdkFont        *font);
60 gint gtkut_get_font_height              (GdkFont        *font);
61
62 void gtkut_convert_int_to_gdk_color     (gint            rgbvalue,
63                                          GdkColor       *color);
64
65 void gtkut_button_set_create            (GtkWidget      **bbox,
66                                          GtkWidget      **button1,
67                                          const gchar     *label1,
68                                          GtkWidget      **button2,
69                                          const gchar     *label2,
70                                          GtkWidget      **button3,
71                                          const gchar     *label3);
72
73 void gtkut_ctree_node_move_if_on_the_edge
74                                         (GtkCTree       *ctree,
75                                          GtkCTreeNode   *node);
76 gint gtkut_ctree_get_nth_from_node      (GtkCTree       *ctree,
77                                          GtkCTreeNode   *node);
78 GtkCTreeNode *gtkut_ctree_node_next     (GtkCTree       *ctree,
79                                          GtkCTreeNode   *node);
80 GtkCTreeNode *gtkut_ctree_find_collapsed_parent
81                                         (GtkCTree       *ctree,
82                                          GtkCTreeNode   *node);
83 void gtkut_ctree_set_focus_row          (GtkCTree       *ctree,
84                                          GtkCTreeNode   *node);
85 void gtkut_clist_set_focus_row          (GtkCList       *clist,
86                                          gint            row);
87 void gtkut_combo_set_items              (GtkCombo       *combo,
88                                          const gchar    *str1, ...);
89 void gtkut_widget_disable_theme_engine  (GtkWidget      *widget);
90
91 void gtkut_widget_wait_for_draw         (GtkWidget      *widget);
92
93 void gtkut_widget_get_uposition         (GtkWidget      *widget,
94                                          gint           *px,
95                                          gint           *py);
96
97 void gtkut_widget_init                  (void);
98
99 #endif /* __GTKUTILS_H__ */