Do a basic check for widget validity in CLAWS_SET_TIP().
[claws.git] / src / gtk / gtkutils.h
index 68f6de23ccba8204e681a097ae08a6c83e2f0e5d..568e334da038f5fbe7b9433a41004b6d94739527 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2013 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
@@ -21,7 +21,7 @@
 #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"
-#endif
-
-#if !GTK_CHECK_VERSION(3, 0, 0)
 #include "gtkcmctree.h"
-#endif
 
 #ifndef GDK_KEY_Escape
 #include "gdkkeysyms-new.h"
@@ -98,7 +86,6 @@ void gtkut_stock_with_text_button_set_create(GtkWidget **bbox,
                                   GtkWidget **button2, const gchar *label2, const gchar *text2,
                                   GtkWidget **button3, const gchar *label3, const gchar *text3);
 
-#if !GTK_CHECK_VERSION(3, 0, 0)
 void gtkut_ctree_node_move_if_on_the_edge
                                        (GtkCMCTree     *ctree,
                                         GtkCMCTreeNode *node,
@@ -120,7 +107,6 @@ gboolean gtkut_ctree_node_is_parent (GtkCMCTreeNode         *parent,
                                         GtkCMCTreeNode         *node);
 void gtkut_ctree_set_focus_row         (GtkCMCTree     *ctree,
                                         GtkCMCTreeNode *node);
-#endif
 
 void gtkut_clist_set_focus_row         (GtkCMCList     *clist,
                                         gint            row);
@@ -175,8 +161,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,
@@ -217,13 +202,61 @@ claws_input_add    (gint        source,
                    gpointer          data,
                    gboolean          is_sock);
 
-#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);  \
+#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);  \
+       }                                                                       \
 }
 
+#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
+
+
+#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
 #if !GTK_CHECK_VERSION(2,22,0)
 #define gdk_drag_context_get_selected_action(x) ((x)->action)
 #define gdk_drag_context_get_actions(x) ((x)->actions)
@@ -238,6 +271,8 @@ claws_input_add    (gint          source,
 #define gtk_widget_get_mapped(x) (GTK_WIDGET_MAPPED(x))
 #endif
 #if !GTK_CHECK_VERSION(2,18,0)
+#define gtk_widget_get_allocation(x,a) (*(a) = (x)->allocation)
+#define gtk_widget_set_allocation(x,a) ((x)->allocation = *(a))
 #define gtk_widget_has_focus(x) (GTK_WIDGET_HAS_FOCUS(x))
 #define gtk_widget_get_can_focus(x) (GTK_WIDGET_CAN_FOCUS(x))
 #define gtk_widget_has_grab(x) (GTK_WIDGET_HAS_GRAB(x))
@@ -250,5 +285,11 @@ claws_input_add    (gint         source,
 #define gtk_widget_get_mapped(x) (GTK_WIDGET_MAPPED(x))
 #define gtk_widget_get_has_window(x) (!(GTK_WIDGET_NO_WINDOW(x)))
 #define gtk_widget_get_app_paintable(x) (GTK_WIDGET_APP_PAINTABLE(x))
+#define gtk_widget_set_window(x,w) {                   \
+       if ((x)->window != w) {                         \
+               (x)->window = w;                        \
+               g_object_notify (G_OBJECT(x), "window");\
+       }                                               \
+}
 #endif
 #endif /* __GTKUTILS_H__ */