about.c: cosmetix
[k8lowj.git] / src / util-gtk.h
blob7cf0dab50fbd0fd147e7b0d952ea16258aa7cc4b
1 /* logjam - a GTK client for LiveJournal.
2 * Copyright (C) 2005 Evan Martin <evan@livejournal.com>
4 * vim: tabstop=4 shiftwidth=4 noexpandtab :
5 */
7 #ifndef __logjam_util_gtk_h__
8 #define __logjam_util_gtk_h__
10 #include "gtk-all.h"
12 #include "conf.h" /* for the "geometry" struct */
14 #define STACK(type, var) type actual_##var = {0}, *var = &actual_##var
15 #define UNREF_AND_NULL(x) if (x) { g_object_unref(G_OBJECT(x)); x = NULL; }
17 typedef enum {
18 JAM_MSG_INFO,
19 JAM_MSG_WARNING,
20 JAM_MSG_ERROR
21 } MessageType;
23 gchar* gettext_translate_func(const gchar *path, gpointer data);
25 GtkWidget* jam_table_new(int rows, int cols);
26 GtkWidget* jam_table_label(GtkTable *table, int row, const char *text);
27 void jam_table_content(GtkTable *table, int row, GtkWidget *content);
28 void jam_table_label_content(GtkTable *table, int row, const char *text, GtkWidget *content);
29 void jam_table_label_content_mne(GtkTable *table, int row, const char *text, GtkWidget *content, GtkWidget *mne);
30 void jam_table_fillrow(GtkTable *table, int row, GtkWidget *content);
31 void jam_spin_button_set(GtkSpinButton *w, gboolean numeric, gdouble range_low, gdouble range_high, gdouble increment_single, gdouble increment_page, gint digits);
33 /* if width or height <= 0, then we make up a reasonable size. */
34 void jam_win_set_size(GtkWindow *win, int width, int height);
36 GtkWidget* jam_dialog_set_contents(GtkDialog *dlg, GtkWidget *contents);
38 GtkWidget* jam_dialog_buttonbox_new(void);
39 void jam_dialog_buttonbox_add(GtkWidget *box, GtkWidget *button);
40 GtkWidget* jam_dialog_buttonbox_button_with_label(GtkWidget *box, const char *label);
41 GtkWidget* jam_dialog_buttonbox_button_from_stock(GtkWidget *box, const char *id);
42 void jam_dialog_set_contents_buttonbox(GtkWidget *dlg, GtkWidget *contents, GtkWidget *buttonbox);
44 int jam_confirm(GtkWindow *parent, const char *title, const char *msg);
45 void jam_message(GtkWindow *parent, MessageType type, gboolean forgettable, const char *title, const char *message, ...);
46 void jam_messagebox(GtkWindow *parent, const char *title, const char *message);
47 void jam_warning(GtkWindow *parent, const char *msg, ...);
50 gdk_color_parse() does exactly this:
51 void hex_to_gdkcolor(const char *buf, GdkColor *c);
53 void gdkcolor_to_hex(GdkColor *color, char* buf);
55 /* wrap this widget in a scrollarea */
56 GtkWidget* scroll_wrap(GtkWidget *w);
58 /* tie a geometry struct to a window */
59 void geometry_tie(GtkWidget *win, GeometryType g);
60 void geometry_tie_full(GeometryType g, GtkWindow *win, GtkPaned *paned);
62 gint text_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data);
64 void jam_widget_set_visible(GtkWidget *w, gboolean visible);
65 void jam_widget_set_font(GtkWidget *w, const gchar *font_name);
67 /* produces an hbox that has a label and a widget, with optional
68 * sizegroup, expansion setting, and mnemonic widget. */
69 GtkWidget* labelled_box_new_all(const char *caption, GtkWidget *w,
70 gboolean expand, GtkSizeGroup *sg,
71 GtkWidget *mne);
72 #define labelled_box_new_sg(c, w, sg) labelled_box_new_all(c, w, TRUE, sg, NULL)
73 #define labelled_box_new_expand(c, w, e) labelled_box_new_all(c, w, e, NULL, NULL)
74 #define labelled_box_new(c, w) labelled_box_new_all(c, w, TRUE, NULL, NULL)
76 /* like gtk_label_new, but appropriate for a form. */
77 GtkWidget* jam_form_label_new(const char *text);
79 typedef struct {
80 GtkWidget *box;
81 GtkWidget *view;
82 GtkListStore *store;
83 GtkWidget *add, *edit, *remove;
84 } JamReorderable;
85 void jam_reorderable_make(JamReorderable* jr);
87 gchar * jam_clipboard_wait_for_text_timeout (GtkClipboard *clipboard, gint timeout);
89 #endif /* __logjam_util_gtk_h__ */