From f9f82573ea65bd41c350f05da3e30b4f1a399b76 Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Fri, 13 Apr 2012 17:57:37 -0400 Subject: [PATCH] * #9815: restored gtk2 support --- gnome/configure.ac | 8 +-- gnome/src/Makefile.am | 5 +- gnome/src/config/accountconfigdialog.c | 1 + gnome/src/config/accountlistconfigdialog.c | 1 + gnome/src/config/addressbook-config.c | 1 + gnome/src/config/assistant.c | 1 + gnome/src/config/audioconf.c | 1 + gnome/src/config/hooks-config.c | 1 + gnome/src/config/preferencesdialog.c | 1 + gnome/src/config/shortcuts-config.c | 1 + gnome/src/config/tlsadvanceddialog.c | 1 + gnome/src/contacts/calltree.c | 1 + gnome/src/contacts/searchbar.c | 11 +-- gnome/src/gtk2_wrappers.c | 83 ++++++++++++++++++++++ gnome/src/gtk2_wrappers.h | 59 +++++++++++++++ gnome/src/imwindow.c | 9 ++- gnome/src/mainwindow.c | 5 +- gnome/src/sliders.c | 1 + gnome/src/uimanager.c | 4 ++ gnome/src/widget/minidialog.c | 1 + 20 files changed, 180 insertions(+), 16 deletions(-) create mode 100644 gnome/src/gtk2_wrappers.c create mode 100644 gnome/src/gtk2_wrappers.h diff --git a/gnome/configure.ac b/gnome/configure.ac index e9738278d7..f87118156f 100644 --- a/gnome/configure.ac +++ b/gnome/configure.ac @@ -15,9 +15,7 @@ AC_PROG_INSTALL AC_HEADER_STDC LT_INIT -dnl Only need these for moving to gtk3 -MIGRATION_CFLAGS="-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES" -CFLAGS="$CFLAGS -Wall -Wextra -Wshadow $MIGRATION_CFLAGS" +CFLAGS="$CFLAGS -Wall -Wextra -Wshadow" dnl GCONF utilities AM_GCONF_SOURCE_2 @@ -32,10 +30,10 @@ if echo "$LIBNOTIFY_LIBS" | grep -q gtk+-x11-2.0; then AC_MSG_ERROR([Your libnotify is linked with GTK+2 ! Install libnotify4-dev]) exit 1 fi -PKG_CHECK_MODULES(GTK, gtk+-3.0) +PKG_CHECK_MODULES(GTK, gtk+-3.0, , [PKG_CHECK_MODULES(GTK, gtk+-2.0)]) PKG_CHECK_MODULES(GCONF, gconf-2.0) PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.24) -PKG_CHECK_MODULES(WEBKIT, webkitgtk-3.0) +PKG_CHECK_MODULES(WEBKIT, webkitgtk-3.0,, [PKG_CHECK_MODULES(WEBKIT, webkit-1.0)]) PKG_CHECK_MODULES(X11, x11) PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, javascriptcoregtk-3.0, , AC_MSG_RESULT(javascriptcoregtk not installed)) diff --git a/gnome/src/Makefile.am b/gnome/src/Makefile.am index eb80e71377..8a0878d10d 100644 --- a/gnome/src/Makefile.am +++ b/gnome/src/Makefile.am @@ -28,13 +28,14 @@ sflphone_client_gnome_SOURCES = \ reqaccount.c \ eel-gconf-extensions.c \ shortcuts.c \ - str_utils.c + str_utils.c \ + gtk2_wrappers.c noinst_HEADERS = actions.h sflnotify.h mainwindow.h dialpad.h codeclist.h \ reqaccount.h sflphone_const.h uimanager.h accountlist.h \ sliders.h statusicon.h callable_obj.h conference_obj.h \ shortcuts.h eel-gconf-extensions.h logger.h imwindow.h \ - unused.h str_utils.h + unused.h str_utils.h gtk2_wrappers.h sflphone_client_gnome_LDADD = $(DBUSGLIB_LIBS) $(LIBNOTIFY_LIBS) \ $(NOTIFY_LIBS) $(SFLPHONEGTK_LIBS) $(X11_LIBS) \ diff --git a/gnome/src/config/accountconfigdialog.c b/gnome/src/config/accountconfigdialog.c index 3ef15b51a3..977014fefc 100644 --- a/gnome/src/config/accountconfigdialog.c +++ b/gnome/src/config/accountconfigdialog.c @@ -40,6 +40,7 @@ #include <gtk/gtk.h> #include "config.h" +#include "gtk2_wrappers.h" #include "str_utils.h" #include "logger.h" #include "actions.h" diff --git a/gnome/src/config/accountlistconfigdialog.c b/gnome/src/config/accountlistconfigdialog.c index 27560b0200..6a8b47f0bf 100644 --- a/gnome/src/config/accountlistconfigdialog.c +++ b/gnome/src/config/accountlistconfigdialog.c @@ -39,6 +39,7 @@ #include "utils.h" #include "unused.h" #include "logger.h" +#include "gtk2_wrappers.h" #include <glib/gi18n.h> #include <string.h> diff --git a/gnome/src/config/addressbook-config.c b/gnome/src/config/addressbook-config.c index 3eb74d378f..1832d38e81 100644 --- a/gnome/src/config/addressbook-config.c +++ b/gnome/src/config/addressbook-config.c @@ -29,6 +29,7 @@ */ #include "addressbook-config.h" +#include "gtk2_wrappers.h" #include "str_utils.h" #include "dbus.h" #include "unused.h" diff --git a/gnome/src/config/assistant.c b/gnome/src/config/assistant.c index bc74e9cf2c..beeda0b8ad 100644 --- a/gnome/src/config/assistant.c +++ b/gnome/src/config/assistant.c @@ -30,6 +30,7 @@ #include <string.h> #include <glib/gi18n.h> +#include "gtk2_wrappers.h" #include "unused.h" #include "assistant.h" #include "logger.h" diff --git a/gnome/src/config/audioconf.c b/gnome/src/config/audioconf.c index 9159586cfe..02b1f1f096 100644 --- a/gnome/src/config/audioconf.c +++ b/gnome/src/config/audioconf.c @@ -29,6 +29,7 @@ */ #include <glib/gi18n.h> +#include "gtk2_wrappers.h" #include "str_utils.h" #include "audioconf.h" #include "utils.h" diff --git a/gnome/src/config/hooks-config.c b/gnome/src/config/hooks-config.c index 2ff4dc5003..cfbc79e44d 100644 --- a/gnome/src/config/hooks-config.c +++ b/gnome/src/config/hooks-config.c @@ -29,6 +29,7 @@ */ #include <glib/gi18n.h> +#include "gtk2_wrappers.h" #include "str_utils.h" #include "hooks-config.h" #include "dbus.h" diff --git a/gnome/src/config/preferencesdialog.c b/gnome/src/config/preferencesdialog.c index 87c114ac43..fb281af2fd 100644 --- a/gnome/src/config/preferencesdialog.c +++ b/gnome/src/config/preferencesdialog.c @@ -39,6 +39,7 @@ #include <string.h> #include <assert.h> +#include "gtk2_wrappers.h" #include "eel-gconf-extensions.h" #include "dbus.h" #include "logger.h" diff --git a/gnome/src/config/shortcuts-config.c b/gnome/src/config/shortcuts-config.c index 4c8365dff8..f6a31c82c0 100644 --- a/gnome/src/config/shortcuts-config.c +++ b/gnome/src/config/shortcuts-config.c @@ -28,6 +28,7 @@ * as that of the covered work. */ +#include "gtk2_wrappers.h" #include <glib/gi18n.h> #include <gdk/gdk.h> #include <X11/XKBlib.h> diff --git a/gnome/src/config/tlsadvanceddialog.c b/gnome/src/config/tlsadvanceddialog.c index 7c77eba19a..b3f4c0d61a 100644 --- a/gnome/src/config/tlsadvanceddialog.c +++ b/gnome/src/config/tlsadvanceddialog.c @@ -29,6 +29,7 @@ */ #include "tlsadvanceddialog.h" +#include "gtk2_wrappers.h" #include "str_utils.h" #include "sflphone_const.h" #include "mainwindow.h" diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c index b945561888..1c909b578e 100644 --- a/gnome/src/contacts/calltree.c +++ b/gnome/src/contacts/calltree.c @@ -36,6 +36,7 @@ #include <string.h> #include <stdlib.h> +#include "gtk2_wrappers.h" #include "eel-gconf-extensions.h" #include "unused.h" #include "dbus.h" diff --git a/gnome/src/contacts/searchbar.c b/gnome/src/contacts/searchbar.c index 1ac515b246..2fc06edb83 100644 --- a/gnome/src/contacts/searchbar.c +++ b/gnome/src/contacts/searchbar.c @@ -32,6 +32,7 @@ */ #include <glib/gi18n.h> +#include "gtk2_wrappers.h" #include "searchbar.h" #include "calltree.h" #include "calltab.h" @@ -46,18 +47,18 @@ static GtkWidget * searchbox; static GtkWidget * addressbookentry; static GtkWidget * cbox; -static GtkListStore * liststore = NULL; +static GtkListStore * liststore; static gint cboxSignalId; -static GtkWidget *menu = NULL; +static GtkWidget *menu; /** * Searchbar icons */ -static GdkPixbuf *incoming_pixbuf = NULL; -static GdkPixbuf *outgoing_pixbuf = NULL; -static GdkPixbuf *missed_pixbuf = NULL; +static GdkPixbuf *incoming_pixbuf; +static GdkPixbuf *outgoing_pixbuf; +static GdkPixbuf *missed_pixbuf; void searchbar_addressbook_activated(GtkEntry *entry, gchar *arg1 UNUSED, gpointer data UNUSED) { diff --git a/gnome/src/gtk2_wrappers.c b/gnome/src/gtk2_wrappers.c new file mode 100644 index 0000000000..732ea151e0 --- /dev/null +++ b/gnome/src/gtk2_wrappers.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. + * Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com> + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#include "gtk2_wrappers.h" + +#if !GTK_CHECK_VERSION(3, 0, 0) + +GtkWidget *gtk_box_new(GtkOrientation orientation, gint spacing) +{ + if (orientation == GTK_ORIENTATION_HORIZONTAL) + return gtk_hbox_new(FALSE, spacing); + else + return gtk_vbox_new(FALSE, spacing); +} + +GtkWidget* gtk_button_box_new(GtkOrientation orientation) +{ + if (orientation == GTK_ORIENTATION_HORIZONTAL) + return gtk_hbutton_box_new(); + else + return gtk_vbutton_box_new(); +} + +void +gtk_widget_get_preferred_size(GtkWidget* widget, GtkRequisition *min_size, GtkRequisition *max_size) +{ + if (max_size) + gtk_widget_size_request(widget, max_size); + else if (min_size) + gtk_widget_size_request(widget, min_size); +} + +GdkPixbuf * +gtk_widget_render_icon_pixbuf(GtkWidget *widget, const gchar *stock_id, GtkIconSize size) +{ + return gtk_widget_render_icon(widget, stock_id, size, NULL); +} + +GtkWidget * +gtk_scale_new_with_range(GtkOrientation orientation, gdouble min, gdouble max, + gdouble step) +{ + if (orientation == GTK_ORIENTATION_HORIZONTAL) + return gtk_hscale_new_with_range(min, max, step); + else + return gtk_vscale_new_with_range(min, max, step); +} + +void +gtk_combo_box_text_append(GtkComboBoxText *combo_box, const gchar *id, const gchar *text) +{ + g_assert(!id); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), text); +} + +#endif diff --git a/gnome/src/gtk2_wrappers.h b/gnome/src/gtk2_wrappers.h new file mode 100644 index 0000000000..aa28a117a3 --- /dev/null +++ b/gnome/src/gtk2_wrappers.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. + * Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com> + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#ifndef BOX_H_ +#define BOX_H_ + +#include <gtk/gtk.h> + +/* Wrappers needed if using gtk2 */ +#if !GTK_CHECK_VERSION(3, 0, 0) +GtkWidget* +gtk_box_new(GtkOrientation orientation, gint spacing); + +GtkWidget* +gtk_button_box_new(GtkOrientation orientation); + +void +gtk_widget_get_preferred_size(GtkWidget* widget, GtkRequisition *min_size, GtkRequisition *max_size); + +GdkPixbuf * +gtk_widget_render_icon_pixbuf(GtkWidget *widget, const gchar *stock_id, GtkIconSize size); + +GtkWidget * +gtk_scale_new_with_range(GtkOrientation orientation, gdouble min, gdouble max, + gdouble step); + +void +gtk_combo_box_text_append(GtkComboBoxText *combo_box, const gchar *id, const gchar *text); + +#endif + +#endif // BOX_H_ diff --git a/gnome/src/imwindow.c b/gnome/src/imwindow.c index d7841631fa..0ddd14d135 100644 --- a/gnome/src/imwindow.c +++ b/gnome/src/imwindow.c @@ -30,7 +30,11 @@ * as that of the covered work. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include "gtk2_wrappers.h" #include "eel-gconf-extensions.h" #include "logger.h" #include "imwindow.h" @@ -41,9 +45,8 @@ #include <sys/stat.h> /** Local variables */ -static GtkWidget *im_window = NULL; -static GtkWidget *im_notebook = NULL; - +static GtkWidget *im_window; +static GtkWidget *im_notebook; static void im_window_init(); diff --git a/gnome/src/mainwindow.c b/gnome/src/mainwindow.c index 9b079d7396..c57a325fc2 100644 --- a/gnome/src/mainwindow.c +++ b/gnome/src/mainwindow.c @@ -30,8 +30,11 @@ * as that of the covered work. */ +#ifdef HAVE_CONFIG_H #include "config.h" -#include "str_utils.h" +#endif + +#include "gtk2_wrappers.h" #include "actions.h" #include "dbus.h" #include "calltree.h" diff --git a/gnome/src/sliders.c b/gnome/src/sliders.c index ab3e40f02c..1994931edc 100644 --- a/gnome/src/sliders.c +++ b/gnome/src/sliders.c @@ -29,6 +29,7 @@ */ #include <glib/gi18n.h> +#include "gtk2_wrappers.h" #include "sliders.h" #include "dbus/dbus.h" #include "actions.h" diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c index b2b16d5d2e..8010757981 100644 --- a/gnome/src/uimanager.c +++ b/gnome/src/uimanager.c @@ -28,7 +28,11 @@ * as that of the covered work. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include "gtk2_wrappers.h" #include "str_utils.h" #include "preferencesdialog.h" #include "logger.h" diff --git a/gnome/src/widget/minidialog.c b/gnome/src/widget/minidialog.c index 46de037960..c844bc28e1 100644 --- a/gnome/src/widget/minidialog.c +++ b/gnome/src/widget/minidialog.c @@ -26,6 +26,7 @@ #include <gtk/gtk.h> #include "unused.h" #include "sflphone_const.h" +#include "gtk2_wrappers.h" #include "minidialog.h" #define HIG_BOX_SPACE 6 -- GitLab