Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Krzyszkowiak
chatty
Commits
52236fdb
Verified
Commit
52236fdb
authored
Oct 07, 2021
by
Sebastian Krzyszkowiak
Browse files
chatty-pp-chat-info: Use GtkFileChooserNative
parent
99d992e0
Pipeline
#71819
passed with stages
in 9 minutes and 51 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/dialogs/chatty-pp-chat-info.c
View file @
52236fdb
...
...
@@ -65,8 +65,6 @@ struct _ChattyPpChatInfo
GtkWidget
*
user_list_label
;
GtkWidget
*
user_list
;
GtkWidget
*
avatar_chooser_dialog
;
GBinding
*
binding
;
gulong
avatar_changed_id
;
};
...
...
@@ -76,20 +74,29 @@ G_DEFINE_TYPE (ChattyPpChatInfo, chatty_pp_chat_info, HDY_TYPE_PREFERENCES_PAGE)
static
void
pp_info_edit_avatar_button_clicked_cb
(
ChattyPpChatInfo
*
self
)
{
g_autoptr
(
GtkFileChooserNative
)
dialog
=
NULL
;
g_autoptr
(
GtkFileFilter
)
filter
=
NULL
;
GtkWindow
*
window
;
GtkDialog
*
dialog
;
g_autofree
char
*
file_name
=
NULL
;
int
response
;
g_assert
(
CHATTY_IS_PP_CHAT_INFO
(
self
));
window
=
(
GtkWindow
*
)
gtk_widget_get_ancestor
(
GTK_WIDGET
(
self
),
GTK_TYPE_WINDOW
);
dialog
=
GTK_DIALOG
(
self
->
avatar_chooser_dialog
);
gtk_window_set_transient_for
(
GTK_WINDOW
(
dialog
),
window
);
response
=
gtk_dialog_run
(
dialog
);
gtk_widget_hide
(
GTK_WIDGET
(
dialog
));
dialog
=
gtk_file_chooser_native_new
(
_
(
"Set Avatar"
),
GTK_WINDOW
(
window
),
GTK_FILE_CHOOSER_ACTION_OPEN
,
_
(
"Open"
),
_
(
"Cancel"
));
filter
=
gtk_file_filter_new
();
gtk_file_filter_add_mime_type
(
filter
,
"image/*"
);
gtk_file_filter_set_name
(
filter
,
_
(
"Images"
));
gtk_file_chooser_add_filter
(
GTK_FILE_CHOOSER
(
dialog
),
filter
);
response
=
gtk_native_dialog_run
(
GTK_NATIVE_DIALOG
(
dialog
));
if
(
response
==
GTK_RESPONSE_A
PPLY
)
if
(
response
==
GTK_RESPONSE_A
CCEPT
)
file_name
=
gtk_file_chooser_get_filename
(
GTK_FILE_CHOOSER
(
dialog
));
if
(
file_name
)
...
...
@@ -397,7 +404,6 @@ chatty_pp_chat_info_class_init (ChattyPpChatInfoClass *klass)
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyPpChatInfo
,
user_list_label
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyPpChatInfo
,
user_list
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyPpChatInfo
,
avatar_chooser_dialog
);
gtk_widget_class_bind_template_child
(
widget_class
,
ChattyPpChatInfo
,
topic_buffer
);
gtk_widget_class_bind_template_callback
(
widget_class
,
pp_info_edit_avatar_button_clicked_cb
);
...
...
@@ -410,7 +416,7 @@ chatty_pp_chat_info_class_init (ChattyPpChatInfoClass *klass)
static
void
chatty_pp_chat_info_init
(
ChattyPpChatInfo
*
self
)
{
GtkWidget
*
clamp
,
*
window
;
GtkWidget
*
clamp
;
gtk_widget_init_template
(
GTK_WIDGET
(
self
));
...
...
@@ -420,12 +426,6 @@ chatty_pp_chat_info_init (ChattyPpChatInfo *self)
hdy_clamp_set_maximum_size
(
HDY_CLAMP
(
clamp
),
360
);
hdy_clamp_set_tightening_threshold
(
HDY_CLAMP
(
clamp
),
320
);
}
window
=
gtk_widget_get_ancestor
(
self
->
avatar
,
GTK_TYPE_DIALOG
);
if
(
window
)
gtk_window_set_transient_for
(
GTK_WINDOW
(
self
->
avatar_chooser_dialog
),
GTK_WINDOW
(
window
));
}
GtkWidget
*
...
...
src/ui/chatty-pp-chat-info.ui
View file @
52236fdb
...
...
@@ -418,35 +418,6 @@
</child>
</template>
<object
class=
"GtkFileChooserDialog"
id=
"avatar_chooser_dialog"
>
<property
name=
"modal"
>
1
</property>
<property
name=
"filter"
>
image_filter
</property>
<property
name=
"title"
translatable=
"yes"
>
Set Avatar
</property>
<signal
name=
"delete-event"
handler=
"gtk_widget_hide_on_delete"
/>
<child
type=
"action"
>
<object
class=
"GtkButton"
id=
"avatar_cancel_button"
>
<property
name=
"visible"
>
1
</property>
<property
name=
"label"
translatable=
"yes"
>
Cancel
</property>
</object>
</child>
<child
type=
"action"
>
<object
class=
"GtkButton"
id=
"avatar_apply_button"
>
<property
name=
"visible"
>
1
</property>
<property
name=
"can-default"
>
1
</property>
<property
name=
"label"
translatable=
"yes"
>
Open
</property>
</object>
</child>
<action-widgets>
<action-widget
response=
"cancel"
>
avatar_cancel_button
</action-widget>
<action-widget
response=
"apply"
default=
"true"
>
avatar_apply_button
</action-widget>
</action-widgets>
</object>
<object
class=
"GtkFileFilter"
id=
"image_filter"
>
<mime-types>
<mime-type>
image/*
</mime-type>
</mime-types>
</object>
<object
class=
"GtkTextBuffer"
id=
"topic_buffer"
/>
...
...
Write
Preview
Markdown
is supported
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