Add gtkut_tree_view_get_selected_pointer() helper function.
[claws.git] / src / gtk / gtkutils.h
index 90fb375c5d2437b869a76dbe515db535348a1dd8..eaf0fb02848e7d7a19fb49ca6eb29c1800c393c3 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2017 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 #ifndef __GTKUTILS_H__
 #define __GTKUTILS_H__
 
 #ifdef HAVE_CONFIG_H
-#  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include <glib.h>
 #  include <wchar.h>
 #endif
 
-#ifdef MAEMO
-#ifdef CHINOOK
-#include <hildon/hildon-program.h>
-#else
-#include <hildon-widgets/hildon-program.h>
-#include <hildon-widgets/hildon-window.h>
-#endif
-#include "main.h"
-#include <gtk/gtkmain.h>
-#endif
-
 #include "gtkcmctree.h"
 
+#ifndef GDK_KEY_Escape
+#include "gdkkeysyms-new.h"
+#endif
+
 #define GTK_EVENTS_FLUSH() \
 { \
        while (gtk_events_pending()) \
                gtk_main_iteration(); \
 }
 
-#define PIXMAP_CREATE(widget, pixmap, mask, xpm_d) \
-{ \
-       if (!pixmap) { \
-               GtkStyle *style = gtk_widget_get_style(widget); \
-               pixmap = gdk_pixmap_create_from_xpm_d \
-                       (widget->window, &mask, \
-                        &style->bg[GTK_STATE_NORMAL], xpm_d); \
-       } \
-}
-
-#define PIXMAP_CREATE_FROM_FILE(widget, pixmap, mask, filename) \
-{ \
-       if (!pixmap) { \
-               GtkStyle *style = gtk_widget_get_style(widget); \
-               pixmap = gdk_pixmap_create_from_xpm \
-                       (widget->window, &mask, \
-                        &style->bg[GTK_STATE_NORMAL], filename); \
-       } \
-}
-
 #define GTK_WIDGET_PTR(wid)    (*(GtkWidget **)wid)
 
 #define GTKUT_CTREE_NODE_SET_ROW_DATA(node, d) \
@@ -84,6 +56,9 @@
 #define GTKUT_CTREE_REFRESH(clist) \
        GTK_CMCLIST_GET_CLASS(clist)->refresh(clist)
 
+#define GTKUT_COLOR_BUTTON() \
+       gtk_button_new_with_label("\x20\xE2\x80\x83\x20")
+
 gboolean gtkut_get_font_size           (GtkWidget      *widget,
                                         gint           *width,
                                         gint           *height);
@@ -180,8 +155,7 @@ GtkWidget *gtkut_get_browse_directory_btn(const gchar *label);
 GtkWidget *gtkut_get_replace_btn(const gchar *label);
 GtkWidget *gtkut_get_options_frame(GtkWidget *box, GtkWidget **frame, const gchar *frame_label);
 #if HAVE_LIBCOMPFACE
-GtkWidget *xface_get_from_header(const gchar *o_xface, GdkColor *background,
-                                GdkWindow *window);
+GtkWidget *xface_get_from_header(const gchar *o_xface);
 #endif
 gboolean get_tag_range(GtkTextIter *iter,
                                       GtkTextTag *tag,
@@ -211,30 +185,75 @@ gboolean gtkut_list_view_select_row(GtkWidget *list, gint row);
 GtkUIManager *gtkut_create_ui_manager(void);
 GtkUIManager *gtkut_ui_manager(void);
 
-#ifdef G_OS_UNIX
+GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *pixbuf, int box_width,
+                                    int box_height);
+
+typedef void (*ClawsIOFunc)(gpointer data, gint source, GIOCondition condition);
 gint
 claws_input_add    (gint             source,
-                   GdkInputCondition condition,
-                   GdkInputFunction  function,
-                   gpointer          data);
-#endif
-#if GTK_CHECK_VERSION(2,12,0)
-#define CLAWS_TIP_DECL() {}
-#define CLAWS_SET_TIP(widget,tip) {                                    \
-       if (tip != NULL)                                                \
-               gtk_widget_set_tooltip_text(GTK_WIDGET(widget), tip);   \
-       else                                                            \
-               gtk_widget_set_has_tooltip(GTK_WIDGET(widget), FALSE);  \
+                   GIOCondition      condition,
+                   ClawsIOFunc       function,
+                   gpointer          data,
+                   gboolean          is_sock);
+
+#define CLAWS_SET_TIP(widget,tip) {                                            \
+       if (widget != NULL) {                                                   \
+               if (tip != NULL)                                                \
+                       gtk_widget_set_tooltip_text(GTK_WIDGET(widget), tip);   \
+               else                                                            \
+                       gtk_widget_set_has_tooltip(GTK_WIDGET(widget), FALSE);  \
+       }                                                                       \
 }
 
-#else
-#define CLAWS_TIP_DECL() \
-       GtkTooltips *tips = gtk_tooltips_new();
-
-#define CLAWS_SET_TIP(widget,tip) {                            \
-       gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), widget,        \
-                           tip, NULL);                         \
-}
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+typedef struct _AutoConfigureData {
+       const gchar *ssl_service;
+       const gchar *tls_service;
+       gchar *address;
+       gint resolver_error;
+
+       GtkEntry *hostname_entry;
+       GtkToggleButton *set_port;
+       GtkSpinButton *port;
+       gint default_port;
+       gint default_ssl_port;
+       GtkToggleButton *tls_checkbtn;
+       GtkToggleButton *ssl_checkbtn;
+       GtkToggleButton *auth_checkbtn;
+       GtkEntry *uid_entry;
+       GtkLabel *info_label;
+       GtkButton *configure_button;
+       GtkButton *cancel_button;
+       GCancellable *cancel;
+       GMainLoop *main_loop;
+} AutoConfigureData;
+
+void auto_configure_service(AutoConfigureData *data);
+gboolean auto_configure_service_sync(const gchar *service, const gchar *domain, gchar **srvhost, guint16 *srvport);
+#endif
 
+/* Returns pointer stored in selected row of a tree view's model
+ * in a given column. The column has to be of type G_TYPE_POINTER. */
+gpointer gtkut_tree_view_get_selected_pointer(GtkTreeView *view,
+               gint column);
+
+#if GTK_CHECK_VERSION (3, 2, 0)
+#define GTK_TYPE_VBOX GTK_TYPE_BOX
+#define GtkVBox GtkBox
+#define GtkVBoxClass GtkBoxClass
+#define gtk_vbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
+    "homogeneous", hmg, "spacing", spc, \
+    "orientation", GTK_ORIENTATION_VERTICAL, NULL)
+#define GTK_TYPE_HBOX GTK_TYPE_BOX
+#define GtkHBox GtkBox
+#define GtkHBoxClass GtkBoxClass
+#define gtk_hbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
+    "homogeneous", hmg, "spacing", spc, \
+    "orientation", GTK_ORIENTATION_HORIZONTAL, NULL)
+#define gtk_hseparator_new() g_object_new (GTK_TYPE_SEPARATOR, NULL)
+#define gtk_hpaned_new() g_object_new (GTK_TYPE_PANED, NULL)
+#define gtk_vpaned_new() g_object_new (GTK_TYPE_PANED, \
+    "orientation", GTK_ORIENTATION_VERTICAL, NULL)
 #endif
+
 #endif /* __GTKUTILS_H__ */