[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Cleanup AddTitle/AddText + fix deprecation warnings
From: |
Nikolas Nyby |
Subject: |
[PATCH] Cleanup AddTitle/AddText + fix deprecation warnings |
Date: |
Sun, 12 May 2024 15:34:27 -0400 |
These functions were using the deprecated gtk_rc_style_new, which we can
replace with GtkStyleContext. However, the styles being set here weren't
having any actual effect in the UI, and I think we can just remove the
style modifications altogether. All this code is doing is setting some
simple text displays.
Also, I refactored out AddTitle() in gtkgame.c, as this function was doing
the exact same thing as AddText().
---
gtkgame.c | 35 +++--------------------------------
gtkscoremap.c | 36 +-----------------------------------
2 files changed, 4 insertions(+), 67 deletions(-)
diff --git a/gtkgame.c b/gtkgame.c
index 03ea764e..1e3777e7 100644
--- a/gtkgame.c
+++ b/gtkgame.c
@@ -2970,7 +2970,6 @@ CreateEvalSettings(GtkWidget * pwParent, const char
*title, evalcontext * pecheq
extern void
AddText(GtkWidget* pwBox, char* Text)
{
- GtkRcStyle * ps = gtk_rc_style_new();
GtkWidget * pwText = gtk_label_new(Text);
GtkWidget * pwHBox;
@@ -2979,14 +2978,8 @@ AddText(GtkWidget* pwBox, char* Text)
#else
pwHBox = gtk_hbox_new(FALSE, 0);
#endif
- gtk_box_pack_start(GTK_BOX(pwBox), pwHBox, FALSE, FALSE, 4);
-
- ps->font_desc = pango_font_description_new();
- //pango_font_description_set_family_static(ps->font_desc, "serif");
- //pango_font_description_set_size(ps->font_desc, 8 * PANGO_SCALE);
- gtk_widget_modify_style(pwText, ps);
- g_object_unref(ps);
+ gtk_box_pack_start(GTK_BOX(pwBox), pwHBox, FALSE, FALSE, 4);
gtk_box_pack_start(GTK_BOX(pwHBox), pwText, FALSE, FALSE, 0);
}
@@ -7127,28 +7120,6 @@ GTKShowBuildInfo(GtkWidget * UNUSED(pw), GtkWidget *
pwParent)
/* Stores names in credits so not duplicated in list at bottom */
static listOLD names;
-static void
-AddTitle(GtkWidget * pwBox, char *Title)
-{
- GtkRcStyle *ps = gtk_rc_style_new();
- GtkWidget *pwTitle = gtk_label_new(Title), *pwHBox;
-
-#if GTK_CHECK_VERSION(3,0,0)
- pwHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- pwHBox = gtk_hbox_new(FALSE, 0);
-#endif
- gtk_box_pack_start(GTK_BOX(pwBox), pwHBox, FALSE, FALSE, 4);
-
- ps->font_desc = pango_font_description_new();
- pango_font_description_set_family_static(ps->font_desc, "serif");
- pango_font_description_set_size(ps->font_desc, 16 * PANGO_SCALE);
- gtk_widget_modify_style(pwTitle, ps);
- g_object_unref(ps);
-
- gtk_box_pack_start(GTK_BOX(pwHBox), pwTitle, TRUE, FALSE, 0);
-}
-
static void
AddName(GtkWidget * pwBox, char *name, const char *type)
{
@@ -7230,7 +7201,7 @@ GTKCommandShowCredits(GtkWidget * UNUSED(pw), GtkWidget *
pwParent)
#endif
gtk_box_pack_start(GTK_BOX(pwHBox), pwVBox, TRUE, FALSE, 0);
- AddTitle(pwVBox, _(credit->Title));
+ AddText(pwVBox, _(credit->Title));
ce = credit->Entry;
while (ce->Name) {
@@ -7254,7 +7225,7 @@ GTKCommandShowCredits(GtkWidget * UNUSED(pw), GtkWidget *
pwParent)
#endif
gtk_box_pack_start(GTK_BOX(pwMainHBox), pwVBox, FALSE, FALSE, 0);
- AddTitle(pwVBox, _("Special thanks"));
+ AddText(pwVBox, _("Special thanks"));
/* create list store */
store = gtk_list_store_new(1, G_TYPE_STRING);
diff --git a/gtkscoremap.c b/gtkscoremap.c
index 4b9da8ef..20c1adfe 100644
--- a/gtkscoremap.c
+++ b/gtkscoremap.c
@@ -2710,11 +2710,6 @@ Allows garbage collection.
static void
AddText(GtkWidget* pwBox, char* Text)
{
- /* TBD: gtk_rc_style_new is deprecated in GTK3.0:
- "warning: 'gtk_rc_style_new' is deprecated: Use 'GtkStyleContext' instead"
- same for gtk_widget_modify_style below
- */
- GtkRcStyle * ps = gtk_rc_style_new();
GtkWidget * pwText = gtk_label_new(Text);
GtkWidget * pwHBox;
@@ -2723,40 +2718,11 @@ AddText(GtkWidget* pwBox, char* Text)
#else
pwHBox = gtk_hbox_new(FALSE, 0);
#endif
- gtk_box_pack_start(GTK_BOX(pwBox), pwHBox, FALSE, FALSE, 4);
-
- ps->font_desc = pango_font_description_new();
- //pango_font_description_set_family_static(ps->font_desc, "serif");
- pango_font_description_set_size(ps->font_desc, 8 * PANGO_SCALE);
- gtk_widget_modify_style(pwText, ps);
- g_object_unref(ps);
+ gtk_box_pack_start(GTK_BOX(pwBox), pwHBox, FALSE, FALSE, 4);
gtk_box_pack_start(GTK_BOX(pwHBox), pwText, TRUE, FALSE, 0);
}
-////Module to add text, based on AddTitle from gtkgame.c
-//static void
-//AddVText(GtkWidget* pwBox, char* Text)
-//{
-// GtkRcStyle* ps = gtk_rc_style_new();
-// GtkWidget* pwText = gtk_label_new(Text), * pwVBox;
-//
-//#if GTK_CHECK_VERSION(3,0,0)
-// pwVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-//#else
-// pwVBox = gtk_vbox_new(FALSE, 0);
-//#endif
-// gtk_box_pack_start(GTK_BOX(pwBox), pwVBox, FALSE, FALSE, 4);
-//
-// ps->font_desc = pango_font_description_new();
-// //pango_font_description_set_family_static(ps->font_desc, "serif");
-// pango_font_description_set_size(ps->font_desc, 8 * PANGO_SCALE);
-// gtk_widget_modify_style(pwText, ps);
-// g_object_unref(ps);
-//
-// gtk_box_pack_start(GTK_BOX(pwVBox), pwText, TRUE, FALSE, 0);
-//}
-
// display info on move scoremap
extern void
GTKShowMoveScoreMapInfo(GtkWidget* UNUSED(pw), GtkWidget* pwParent)
--
2.45.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Cleanup AddTitle/AddText + fix deprecation warnings,
Nikolas Nyby <=