mirror of
https://github.com/lakinduakash/linux-wifi-hotspot.git
synced 2024-11-10 06:00:11 +00:00
Refcator and fix warnings in connecetd devices
This commit is contained in:
parent
4cc946b5fe
commit
af913a0968
113
src/ui/ui.c
113
src/ui/ui.c
@ -60,11 +60,11 @@ GtkButton *button_about;
|
|||||||
GtkButton *button_refresh;
|
GtkButton *button_refresh;
|
||||||
|
|
||||||
GtkGrid *grid_devices;
|
GtkGrid *grid_devices;
|
||||||
GtkWidget *h;
|
GtkWidget *label_cd_hostname;
|
||||||
GtkWidget *i;
|
GtkWidget *label_cd_ip;
|
||||||
GtkWidget *m;
|
GtkWidget *label_cd_mac;
|
||||||
GtkWidget *n;
|
GtkWidget *label_cd_number;
|
||||||
PtrToNode l;
|
PtrToNode device_list;
|
||||||
|
|
||||||
GtkEntry *entry_ssd;
|
GtkEntry *entry_ssd;
|
||||||
GtkEntry *entry_pass;
|
GtkEntry *entry_pass;
|
||||||
@ -161,48 +161,6 @@ static void on_about_open_click(GtkWidget *widget, gpointer data){
|
|||||||
show_info(widget,data);
|
show_info(widget,data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_connected_devices_label()
|
|
||||||
{
|
|
||||||
Position tmp;
|
|
||||||
l = get_connected_devices(running_info[0]); // running_info[0] PID
|
|
||||||
|
|
||||||
// Remove all the children widgets
|
|
||||||
GList *children, *iter;
|
|
||||||
|
|
||||||
children = gtk_container_get_children(GTK_CONTAINER(grid_devices));
|
|
||||||
for (iter = children; iter != NULL; iter = g_list_next(iter))
|
|
||||||
{
|
|
||||||
gtk_widget_destroy(GTK_WIDGET(iter->data));
|
|
||||||
}
|
|
||||||
g_list_free(children);
|
|
||||||
|
|
||||||
while (l->Next != NULL)
|
|
||||||
{
|
|
||||||
tmp = l; // Save the last one
|
|
||||||
l = l->Next;
|
|
||||||
char number[1];
|
|
||||||
sprintf(number, "%d", l->Number);
|
|
||||||
n = gtk_label_new(number);
|
|
||||||
h = gtk_label_new(l->HOSTNAME);
|
|
||||||
i = gtk_label_new(l->IP);
|
|
||||||
m = gtk_label_new(l->MAC);
|
|
||||||
|
|
||||||
gtk_grid_attach(grid_devices, n, 0, l->Number, 1, 1);
|
|
||||||
gtk_grid_attach(grid_devices, h, 1, l->Number, 1, 1);
|
|
||||||
gtk_grid_attach(grid_devices, i, 2, l->Number, 1, 1);
|
|
||||||
gtk_grid_attach(grid_devices, m, 3, l->Number, 1, 1);
|
|
||||||
gtk_widget_show_all((GtkWidget *)grid_devices);
|
|
||||||
free(tmp); // Free the last pointer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_refresh_clicked(GtkWidget *widget, gpointer data)
|
|
||||||
{
|
|
||||||
if (running_info[0] != NULL)
|
|
||||||
{
|
|
||||||
set_connected_devices_label();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void loadStyles(){
|
static void loadStyles(){
|
||||||
provider = gtk_css_provider_new();
|
provider = gtk_css_provider_new();
|
||||||
@ -919,4 +877,65 @@ gchar* get_accepted_macs(){
|
|||||||
|
|
||||||
return accepted_macs;
|
return accepted_macs;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear device list
|
||||||
|
*/
|
||||||
|
static void clear_connecetd_devices_list(){
|
||||||
|
|
||||||
|
// Remove all the children widgets
|
||||||
|
GList *children, *iter;
|
||||||
|
|
||||||
|
children = gtk_container_get_children(GTK_CONTAINER(grid_devices));
|
||||||
|
for (iter = children; iter != NULL; iter = g_list_next(iter))
|
||||||
|
{
|
||||||
|
gtk_widget_destroy(GTK_WIDGET(iter->data));
|
||||||
|
}
|
||||||
|
g_list_free(children);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set connected device list
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void set_connected_devices_label()
|
||||||
|
{
|
||||||
|
Position tmp;
|
||||||
|
device_list = get_connected_devices(running_info[0]); // running_info[0] PID
|
||||||
|
|
||||||
|
clear_connecetd_devices_list();
|
||||||
|
|
||||||
|
while (device_list->Next != NULL)
|
||||||
|
{
|
||||||
|
tmp = device_list; // Save the last one
|
||||||
|
device_list = device_list->Next;
|
||||||
|
char number[2];
|
||||||
|
sprintf(number, "%d", device_list->Number);
|
||||||
|
label_cd_number = gtk_label_new(number);
|
||||||
|
label_cd_hostname = gtk_label_new(device_list->HOSTNAME);
|
||||||
|
label_cd_ip = gtk_label_new(device_list->IP);
|
||||||
|
label_cd_mac = gtk_label_new(device_list->MAC);
|
||||||
|
|
||||||
|
gtk_grid_attach(grid_devices, label_cd_number, 0, device_list->Number, 1, 1);
|
||||||
|
gtk_grid_attach(grid_devices, label_cd_hostname, 1, device_list->Number, 1, 1);
|
||||||
|
gtk_grid_attach(grid_devices, label_cd_ip, 2, device_list->Number, 1, 1);
|
||||||
|
gtk_grid_attach(grid_devices, label_cd_mac, 3, device_list->Number, 1, 1);
|
||||||
|
gtk_widget_show_all((GtkWidget *)grid_devices);
|
||||||
|
free(tmp); // Free the last pointer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When conncetd devices refresh button clicked
|
||||||
|
*/
|
||||||
|
static void on_refresh_clicked(GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
if (running_info[0] != NULL)
|
||||||
|
{
|
||||||
|
set_connected_devices_label();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clear_connecetd_devices_list();
|
||||||
|
}
|
||||||
}
|
}
|
@ -72,4 +72,8 @@ gchar* get_accepted_macs();
|
|||||||
|
|
||||||
static void set_connected_devices_label(); // new
|
static void set_connected_devices_label(); // new
|
||||||
|
|
||||||
|
static void on_refresh_clicked(GtkWidget *widget, gpointer data);
|
||||||
|
|
||||||
|
static void clear_connecetd_devices_list();
|
||||||
|
|
||||||
#endif //WIHOTSPOT_UI_H
|
#endif //WIHOTSPOT_UI_H
|
||||||
|
Loading…
Reference in New Issue
Block a user