Author: rpmcruz Date: Wed Feb 27 23:38:23 2008 New Revision: 45096
URL: http://svn.opensuse.org/viewcvs/yast?rev=45096&view=rev Log: * src/YGBarGraph.cc & src/ygtkbargraph.c: honor bar graph segment's custom color.
Modified: trunk/gtk/ChangeLog trunk/gtk/src/YGBarGraph.cc trunk/gtk/src/ygtkbargraph.c trunk/gtk/src/ygtkbargraph.h
Modified: trunk/gtk/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=45096&r1=45... ============================================================================== --- trunk/gtk/ChangeLog (original) +++ trunk/gtk/ChangeLog Wed Feb 27 23:38:23 2008 @@ -26,6 +26,8 @@
* src/yzyppwrapper.cc: added 10.3 zypp compatibility flag.
+ * src/YGBarGraph.cc & src/ygtkbargraph.c: honor bar graph segment's custom color. + 2008-02-27 Ricardo Cruz rpmcruz@alunos.dcc.fc.up.pt
* src/yzyppwrapper.cc: got rid of depreacated warning.
Modified: trunk/gtk/src/YGBarGraph.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGBarGraph.cc?rev=45096&a... ============================================================================== --- trunk/gtk/src/YGBarGraph.cc (original) +++ trunk/gtk/src/YGBarGraph.cc Wed Feb 27 23:38:23 2008 @@ -21,11 +21,20 @@ // YBarGraph virtual void doUpdate() { + GdkColor clr; ygtk_bar_graph_create_entries (YGTK_BAR_GRAPH (getWidget()), segments()); for (int i = 0; i < segments(); i++) { const YBarGraphSegment &s = segment (i); + GdkColor *c = 0; + if (s.hasSegmentColor()) { + const YColor &color = s.segmentColor(); + clr.red = color.red(); + clr.green = color.green(); + clr.blue = color.blue(); + c = &clr; + } ygtk_bar_graph_setup_entry (YGTK_BAR_GRAPH (getWidget()), i, - s.label().c_str(), s.value()); + s.label().c_str(), s.value(), c); } // FIXME: new libyui colors segments ... We probably should honor that } @@ -57,7 +66,7 @@ GtkWidget *graph = ygtk_bar_graph_new(); m_barGraph = YGTK_BAR_GRAPH (graph); ygtk_bar_graph_create_entries (m_barGraph, 3); - ygtk_bar_graph_setup_entry (m_barGraph, 0, usedLabel.c_str(), usedSize); + ygtk_bar_graph_setup_entry (m_barGraph, 0, usedLabel.c_str(), usedSize, NULL);
/* Labels over the slider */ GtkWidget *labels_box, *free_label, *new_part_label; @@ -106,9 +115,9 @@ { IMPL ygtk_bar_graph_setup_entry (m_barGraph, 1, freeLabel().c_str(), - freeSize()); + freeSize(), NULL); ygtk_bar_graph_setup_entry (m_barGraph, 2, newPartLabel().c_str(), - newPartSize()); + newPartSize(), NULL);
// block connections g_signal_handlers_block_by_func (m_scale,
Modified: trunk/gtk/src/ygtkbargraph.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkbargraph.c?rev=45096&... ============================================================================== --- trunk/gtk/src/ygtkbargraph.c (original) +++ trunk/gtk/src/ygtkbargraph.c Wed Feb 27 23:38:23 2008 @@ -61,8 +61,8 @@ } }
-void ygtk_bar_graph_setup_entry (YGtkBarGraph *bar, int index, - const gchar *label_entry, int value) +void ygtk_bar_graph_setup_entry (YGtkBarGraph *bar, int index, const gchar *label_entry, + int value, GdkColor *color) { YGtkRatioBoxChild *box_child = (YGtkRatioBoxChild *) g_list_nth_data (YGTK_RATIO_BOX (bar)->children, index); @@ -130,10 +130,14 @@ { 46, 52, 54 }, // Aluminium 6 };
- const guint *color = palette [index % G_N_ELEMENTS (palette)]; - YGtkColoredLabel *color_label = YGTK_COLORED_LABEL (label); - ygtk_colored_label_set_background (color_label, color[0], color[1], color[2]); + + if (color) + ygtk_colored_label_set_background (color_label, color->red, color->green, color->blue); + else { + const guint *color = palette [index % G_N_ELEMENTS (palette)]; + ygtk_colored_label_set_background (color_label, color[0], color[1], color[2]); + } }
static void ygtk_bar_graph_class_init (YGtkBarGraphClass *klass)
Modified: trunk/gtk/src/ygtkbargraph.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkbargraph.h?rev=45096&... ============================================================================== --- trunk/gtk/src/ygtkbargraph.h (original) +++ trunk/gtk/src/ygtkbargraph.h Wed Feb 27 23:38:23 2008 @@ -46,7 +46,7 @@
void ygtk_bar_graph_create_entries (YGtkBarGraph *bar, guint entries); void ygtk_bar_graph_setup_entry (YGtkBarGraph *bar, int index, - const gchar *label_entry, int value); + const gchar *label_entry, int value, GdkColor *color);
G_END_DECLS #endif /*YGTK_BAR_GRAPH_H*/
yast-commit@lists.opensuse.org