pidgin/pidgin

Parents ba08026458f4
Children 9753153c49fc
Re-subclass PidginPresenceIcon onto GtkBox as GtkImage is final in Gtk4

Testing Done:
Verfied that the infopane showed the icon properly with no new warnings.

Reviewed at https://reviews.imfreedom.org/r/1413/
--- a/pidgin/pidginpresenceicon.c Tue May 03 02:32:33 2022 -0500
+++ b/pidgin/pidginpresenceicon.c Thu May 05 22:15:44 2022 -0500
@@ -25,7 +25,9 @@
#include "pidgin/pidginiconname.h"
struct _PidginPresenceIcon {
- GtkImage parent;
+ GtkBox parent;
+
+ GtkWidget *icon;
PurplePresence *presence;
gchar *fallback;
@@ -41,7 +43,7 @@
};
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
-G_DEFINE_TYPE(PidginPresenceIcon, pidgin_presence_icon, GTK_TYPE_IMAGE)
+G_DEFINE_TYPE(PidginPresenceIcon, pidgin_presence_icon, GTK_TYPE_BOX)
/******************************************************************************
* Implementation
@@ -52,7 +54,8 @@
icon_name = pidgin_icon_name_from_presence(icon->presence, icon->fallback);
- gtk_image_set_from_icon_name(GTK_IMAGE(icon), icon_name, icon->icon_size);
+ gtk_image_set_from_icon_name(GTK_IMAGE(icon->icon), icon_name,
+ icon->icon_size);
}
static void
@@ -121,13 +124,13 @@
static void
pidgin_presence_icon_init(PidginPresenceIcon *presenceicon) {
- /* Use the icon name fallback that we're expecting. */
- g_object_set(G_OBJECT(presenceicon), "use-fallback", TRUE, NULL);
+ gtk_widget_init_template(GTK_WIDGET(presenceicon));
}
static void
pidgin_presence_icon_class_init(PidginPresenceIconClass *klass) {
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
obj_class->finalize = pidgin_presence_icon_finalize;
obj_class->get_property = pidgin_presence_icon_get_property;
@@ -168,6 +171,14 @@
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+
+ gtk_widget_class_set_template_from_resource(
+ widget_class,
+ "/im/pidgin/Pidgin3/presenceicon.ui"
+ );
+
+ gtk_widget_class_bind_template_child(widget_class, PidginPresenceIcon,
+ icon);
}
/******************************************************************************
--- a/pidgin/pidginpresenceicon.h Tue May 03 02:32:33 2022 -0500
+++ b/pidgin/pidginpresenceicon.h Thu May 05 22:15:44 2022 -0500
@@ -42,7 +42,7 @@
#define PIDGIN_TYPE_PRESENCE_ICON (pidgin_presence_icon_get_type())
G_DECLARE_FINAL_TYPE(PidginPresenceIcon, pidgin_presence_icon,
- PIDGIN, PRESENCE_ICON, GtkImage)
+ PIDGIN, PRESENCE_ICON, GtkBox)
G_BEGIN_DECLS
--- a/pidgin/resources/Conversations/infopane.ui Tue May 03 02:32:33 2022 -0500
+++ b/pidgin/resources/Conversations/infopane.ui Thu May 05 22:15:44 2022 -0500
@@ -37,8 +37,6 @@
<object class="PidginPresenceIcon" id="presence_icon">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="icon-name">image-missing</property>
- <property name="use-fallback">True</property>
<property name="fallback">chat</property>
<property name="icon_size">3</property>
</object>
--- a/pidgin/resources/pidgin.gresource.xml Tue May 03 02:32:33 2022 -0500
+++ b/pidgin/resources/pidgin.gresource.xml Thu May 05 22:15:44 2022 -0500
@@ -37,6 +37,7 @@
<file compressed="true">Xfer/xfer.ui</file>
<file compressed="true">closebutton.ui</file>
<file compressed="true">gtk/menus.ui</file>
+ <file compressed="true">presenceicon.ui</file>
<file compressed="true">proxyoptions.ui</file>
<file compressed="true">statusprimitivechooser.ui</file>
<file>icons/16x16/status/pidgin-user-available.png</file>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/presenceicon.ui Thu May 05 22:15:44 2022 -0500
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Pidgin - Internet Messenger
+Copyright (C) Pidgin Developers <devel@pidgin.im>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, see <https://www.gnu.org/licenses/>.
+
+-->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <!-- interface-license-type gplv2 -->
+ <!-- interface-name Pidgin -->
+ <!-- interface-description Internet Messenger -->
+ <!-- interface-copyright Pidgin Developers <devel@pidgin.im> -->
+ <template class="PidginPresenceIcon" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkImage" id="icon">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">image-missing</property>
+ <property name="use-fallback">True</property>
+ <property name="icon_size">6</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </template>
+</interface>