[gnome-power-manager] Show a label to the user when there is no graph data



commit 04c65d343cf48df7df3d554c2584ba586c9777eb
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jun 15 10:20:39 2009 +0100

    Show a label to the user when there is no graph data

 data/gpm-statistics.ui |   18 ++++++++++++++++++
 src/gpm-statistics.c   |   13 +++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/data/gpm-statistics.ui b/data/gpm-statistics.ui
index 21f7b80..2f62188 100644
--- a/data/gpm-statistics.ui
+++ b/data/gpm-statistics.ui
@@ -154,6 +154,15 @@
                                 <property name="position">0</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkLabel" id="label_history_nodata">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">There is no data to display.</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="position">0</property>
@@ -278,6 +287,15 @@
                                 <property name="position">0</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkLabel" id="label_stats_nodata">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">There is no data to display.</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="position">0</property>
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index e1720d7..d123195 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -535,11 +535,17 @@ gpm_stats_update_info_page_history (DkpDevice *device)
 			      NULL);
 	}
 
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_history_nodata"));
 	array = dkp_device_get_history (device, history_type, history_time, 150, NULL);
 	if (array == NULL) {
+		/* show no data label and hide graph */
 		gtk_widget_hide (graph_history);
+		gtk_widget_show (widget);
 		goto out;
 	}
+
+	/* hide no data and show graph */
+	gtk_widget_hide (widget);
 	gtk_widget_show (graph_history);
 
 	g_get_current_time (&timeval);
@@ -636,12 +642,19 @@ gpm_stats_update_info_page_stats (DkpDevice *device)
 			      NULL);
 	}
 
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_stats_nodata"));
 	array = dkp_device_get_statistics (device, type, NULL);
 	if (array == NULL) {
+		/* show no data label and hide graph */
 		gtk_widget_hide (graph_statistics);
+		gtk_widget_show (widget);
 		goto out;
 	}
 
+	/* hide no data and show graph */
+	gtk_widget_hide (widget);
+	gtk_widget_show (graph_statistics);
+
 	for (i=0; i<array->len; i++) {
 		sobj = (DkpStatsObj *) g_ptr_array_index (array, i);
 		point = gpm_point_obj_new ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]