2 Copyright (C) 2010-2011 jeanfi@gmail.com
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
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
25 cb_preferences(gpointer data, guint callback_action, GtkWidget *item)
27 ui_pref_dialog_run((struct ui_psensor *)data);
30 static GtkItemFactoryEntry menu_items[] = {
32 NULL, cb_preferences, 0, "<Item>"},
35 NULL, NULL, 0, "<Separator>"},
38 "", ui_psensor_exit, 0, "<StockItem>", GTK_STOCK_QUIT},
41 static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
43 GtkWidget *ui_graph_create_popupmenu(struct ui_psensor *ui)
45 GtkItemFactory *item_factory;
47 item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
48 gtk_item_factory_create_items(item_factory,
49 nmenu_items, menu_items, ui);
50 return gtk_item_factory_get_widget(item_factory, "<main>");
53 int on_graph_clicked(GtkWidget *widget, GdkEventButton *event, gpointer data)
57 if (event->type != GDK_BUTTON_PRESS)
60 menu = ui_graph_create_popupmenu((struct ui_psensor *)data);
62 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
63 event->button, event->time);
69 on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
71 struct ui_psensor *ui_psensor = (struct ui_psensor *)data;
73 graph_update(ui_psensor->sensors,
74 ui_psensor->w_graph, ui_psensor->config);
79 GtkWidget *ui_graph_create(struct ui_psensor * ui)
83 w_graph = gtk_drawing_area_new();
85 g_signal_connect(G_OBJECT(w_graph),
86 "expose-event", G_CALLBACK(on_expose_event), ui);
88 gtk_widget_add_events(w_graph, GDK_BUTTON_PRESS_MASK);
89 gtk_signal_connect(GTK_OBJECT(w_graph),
91 (GCallback) on_graph_clicked, ui);