Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Photo scrolling, arrow not disappears
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazar Taran committed Feb 2, 2021
1 parent 2112112 commit f74b4cb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/inc/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 420,7 @@ void instinct_event_button_click(GtkWidget *widget, GdkEventButton *event);
void valor_event_button_click(GtkWidget *widget, GdkEventButton *event);
void login_butt_click(GtkWidget *widget);
void reg_butt_click(GtkWidget *widget);
void arrow_click(GtkWidget *widget, GdkEventButton *event);
void arrow_click(GtkWidget *widget, GdkEventButton *event, GtkWidget* arrow);


#endif
18 changes: 18 additions & 0 deletions client/src/creator_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 28,14 @@ void *scrolling_sticker() {
return NULL;
}

void *scrolling_photo() {
usleep(100000);
GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(t_msg.scrolled_message));
gtk_adjustment_set_value(adjustment, G_MAXDOUBLE);
gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(t_msg.scrolled_message), adjustment);
return NULL;
}

void new_outgoing_message(GtkWidget *messages_block)
{
if(strcmp(msg_data.date, msg_data.date_prev))
Expand Down Expand Up @@ -233,6 241,11 @@ void new_outgoing_embedded(GtkWidget *messages_block, char* path)

gtk_container_set_focus_vadjustment(GTK_CONTAINER(embedded_body), NULL);
gtk_widget_show_all(GTK_WIDGET(embedded_body));

if (!upd_data.filling_init) {
pthread_t display_thread = NULL;
pthread_create(&display_thread, NULL, scrolling_photo, NULL);
}
}

void new_incoming_embedded(GtkWidget *messages_block, char* path)
Expand Down Expand Up @@ -273,4 286,9 @@ void new_incoming_embedded(GtkWidget *messages_block, char* path)

gtk_container_set_focus_vadjustment(GTK_CONTAINER(embedded_body), NULL);
gtk_widget_show_all(GTK_WIDGET(embedded_body));

if (!upd_data.filling_init) {
pthread_t display_thread = NULL;
pthread_create(&display_thread, NULL, scrolling_photo, NULL);
}
}
10 changes: 6 additions & 4 deletions client/src/events_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 274,8 @@ void msggroup_click(GtkWidget *widget, GdkEventButton *event, GtkWidget *main) {
creator_group(main);
}

static void *scrolling_to_bottom() {
static void *scrolling_to_bottom(void *p) {
GtkWidget *arrow = (GtkWidget*)p;
GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(t_msg.scrolled_message));
for (int i = 1; i <= 30; i ) {
gtk_adjustment_set_value(adjustment, gtk_adjustment_get_value(adjustment) i);
Expand All @@ -285,14 286,15 @@ static void *scrolling_to_bottom() {
gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(t_msg.scrolled_message), adjustment);
gtk_widget_hide(t_msg.scrolled_message);
gtk_widget_show(t_msg.scrolled_message);
gtk_widget_hide(arrow);
gtk_widget_show(arrow);
return NULL;
}

void arrow_click(GtkWidget *widget, GdkEventButton *event) {
printf("OK\n");
void arrow_click(GtkWidget *widget, GdkEventButton *event, GtkWidget *arrow) {
if(widget) {}
if(event->type == GDK_BUTTON_PRESS && event->button == 1) {
pthread_t scrolling_thread = NULL;
pthread_create(&scrolling_thread, NULL, scrolling_to_bottom, NULL);
pthread_create(&scrolling_thread, NULL, scrolling_to_bottom, (void*)arrow);
}
}
2 changes: 1 addition & 1 deletion client/src/screen_messanger.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 162,7 @@ static void build_entryfield(GtkWidget *main)

g_signal_connect(G_OBJECT(arrow), "enter-notify-event", G_CALLBACK(event_enter_notify), NULL);
g_signal_connect(G_OBJECT(arrow), "leave-notify-event", G_CALLBACK(event_leave_notify), NULL);
g_signal_connect(G_OBJECT(arrow), "button_press_event", G_CALLBACK(arrow_click), NULL);
g_signal_connect(G_OBJECT(arrow), "button_press_event", G_CALLBACK(arrow_click), arrow);
}

// static gboolean scrolled (GtkWidget *widget, GdkEventButton *event)
Expand Down
4 changes: 1 addition & 3 deletions client/src/updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 16,8 @@ static void generate_new_message(int user_id, int avatar, char *username, char *
if (user_id == t_account.id) {
if (text) {
msg_data.content = text;
msg_data.content_final = strdup(msg_data.content); // TODO эта хрень очень мешает, сделать переменную независимой, чтобы не пересекались инициализации
msg_data.content_final = strdup(msg_data.content);
new_outgoing_message(t_msg.chat_screen);
// mx_strdel(&msg_data.content_final);
}
else if (sticker)
new_outgoing_sticker(t_msg.chat_screen, sticker);
Expand All @@ -30,7 29,6 @@ static void generate_new_message(int user_id, int avatar, char *username, char *
msg_data.content = text;
msg_data.content_final = strdup(msg_data.content);
new_incoming_message(t_msg.chat_screen);
// mx_strdel(&msg_data.content_final);
}
else if (sticker)
new_incoming_sticker(t_msg.chat_screen, sticker);
Expand Down

0 comments on commit f74b4cb

Please sign in to comment.