sync with 0.9.10cvs11
[claws.git] / src / gtk / gtkutils.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2004 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 <gtk/gtkitemfactory.h>
36 #include <stdlib.h>
37 #if HAVE_WCHAR_H
38 #  include <wchar.h>
39 #endif
40
41 typedef struct _ComboButton     ComboButton;
42
43 #include "gtkstext.h"
44
45 struct _ComboButton
46 {
47         GtkWidget *arrow;
48         GtkWidget *button;
49         GtkWidget *menu;
50         GtkItemFactory *factory;
51         gpointer data;
52 };
53
54 #define GTK_EVENTS_FLUSH() \
55 { \
56         while (gtk_events_pending()) \
57                 gtk_main_iteration(); \
58 }
59
60 #define PIXMAP_CREATE(widget, pixmap, mask, xpm_d) \
61 { \
62         if (!pixmap) { \
63                 GtkStyle *style = gtk_widget_get_style(widget); \
64                 pixmap = gdk_pixmap_create_from_xpm_d \
65                         (widget->window, &mask, \
66                          &style->bg[GTK_STATE_NORMAL], xpm_d); \
67         } \
68 }
69
70 #define PIXMAP_CREATE_FROM_FILE(widget, pixmap, mask, filename) \
71 { \
72         if (!pixmap) { \
73                 GtkStyle *style = gtk_widget_get_style(widget); \
74                 pixmap = gdk_pixmap_create_from_xpm \
75                         (widget->window, &mask, \
76                          &style->bg[GTK_STATE_NORMAL], filename); \
77         } \
78 }
79
80 #define GTK_WIDGET_PTR(wid)     (*(GtkWidget **)wid)
81
82 #define GTKUT_CTREE_NODE_SET_ROW_DATA(node, d) \
83 { \
84         GTK_CTREE_ROW(node)->row.data = d; \
85 }
86
87 #define GTKUT_CTREE_NODE_GET_ROW_DATA(node) \
88         (GTK_CTREE_ROW(node)->row.data)
89
90 #define GTKUT_CTREE_REFRESH(clist) \
91         GTK_CLIST_CLASS(GTK_OBJECT(clist)->klass)->refresh(clist)
92
93 gint gtkut_get_font_width               (GdkFont        *font);
94 gint gtkut_get_font_height              (GdkFont        *font);
95
96 GdkFont *gtkut_font_load                (const gchar    *fontset_name);
97 GdkFont *gtkut_font_load_from_fontset   (const gchar    *fontset_name);
98
99 void gtkut_convert_int_to_gdk_color     (gint            rgbvalue,
100                                          GdkColor       *color);
101
102 void gtkut_button_set_create            (GtkWidget      **bbox,
103                                          GtkWidget      **button1,
104                                          const gchar     *label1,
105                                          GtkWidget      **button2,
106                                          const gchar     *label2,
107                                          GtkWidget      **button3,
108                                          const gchar     *label3);
109
110 ComboButton *gtkut_combo_button_create  (GtkWidget              *button,
111                                          GtkItemFactoryEntry    *entries,
112                                          gint                    n_entries,
113                                          const gchar            *path,
114                                          gpointer                data);
115
116 void gtkut_ctree_node_move_if_on_the_edge
117                                         (GtkCTree       *ctree,
118                                          GtkCTreeNode   *node);
119 gint gtkut_ctree_get_nth_from_node      (GtkCTree       *ctree,
120                                          GtkCTreeNode   *node);
121 GtkCTreeNode *gtkut_ctree_node_next     (GtkCTree       *ctree,
122                                          GtkCTreeNode   *node);
123 GtkCTreeNode *gtkut_ctree_node_prev     (GtkCTree       *ctree,
124                                          GtkCTreeNode   *node);
125 gboolean gtkut_ctree_node_is_selected   (GtkCTree       *ctree,
126                                          GtkCTreeNode   *node);
127 GtkCTreeNode *gtkut_ctree_find_collapsed_parent
128                                         (GtkCTree       *ctree,
129                                          GtkCTreeNode   *node);
130 void gtkut_ctree_expand_parent_all      (GtkCTree       *ctree,
131                                          GtkCTreeNode   *node);
132 gboolean gtkut_ctree_node_is_parent     (GtkCTreeNode   *parent, 
133                                          GtkCTreeNode   *node);
134 void gtkut_ctree_set_focus_row          (GtkCTree       *ctree,
135                                          GtkCTreeNode   *node);
136
137 void gtkut_clist_set_focus_row          (GtkCList       *clist,
138                                          gint            row);
139
140 void gtkut_combo_set_items              (GtkCombo       *combo,
141                                          const gchar    *str1, ...);
142
143 gchar *gtkut_editable_get_selection     (GtkEditable    *editable);
144 void gtkut_editable_disable_im          (GtkEditable    *editable);
145
146 void gtkut_container_remove             (GtkContainer   *container,
147                                          GtkWidget      *widget);
148
149
150 void gtkut_window_popup                 (GtkWidget      *window);
151
152 void gtkut_widget_get_uposition         (GtkWidget      *widget,
153                                          gint           *px,
154                                          gint           *py);
155 void gtkut_widget_disable_theme_engine  (GtkWidget      *widget);
156 void gtkut_widget_wait_for_draw         (GtkWidget      *widget);
157 void gtkut_widget_init                  (void);
158
159 void gtkut_widget_set_app_icon          (GtkWidget      *widget);
160 void gtkut_widget_set_composer_icon     (GtkWidget      *widget);
161
162 GtkWidget *gtkut_account_menu_new       (GList                  *ac_list,
163                                          GtkSignalFunc           callback,
164                                          gpointer                data);
165
166 void gtkut_set_widget_bgcolor_rgb       (GtkWidget      *widget,
167                                          guint           rgbvalue);
168 #endif /* __GTKUTILS_H__ */