fixed indentation
[psensor.git] / src / ui_graph.c
1 /*
2  * Copyright (C) 2010-2013 jeanfi@gmail.com
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19 #include "graph.h"
20 #include "ui_graph.h"
21 #include "ui_pref.h"
22 #include "ui_sensorpref.h"
23
24 static int
25 on_graph_clicked(GtkWidget *widget, GdkEventButton *event, gpointer data)
26 {
27         if (event->type != GDK_BUTTON_PRESS)
28                 return FALSE;
29
30         gtk_menu_popup(GTK_MENU(((struct ui_psensor *)data)->popup_menu),
31                        NULL, NULL, NULL, NULL,
32                        event->button, event->time);
33
34         return TRUE;
35 }
36
37 static gboolean
38 on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
39 {
40         struct ui_psensor *ui_psensor = (struct ui_psensor *)data;
41
42         graph_update(ui_psensor->sensors,
43                      ui_psensor->w_graph,
44                      ui_psensor->config,
45                      ui_psensor->main_window);
46
47         return FALSE;
48 }
49
50 GtkWidget *ui_graph_create(struct ui_psensor *ui)
51 {
52         GtkWidget *w_graph;
53
54         w_graph = gtk_drawing_area_new();
55
56         g_signal_connect(GTK_WIDGET(w_graph),
57                          "draw",
58                          G_CALLBACK(on_expose_event),
59                          ui);
60
61         gtk_widget_add_events(w_graph, GDK_BUTTON_PRESS_MASK);
62
63         g_signal_connect(GTK_WIDGET(w_graph),
64                          "button_press_event",
65                          (GCallback) on_graph_clicked, ui);
66
67         return w_graph;
68 }