Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mohammed Sadiq
chatty
Commits
7ada1150
Commit
7ada1150
authored
Jan 10, 2022
by
Mohammed Sadiq
Committed by
Mohammed Sadiq
Jan 16, 2022
Browse files
list-row: Add close button
And an API to show it when required
parent
f460cc1b
Pipeline
#74328
passed with stages
in 12 minutes and 49 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/chatty-list-row.c
View file @
7ada1150
...
...
@@ -18,6 +18,7 @@
#include
"chatty-purple.h"
#include
"chatty-contact.h"
#include
"chatty-contact-list.h"
#include
"chatty-chat.h"
#include
"chatty-avatar.h"
#include
"chatty-list-row.h"
...
...
@@ -39,6 +40,7 @@ struct _ChattyListRow
GtkWidget
*
last_modified
;
GtkWidget
*
unread_message_count
;
GtkWidget
*
checkbox
;
GtkWidget
*
close_button
;
GtkWidget
*
add_contact_button
;
GtkWidget
*
call_button
;
...
...
@@ -382,6 +384,24 @@ write_eds_contact_cb (GObject *object,
}
}
static
void
chatty_list_row_delete_clicked_cb
(
ChattyListRow
*
self
)
{
GtkWidget
*
scrolled
,
*
list
;
g_assert
(
CHATTY_IS_LIST_ROW
(
self
));
/* We can't directly use CHATTY_TYPE_CONTACT_LIST as it's not linked with the shared library */
scrolled
=
gtk_widget_get_ancestor
(
GTK_WIDGET
(
self
),
GTK_TYPE_SCROLLED_WINDOW
);
if
(
!
scrolled
)
return
;
list
=
gtk_widget_get_parent
(
scrolled
);
if
(
list
)
g_signal_emit_by_name
(
list
,
"delete-row"
,
self
);
}
static
void
chatty_list_row_add_contact_clicked_cb
(
ChattyListRow
*
self
)
{
...
...
@@ -434,6 +454,7 @@ chatty_list_row_class_init (ChattyListRowClass *klass)
"ui/chatty-list-row.ui"
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
avatar
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
checkbox
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
close_button
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
title
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
subtitle
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
last_modified
);
...
...
@@ -441,6 +462,7 @@ chatty_list_row_class_init (ChattyListRowClass *klass)
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
add_contact_button
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyListRow
,
call_button
);
gtk_widget_class_bind_template_callback
(
widget_class
,
chatty_list_row_delete_clicked_cb
);
gtk_widget_class_bind_template_callback
(
widget_class
,
chatty_list_row_add_contact_clicked_cb
);
gtk_widget_class_bind_template_callback
(
widget_class
,
chatty_list_row_call_button_clicked_cb
);
}
...
...
@@ -560,3 +582,12 @@ chatty_list_row_set_call (ChattyListRow *self, gboolean enable)
}
else
gtk_widget_hide
(
self
->
call_button
);
}
void
chatty_list_row_show_delete_button
(
ChattyListRow
*
self
)
{
g_return_if_fail
(
CHATTY_IS_LIST_ROW
(
self
));
gtk_widget_show
(
self
->
close_button
);
gtk_widget_hide
(
self
->
checkbox
);
}
src/chatty-list-row.h
View file @
7ada1150
...
...
@@ -32,5 +32,6 @@ void chatty_list_row_set_contact (ChattyListRow *self,
gboolean
enable
);
void
chatty_list_row_set_call
(
ChattyListRow
*
self
,
gboolean
enable
);
void
chatty_list_row_show_delete_button
(
ChattyListRow
*
self
);
G_END_DECLS
src/ui/chatty-list-row.ui
View file @
7ada1150
...
...
@@ -98,6 +98,29 @@
</packing>
</child>
<!-- Close Button -->
<child>
<object
class=
"GtkButton"
id=
"close_button"
>
<property
name=
"visible"
>
0
</property>
<signal
name=
"clicked"
handler=
"chatty_list_row_delete_clicked_cb"
swapped=
"yes"
/>
<style>
<class
name=
"circular"
/>
<class
name=
"flat"
/>
</style>
<child>
<object
class=
"GtkImage"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"width-request"
>
32
</property>
<property
name=
"height-request"
>
32
</property>
<property
name=
"icon_name"
>
edit-delete-symbolic
</property>
</object>
</child>
</object>
<packing>
<property
name=
"height"
>
2
</property>
</packing>
</child>
<!-- Add Contact -->
<child>
<object
class=
"GtkButton"
id=
"add_contact_button"
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment