* WIP: fixes for gtk3.2 (prevent warnings for deprecated widgets)

This commit is contained in:
djcb
2012-03-22 22:37:54 +02:00
parent 9444a3eb0e
commit 3fb7e5d6ff
12 changed files with 177 additions and 64 deletions

View File

@ -198,6 +198,10 @@ AM_CONDITIONAL(HAVE_GTK,[test "x$have_gtk2" = "xyes" -o "x$have_gtk3" = "xyes" ]
AS_IF([test "x$have_gtk2" = "xyes" -o "x$have_gtk3" = "xyes"],[buildgui=yes],
[buildgui=no])
AS_IF([test "x$have_gtk3" = "xyes"],
[AC_DEFINE_UNQUOTED([HAVE_GTK3],1,[Whether we have GTK+ 3.x])])
# webkit? needed for the fancy web widget
AS_IF([test "x$buildgui" = "xyes"],[
PKG_CHECK_MODULES(WEBKIT,webkit-1.0 >= 1.0.3,[have_webkit=yes],[have_webkit=no])

View File

@ -46,13 +46,18 @@ struct _MugMsgViewPrivate {
};
#define MUG_MSG_VIEW_GET_PRIVATE(o)(G_TYPE_INSTANCE_GET_PRIVATE((o),MUG_TYPE_MSG_VIEW, MugMsgViewPrivate))
/* globals */
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_BOX);
#else
static GtkVBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_VBOX);
#endif /*!HAVE_GTK3*/
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_VBOX);
static void
mug_msg_view_class_init (MugMsgViewClass * klass)
{
@ -88,7 +93,7 @@ mug_msg_view_init (MugMsgView * obj)
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
priv->_view);
gtk_box_pack_start (GTK_BOX (obj), scrolled, TRUE, TRUE, 0);
}
@ -135,7 +140,7 @@ mug_msg_view_set_msg (MugMsgView * self, const char *msgpath)
msgpath);
mu_msg_view_set_note (MU_MSG_VIEW (priv->_view), note);
g_free (note);
}
}
}
return TRUE;
@ -147,7 +152,7 @@ mug_msg_view_set_note (MugMsgView * self, const char* html)
{
MugMsgViewPrivate *priv;
g_return_if_fail (MUG_IS_MSG_VIEW (self));
priv = MUG_MSG_VIEW_GET_PRIVATE (self);
mu_msg_view_set_note (MU_MSG_VIEW (priv->_view), html);

View File

@ -23,6 +23,9 @@
#include <gtk/gtk.h>
/* other include files */
G_BEGIN_DECLS
/* convenience macros */
#define MUG_TYPE_MSG_VIEW (mug_msg_view_get_type())
@ -35,12 +38,20 @@ typedef struct _MugMsgView MugMsgView;
typedef struct _MugMsgViewClass MugMsgViewClass;
struct _MugMsgView {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
/* insert public members, if any */
#endif /*!HAVE_GTK3*/
};
struct _MugMsgViewClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
#endif /*!HAVE_GTK3*/
/* insert signal callback declarations, e.g. */
/* void (* my_event) (MugMsg* obj); */
};

View File

@ -26,30 +26,16 @@ struct _MugQueryBarPrivate {
/* globals */
static GtkContainerClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
GType
mug_query_bar_get_type (void)
{
static GType my_type = 0;
if (!my_type) {
static const GTypeInfo my_info = {
sizeof (MugQueryBarClass),
NULL, /* base init */
NULL, /* base finalize */
(GClassInitFunc) mug_query_bar_class_init,
NULL, /* class finalize */
NULL, /* class data */
sizeof (MugQueryBar),
0, /* n_preallocs, ignored since 2.10 */
(GInstanceInitFunc) mug_query_bar_init,
NULL
};
my_type = g_type_register_static (GTK_TYPE_HBOX,
"MugQueryBar", &my_info, 0);
}
return my_type;
}
#ifdef HAVE_GTK3
G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_BOX);
#else
G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_HBOX);
#endif /*!HAVE_GTK3*/
static void
mug_query_bar_class_init (MugQueryBarClass * klass)

View File

@ -4,8 +4,11 @@
#ifndef __MUG_QUERY_BAR_H__
#define __MUG_QUERY_BAR_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG*/
#include <gtk/gtk.h>
/* other include files */
G_BEGIN_DECLS
/* convenience macros */
@ -19,12 +22,22 @@ typedef struct _MugQueryBar MugQueryBar;
typedef struct _MugQueryBarClass MugQueryBarClass;
struct _MugQueryBar {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkHBox parent;
/* insert public members, if any */
#endif /*!HAVE_GTK3*/
};
struct _MugQueryBarClass {
#ifdef HAVE_GTK3
GtkBox parent;
GtkBoxClass parent_class;
#else
GtkHBox parent;
GtkHBoxClass parent_class;
#endif /*!HAVE_GTK3*/
/* insert signal callback declarations, e.g. */
void (*query_changed) (MugQueryBar * obj, const char *query);
};

View File

@ -45,11 +45,17 @@ struct _MugShortcutsPrivate {
MUG_TYPE_SHORTCUTS, \
MugShortcutsPrivate))
/* globals */
static GtkVBoxClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_BOX);
#else
static GtkVBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_VBOX);
#endif /*!HAVE_GTK3*/
static void
mug_shortcuts_class_init (MugShortcutsClass * klass)
@ -82,7 +88,12 @@ mug_shortcuts_init (MugShortcuts * obj)
{
obj->_priv = MUG_SHORTCUTS_GET_PRIVATE (obj);
#ifdef HAVE_GTK3
obj->_priv->_bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
#else
obj->_priv->_bbox = gtk_vbutton_box_new ();
#endif /*!HAVE_GTK3*/
gtk_button_box_set_layout (GTK_BUTTON_BOX (obj->_priv->_bbox),
GTK_BUTTONBOX_START);
gtk_box_pack_start (GTK_BOX (obj), obj->_priv->_bbox, TRUE, TRUE, 0);

View File

@ -20,6 +20,11 @@
#ifndef __MUG_SHORTCUTS_H__
#define __MUG_SHORTCUTS_H__
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <gtk/gtk.h>
/* other include files */
@ -36,15 +41,23 @@ typedef struct _MugShortcutsClass MugShortcutsClass;
typedef struct _MugShortcutsPrivate MugShortcutsPrivate;
struct _MugShortcuts {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
/* insert public members, if any */
#endif /*!HAVE_GTK3*/
/* private */
MugShortcutsPrivate *_priv;
};
struct _MugShortcutsClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
#endif /*!HAVE_GTK3*/
void (*clicked) (MugShortcuts * obj, const char *query);
};

View File

@ -243,9 +243,8 @@ on_list_view_error (MugMsgListView * mlist, MugError err, MugData * mugdata)
gtk_dialog_run (GTK_DIALOG (errdialog));
gtk_widget_destroy (errdialog);
if (err == MUG_ERROR_QUERY) {
if (err == MUG_ERROR_QUERY)
mug_query_bar_grab_focus (MUG_QUERY_BAR (mugdata->querybar));
}
}
static GtkWidget *
@ -263,8 +262,14 @@ mug_query_area (MugData * mugdata)
{
GtkWidget *queryarea, *paned, *scrolled;
#ifdef HAVE_GTK3
queryarea = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
#else
queryarea = gtk_vbox_new (FALSE, 2);
paned = gtk_vpaned_new ();
#endif /*!HAVE_GTK3*/
mugdata->mlist = mug_msg_list_view_new
(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB));
@ -303,7 +308,12 @@ static GtkWidget *
mug_main_area (MugData * mugdata)
{
GtkWidget *mainarea, *w;
#ifdef HAVE_GTK3
mainarea = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
#else
mainarea = gtk_hbox_new (FALSE, 5);
#endif /*!HAVE_GTK3*/
w = mug_shortcuts_bar (mugdata);
gtk_box_pack_start (GTK_BOX (mainarea), w, FALSE, FALSE, 0);
@ -324,7 +334,12 @@ mug_shell (MugData * mugdata)
mugdata->win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (mugdata->win), "Mug Mail Search");
#ifdef HAVE_GTK3
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
#else
vbox = gtk_vbox_new (FALSE, 2);
#endif /*!HAVE_GTK3*/
mugdata->toolbar = mug_toolbar (mugdata);
gtk_box_pack_start (GTK_BOX (vbox), mugdata->toolbar, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), mug_main_area (mugdata), TRUE,

View File

@ -22,6 +22,10 @@
#include <mu-str.h>
#include <mu-date.h>
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
/* 'private'/'protected' functions */
static void mu_msg_header_view_class_init (MuMsgHeaderViewClass *klass);
static void mu_msg_header_view_init (MuMsgHeaderView *obj);
@ -41,12 +45,21 @@ struct _MuMsgHeaderViewPrivate {
MU_TYPE_MSG_HEADER_VIEW, \
MuMsgHeaderViewPrivate))
/* globals */
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
#else
static GtkVBoxClass *parent_class = NULL;
#endif /*!HAVE_GTK3*/
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
#ifdef HAVE_GTK3
G_DEFINE_TYPE (MuMsgHeaderView, mu_msg_header_view, GTK_TYPE_BOX);
#else
G_DEFINE_TYPE (MuMsgHeaderView, mu_msg_header_view, GTK_TYPE_VBOX);
#endif /*!HAVE_GTK3*/
static void
@ -73,6 +86,12 @@ mu_msg_header_view_init (MuMsgHeaderView *obj)
{
obj->_priv = MU_MSG_HEADER_VIEW_GET_PRIVATE(obj);
obj->_priv->_table = NULL;
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
#endif /*!HAVE_GTK3*/
}
static void
@ -99,7 +118,7 @@ get_label (const gchar *txt, gboolean istitle)
markup = g_strdup_printf ("<b>%s</b>: ", txt);
gtk_label_set_markup (GTK_LABEL(label), markup);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
g_free (markup);
g_free (markup);
} else {
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
gtk_label_set_text (GTK_LABEL(label), txt ? txt : "");
@ -121,7 +140,7 @@ add_row (GtkWidget *table, guint row, const char* fieldname, const char *value,
label = get_label (fieldname, TRUE);
al = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (al), label);
gtk_table_attach (
GTK_TABLE(table), al,
0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
@ -134,21 +153,21 @@ add_row (GtkWidget *table, guint row, const char* fieldname, const char *value,
gtk_table_attach (
GTK_TABLE(table), al, 1, 2, row, row + 1, GTK_FILL,
0, 0, 0);
return TRUE;
}
GtkWidget *
get_table (MuMsg *msg)
{
GtkWidget *table;
int row;
row = 0;
table = gtk_table_new (5, 2, FALSE);
if (add_row (table, row, "From", mu_msg_get_from (msg), TRUE))
++row;
if (add_row (table, row, "To", mu_msg_get_to (msg), FALSE))
@ -170,7 +189,7 @@ void
mu_msg_header_view_set_message (MuMsgHeaderView *self, MuMsg *msg)
{
g_return_if_fail (MU_IS_MSG_HEADER_VIEW(self));
if (self->_priv->_table) {
gtk_container_remove (GTK_CONTAINER(self), self->_priv->_table);
self->_priv->_table = NULL;
@ -183,4 +202,3 @@ mu_msg_header_view_set_message (MuMsgHeaderView *self, MuMsg *msg)
gtk_widget_show_all (self->_priv->_table);
}
}

View File

@ -23,6 +23,10 @@
#include <gtk/gtk.h>
#include <mu-msg.h>
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
G_BEGIN_DECLS
/* convenience macros */
@ -38,7 +42,12 @@ typedef struct _MuMsgHeaderViewClass MuMsgHeaderViewClass;
typedef struct _MuMsgHeaderViewPrivate MuMsgHeaderViewPrivate;
struct _MuMsgHeaderView {
GtkVBox parent;
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
#endif /*!HAVE_GTK3*/
/* insert public members, if any */
/* private */
@ -46,7 +55,11 @@ struct _MuMsgHeaderView {
};
struct _MuMsgHeaderViewClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
#endif /*!HAVE_GTK3*/
/* insert signal callback declarations, e.g. */
/* void (* my_event) (MuMsgHeaderView* obj); */
};
@ -64,4 +77,3 @@ void mu_msg_header_view_set_message (MuMsgHeaderView *self, MuMsg *msg);
G_END_DECLS
#endif /* __MU_MSG_HEADER_VIEW_H__ */

View File

@ -17,12 +17,17 @@
**
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include "mu-msg-view.h"
#include "mu-msg-body-view.h"
#include "mu-msg-header-view.h"
#include "mu-msg-attach-view.h"
#include "mu-msg-part.h"
/* 'private'/'protected' functions */
static void mu_msg_view_class_init (MuMsgViewClass *klass);
static void mu_msg_view_init (MuMsgView *obj);
@ -43,19 +48,31 @@ struct _MuMsgViewPrivate {
MU_TYPE_MSG_VIEW, \
MuMsgViewPrivate))
/* globals */
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
#else
static GtkVBoxClass *parent_class = NULL;
#endif /*!HAVE_GTK3*/
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
#ifdef HAVE_GTK3
G_DEFINE_TYPE (MuMsgView, mu_msg_view, GTK_TYPE_BOX);
#else
G_DEFINE_TYPE (MuMsgView, mu_msg_view, GTK_TYPE_VBOX);
#endif /*HAVE_GTK3*/
static void
set_message (MuMsgView *self, MuMsg *msg)
{
if (self->_priv->_msg == msg)
return; /* nothing to todo */
if (self->_priv->_msg) {
mu_msg_unref (self->_priv->_msg);
self->_priv->_msg = NULL;
@ -97,19 +114,19 @@ on_body_action_requested (GtkWidget *w, const char* action,
} else if (g_strcmp0 (action, "view-message") == 0) {
if (self->_priv->_msg)
mu_msg_view_set_message (self, self->_priv->_msg);
} else if (g_strcmp0 (action, "reindex") == 0) {
g_warning ("reindex");
} else {
g_warning ("unknown action '%s'", action);
}
}
}
static void
on_attach_activated (GtkWidget *w, guint partnum, MuMsg *msg)
{
gchar *filepath;
filepath = mu_msg_part_filepath_cache (msg, partnum);
if (filepath) {
GError *err;
@ -120,7 +137,7 @@ on_attach_activated (GtkWidget *w, guint partnum, MuMsg *msg)
if (err)
g_error_free(err);
}
mu_util_play (filepath, TRUE, FALSE);
g_free (filepath);
}
@ -139,17 +156,17 @@ mu_msg_view_init (MuMsgView *self)
self->_priv->_attachexpander = gtk_expander_new_with_mnemonic
("_Attachments");
gtk_container_add (GTK_CONTAINER(self->_priv->_attachexpander),
self->_priv->_attach);
self->_priv->_attach);
g_signal_connect (self->_priv->_attach, "attach-activated",
G_CALLBACK(on_attach_activated),
self);
self->_priv->_body = mu_msg_body_view_new ();
g_signal_connect (self->_priv->_body,
"action-requested",
G_CALLBACK(on_body_action_requested),
self);
gtk_box_pack_start (GTK_BOX(self), self->_priv->_headers,
FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX(self), self->_priv->_attachexpander,
@ -176,7 +193,7 @@ void
mu_msg_view_set_message (MuMsgView *self, MuMsg *msg)
{
gint attachnum;
g_return_if_fail (MU_IS_MSG_VIEW(self));
set_message (self, msg);
@ -185,10 +202,10 @@ mu_msg_view_set_message (MuMsgView *self, MuMsg *msg)
msg);
attachnum = mu_msg_attach_view_set_message (MU_MSG_ATTACH_VIEW(self->_priv->_attach),
msg);
mu_msg_body_view_set_message (MU_MSG_BODY_VIEW(self->_priv->_body),
msg);
gtk_widget_set_visible (self->_priv->_headers, TRUE);
gtk_widget_set_visible (self->_priv->_attachexpander, attachnum > 0);
gtk_widget_set_visible (self->_priv->_body, TRUE);
@ -198,14 +215,14 @@ mu_msg_view_set_message (MuMsgView *self, MuMsg *msg)
void
mu_msg_view_set_message_source (MuMsgView *self, MuMsg *msg)
{
{
g_return_if_fail (MU_IS_MSG_VIEW(self));
set_message (self, msg);
mu_msg_body_view_set_message_source (MU_MSG_BODY_VIEW(self->_priv->_body),
msg);
gtk_widget_set_visible (self->_priv->_headers, FALSE);
gtk_widget_set_visible (self->_priv->_attachexpander, FALSE);
gtk_widget_set_visible (self->_priv->_body, TRUE);
@ -217,7 +234,7 @@ void
mu_msg_view_set_note (MuMsgView *self, const gchar* html)
{
g_return_if_fail (MU_IS_MSG_VIEW(self));
gtk_widget_set_visible (self->_priv->_headers, FALSE);
gtk_widget_set_visible (self->_priv->_attachexpander, FALSE);
gtk_widget_set_visible (self->_priv->_body, TRUE);
@ -225,4 +242,3 @@ mu_msg_view_set_note (MuMsgView *self, const gchar* html)
mu_msg_body_view_set_note (MU_MSG_BODY_VIEW(self->_priv->_body),
html);
}

View File

@ -23,6 +23,10 @@
#include <gtk/gtk.h>
#include <mu-msg.h>
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
G_BEGIN_DECLS
/* convenience macros */
@ -38,16 +42,22 @@ typedef struct _MuMsgViewClass MuMsgViewClass;
typedef struct _MuMsgViewPrivate MuMsgViewPrivate;
struct _MuMsgView {
GtkVBox parent;
/* insert public members, if any */
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
#endif /*!HAVE_GTK3*/
/* private */
MuMsgViewPrivate *_priv;
};
struct _MuMsgViewClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
/* insert signal callback declarations, e.g. */
#endif /*!HAVE_GTK3*/
/* void (* my_event) (MuMsgView* obj); */
};
@ -65,4 +75,3 @@ void mu_msg_view_set_message_source (MuMsgView *self, MuMsg *msg);
G_END_DECLS
#endif /* __MU_MSG_VIEW_H__ */