Author: vince
Date: Tue Jun 7 12:23:39 2011
New Revision: 12469
URL:
http://source.netsurf-browser.org?rev=12469&view=rev
Log:
compatability fix for recent gtk API deprecation
Modified:
trunk/netsurf/gtk/compat.c
trunk/netsurf/gtk/compat.h
trunk/netsurf/gtk/dialogs/options.c
Modified: trunk/netsurf/gtk/compat.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/gtk/compat.c?rev=12469&am...
==============================================================================
--- trunk/netsurf/gtk/compat.c (original)
+++ trunk/netsurf/gtk/compat.c Tue Jun 7 12:23:39 2011
@@ -97,3 +97,30 @@
#endif
}
+GtkWidget *nsgtk_combo_box_text_new(void)
+{
+ #if GTK_CHECK_VERSION(2,24,0)
+ return gtk_combo_box_text_new();
+ #else
+ return gtk_combo_box_new_text();
+ #endif
+}
+
+void nsgtk_combo_box_text_append_text(GtkWidget *combo_box, const gchar *text)
+{
+ #if GTK_CHECK_VERSION(2,24,0)
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box), text);
+ #else
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), text);
+ #endif
+
+}
+
+gchar *nsgtk_combo_box_text_get_active_text(GtkWidget *combo_box)
+{
+ #if GTK_CHECK_VERSION(2,24,0)
+ return gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo_box));
+ #else
+ return gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo_box));
+ #endif
+}
Modified: trunk/netsurf/gtk/compat.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/gtk/compat.h?rev=12469&am...
==============================================================================
--- trunk/netsurf/gtk/compat.h (original)
+++ trunk/netsurf/gtk/compat.h Tue Jun 7 12:23:39 2011
@@ -33,5 +33,8 @@
gboolean nsgtk_widget_is_drawable(GtkWidget *widget);
GtkStateType nsgtk_widget_get_state(GtkWidget *widget);
void nsgtk_dialog_set_has_separator(GtkDialog *dialog, gboolean setting);
+GtkWidget *nsgtk_combo_box_text_new(void);
+void nsgtk_combo_box_text_append_text(GtkWidget *combo_box, const gchar *text);
+gchar *nsgtk_combo_box_text_get_active_text(GtkWidget *combo_box);
#endif /* NETSURF_GTK_COMPAT_H */
Modified: trunk/netsurf/gtk/dialogs/options.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/gtk/dialogs/options.c?rev...
==============================================================================
--- trunk/netsurf/gtk/dialogs/options.c (original)
+++ trunk/netsurf/gtk/dialogs/options.c Tue Jun 7 12:23:39 2011
@@ -30,6 +30,8 @@
#include "desktop/options.h"
#include "desktop/print.h"
#include "desktop/searchweb.h"
+
+#include "gtk/compat.h"
#include "gtk/options.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
@@ -297,7 +299,7 @@
/* Create combobox */
box = GTK_BOX(glade_xml_get_widget(gladeFile, "combolanguagevbox"));
- comboLanguage = gtk_combo_box_new_text();
+ comboLanguage = nsgtk_combo_box_text_new();
/* Populate combobox from languages file */
if ((languages_file_location != NULL) &&
@@ -311,7 +313,7 @@
/* Remove trailing \n */
buf[strlen(buf) - 1] = '\0';
- gtk_combo_box_append_text(GTK_COMBO_BOX(comboLanguage), buf);
+ nsgtk_combo_box_text_append_text(comboLanguage, buf);
if (strcmp(buf, default_accept_language) == 0)
active_language = combo_row_count;
@@ -323,7 +325,7 @@
} else {
LOG(("Failed opening languages file"));
warn_user("FileError", languages_file_location);
- gtk_combo_box_append_text(GTK_COMBO_BOX(comboLanguage), "en");
+ nsgtk_combo_box_text_append_text(comboLanguage, "en");
}
@@ -450,9 +452,11 @@
/* populate theme combo from themelist file */
GtkBox *box = GTK_BOX(glade_xml_get_widget(gladeFile, "themehbox"));
char buf[50];
- combotheme = gtk_combo_box_new_text();
size_t len = SLEN("themelist") + strlen(res_dir_location) + 1;
char themefile[len];
+
+ combotheme = nsgtk_combo_box_text_new();
+
if ((combotheme == NULL) || (box == NULL)) {
warn_user(messages_get("NoMemory"), 0);
return;
@@ -472,7 +476,7 @@
/* Remove trailing \n */
buf[strlen(buf) - 1] = '\0';
- gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), buf);
+ nsgtk_combo_box_text_append_text(combotheme, buf);
}
fclose(fp);
gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme),
@@ -485,7 +489,7 @@
{
if (wndPreferences == NULL)
return false;
- gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), themename);
+ nsgtk_combo_box_text_append_text(combotheme, themename);
return true;
}
@@ -547,17 +551,17 @@
static gboolean on_comboLanguage_changed(GtkWidget *widget, gpointer data)
{
- char *old_lang = option_accept_language;
- gchar *lang =
- gtk_combo_box_get_active_text(GTK_COMBO_BOX(comboLanguage));
+ gchar *lang;
+
+ lang = nsgtk_combo_box_text_get_active_text(comboLanguage);
if (lang == NULL)
return FALSE;
- option_accept_language = strdup((const char *) lang);
- if (option_accept_language == NULL)
- option_accept_language = old_lang;
- else
- free(old_lang);
+ if (option_accept_language != NULL) {
+ free(option_accept_language);
+ }
+
+ option_accept_language = lang;
g_free(lang);
@@ -810,18 +814,17 @@
if (option_current_theme != 0) {
if (nsgtk_theme_name() != NULL)
free(nsgtk_theme_name());
- name = strdup(gtk_combo_box_get_active_text(
- GTK_COMBO_BOX(combotheme)));
- if (name == NULL) {
- warn_user(messages_get("NoMemory"), 0);
- continue;
+ name = nsgtk_combo_box_text_get_active_text(combotheme);
+ if (name != NULL) {
+ nsgtk_theme_set_name(name);
+ nsgtk_theme_prepare();
+ /* possible name leak */
}
- nsgtk_theme_set_name(name);
- nsgtk_theme_prepare();
} else if (nsgtk_theme_name() != NULL) {
free(nsgtk_theme_name());
nsgtk_theme_set_name(NULL);
}
+
while (current) {
nsgtk_theme_implement(current);
current = nsgtk_scaffolding_iterate(current);