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

Commit

Permalink
New notification function added. Alpha 0.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
PAXANDDOS committed Jan 25, 2021
1 parent 919a476 commit 55bc447
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 55 deletions.
37 changes: 36 additions & 1 deletion client/data/css/auth.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,39 @@
#valor_event:link #team_valor_selection
{
box-shadow: inset 0 0 0 1.5px #ff0500;
}
}

#notification_body
{
transition: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
border-radius: 10px;
background-color: #39456d;
box-shadow: inset 0 0 0 2.5px #4564a7;
}
#notification_body_error
{
transition: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
border-radius: 10px;
background-color: #f04848;
box-shadow: inset 0 0 0 2.5px #ac3434;
}
#notification_box
{
padding: 6px;
}
#notification_text
{
font-family: Rubik, 'Uni Sans', 'Helvetica Neue Light', sans-serif;
font-weight: 600;
font-size: 15px;
letter-spacing: 0.9px;
color: #e7ecff;
}
#notification_text_error
{
font-family: Rubik, 'Uni Sans', 'Helvetica Neue Light', sans-serif;
font-weight: 600;
font-size: 15px;
letter-spacing: 0.9px;
color: #ebebee;
}
21 changes: 20 additions & 1 deletion client/data/css/themes/default/home_default.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,23 @@
#active_name
{
color: #8f9ed1;
}
}

#notification_body
{
background-color: #39456d;
box-shadow: inset 0 0 0 2.5px #4564a7;
}
#notification_body_error
{
background-color: #f04848;
box-shadow: inset 0 0 0 2.5px #ac3434;
}
#notification_text
{
color: #e7ecff;
}
#notification_text_error
{
color: #ebebee;
}
3 changes: 3 additions & 0 deletions client/inc/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@
//-------> Overall
struct {
GtkWidget *window;
GtkWidget *main_area;
GtkWidget *auth;
GtkWidget *messanger;
GtkWidget *notificaton;
char *app;
char *user;
} t_application;
Expand Down Expand Up @@ -298,6 +300,7 @@ void create_gallery(GtkWidget *main);
void create_stickerlist(GtkWidget *main);
void creator_group(GtkWidget *main);
void creator_userprofile(GtkWidget *main, char *username, bool status);
void create_notification(GtkWidget *widget, char *text, short type, int x, int y, int w, int h);

char *get_avatar_by_number(int num);
GdkPixbuf *create_pixbuf(const gchar *filename);
Expand Down
10 changes: 5 additions & 5 deletions client/src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ int main(int argc, char *argv[]) {
gtk_window_set_icon(GTK_WINDOW(t_application.window), icon); // Setting icon to window

load_providers(); // Loading chosen CSS providers
GtkWidget *main_area = gtk_fixed_new(); // Creating main area
gtk_container_add(GTK_CONTAINER(t_application.window), main_area); // Applying main area to current window
gtk_widget_set_size_request(GTK_WIDGET(main_area), WINDOW_WIDTH, WINDOW_HEIGHT);// Setting size
t_application.main_area = gtk_fixed_new(); // Creating main area
gtk_container_add(GTK_CONTAINER(t_application.window), t_application.main_area); // Applying main area to current window
gtk_widget_set_size_request(GTK_WIDGET(t_application.main_area), WINDOW_WIDTH, WINDOW_HEIGHT);// Setting size

t_application.auth = gtk_fixed_new();
gtk_fixed_put(GTK_FIXED(main_area), t_application.auth, 0, 0);
gtk_fixed_put(GTK_FIXED(t_application.main_area), t_application.auth, 0, 0);
gtk_widget_set_size_request(GTK_WIDGET(t_application.auth), WINDOW_WIDTH, WINDOW_HEIGHT);

t_application.messanger = gtk_fixed_new();
gtk_fixed_put(GTK_FIXED(main_area), t_application.messanger, 0, 0);
gtk_fixed_put(GTK_FIXED(t_application.main_area), t_application.messanger, 0, 0);
gtk_widget_set_size_request(GTK_WIDGET(t_application.messanger), WINDOW_WIDTH, WINDOW_HEIGHT);

test_autofill(); // Заполнение данных аккаунта // Оставь это
Expand Down
2 changes: 1 addition & 1 deletion client/src/client_auto.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ void test_autofill()

t_msg.current = "here..."; // Имя выбранного пользователя в плейсхолдере

t_application.app = "PokeChat alpha 0.8.4";
t_application.app = "PokeChat alpha 0.8.6";
t_application.user = getenv("USER");
}
12 changes: 2 additions & 10 deletions client/src/creator_gallery.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ static void avatar_click(GtkWidget *widget) {
g_list_free(g_steal_pointer(&parent)); // g_list_free(parent); //
}

static void sgallery_click(GtkWidget *widget) {
gtk_widget_destroy(GTK_WIDGET(widget));
}

static void sgallery2_click(GtkWidget *widget) {
if(widget) {}
}

static GtkWidget *create_avatar_list(int avatar_num)
{
char *path = "client/data/avatars/";
Expand All @@ -58,13 +50,13 @@ void create_gallery(GtkWidget *main)
t_settings.background = gtk_event_box_new();
gtk_widget_set_name(GTK_WIDGET(t_settings.background), "sgallery");
gtk_widget_set_size_request(GTK_WIDGET(t_settings.background), WINDOW_WIDTH-67, WINDOW_HEIGHT);
g_signal_connect(G_OBJECT(t_settings.background), "button_press_event", G_CALLBACK(sgallery_click), NULL);
g_signal_connect(G_OBJECT(t_settings.background), "button_press_event", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_fixed_put(GTK_FIXED(main), t_settings.background, 0, 0);

GtkWidget *clickable = gtk_event_box_new();
gtk_widget_set_halign(GTK_WIDGET(clickable), GTK_ALIGN_CENTER);
gtk_widget_set_valign(GTK_WIDGET(clickable), GTK_ALIGN_CENTER);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(sgallery2_click), NULL);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(gtk_widget_show), NULL);
gtk_container_add(GTK_CONTAINER(t_settings.background), clickable);

GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
Expand Down
22 changes: 14 additions & 8 deletions client/src/creator_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ static void s_click(GtkWidget *widget) {
free(new_group);
}

static void s2_click(GtkWidget *widget) {
if(widget) {}
}

static void remove_person(GtkWidget *widget, GdkEventButton *event, gpointer user_id) {
if(event->type == GDK_BUTTON_PRESS && event->button == 1) {
gtk_widget_destroy(GTK_WIDGET(widget));
Expand All @@ -24,6 +20,7 @@ static void remove_person(GtkWidget *widget, GdkEventButton *event, gpointer use
for (int i = 0; i < new_group->count; i++)
new_group->users_id[i] = temp[i];
free(temp);
create_notification(t_application.main_area, "User deleted", 0, 461, 110, 420, 10);
}
}

Expand Down Expand Up @@ -77,13 +74,16 @@ static void add_person(GtkWidget *widget, GdkEventButton *event) {
// проверить имя пользователя name на существование
printf("Username: %s\n", name);
int avatar = 0, user_id = 0;
if (!add_user_to_group(name, &user_id, &avatar))
if (!add_user_to_group(name, &user_id, &avatar)) {
create_notification(t_application.main_area, "Invalid username!", 1, 461, 110, 420, 10);
return;
}

gtk_entry_set_text(GTK_ENTRY(new_group->search_field), "");
GtkWidget *single = create_single_person(name, avatar);
gtk_box_pack_start(GTK_BOX(t_msg.crlist), single, FALSE, FALSE, 0);
gtk_widget_show_all(GTK_WIDGET(t_msg.crlist));
create_notification(t_application.main_area, mx_strjoin(name, " added!"), 0, 461, 110, 420, 10);

g_signal_connect(G_OBJECT(single), "enter-notify-event", G_CALLBACK(event_enter_notify), NULL);
g_signal_connect(G_OBJECT(single), "leave-notify-event", G_CALLBACK(event_leave_notify), NULL);
Expand All @@ -95,14 +95,19 @@ static void add_person(GtkWidget *widget, GdkEventButton *event) {
static void create_group_button_click(GtkWidget *widget, gpointer group_name) {
if(widget) {}
GList *parent = gtk_container_get_children(GTK_CONTAINER(t_msg.crlist)); // GList *parent_c = parent;
if(parent == NULL)
if(parent == NULL){
create_notification(t_application.main_area, "No user selected!", 1, 461, 110, 420, 10);
return;
}

char *name = (char*)gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY((GtkWidget*)group_name)));
if(name != NULL)
name = mx_del_extra_spaces(name);
if(!strcmp(name, ""))
if(!strcmp(name, "")){
create_notification(t_application.main_area, "Name your group!", 1, 461, 110, 420, 10);
return;
}

printf("Group name: %s \n", name);

while(parent != NULL) {
Expand All @@ -118,6 +123,7 @@ static void create_group_button_click(GtkWidget *widget, gpointer group_name) {
new_group->title = strdup(name);
create_group();
g_list_free(g_steal_pointer(&parent)); // g_list_free(parent_c); //
gtk_widget_destroy(GTK_WIDGET(t_application.notificaton));
gtk_widget_destroy(GTK_WIDGET(t_msg.background));
}

Expand All @@ -132,7 +138,7 @@ void creator_group(GtkWidget *main)
GtkWidget *clickable = gtk_event_box_new();
gtk_widget_set_halign(GTK_WIDGET(clickable), GTK_ALIGN_CENTER);
gtk_widget_set_valign(GTK_WIDGET(clickable), GTK_ALIGN_CENTER);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(s2_click), NULL);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(gtk_widget_show), NULL);
gtk_container_add(GTK_CONTAINER(t_msg.background), clickable);

GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
Expand Down
1 change: 0 additions & 1 deletion client/src/creator_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ void new_incoming_embedded(GtkWidget *messages_block, char* path)
GtkWidget *embedded = gtk_drawing_area_new();
gtk_widget_set_size_request(GTK_WIDGET(embedded), a, b);
g_signal_connect(G_OBJECT(embedded), "draw", G_CALLBACK(draw_event_embedded), (char*)path);
//gtk_box_pack_end(GTK_BOX(embedded_body), embedded, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(embedded_body), embedded, FALSE, FALSE, 0);

GtkWidget *name_time_block = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1);
Expand Down
40 changes: 40 additions & 0 deletions client/src/creator_notification.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "../inc/client.h"

void create_notification(GtkWidget *widget, char *text, short type, int x, int y, int w, int h)
{
if(t_application.notificaton != NULL)
gtk_widget_destroy(GTK_WIDGET(t_application.notificaton));

t_application.notificaton = gtk_event_box_new();
g_signal_connect(G_OBJECT(t_application.notificaton), "button_press_event", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_fixed_put(GTK_FIXED(widget), t_application.notificaton, x, y);

GtkWidget* box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_widget_set_size_request(GTK_WIDGET(box), w, h);
gtk_widget_set_name(GTK_WIDGET(box), "notification_box");
gtk_container_add(GTK_CONTAINER(t_application.notificaton), box);

GtkWidget *label = gtk_label_new(text);
gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);

switch(type)
{
case 0: {
gtk_widget_set_name(GTK_WIDGET(t_application.notificaton), "notification_body");
gtk_widget_set_name(GTK_WIDGET(label), "notification_text");
break;
}
case 1: {
gtk_widget_set_name(GTK_WIDGET(t_application.notificaton), "notification_body_error");
gtk_widget_set_name(GTK_WIDGET(label), "notification_text_error");
break;
}
default: {
gtk_widget_set_name(GTK_WIDGET(t_application.notificaton), "notification_body");
gtk_widget_set_name(GTK_WIDGET(label), "notification_text");
break;
}
}

gtk_widget_show_all(GTK_WIDGET(t_application.notificaton));
}
12 changes: 2 additions & 10 deletions client/src/creator_stickers.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#include "../inc/client.h"

static void s_click(GtkWidget *widget) {
gtk_widget_destroy(GTK_WIDGET(widget));
}

static void s2_click(GtkWidget *widget) {
if(widget) {}
}

static void onsticker_click(GtkWidget *widget) {
GList *parent = gtk_container_get_children(GTK_CONTAINER(widget));
GList *children = gtk_container_get_children(GTK_CONTAINER(parent->data));
Expand Down Expand Up @@ -50,7 +42,7 @@ void create_stickerlist(GtkWidget *main)
{
t_msg.stickers = gtk_event_box_new();
gtk_widget_set_size_request(GTK_WIDGET(t_msg.stickers), WINDOW_WIDTH-LEFTBAR_W, WINDOW_HEIGHT);
g_signal_connect(G_OBJECT(t_msg.stickers), "button_press_event", G_CALLBACK(s_click), NULL);
g_signal_connect(G_OBJECT(t_msg.stickers), "button_press_event", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_fixed_put(GTK_FIXED(main), t_msg.stickers, 0, 0);

GtkWidget *positionable = gtk_fixed_new();
Expand All @@ -59,7 +51,7 @@ void create_stickerlist(GtkWidget *main)
GtkWidget *clickable = gtk_event_box_new();
gtk_widget_set_halign(GTK_WIDGET(clickable), GTK_ALIGN_END);
gtk_widget_set_valign(GTK_WIDGET(clickable), GTK_ALIGN_END);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(s2_click), NULL);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(gtk_widget_show), NULL);
gtk_fixed_put(GTK_FIXED(positionable), clickable, WINDOW_WIDTH-380, WINDOW_HEIGHT-ENTRY_H-360);

GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
Expand Down
14 changes: 3 additions & 11 deletions client/src/creator_userprofile.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
#include "../inc/client.h"

static void s_click(GtkWidget *widget) {
gtk_widget_destroy(GTK_WIDGET(widget));
}

static void s2_click(GtkWidget *widget) {
if(widget) {}
}

void creator_userprofile(GtkWidget *main, char *username, bool status)
{
t_msg.background = gtk_event_box_new();
gtk_widget_set_name(GTK_WIDGET(t_msg.background), "crgroup");
gtk_widget_set_size_request(GTK_WIDGET(t_msg.background), WINDOW_WIDTH-67, WINDOW_HEIGHT);
g_signal_connect(G_OBJECT(t_msg.background), "button_press_event", G_CALLBACK(s_click), NULL);
g_signal_connect(G_OBJECT(t_msg.background), "button_press_event", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_fixed_put(GTK_FIXED(main), t_msg.background, 0, 0);

GtkWidget *clickable = gtk_event_box_new();
gtk_widget_set_halign(GTK_WIDGET(clickable), GTK_ALIGN_CENTER);
gtk_widget_set_valign(GTK_WIDGET(clickable), GTK_ALIGN_CENTER);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(s2_click), NULL);
g_signal_connect(G_OBJECT(clickable), "button_press_event", G_CALLBACK(gtk_widget_show), NULL);
gtk_container_add(GTK_CONTAINER(t_msg.background), clickable);

GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
Expand Down Expand Up @@ -56,7 +48,7 @@ void creator_userprofile(GtkWidget *main, char *username, bool status)
gtk_box_pack_start(GTK_BOX(usernamebox), status_label, FALSE, FALSE, 0);
}

short team = 3; // Получить команду (1-3)
short team = 1; // Получить команду (1-3)
char *team_char;

GtkWidget *badge = gtk_event_box_new();
Expand Down
23 changes: 18 additions & 5 deletions client/src/events_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ void valor_event_button_click(GtkWidget *widget, GdkEventButton *event)
void login_butt_click(GtkWidget *widget){
if(widget) {}

t_account_temp.username = mx_del_extra_spaces(t_account_temp.username);
t_account_temp.name = mx_del_extra_spaces(t_account_temp.name);

if(t_account_temp.username == NULL \
|| !strcmp(t_account_temp.username, "") \
|| t_account_temp.password == NULL \
|| !strcmp(t_account_temp.password, "")
|| strlen(t_account_temp.password) < 5)
return;

cJSON *json = cJSON_CreateObject();
cJSON *json_login_user = cJSON_CreateObject();
cJSON_AddStringToObject(json_login_user, "username", t_account_temp.username);
Expand Down Expand Up @@ -103,14 +113,13 @@ void login_butt_click(GtkWidget *widget){
gtk_widget_hide(GTK_WIDGET(t_leftbar.settings_scr));// Hiding settings tab
}
else {
printf("Login error!\n");
create_notification(t_application.auth, "Login error!", 1, 430, 160, 420, 10);
}
mx_strdel(&result);
mx_strdel(&json_string);
mx_strdel(&msg_data.content_final);
cJSON_Delete(json);
cJSON_Delete(response);

}

void reg_send_request() {
Expand Down Expand Up @@ -160,9 +169,13 @@ void reg_butt_click(GtkWidget *widget){
|| !strcmp(t_account_temp.password, "")
|| t_account_temp.repass == NULL \
|| !strcmp(t_account_temp.repass, "")
|| strlen(t_account_temp.password) < 5 \
|| strcmp(t_account_temp.repass, t_account_temp.password))
|| strlen(t_account_temp.password) < 5)
return;

if(strcmp(t_account_temp.repass, t_account_temp.password)){
create_notification(t_application.auth, "Passwords do not match!", 1, 430, 30, 420, 10);
return;
}

t_account.avatar = t_avatar.avatar_generated;
t_account.username = strdup(t_account_temp.username);
Expand All @@ -184,7 +197,7 @@ void reg_butt_click(GtkWidget *widget){
reg_send_request();
printf("-- %d\n", t_account.id);
if (t_account.id <= 0) {
// Appears an error message on the screen
create_notification(t_application.auth, "This username is already taken!", 1, 430, 30, 420, 10);
return;
}

Expand Down
Loading

0 comments on commit 55bc447

Please sign in to comment.