summaryrefslogtreecommitdiff
path: root/rcm-client-hardware-info.c
blob: 662f5269a6c5cc56baa400caed2ed9eef55b0b5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <gtk/gtk.h>

#include "generated.h"
#include "rcm-client-main.h"
#include "rcm-client-hardware-list.h"
#include "rcm-client-hardware-info.h"
#include "rcm-client-receive.h"
#include "rcm-client-transmit.h"

static GtkWidget *info = NULL;
static GDBusObject *hw = NULL;

void
rcng_client_hardware_init_info_ui(GDBusObject *new_hw)
{
	GtkWidget *icon;
	GtkWidget *hbox;
	GtkWidget *title;
	GtkWidget *line;
      
	if (new_hw == hw)
		return;

	hw = new_hw;
	if (info)
		gtk_widget_destroy(info);
	info = NULL;
	rcng_client_receive_destroy_ui();
	rcng_client_transmit_destroy_ui();

	if (!hw)
		return;

	icon = gtk_image_new_from_icon_name("gtk-harddisk", GTK_ICON_SIZE_DIALOG);
	gtk_widget_set_valign(icon, GTK_ALIGN_START);
	gtk_widget_set_halign(icon, GTK_ALIGN_START);
	gtk_widget_set_margin_start(icon, 12);
	gtk_widget_set_margin_end(icon, 12);

	hbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);

	title = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(title), "<b>Hardware</b>");
	gtk_widget_set_halign(title, GTK_ALIGN_START);
	gtk_box_pack_start(GTK_BOX(hbox), title, FALSE, FALSE, 0);

	line = gtk_label_new("Apan 1");
	gtk_widget_set_halign(line, GTK_ALIGN_START);
	gtk_box_pack_start(GTK_BOX(hbox), line, FALSE, FALSE, 0);

	line = gtk_label_new("Apan 2");
	line = gtk_label_new(g_dbus_object_get_object_path(hw));
	gtk_widget_set_halign(line, GTK_ALIGN_START);
	gtk_box_pack_start(GTK_BOX(hbox), line, FALSE, FALSE, 0);

	info = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_set_margin_start(info, 12);
	gtk_widget_set_margin_end(info, 12);
	gtk_widget_set_margin_top(info, 12);
	gtk_widget_set_margin_bottom(info, 12);
	gtk_box_pack_start(GTK_BOX(info), icon, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(info), hbox, FALSE, FALSE, 0);

	gtk_widget_show_all(info);
	gtk_notebook_append_page(global->notebook, info, gtk_label_new("Details"));
	gtk_notebook_set_current_page(global->notebook, 1);

	rcng_client_receive_init_ui(new_hw);
}