diff --git a/client/data/img/logo.png b/client/data/img/logo.png new file mode 100644 index 0000000..2a33cbf Binary files /dev/null and b/client/data/img/logo.png differ diff --git a/client/data/img/send.png b/client/data/img/send.png index 5df975f..9293a6e 100644 Binary files a/client/data/img/send.png and b/client/data/img/send.png differ diff --git a/client/data/img/send2.png b/client/data/img/send2.png deleted file mode 100644 index c503527..0000000 Binary files a/client/data/img/send2.png and /dev/null differ diff --git a/client/data/img/send3.png b/client/data/img/send3.png deleted file mode 100644 index 9293a6e..0000000 Binary files a/client/data/img/send3.png and /dev/null differ diff --git a/client/data/styles/button.css b/client/data/styles/button.css index fa13218..3c8ec45 100644 --- a/client/data/styles/button.css +++ b/client/data/styles/button.css @@ -93,7 +93,7 @@ .input-msg_send-btn { border-radius: 50%; - background-image: url("../img/send3.png"); + background-image: url("../img/send.png"); background-size: 25px 25px; background-position: 50% 50%; background-repeat: no-repeat; diff --git a/client/inc/client.h b/client/inc/client.h index c4e5a4d..bf9c43c 100644 --- a/client/inc/client.h +++ b/client/inc/client.h @@ -36,6 +36,7 @@ t_avatar_color get_avatar_color(); void handle_error(const char* error); //GUI UTILS +void load_css(); void on_crossing (GtkWidget *widget, GdkEventCrossing *event); void add_class(GtkWidget *widget, char *class_name); void remove_class(GtkWidget *widget, char *class_name); @@ -52,7 +53,7 @@ char *ellipsis_str(const char *str, int overflow_len); GtkWidget* create_new_window(char *title, int width, int height, bool resizable); GtkWidget *create_popup_window(int width, int height); void destroy_popup_window(GtkWidget *widget, gpointer chat_screen); -void build_authorizatioin_window(); +void build_authorization_window(); void build_chat_window(); //DRAW AVATAR diff --git a/client/src/client.c b/client/src/client.c index 1c4694d..69bcd80 100644 --- a/client/src/client.c +++ b/client/src/client.c @@ -18,13 +18,11 @@ int main(int argc, char **argv) { gtk_init(&argc, &argv); - // CSS - GtkCssProvider *styles = gtk_css_provider_new(); - gtk_css_provider_load_from_path(styles, "client/data/styles/main.css", NULL); - gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(styles), GTK_STYLE_PROVIDER_PRIORITY_USER); - // + load_css(); + build_authorization_window(); - build_authorizatioin_window(); + // gtk_window_set_icon_from_file(GTK_WINDOW(main_window), "client/data/img/logo.png", NULL); + // gtk_window_set_icon_name(GTK_WINDOW(main_window), "UChat"); pthread_create(&utils->th_reader, NULL, handle_server_updates, utils); diff --git a/client/src/gui/build_windows.c b/client/src/gui/build_windows.c index b1dbac9..92486f4 100644 --- a/client/src/gui/build_windows.c +++ b/client/src/gui/build_windows.c @@ -23,12 +23,12 @@ GtkWidget* create_new_window(char *title, int width, int height, bool resizable) return window; } -void build_authorizatioin_window() +void build_authorization_window() { if (main_window) gtk_widget_destroy(main_window); - main_window = create_new_window("login", 500, 0, false); + main_window = create_new_window("Authorization", 500, 0, false); GtkWidget* main_area = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_name(main_area, "main_area"); diff --git a/client/src/gui/delete_account_event.c b/client/src/gui/delete_account_event.c index e7215bc..0961aea 100644 --- a/client/src/gui/delete_account_event.c +++ b/client/src/gui/delete_account_event.c @@ -6,7 +6,7 @@ void delete_account_btn_click(GtkWidget *widget, gpointer data) { if (handle_delete_account_request() == R_SUCCESS) { client_cleanup(false); - build_authorizatioin_window(); + build_authorization_window(); } } diff --git a/client/src/gui/draw_avatar.c b/client/src/gui/draw_avatar.c index d95c32f..6437a04 100644 --- a/client/src/gui/draw_avatar.c +++ b/client/src/gui/draw_avatar.c @@ -3,7 +3,6 @@ gboolean draw_user_avatar(GtkWidget *widget, cairo_t *cr, gpointer data) { if (widget) {} - // (void)data; int avatar_color = (int)data; char *path = "client/data/img/user_avatars/avatar"; @@ -36,35 +35,6 @@ gboolean draw_user_avatar(GtkWidget *widget, cairo_t *cr, gpointer data) return FALSE; } -// gboolean draw_message_avatar(GtkWidget *widget, cairo_t *cr, gpointer data) -// { -// if (widget) {} -// t_msg *message = (t_msg*)data; - -// GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_scale(message->avatar_path, 27, 27, FALSE, NULL); -// gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); -// g_object_unref(G_OBJECT(pixbuf)); - -// double x = 0; -// double y = 0; -// double width = 27; -// double height = 27; -// double aspect = 1.0; -// double corner_radius = height / 2.0; -// double radius = corner_radius / aspect; -// double degrees = 3.14159265358979 / 180.0; - -// cairo_new_sub_path (cr); -// cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees); -// cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees); -// cairo_arc (cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees); -// cairo_arc (cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees); -// cairo_close_path (cr); - -// cairo_fill(cr); -// return FALSE; -// } - gboolean draw_chat_avatar(GtkWidget *widget, cairo_t *cr, gpointer data) { if (widget) {} diff --git a/client/src/gui/gui_utils.c b/client/src/gui/gui_utils.c index 4b10857..67fdd57 100644 --- a/client/src/gui/gui_utils.c +++ b/client/src/gui/gui_utils.c @@ -1,5 +1,12 @@ #include "../../inc/client.h" +void load_css() +{ + GtkCssProvider *styles = gtk_css_provider_new(); + gtk_css_provider_load_from_path(styles, "client/data/styles/main.css", NULL); + gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(styles), GTK_STYLE_PROVIDER_PRIORITY_USER); +} + void add_class(GtkWidget *widget, char *class_name) { GtkStyleContext *context = gtk_widget_get_style_context(widget); diff --git a/client/src/gui/logout_event.c b/client/src/gui/logout_event.c index b86c2f3..d11bf91 100644 --- a/client/src/gui/logout_event.c +++ b/client/src/gui/logout_event.c @@ -9,14 +9,9 @@ void logout_btn_click(GtkWidget *widget, gpointer data) handle_logout_request(false); client_cleanup(false); pthread_create(&utils->th_reader, NULL, handle_server_updates, NULL); - build_authorizatioin_window(); + build_authorization_window(); } -// void cancel_btn_click(GtkWidget *widget, gpointer data) { -// GtkWidget *toplevel = gtk_widget_get_toplevel(widget); -// gtk_widget_destroy(toplevel); -// } - void build_confirm_logout_window(GtkWidget *widget, gpointer data) { if(widget){} (void)data; diff --git a/client/src/gui/update_chat_field.c b/client/src/gui/update_chat_field.c index 95d953f..68d28de 100644 --- a/client/src/gui/update_chat_field.c +++ b/client/src/gui/update_chat_field.c @@ -14,7 +14,7 @@ void add_message(t_msg *message) { GtkWidget *avatar = gtk_drawing_area_new(); gtk_widget_set_size_request(GTK_WIDGET(avatar), 27, 27); - // g_signal_connect(G_OBJECT(avatar), "draw", G_CALLBACK(draw_message_avatar), message->); // Получить avatar пользовтеля + g_signal_connect(G_OBJECT(avatar), "draw", G_CALLBACK(draw_user_avatar), (gpointer)message->avatar_color); // Получить avatar пользовтеля gtk_widget_set_halign(avatar, cur_user ? GTK_ALIGN_START : GTK_ALIGN_END); gtk_widget_set_valign(avatar, GTK_ALIGN_START); if (!cur_user) {