talkatu/talkatu

Convert attachment preview to GTK4
gtk4
2022-01-29, Elliott Sales de Andrade
0cef8587d507
Parents ca193e4176a8
Children f9511fd0e4ac
Convert attachment preview to GTK4

Converted the `.ui` and source files to GTK 4.

Testing Done:
Compiled this file only. Checked in GTK builder preview only.

Reviewed at https://reviews.imfreedom.org/r/1250/
--- a/talkatu/data/attachmentpreview.ui Sun Jan 16 01:56:34 2022 -0600
+++ b/talkatu/data/attachmentpreview.ui Sat Jan 29 21:49:25 2022 -0600
@@ -19,112 +19,62 @@
-->
<interface>
- <requires lib="gtk+" version="3.18"/>
+ <requires lib="gtk" version="4.0"/>
<!-- interface-license-type gplv2 -->
<!-- interface-name Talkatu -->
<!-- interface-description GTK widgets for chat applications -->
<!-- interface-copyright Gary Kramlich <grim@reaperworld.com> -->
- <template class="TalkatuAttachmentPreview" parent="GtkInfoBar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">none</property>
- <signal name="clicked" handler="talkatu_attachment_preview_download_cb" object="TalkatuAttachmentPreview" swapped="no"/>
+ <template class="TalkatuAttachmentPreview" parent="GtkWidget">
+ <child>
+ <object class="GtkInfoBar">
+ <property name="hexpand">1</property>
+ <signal name="response" handler="talkatu_attachment_preview_download_cb" object="TalkatuAttachmentPreview" swapped="no"/>
+ <child type="action">
+ <object class="GtkButton" id="download_button">
<child>
<object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="icon_name">document-save-symbolic</property>
- <property name="icon_size">5</property>
</object>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- <property name="non_homogeneous">True</property>
- </packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child internal-child="content_area">
- <object class="GtkBox">
- <property name="can_focus">False</property>
- <property name="spacing">16</property>
- <child>
- <object class="GtkImage" id="preview">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">text-x-generic</property>
- <property name="icon_size">6</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <action-widgets>
+ <action-widget response="0">download_button</action-widget>
+ </action-widgets>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
+ <property name="can_focus">0</property>
+ <property name="spacing">16</property>
<child>
- <object class="GtkLabel" id="filename">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">unknown</property>
- <property name="xalign">0</property>
+ <object class="GtkImage" id="preview">
+ <property name="can_focus">0</property>
+ <property name="icon_name">text-x-generic</property>
+ <property name="icon_size">large</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
- <object class="GtkLabel" id="filesize">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
+ <object class="GtkBox">
+ <property name="hexpand">1</property>
+ <property name="can_focus">0</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="filename">
+ <property name="can_focus">0</property>
+ <property name="label" translatable="yes">unknown</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="filesize">
+ <property name="can_focus">0</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <placeholder/>
</child>
</template>
</interface>
--- a/talkatu/talkatuattachmentpreview.c Sun Jan 16 01:56:34 2022 -0600
+++ b/talkatu/talkatuattachmentpreview.c Sat Jan 29 21:49:25 2022 -0600
@@ -27,7 +27,7 @@
* user to save it.
*/
struct _TalkatuAttachmentPreview {
- GtkInfoBar parent;
+ GtkWidget parent;
TalkatuAttachment *attachment;
@@ -47,9 +47,11 @@
/******************************************************************************
* Callbacks
*****************************************************************************/
-static gboolean
-talkatu_attachment_preview_download_cb(GtkButton *button, gpointer data) {
- return FALSE;
+static void
+talkatu_attachment_preview_download_cb(G_GNUC_UNUSED GtkInfoBar *self,
+ G_GNUC_UNUSED gint response_id,
+ G_GNUC_UNUSED gpointer user_data)
+{
}
/******************************************************************************
@@ -66,8 +68,7 @@
gchar *filesize = NULL;
if(G_IS_ICON(icon)) {
- gtk_image_set_from_gicon(GTK_IMAGE(preview->preview), icon,
- GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_from_gicon(GTK_IMAGE(preview->preview), icon);
g_object_unref(G_OBJECT(icon));
}
@@ -88,7 +89,7 @@
/******************************************************************************
* GObject Implementation
*****************************************************************************/
-G_DEFINE_TYPE(TalkatuAttachmentPreview, talkatu_attachment_preview, GTK_TYPE_INFO_BAR)
+G_DEFINE_TYPE(TalkatuAttachmentPreview, talkatu_attachment_preview, GTK_TYPE_WIDGET)
static void
talkatu_attachment_preview_get_property(GObject *obj, guint prop_id,
--- a/talkatu/talkatuattachmentpreview.h Sun Jan 16 01:56:34 2022 -0600
+++ b/talkatu/talkatuattachmentpreview.h Sat Jan 29 21:49:25 2022 -0600
@@ -33,7 +33,7 @@
G_BEGIN_DECLS
#define TALKATU_TYPE_ATTACHMENT_PREVIEW (talkatu_attachment_preview_get_type())
-G_DECLARE_FINAL_TYPE(TalkatuAttachmentPreview, talkatu_attachment_preview, TALKATU, ATTACHMENT_PREVIEW, GtkInfoBar)
+G_DECLARE_FINAL_TYPE(TalkatuAttachmentPreview, talkatu_attachment_preview, TALKATU, ATTACHMENT_PREVIEW, GtkWidget)
GtkWidget *talkatu_attachment_preview_new(TalkatuAttachment *attachment);