summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/compat.c27
-rw-r--r--gtk/compat.h3
-rw-r--r--gtk/dialogs/options.c45
3 files changed, 54 insertions, 21 deletions
diff --git a/gtk/compat.c b/gtk/compat.c
index 2361dc201..86b87d4cb 100644
--- a/gtk/compat.c
+++ b/gtk/compat.c
@@ -97,3 +97,30 @@ void nsgtk_dialog_set_has_separator(GtkDialog *dialog, gboolean setting)
#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
+}
diff --git a/gtk/compat.h b/gtk/compat.h
index 1bd18a0d6..3b0dd497e 100644
--- a/gtk/compat.h
+++ b/gtk/compat.h
@@ -33,5 +33,8 @@ gboolean nsgtk_widget_get_mapped(GtkWidget *widget);
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 */
diff --git a/gtk/dialogs/options.c b/gtk/dialogs/options.c
index 0587c3cae..380b767c4 100644
--- a/gtk/dialogs/options.c
+++ b/gtk/dialogs/options.c
@@ -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 @@ void nsgtk_options_load(void)
/* 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 @@ void nsgtk_options_load(void)
/* 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 @@ void nsgtk_options_load(void)
} 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 @@ static void nsgtk_options_theme_combo(void) {
/* 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 @@ static void nsgtk_options_theme_combo(void) {
/* 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 @@ bool nsgtk_options_combo_theme_add(const char *themename)
{
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 @@ bool nsgtk_options_combo_theme_add(const char *themename)
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 @@ COMBO_CHANGED(combotheme, option_current_theme)
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);