diff --git a/src/fe-gtk/chanview-tree.c b/src/fe-gtk/chanview-tree.c index dbdddf54..7d4ce157 100644 --- a/src/fe-gtk/chanview-tree.c +++ b/src/fe-gtk/chanview-tree.c @@ -118,9 +118,14 @@ cv_tree_init (chanview *cv) gtk_widget_set_name (view, "zoitechat-tree"); if (cv->style) { +#if HAVE_GTK3 + gtkutil_apply_palette (view, &colors[COL_BG], &colors[COL_FG], + cv->style->font_desc); +#else gtkutil_apply_palette (view, &cv->style->base[GTK_STATE_NORMAL], &cv->style->text[GTK_STATE_NORMAL], cv->style->font_desc); +#endif } /*gtk_widget_modify_base (view, GTK_STATE_NORMAL, &colors[COL_BG]);*/ gtk_widget_set_can_focus (view, FALSE); diff --git a/src/fe-gtk/chanview.c b/src/fe-gtk/chanview.c index d311b7b3..2e261c64 100644 --- a/src/fe-gtk/chanview.c +++ b/src/fe-gtk/chanview.c @@ -45,7 +45,7 @@ struct _chanview int size; /* number of channels in view */ GtkWidget *box; /* the box we destroy when changing implementations */ - GtkStyle *style; /* style used for tree */ + InputStyle *style; /* style used for tree */ chan *focused; /* currently focused channel */ int trunc_len; @@ -292,7 +292,7 @@ chanview_box_destroy_cb (GtkWidget *box, chanview *cv) chanview * chanview_new (int type, int trunc_len, gboolean sort, gboolean use_icons, - GtkStyle *style) + InputStyle *style) { chanview *cv; diff --git a/src/fe-gtk/chanview.h b/src/fe-gtk/chanview.h index ae77d6b1..dd91d1a7 100644 --- a/src/fe-gtk/chanview.h +++ b/src/fe-gtk/chanview.h @@ -20,10 +20,12 @@ #ifndef ZOITECHAT_CHANVIEW_H #define ZOITECHAT_CHANVIEW_H +#include "fe-gtk.h" + typedef struct _chanview chanview; typedef struct _chan chan; -chanview *chanview_new (int type, int trunc_len, gboolean sort, gboolean use_icons, GtkStyle *style); +chanview *chanview_new (int type, int trunc_len, gboolean sort, gboolean use_icons, InputStyle *style); void chanview_set_callbacks (chanview *cv, void (*cb_focus) (chanview *, chan *, int tag, void *userdata), void (*cb_xbutton) (chanview *, chan *, int tag, void *userdata), diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 47508a8b..64730d40 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -250,6 +250,7 @@ fe_args (int argc, char *argv[]) return -1; } +#if !HAVE_GTK3 const char cursor_color_rc[] = "style \"xc-ib-st\"" "{" @@ -272,6 +273,7 @@ static const char adwaita_workaround_rc[] = "}" "}" "widget \"*.zoitechat-inputbox\" style \"zoitechat-input-workaround\""; +#endif static gboolean fe_system_prefers_dark (void) @@ -397,13 +399,19 @@ fe_dark_mode_is_enabled (void) return fe_dark_mode_is_enabled_for (prefs.hex_gui_dark_mode); } -GtkStyle * -create_input_style (GtkStyle *style) +InputStyle * +create_input_style (InputStyle *style) { char buf[256]; static int done_rc = FALSE; - pango_font_description_free (style->font_desc); +#if HAVE_GTK3 + if (!style) + style = g_new0 (InputStyle, 1); +#endif + + if (style->font_desc) + pango_font_description_free (style->font_desc); style->font_desc = pango_font_description_from_string (prefs.hex_text_font); /* fall back */ @@ -417,6 +425,7 @@ create_input_style (GtkStyle *style) if (prefs.hex_gui_input_style && !done_rc) { +#if !HAVE_GTK3 GtkSettings *settings = gtk_settings_get_default (); char *theme_name; @@ -427,7 +436,6 @@ create_input_style (GtkStyle *style) gtk_rc_parse_string (adwaita_workaround_rc); g_free (theme_name); - done_rc = TRUE; { guint16 red; guint16 green; @@ -437,11 +445,15 @@ create_input_style (GtkStyle *style) sprintf (buf, cursor_color_rc, (red >> 8), (green >> 8), (blue >> 8)); } gtk_rc_parse_string (buf); +#endif + done_rc = TRUE; } +#if !HAVE_GTK3 style->bg[GTK_STATE_NORMAL] = colors[COL_FG]; style->base[GTK_STATE_NORMAL] = colors[COL_BG]; style->text[GTK_STATE_NORMAL] = colors[COL_FG]; +#endif return style; } @@ -460,7 +472,11 @@ fe_init (void) gtkosx_application_set_dock_icon_pixbuf (osx_app, pix_zoitechat); #endif channelwin_pix = pixmap_load_from_file (prefs.hex_text_background); +#if HAVE_GTK3 + input_style = create_input_style (input_style); +#else input_style = create_input_style (gtk_style_new ()); +#endif settings = gtk_settings_get_default (); if (settings) diff --git a/src/fe-gtk/fe-gtk.h b/src/fe-gtk/fe-gtk.h index 6d9ca0b1..fefb442d 100644 --- a/src/fe-gtk/fe-gtk.h +++ b/src/fe-gtk/fe-gtk.h @@ -48,6 +48,15 @@ #define flag_b flag_wid[7] #define NUM_FLAG_WIDS 8 +#if HAVE_GTK3 +typedef struct _input_style +{ + PangoFontDescription *font_desc; +} InputStyle; +#else +typedef GtkStyle InputStyle; +#endif + #ifdef HAVE_GTK_MAC extern GtkosxApplication *osx_app; #endif diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 18a9b23d..d15a3ff5 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -272,7 +272,7 @@ static const char chan_flags[] = { 'c', 'n', 't', 'i', 'm', 'l', 'k' }; static chan *active_tab = NULL; /* active tab */ GtkWidget *parent_window = NULL; /* the master window */ -GtkStyle *input_style; +InputStyle *input_style; static PangoAttrList *away_list; static PangoAttrList *newdata_list; diff --git a/src/fe-gtk/maingui.h b/src/fe-gtk/maingui.h index aaf5c2f8..9f7eae22 100644 --- a/src/fe-gtk/maingui.h +++ b/src/fe-gtk/maingui.h @@ -20,7 +20,7 @@ #ifndef ZOITECHAT_MAINGUI_H #define ZOITECHAT_MAINGUI_H -extern GtkStyle *input_style; +extern InputStyle *input_style; extern GtkWidget *parent_window; void mg_changui_new (session *sess, restore_gui *res, int tab, int focus); diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 1d64a68d..645bcb3c 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -48,7 +48,7 @@ #endif #include "sexy-spell-entry.h" -GtkStyle *create_input_style (GtkStyle *); +InputStyle *create_input_style (InputStyle *); #define LABEL_INDENT 12 @@ -2860,7 +2860,7 @@ setup_apply_to_sess (session_gui *gui) if (prefs.hex_gui_input_style) { -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 char buf[128]; GtkCssProvider *provider = gtk_css_provider_new (); GtkStyleContext *context;