From 496d646dba360512d3764af54ccf7df513efcfb6 Mon Sep 17 00:00:00 2001 From: bill-auger <mr.j.spam.me@gmail.com> Date: Tue, 3 Nov 2020 22:38:02 -0500 Subject: fix warnings -Wdeprecated-declarations deprecated since GTK v3.22: src/appearance.c: gtk_font_button_set_font_name() gtk_font_button_get_font_name() deprecated since GTK v3.10: src/theme.c: GTK_STOCK_OK GTK_STOCK_CANCEL --- src/appearance.c | 62 +++++++++++++++++++++++++++++++++----------------------- src/theme.c | 11 ++++++++++ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/appearance.c b/src/appearance.c index a9b139d..c20c785 100644 --- a/src/appearance.c +++ b/src/appearance.c @@ -23,6 +23,10 @@ * 2010-08-07 and some modifications were done to make it a loadable * module of LXAppearance. */ +/* NOTE: all functions in this file expect that the GtkWidget* is one of: + - GtkFontButton* (GTK2) + - GtkFontChooser* (GTK3) */ + #include "main.h" #include "tree.h" #include "preview_update.h" @@ -31,18 +35,18 @@ static gboolean mapping = FALSE; -static RrFont *read_font(GtkFontButton *w, const gchar *place); -static RrFont *write_font(GtkFontButton *w, const gchar *place); +static RrFont *read_font(GtkWidget *w, const gchar *place); +static RrFont *write_font(GtkWidget *w, const gchar *place); /* Forwarded */ void on_title_layout_changed(GtkEntry *w, gpointer data); -void on_font_active_font_set(GtkFontButton *w, gpointer data); -void on_font_inactive_font_set(GtkFontButton *w, gpointer data); -void on_font_menu_header_font_set(GtkFontButton *w, gpointer data); -void on_font_menu_item_font_set(GtkFontButton *w, gpointer data); -void on_font_active_display_font_set(GtkFontButton *w, gpointer data); -void on_font_inactive_display_font_set(GtkFontButton *w, gpointer data); +void on_font_active_font_set(GtkWidget *w, gpointer data); +void on_font_inactive_font_set(GtkWidget *w, gpointer data); +void on_font_menu_header_font_set(GtkWidget *w, gpointer data); +void on_font_menu_item_font_set(GtkWidget *w, gpointer data); +void on_font_active_display_font_set(GtkWidget *w, gpointer data); +void on_font_inactive_display_font_set(GtkWidget *w, gpointer data); /* End of forwarded */ @@ -69,30 +73,30 @@ void appearance_setup_tab() g_free(layout); w = get_widget("font_active"); - f = read_font(GTK_FONT_BUTTON(w), "ActiveWindow"); + f = read_font(w, "ActiveWindow"); preview_update_set_active_font(f); w = get_widget("font_inactive"); - f = read_font(GTK_FONT_BUTTON(w), "InactiveWindow"); + f = read_font(w, "InactiveWindow"); preview_update_set_inactive_font(f); w = get_widget("font_menu_header"); - f = read_font(GTK_FONT_BUTTON(w), "MenuHeader"); + f = read_font(w, "MenuHeader"); preview_update_set_menu_header_font(f); w = get_widget("font_menu_item"); - f = read_font(GTK_FONT_BUTTON(w), "MenuItem"); + f = read_font(w, "MenuItem"); preview_update_set_menu_item_font(f); w = get_widget("font_active_display"); - if (!(f = read_font(GTK_FONT_BUTTON(w), "ActiveOnScreenDisplay"))) { - f = read_font(GTK_FONT_BUTTON(w), "OnScreenDisplay"); + if (!(f = read_font(w, "ActiveOnScreenDisplay"))) { + f = read_font(w, "OnScreenDisplay"); tree_delete_node("theme/font:place=OnScreenDisplay"); } preview_update_set_osd_active_font(f); w = get_widget("font_inactive_display"); - f = read_font(GTK_FONT_BUTTON(w), "InactiveOnScreenDisplay"); + f = read_font(w, "InactiveOnScreenDisplay"); preview_update_set_osd_inactive_font(f); mapping = FALSE; @@ -164,35 +168,35 @@ void on_title_layout_changed(GtkEntry *w, gpointer data) g_free(layout); } -void on_font_active_font_set(GtkFontButton *w, gpointer data) +void on_font_active_font_set(GtkWidget *w, gpointer data) { if (mapping) return; preview_update_set_active_font(write_font(w, "ActiveWindow")); } -void on_font_inactive_font_set(GtkFontButton *w, gpointer data) +void on_font_inactive_font_set(GtkWidget *w, gpointer data) { if (mapping) return; preview_update_set_inactive_font(write_font(w, "InactiveWindow")); } -void on_font_menu_header_font_set(GtkFontButton *w, gpointer data) +void on_font_menu_header_font_set(GtkWidget *w, gpointer data) { if (mapping) return; preview_update_set_menu_header_font(write_font(w, "MenuHeader")); } -void on_font_menu_item_font_set(GtkFontButton *w, gpointer data) +void on_font_menu_item_font_set(GtkWidget *w, gpointer data) { if (mapping) return; preview_update_set_menu_item_font(write_font(w, "MenuItem")); } -void on_font_active_display_font_set(GtkFontButton *w, gpointer data) +void on_font_active_display_font_set(GtkWidget *w, gpointer data) { if (mapping) return; #if RR_CHECK_VERSION(3, 5, 29) @@ -202,14 +206,14 @@ void on_font_active_display_font_set(GtkFontButton *w, gpointer data) #endif } -void on_font_inactive_display_font_set(GtkFontButton *w, gpointer data) +void on_font_inactive_display_font_set(GtkWidget *w, gpointer data) { if (mapping) return; preview_update_set_osd_inactive_font(write_font(w, "InactiveOnScreenDisplay")); } -static RrFont *read_font(GtkFontButton *w, const gchar *place) +static RrFont *read_font(GtkWidget *w, const gchar *place) { RrFont *font; gchar *fontstring, *node; @@ -254,7 +258,11 @@ static RrFont *read_font(GtkFontButton *w, const gchar *place) } fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size); - gtk_font_button_set_font_name(w, fontstring); +#if GTK_CHECK_VERSION(3, 22, 0) + gtk_font_chooser_set_font(GTK_FONT_CHOOSER(w), fontstring); +#else + gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring); +#endif if (!g_ascii_strcasecmp(weight, "Bold")) rr_weight = RR_FONTWEIGHT_BOLD; if (!g_ascii_strcasecmp(slant, "Italic")) rr_slant = RR_FONTSLANT_ITALIC; @@ -272,7 +280,7 @@ static RrFont *read_font(GtkFontButton *w, const gchar *place) return font; } -static RrFont *write_font(GtkFontButton *w, const gchar *place) +static RrFont *write_font(GtkWidget *w, const gchar *place) { gchar *c; gchar *font, *node; @@ -285,7 +293,11 @@ static RrFont *write_font(GtkFontButton *w, const gchar *place) if (mapping) return NULL; - font = g_strdup(gtk_font_button_get_font_name(w)); +#if GTK_CHECK_VERSION(3, 22, 0) + font = g_strdup(gtk_font_chooser_get_font(GTK_FONT_CHOOSER(w))); +#else + font = g_strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(w))); +#endif while ((c = strrchr(font, ' '))) { if (!bold && !italic && !size && atoi(c+1)) size = c+1; diff --git a/src/theme.c b/src/theme.c index 4d7b988..b29a358 100644 --- a/src/theme.c +++ b/src/theme.c @@ -112,8 +112,14 @@ void on_install_theme_clicked(GtkButton *w, gpointer data) d = gtk_file_chooser_dialog_new(_("Choose an Openbox theme"), GTK_WINDOW(mainwin), GTK_FILE_CHOOSER_ACTION_OPEN, + +#if GTK_CHECK_VERSION(3, 10, 0) + "_OK", GTK_RESPONSE_OK, + "_Cancel", GTK_RESPONSE_NONE, +#else GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, +#endif NULL); gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(d), FALSE); @@ -144,8 +150,13 @@ void on_theme_archive_clicked(GtkButton *w, gpointer data) d = gtk_file_chooser_dialog_new(_("Choose an Openbox theme"), GTK_WINDOW(mainwin), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, +#if GTK_CHECK_VERSION(3, 10, 0) + "_OK", GTK_RESPONSE_OK, + "_Cancel", GTK_RESPONSE_NONE, +#else GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, +#endif NULL); gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(d), TRUE); -- cgit v1.2.2