talkatu/talkatu

Fix a few more things found in review

2020-06-30, Gary Kramlich
697faca1d847
Parents a831357ccddd
Children db6cb7b86ab3
Fix a few more things found in review
--- a/talkatu/talkatuattachment.c Mon Jun 29 20:43:52 2020 -0500
+++ b/talkatu/talkatuattachment.c Tue Jun 30 00:10:19 2020 -0500
@@ -248,7 +248,7 @@
*
* Gets the hash key of @attachment. This should only be used when
* trying to address a #TalkatuAttachment in a #GHashTable that is using
- * #g_int64_hash as the key function.
+ * g_int64_hash() as the key function.
*
* Returns: (transfer none): The hash key of @attachment.
*/
@@ -367,7 +367,7 @@
*/
void
talkatu_attachment_set_remote_uri(TalkatuAttachment *attachment,
- const gchar *remote_uri)
+ const gchar *remote_uri)
{
g_return_if_fail(TALKATU_IS_ATTACHMENT(attachment));
@@ -416,7 +416,7 @@
* talkatu_attachment_get_filename:
* @attachment: The #TalkatuAttachment instance.
*
- * Gets the base filename for @attachment. Remote URI will be check before
+ * Gets the base filename for @attachment. Remote URI will be checked before
* local URI, but the basename of one of those is what will be returned.
*
* Returns: (transfer full): The filename for @attachment.
@@ -425,15 +425,11 @@
talkatu_attachment_get_filename(TalkatuAttachment *attachment) {
g_return_val_if_fail(TALKATU_IS_ATTACHMENT(attachment), NULL);
- if(attachment->remote_uri != NULL &&
- g_utf8_strlen(attachment->remote_uri, -1) > 0)
- {
+ if(attachment->remote_uri != NULL && attachment->remote_uri[0] != '\0') {
return g_path_get_basename(attachment->remote_uri);
}
- if(attachment->local_uri != NULL &&
- g_utf8_strlen(attachment->local_uri, -1) > 0)
- {
+ if(attachment->local_uri != NULL && attachment->local_uri[0] != '\0') {
return g_path_get_basename(attachment->local_uri);
}
--- a/talkatu/talkatuattachmentdialog.c Mon Jun 29 20:43:52 2020 -0500
+++ b/talkatu/talkatuattachmentdialog.c Tue Jun 30 00:10:19 2020 -0500
@@ -24,7 +24,7 @@
* @Title: Attachment Dialog
* @Short_description: A GtkDialog for sending message attachments.
*
- * A #GtkDialog that allows the user to customize an attachments for a message.
+ * A #GtkDialog that allows the user to customize attachments for a message.
*/
/**
@@ -109,7 +109,7 @@
switch(prop_id) {
case PROP_ATTACHMENT:
- g_value_set_object(value, talkatu_attachment_dialog_get_attachment(dialog));
+ g_value_take_object(value, talkatu_attachment_dialog_get_attachment(dialog));
break;
case PROP_COMMENT:
g_value_set_string(value, talkatu_attachment_dialog_get_comment(dialog));
@@ -132,7 +132,7 @@
break;
case PROP_COMMENT:
talkatu_attachment_dialog_set_comment(dialog,
- g_value_get_string(value));
+ g_value_get_string(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
--- a/talkatu/talkatuattachmentpreview.c Mon Jun 29 20:43:52 2020 -0500
+++ b/talkatu/talkatuattachmentpreview.c Tue Jun 30 00:10:19 2020 -0500
@@ -111,7 +111,7 @@
switch(prop_id) {
case PROP_ATTACHMENT:
- g_value_set_object(value, talkatu_attachment_preview_get_attachment(preview));
+ g_value_take_object(value, talkatu_attachment_preview_get_attachment(preview));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
--- a/talkatu/talkatuinput.c Mon Jun 29 20:43:52 2020 -0500
+++ b/talkatu/talkatuinput.c Tue Jun 30 00:10:19 2020 -0500
@@ -189,6 +189,10 @@
talkatu_input_set_author(TalkatuInput *input, const gchar *author) {
TalkatuInputPrivate *priv = talkatu_input_get_instance_private(input);
+ if(author == priv->author) {
+ return;
+ }
+
g_clear_pointer(&priv->author, g_free);
priv->author = g_strdup(author);
@@ -474,6 +478,9 @@
error->message);
g_error_free(error);
+ g_io_stream_close(G_IO_STREAM(stream), NULL, NULL);
+ g_object_unref(G_OBJECT(stream));
+
return;
}
@@ -483,14 +490,18 @@
size = g_seekable_tell(G_SEEKABLE(ostream));
if(!g_io_stream_close(G_IO_STREAM(stream), NULL, &error)) {
+ g_object_unref(G_OBJECT(file));
+
g_warning("failed to save an image from the clipboard: %s",
error->message);
g_error_free(error);
+ g_object_unref(G_OBJECT(stream));
+
return;
}
- /* now create the message and it's attachment */
+ /* now create the message and its attachment */
input = GTK_WIDGET(data);
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(input));
comment = talkatu_markup_get_html(buffer, NULL);
@@ -501,7 +512,7 @@
talkatu_attachment_set_local_uri(attachment, filename);
g_free(filename);
- /* for the remote side, we're set the filename to something
+ /* for the remote side, we'll set the filename to something
* non-descriptive.
*/
talkatu_attachment_set_remote_uri(attachment, "unknown.png");
@@ -515,6 +526,7 @@
g_object_unref(G_OBJECT(file));
g_free(comment);
+ g_object_unref(G_OBJECT(stream));
}
/******************************************************************************