Statistics
| Revision:

root / src / gtkutils.h @ 2815

History | View | Annotate | Download (6.3 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 1974 hiro
 * Copyright (C) 1999-2008 Hiroyuki Yamamoto
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
#ifndef __GTKUTILS_H__
21 1 hiro
#define __GTKUTILS_H__
22 1 hiro
23 1 hiro
#ifdef HAVE_CONFIG_H
24 1 hiro
#  include "config.h"
25 1 hiro
#endif
26 1 hiro
27 1 hiro
#include <glib.h>
28 1 hiro
#include <gdk/gdk.h>
29 1 hiro
#include <gtk/gtkmain.h>
30 1 hiro
#include <gtk/gtkwidget.h>
31 1 hiro
#include <gtk/gtkcontainer.h>
32 1 hiro
#include <gtk/gtkeditable.h>
33 1 hiro
#include <gtk/gtkctree.h>
34 202 hiro
#include <gtk/gtktreemodel.h>
35 1089 hiro
#include <gtk/gtktreestore.h>
36 202 hiro
#include <gtk/gtktreeview.h>
37 1 hiro
#include <gtk/gtkcombo.h>
38 198 hiro
#include <gtk/gtkscrolledwindow.h>
39 1 hiro
#include <gtk/gtktextview.h>
40 1 hiro
#include <gtk/gtkitemfactory.h>
41 1977 hiro
#include <gtk/gtkentry.h>
42 237 hiro
#include <gtk/gtkstock.h>
43 237 hiro
44 1 hiro
#include <stdlib.h>
45 1 hiro
46 1 hiro
typedef struct _ComboButton        ComboButton;
47 1 hiro
48 1 hiro
struct _ComboButton
49 1 hiro
{
50 1 hiro
        GtkWidget *arrow;
51 1 hiro
        GtkWidget *button;
52 1 hiro
        GtkWidget *menu;
53 1 hiro
        GtkItemFactory *factory;
54 1 hiro
        gpointer data;
55 1 hiro
};
56 1 hiro
57 1 hiro
#define GTK_EVENTS_FLUSH() \
58 1 hiro
{ \
59 1 hiro
        while (gtk_events_pending()) \
60 1 hiro
                gtk_main_iteration(); \
61 1 hiro
}
62 1 hiro
63 1 hiro
#define PIXMAP_CREATE(widget, pixmap, mask, xpm_d) \
64 1 hiro
{ \
65 1 hiro
        if (!pixmap) { \
66 1 hiro
                GtkStyle *style = gtk_widget_get_style(widget); \
67 1 hiro
                pixmap = gdk_pixmap_create_from_xpm_d \
68 1 hiro
                        (widget->window, &mask, \
69 1 hiro
                         &style->bg[GTK_STATE_NORMAL], xpm_d); \
70 1 hiro
        } \
71 1 hiro
}
72 1 hiro
73 1 hiro
#define GTK_WIDGET_PTR(wid)        (*(GtkWidget **)wid)
74 1 hiro
75 1 hiro
#define GTKUT_CTREE_NODE_SET_ROW_DATA(node, d) \
76 1 hiro
{ \
77 1 hiro
        GTK_CTREE_ROW(node)->row.data = d; \
78 1 hiro
}
79 1 hiro
80 1 hiro
#define GTKUT_CTREE_NODE_GET_ROW_DATA(node) \
81 1 hiro
        (GTK_CTREE_ROW(node)->row.data)
82 1 hiro
83 1 hiro
#define GTKUT_CTREE_REFRESH(clist) \
84 1 hiro
        GTK_CLIST_GET_CLASS(clist)->refresh(clist)
85 1 hiro
86 1514 hiro
gboolean gtkut_get_str_size                (GtkWidget        *widget,
87 1514 hiro
                                         const gchar        *str,
88 1514 hiro
                                         gint                *width,
89 1514 hiro
                                         gint                *height);
90 1 hiro
gboolean gtkut_get_font_size                (GtkWidget        *widget,
91 1 hiro
                                         gint                *width,
92 1 hiro
                                         gint                *height);
93 39 hiro
PangoFontDescription *gtkut_get_default_font_desc
94 39 hiro
                                        (void);
95 89 hiro
void gtkut_widget_set_small_font_size        (GtkWidget        *widget);
96 1 hiro
97 1637 hiro
gboolean gtkut_font_can_load                (const gchar        *str);
98 1637 hiro
99 1 hiro
void gtkut_convert_int_to_gdk_color        (gint                 rgbvalue,
100 1 hiro
                                         GdkColor        *color);
101 1 hiro
102 405 hiro
void gtkut_stock_button_set_set_reverse        (gboolean         reverse);
103 30 hiro
void gtkut_stock_button_set_create        (GtkWidget        **bbox,
104 30 hiro
                                         GtkWidget        **button1,
105 30 hiro
                                         const gchar         *label1,
106 30 hiro
                                         GtkWidget        **button2,
107 30 hiro
                                         const gchar         *label2,
108 30 hiro
                                         GtkWidget        **button3,
109 30 hiro
                                         const gchar         *label3);
110 30 hiro
111 405 hiro
void gtkut_box_set_reverse_order        (GtkBox                *box,
112 405 hiro
                                         gboolean         reverse);
113 405 hiro
114 1 hiro
ComboButton *gtkut_combo_button_create        (GtkWidget                *button,
115 1 hiro
                                         GtkItemFactoryEntry        *entries,
116 1 hiro
                                         gint                         n_entries,
117 1 hiro
                                         const gchar                *path,
118 1 hiro
                                         gpointer                 data);
119 1 hiro
120 207 hiro
/* CTree functions */
121 207 hiro
122 1 hiro
gint gtkut_ctree_get_nth_from_node        (GtkCTree        *ctree,
123 1 hiro
                                         GtkCTreeNode        *node);
124 1 hiro
void gtkut_ctree_set_focus_row                (GtkCTree        *ctree,
125 1 hiro
                                         GtkCTreeNode        *node);
126 1 hiro
void gtkut_clist_set_focus_row                (GtkCList        *clist,
127 1 hiro
                                         gint                 row);
128 1577 hiro
void gtkut_clist_set_redraw                (GtkCList        *clist);
129 1 hiro
130 207 hiro
/* TreeView functions */
131 207 hiro
132 202 hiro
gboolean gtkut_tree_model_next                (GtkTreeModel        *model,
133 202 hiro
                                         GtkTreeIter        *iter);
134 237 hiro
gboolean gtkut_tree_model_prev                (GtkTreeModel        *model,
135 237 hiro
                                         GtkTreeIter        *iter);
136 237 hiro
137 237 hiro
gboolean gtkut_tree_model_get_iter_last        (GtkTreeModel        *model,
138 237 hiro
                                         GtkTreeIter        *iter);
139 237 hiro
140 202 hiro
gboolean gtkut_tree_model_find_by_column_data
141 202 hiro
                                        (GtkTreeModel        *model,
142 202 hiro
                                         GtkTreeIter        *iter,
143 202 hiro
                                         GtkTreeIter        *start,
144 202 hiro
                                         gint                 col,
145 202 hiro
                                         gpointer         data);
146 202 hiro
147 935 hiro
void gtkut_tree_model_foreach                (GtkTreeModel                *model,
148 935 hiro
                                         GtkTreeIter                *start,
149 935 hiro
                                         GtkTreeModelForeachFunc func,
150 935 hiro
                                         gpointer                 user_data);
151 935 hiro
152 237 hiro
gboolean gtkut_tree_row_reference_get_iter
153 237 hiro
                                        (GtkTreeModel                *model,
154 237 hiro
                                         GtkTreeRowReference        *ref,
155 237 hiro
                                         GtkTreeIter                *iter);
156 212 hiro
gboolean gtkut_tree_row_reference_equal        (GtkTreeRowReference        *ref1,
157 212 hiro
                                         GtkTreeRowReference        *ref2);
158 212 hiro
159 239 hiro
void gtkut_tree_sortable_unset_sort_column_id
160 239 hiro
                                        (GtkTreeSortable        *sortable);
161 239 hiro
162 202 hiro
gboolean gtkut_tree_view_find_collapsed_parent
163 202 hiro
                                        (GtkTreeView        *treeview,
164 202 hiro
                                         GtkTreeIter        *parent,
165 202 hiro
                                         GtkTreeIter        *iter);
166 237 hiro
void gtkut_tree_view_expand_parent_all        (GtkTreeView        *treeview,
167 237 hiro
                                         GtkTreeIter        *iter);
168 202 hiro
169 207 hiro
void gtkut_tree_view_vertical_autoscroll(GtkTreeView        *treeview);
170 207 hiro
171 322 hiro
void gtkut_tree_view_scroll_to_cell        (GtkTreeView        *treeview,
172 600 hiro
                                         GtkTreePath        *path,
173 600 hiro
                                         gboolean         align_center);
174 322 hiro
175 1089 hiro
void gtkut_tree_view_fast_clear                (GtkTreeView        *treeview,
176 1089 hiro
                                         GtkTreeStore        *store);
177 1089 hiro
178 1 hiro
void gtkut_combo_set_items                (GtkCombo        *combo,
179 1 hiro
                                         const gchar        *str1, ...);
180 1 hiro
181 1 hiro
gchar *gtkut_editable_get_selection        (GtkEditable        *editable);
182 1 hiro
void gtkut_editable_disable_im                (GtkEditable        *editable);
183 1 hiro
184 1974 hiro
void gtkut_entry_strip_text                (GtkEntry        *entry);
185 1974 hiro
186 1 hiro
void gtkut_container_remove                (GtkContainer        *container,
187 1 hiro
                                         GtkWidget        *widget);
188 1 hiro
189 198 hiro
void gtkut_scrolled_window_reset_position
190 198 hiro
                                        (GtkScrolledWindow        *window);
191 198 hiro
192 207 hiro
/* TextView functions */
193 207 hiro
194 123 hiro
gboolean gtkut_text_buffer_match_string        (GtkTextBuffer                *buffer,
195 123 hiro
                                         const GtkTextIter        *iter,
196 123 hiro
                                         gunichar                *wcs,
197 123 hiro
                                         gint                         len,
198 123 hiro
                                         gboolean                 case_sens);
199 123 hiro
gboolean gtkut_text_buffer_find                (GtkTextBuffer                *buffer,
200 123 hiro
                                         const GtkTextIter        *iter,
201 123 hiro
                                         const gchar                *str,
202 123 hiro
                                         gboolean                 case_sens,
203 123 hiro
                                         GtkTextIter                *match_pos);
204 123 hiro
gboolean gtkut_text_buffer_find_backward(GtkTextBuffer                *buffer,
205 123 hiro
                                         const GtkTextIter        *iter,
206 123 hiro
                                         const gchar                *str,
207 123 hiro
                                         gboolean                 case_sens,
208 123 hiro
                                         GtkTextIter                *match_pos);
209 1 hiro
210 153 hiro
void gtkut_text_buffer_insert_with_tag_by_name
211 153 hiro
                                        (GtkTextBuffer                *buffer,
212 153 hiro
                                         GtkTextIter                *iter,
213 153 hiro
                                         const gchar                *text,
214 153 hiro
                                         gint                         len,
215 153 hiro
                                         const gchar                *tag);
216 153 hiro
217 1 hiro
gchar *gtkut_text_view_get_selection        (GtkTextView        *textview);
218 1 hiro
219 1 hiro
void gtkut_window_popup                        (GtkWidget        *window);
220 962 hiro
gboolean gtkut_window_modal_exist        (void);
221 1 hiro
222 2615 hiro
void gtkut_window_move                        (GtkWindow        *window,
223 2615 hiro
                                         gint                 x,
224 2615 hiro
                                         gint                 y);
225 2615 hiro
226 1 hiro
void gtkut_widget_get_uposition                (GtkWidget        *widget,
227 1 hiro
                                         gint                *px,
228 1 hiro
                                         gint                *py);
229 227 hiro
void gtkut_widget_draw_now                (GtkWidget        *widget);
230 1 hiro
void gtkut_widget_init                        (void);
231 1 hiro
232 552 hiro
void gtkut_events_flush                        (void);
233 552 hiro
234 1 hiro
#endif /* __GTKUTILS_H__ */