Author: rpmcruz
Date: Sun Oct 19 19:23:17 2008
New Revision: 52350
URL: http://svn.opensuse.org/viewcvs/yast?rev=52350&view=rev
Log:
* src/ygtkbargraph.h/cc: moved color customization out of setup routine.
* src/YGBarGraph.cc (YGBarGraph): honor textColor().
* src/ygtkratiobox.cc (used by YGtkBarGraph): was allocating the widget
at the window position x=0.
* src/YGBarGraph.cc (YGPartitionSplitter): bug fix: the widget was
broken. Aligned labels correctly as well.
* src/ygtkwizard.h/cc: added history combo box to the help dialog.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGBarGraph.cc
trunk/gtk/src/ygtkbargraph.c
trunk/gtk/src/ygtkbargraph.h
trunk/gtk/src/ygtkratiobox.c
trunk/gtk/src/ygtkwizard.c
trunk/gtk/src/ygtkwizard.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=52350&r1=52349&r2=52350&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Sun Oct 19 19:23:17 2008
@@ -1,3 +1,16 @@
+2008-10-19 Ricardo Cruz
+
+ * src/ygtkbargraph.h/cc: moved color customization out of setup routine.
+ * src/YGBarGraph.cc (YGBarGraph): honor textColor().
+
+ * src/ygtkratiobox.cc (used by YGtkBarGraph): was allocating the widget
+ at the window position x=0.
+
+ * src/YGBarGraph.cc (YGPartitionSplitter): bug fix: the widget was
+ broken. Aligned labels correctly as well.
+
+ * src/ygtkwizard.h/cc: added history combo box to the help dialog.
+
2008-10-18 Ricardo Cruz
* src/YGUtils.h/cc: added PangoStyle (for italic) option to
Modified: trunk/gtk/src/YGBarGraph.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGBarGraph.cc?rev=52350&r1=52349&r2=52350&view=diff
==============================================================================
--- trunk/gtk/src/YGBarGraph.cc (original)
+++ trunk/gtk/src/YGBarGraph.cc Sun Oct 19 19:23:17 2008
@@ -20,22 +20,26 @@
// YBarGraph
virtual void doUpdate()
{
- GdkColor clr;
- ygtk_bar_graph_create_entries (YGTK_BAR_GRAPH (getWidget()), segments());
+ YGtkBarGraph *graph = YGTK_BAR_GRAPH (getWidget());
+ ygtk_bar_graph_create_entries (graph, segments());
for (int i = 0; i < segments(); i++) {
const YBarGraphSegment &s = segment (i);
- GdkColor *c = 0;
+ ygtk_bar_graph_setup_entry (graph, i, s.label().c_str(), s.value());
if (s.hasSegmentColor()) {
- const YColor &color = s.segmentColor();
- clr.red = color.red();
- clr.green = color.green();
- clr.blue = color.blue();
- c = &clr;
+ GdkColor color = ycolorToGdk (s.segmentColor());
+ ygtk_bar_graph_customize_bg (graph, i, &color);
+ }
+ if (s.hasTextColor()) {
+ GdkColor color = ycolorToGdk (s.textColor());
+ ygtk_bar_graph_customize_fg (graph, i, &color);
}
- ygtk_bar_graph_setup_entry (YGTK_BAR_GRAPH (getWidget()), i,
- s.label().c_str(), s.value(), c);
}
- // FIXME: new libyui colors segments ... We probably should honor that
+ }
+
+ static GdkColor ycolorToGdk (const YColor &ycolor)
+ {
+ GdkColor color = { 0, ycolor.red() << 8, ycolor.green() << 8, ycolor.blue() << 8 };
+ return color;
}
YGWIDGET_IMPL_COMMON
@@ -70,15 +74,15 @@
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, NULL);
+ ygtk_bar_graph_setup_entry (m_barGraph, 0, usedLabel.c_str(), usedSize);
/* Labels over the slider */
- GtkWidget *labels_box, *free_label, *new_part_label;
- labels_box = gtk_hbox_new (FALSE, 0);
- free_label = gtk_label_new (freeFieldLabel.c_str());
- new_part_label = gtk_label_new (newPartFieldLabel.c_str());
- gtk_box_pack_start (GTK_BOX (labels_box), free_label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (labels_box), new_part_label, FALSE, FALSE, 0);
+ GtkWidget *labels_box = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (labels_box),
+ gtk_label_new (freeFieldLabel.c_str()), FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (labels_box), gtk_label_new (NULL), TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (labels_box),
+ gtk_label_new (newPartFieldLabel.c_str()), FALSE, TRUE, 0);
/* Slider and the spinners */
GtkWidget *slider_box = gtk_hbox_new (FALSE, 0);
@@ -101,7 +105,7 @@
G_CALLBACK (new_spin_changed_cb), this);
/* Main layout */
- gtk_box_pack_start (GTK_BOX (getWidget()), graph, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (getWidget()), graph, TRUE, TRUE, 6);
gtk_box_pack_start (GTK_BOX (getWidget()), labels_box, FALSE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (getWidget()), slider_box, FALSE, TRUE, 2);
@@ -118,10 +122,8 @@
virtual void setValue (int newValue)
{
IMPL
- ygtk_bar_graph_setup_entry (m_barGraph, 1, freeLabel().c_str(),
- freeSize(), NULL);
- ygtk_bar_graph_setup_entry (m_barGraph, 2, newPartLabel().c_str(),
- newPartSize(), NULL);
+ ygtk_bar_graph_setup_entry (m_barGraph, 1, freeLabel().c_str(), freeSize());
+ ygtk_bar_graph_setup_entry (m_barGraph, 2, newPartLabel().c_str(), newPartSize());
// block connections
g_signal_handlers_block_by_func (m_scale,
@@ -131,9 +133,13 @@
g_signal_handlers_block_by_func (m_new_spin,
(gpointer) new_spin_changed_cb, this);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_free_spin), freeSize());
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_new_spin), newPartSize());
- gtk_range_set_value (GTK_RANGE (m_scale), freeSize());
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_new_spin), newValue);
+ int freeSize = totalFreeSize() - newValue;
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_free_spin), freeSize);
+ gtk_range_set_value (GTK_RANGE (m_scale), freeSize);
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_free_spin), freeSize);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_new_spin), newValue);
// unblock connections
g_signal_handlers_unblock_by_func (m_scale,
Modified: trunk/gtk/src/ygtkbargraph.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkbargraph.c?rev=52350&r1=52349&r2=52350&view=diff
==============================================================================
--- trunk/gtk/src/ygtkbargraph.c (original)
+++ trunk/gtk/src/ygtkbargraph.c Sun Oct 19 19:23:17 2008
@@ -54,15 +54,18 @@
}
}
-void ygtk_bar_graph_setup_entry (YGtkBarGraph *bar, int index, const gchar *label_entry,
- int value, GdkColor *color)
+static GtkWidget *ygtk_bar_graph_get_label (YGtkBarGraph *bar, int index, GtkWidget **b)
{
- YGtkRatioBoxChild *box_child = (YGtkRatioBoxChild *)
- g_list_nth_data (YGTK_RATIO_BOX (bar)->children, index);
+ GtkWidget *box = ((YGtkRatioBoxChild *) g_list_nth_data (
+ YGTK_RATIO_BOX (bar)->children, index))->widget;
+ if (b) *b = box;
+ return gtk_bin_get_child (GTK_BIN (box));
+}
- g_return_if_fail (box_child);
- GtkWidget *box = box_child->widget;
- GtkWidget *label = gtk_bin_get_child (GTK_BIN (box));
+void ygtk_bar_graph_setup_entry (YGtkBarGraph *bar, int index, const gchar *label_entry, int value)
+{
+ GtkWidget *box, *label;
+ label = ygtk_bar_graph_get_label (bar, index, &box);
if (value < 0)
value = 0;
@@ -84,10 +87,11 @@
// tooltip for the labels -- useful if the bar entry gets too small
gtk_widget_set_tooltip_text (box, label_text->str);
+ g_string_free (label_text, TRUE);
}
// Set proportion
- gtk_widget_set_size_request (box, 10, -1); // for homogeneous...
+ gtk_widget_set_size_request (box, 0, -1);
ygtk_ratio_box_set_child_packing (YGTK_RATIO_BOX (bar), box, MAX (value, 1));
// Set background color
@@ -123,13 +127,21 @@
};
YGtkColoredLabel *color_label = YGTK_COLORED_LABEL (label);
+ const guint *color = palette [index % G_N_ELEMENTS (palette)];
+ GdkColor gcolor = { 0, color[0] << 8, color[1] << 8, color[2] << 8 };
+ ygtk_colored_label_set_background (color_label, &gcolor);
+}
- 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]);
- }
+void ygtk_bar_graph_customize_bg (YGtkBarGraph *bar, int index, GdkColor *color)
+{
+ GtkWidget *label = ygtk_bar_graph_get_label (bar, index, NULL);
+ ygtk_colored_label_set_background (YGTK_COLORED_LABEL (label), color);
+}
+
+void ygtk_bar_graph_customize_fg (YGtkBarGraph *bar, int index, GdkColor *color)
+{
+ GtkWidget *label = ygtk_bar_graph_get_label (bar, index, NULL);
+ ygtk_colored_label_set_foreground (YGTK_COLORED_LABEL (label), color);
}
static void ygtk_bar_graph_class_init (YGtkBarGraphClass *klass)
@@ -164,19 +176,11 @@
GtkWidget *ygtk_colored_label_new (void)
{ return g_object_new (YGTK_TYPE_COLORED_LABEL, NULL); }
-void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, guint red,
- guint green, guint blue)
-{
- GdkColor color = { 0, red << 8, green << 8, blue << 8 };
- gtk_widget_modify_fg (GTK_WIDGET (label), GTK_STATE_NORMAL, &color);
-}
+void ygtk_colored_label_set_background (YGtkColoredLabel *label, GdkColor *color)
+{ gtk_widget_modify_bg (GTK_WIDGET (label), GTK_STATE_NORMAL, color); }
-void ygtk_colored_label_set_background (YGtkColoredLabel *label, guint red,
- guint green, guint blue)
-{
- GdkColor color = { 0, red << 8, green << 8, blue << 8 };
- gtk_widget_modify_bg (GTK_WIDGET (label), GTK_STATE_NORMAL, &color);
-}
+void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, GdkColor *color)
+{ gtk_widget_modify_fg (GTK_WIDGET (label), GTK_STATE_NORMAL, color); }
void ygtk_colored_label_set_shadow_type (YGtkColoredLabel *label, GtkShadowType type)
{
Modified: trunk/gtk/src/ygtkbargraph.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkbargraph.h?rev=52350&r1=52349&r2=52350&view=diff
==============================================================================
--- trunk/gtk/src/ygtkbargraph.h (original)
+++ trunk/gtk/src/ygtkbargraph.h Sun Oct 19 19:23:17 2008
@@ -41,8 +41,10 @@
GType ygtk_bar_graph_get_type (void) G_GNUC_CONST;
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, GdkColor *color);
+void ygtk_bar_graph_setup_entry (YGtkBarGraph *bar, int index, const gchar *label_entry, int value);
+
+void ygtk_bar_graph_customize_bg (YGtkBarGraph *bar, int index, GdkColor *color);
+void ygtk_bar_graph_customize_fg (YGtkBarGraph *bar, int index, GdkColor *color);
G_END_DECLS
#endif /*YGTK_BAR_GRAPH_H*/
@@ -86,12 +88,11 @@
// A convenience function (you may use gtk_widget_modify_fg() and
// gtk_widget_modify_bg() instead), where colors range is [0, 255]
-void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, guint red,
- guint green, guint blue);
-void ygtk_colored_label_set_background (YGtkColoredLabel *label, guint red,
- guint green, guint blue);
+void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, GdkColor *color);
+void ygtk_colored_label_set_background (YGtkColoredLabel *label, GdkColor *color);
void ygtk_colored_label_set_shadow_type (YGtkColoredLabel *label, GtkShadowType type);
G_END_DECLS
#endif /*YGTK_COLORED_LABEL*/
+
Modified: trunk/gtk/src/ygtkratiobox.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkratiobox.c?rev=52350&r1=52349&r2=52350&view=diff
==============================================================================
--- trunk/gtk/src/ygtkratiobox.c (original)
+++ trunk/gtk/src/ygtkratiobox.c Sun Oct 19 19:23:17 2008
@@ -163,14 +163,14 @@
GtkAllocation child_alloc;
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- child_alloc.x = child_pos;
+ child_alloc.x = allocation->x + child_pos;
child_alloc.y = allocation->y;
child_alloc.width = child_length;
child_alloc.height = allocation->height;
}
else { // GTK_ORIENTATION_VERTICAL
child_alloc.x = allocation->x;
- child_alloc.y = child_pos;
+ child_alloc.y = allocation->y + child_pos;
child_alloc.width = allocation->width;
child_alloc.height = child_length;
}
@@ -215,20 +215,15 @@
G_DEFINE_TYPE (YGtkRatioHBox, ygtk_ratio_hbox, YGTK_TYPE_RATIO_BOX)
static void ygtk_ratio_hbox_init (YGtkRatioHBox *box)
-{
-}
+{ }
static void ygtk_ratio_hbox_size_request (GtkWidget *widget,
GtkRequisition *requisition)
-{
- ygtk_ratio_box_size_request (widget, requisition, GTK_ORIENTATION_HORIZONTAL);
-}
+{ ygtk_ratio_box_size_request (widget, requisition, GTK_ORIENTATION_HORIZONTAL); }
static void ygtk_ratio_hbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
-{
- ygtk_ratio_box_size_allocate (widget, allocation, GTK_ORIENTATION_HORIZONTAL);
-}
+{ ygtk_ratio_box_size_allocate (widget, allocation, GTK_ORIENTATION_HORIZONTAL); }
GtkWidget* ygtk_ratio_hbox_new (gint spacing)
{
@@ -251,20 +246,15 @@
G_DEFINE_TYPE (YGtkRatioVBox, ygtk_ratio_vbox, YGTK_TYPE_RATIO_BOX)
static void ygtk_ratio_vbox_init (YGtkRatioVBox *box)
-{
-}
+{ }
static void ygtk_ratio_vbox_size_request (GtkWidget *widget,
GtkRequisition *requisition)
-{
- ygtk_ratio_box_size_request (widget, requisition, GTK_ORIENTATION_VERTICAL);
-}
+{ ygtk_ratio_box_size_request (widget, requisition, GTK_ORIENTATION_VERTICAL); }
static void ygtk_ratio_vbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
-{
- ygtk_ratio_box_size_allocate (widget, allocation, GTK_ORIENTATION_VERTICAL);
-}
+{ ygtk_ratio_box_size_allocate (widget, allocation, GTK_ORIENTATION_VERTICAL); }
GtkWidget* ygtk_ratio_vbox_new (gint spacing)
{
Modified: trunk/gtk/src/ygtkwizard.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=52350&r1=52349&r2=52350&view=diff
==============================================================================
--- trunk/gtk/src/ygtkwizard.c (original)
+++ trunk/gtk/src/ygtkwizard.c Sun Oct 19 19:23:17 2008
@@ -24,6 +24,9 @@
#define HELP_IMG_BG "yelp-icon-big"
+// test feature: history on help dialog
+#define SET_HELP_HISTORY
+
// YGUtils bridge
extern void ygutils_setWidgetFont (GtkWidget *widget, PangoStyle style,
PangoWeight weight, double scale);
@@ -60,6 +63,7 @@
}
static void search_entry_activated_cb (GtkEntry *entry, YGtkHelpDialog *dialog)
{ ygtk_help_dialog_find_next (dialog); }
+
static void close_button_clicked_cb (GtkButton *button, YGtkHelpDialog *dialog)
{ gtk_widget_hide (GTK_WIDGET (dialog)); }
@@ -113,10 +117,20 @@
g_signal_connect (G_OBJECT (dialog->search_entry), "activate",
G_CALLBACK (search_entry_activated_cb), dialog);
+#ifdef SET_HELP_HISTORY
+ dialog->history_combo = gtk_combo_box_new_text();
+#endif
+
// glue it
dialog->vbox = gtk_vbox_new (FALSE, 12);
+#ifdef SET_HELP_HISTORY
+ GtkWidget *hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON), FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->history_combo, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, FALSE, TRUE, 0);
+#endif
gtk_box_pack_start (GTK_BOX (dialog->vbox), dialog->help_box, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (dialog->vbox), bottom_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->vbox), bottom_box, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (dialog), dialog->vbox);
gtk_widget_show_all (dialog->vbox);
@@ -151,6 +165,7 @@
{
gtk_editable_delete_text (GTK_EDITABLE (dialog->search_entry), 0, -1);
ygtk_html_wrap_set_text (dialog->help_text, text, FALSE);
+ ygtk_html_wrap_scroll (dialog->help_text, TRUE);
}
static void ygtk_help_dialog_class_init (YGtkHelpDialogClass *klass)
@@ -176,6 +191,125 @@
gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "close", 0);
}
+typedef struct TitleTextPair {
+ gchar *title, *text;
+} TitleTextPair;
+
+YGtkHelpText *ygtk_help_text_new (void)
+{ return g_new0 (YGtkHelpText, 1); }
+
+void ygtk_help_text_destroy (YGtkHelpText *help)
+{
+ if (help->history) {
+ GList *i;
+ for (i = help->history; i; i = i->next) {
+ TitleTextPair *pair = i->data;
+ g_free (pair->title);
+ g_free (pair->text);
+ g_free (pair);
+ }
+ g_list_free (help->history);
+ help->history = 0;
+ }
+ if (help->dialog) {
+ gtk_widget_destroy (help->dialog);
+ help->dialog = 0;
+ }
+}
+
+static gint compare_links (gconstpointer pa, gconstpointer pb)
+{
+ const TitleTextPair *a = pa, *b = pb;
+ return strcmp (a->text, b->text);
+}
+
+void ygtk_help_text_set (YGtkHelpText *help, const gchar *title, const gchar *text)
+{
+ if (!*text) return;
+ TitleTextPair *pair = g_new (TitleTextPair, 1);
+ if (title)
+ pair->title = g_strdup (title);
+ else {
+ gboolean in_tag = FALSE;
+ GString *str = g_string_new ("");
+ const gchar *i;
+ for (i = text; *i; i++) {
+ if (*i == '<')
+ in_tag = TRUE;
+ else if (*i == '>')
+ in_tag = FALSE;
+ else if (*i == '\n') {
+ if (str->len)
+ break;
+ }
+ else if (!in_tag)
+ str = g_string_append_c (str, *i);
+ }
+ pair->title = g_string_free (str, FALSE);
+ }
+ pair->text = g_strdup (text);
+
+ GList *i = g_list_find_custom (help->history, pair, (GCompareFunc) compare_links);
+ if (i) {
+ TitleTextPair *p = i->data;
+ g_free (p->text);
+ g_free (p->title);
+ g_free (p);
+ help->history = g_list_delete_link (help->history, i);
+ }
+ help->history = g_list_prepend (help->history, pair);
+ if (help->dialog)
+ ygtk_help_text_sync (help, NULL);
+}
+
+const gchar *ygtk_help_text_get (YGtkHelpText *help, gint n)
+{
+ TitleTextPair *pair = g_list_nth_data (help->history, n);
+ if (pair)
+ return pair->text;
+ return NULL;
+}
+
+#ifdef SET_HELP_HISTORY
+static void history_changed_cb (GtkComboBox *combo, YGtkHelpText *text)
+{
+ YGtkHelpDialog *dialog = YGTK_HELP_DIALOG (text->dialog);
+ gint active = gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->history_combo));
+ ygtk_help_dialog_set_text (dialog, ygtk_help_text_get (text, active));
+}
+#endif
+
+void ygtk_help_text_sync (YGtkHelpText *help, GtkWidget *widget)
+{
+ YGtkHelpDialog *dialog;
+ if (!help->dialog) {
+ if (!widget)
+ return;
+#ifdef SET_HELP_HISTORY
+ dialog = YGTK_HELP_DIALOG (widget);
+ g_signal_connect (G_OBJECT (dialog->history_combo), "changed",
+ G_CALLBACK (history_changed_cb), help);
+#endif
+ help->dialog = widget;
+ }
+ dialog = YGTK_HELP_DIALOG (help->dialog);
+ ygtk_help_dialog_set_text (dialog, ygtk_help_text_get (help, 0));
+
+#ifdef SET_HELP_HISTORY
+ g_signal_handlers_block_by_func (dialog->history_combo, history_changed_cb, help);
+ GtkListStore *store = GTK_LIST_STORE (gtk_combo_box_get_model (
+ GTK_COMBO_BOX (dialog->history_combo)));
+ gtk_list_store_clear (store);
+ GList *i;
+ for (i = help->history; i; i = i->next) {
+ TitleTextPair *pair = i->data;
+ gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->history_combo), pair->title);
+ }
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->history_combo), 0);
+ g_signal_handlers_unblock_by_func (dialog->history_combo, history_changed_cb, help);
+#endif
+}
+
//** Header
typedef struct _YGtkWizardHeader
@@ -263,6 +397,9 @@
static void ygtk_wizard_header_set_title (YGtkWizardHeader *header, const gchar *text)
{ gtk_label_set_text (GTK_LABEL (header->title), text); }
+static const gchar *ygtk_wizard_header_get_title (YGtkWizardHeader *header)
+{ return gtk_label_get_text (GTK_LABEL (header->title)); }
+
static void ygtk_wizard_header_set_description (YGtkWizardHeader *header, const gchar *text)
{
GString *str = g_string_new ("");
@@ -405,11 +542,12 @@
{
if (gtk_toggle_button_get_active (button))
ygtk_wizard_popup_help (wizard);
- else if (wizard->m_help_dialog)
- gtk_widget_hide (wizard->m_help_dialog);
+ else if (wizard->m_help->dialog)
+ gtk_widget_hide (wizard->m_help->dialog);
}
static void help_button_silent_set_active (YGtkWizard *wizard, gboolean active)
{
+ if (!wizard->help_button) return; // unmap may be issued at destroy
GtkToggleButton *button = GTK_TOGGLE_BUTTON (wizard->help_button);
g_signal_handlers_block_by_func (button,
(gpointer) help_button_toggled_cb, wizard);
@@ -422,17 +560,16 @@
static void ygtk_wizard_popup_help (YGtkWizard *wizard)
{
- if (!wizard->m_help_dialog) {
+ if (!wizard->m_help->dialog) {
GtkWindow *window = (GtkWindow *) gtk_widget_get_ancestor (
GTK_WIDGET (wizard), GTK_TYPE_WINDOW);
- wizard->m_help_dialog = ygtk_help_dialog_new (window);
- ygtk_help_dialog_set_text (YGTK_HELP_DIALOG (wizard->m_help_dialog),
- wizard->m_help);
- g_signal_connect (G_OBJECT (wizard->m_help_dialog), "unmap",
+ GtkWidget *dialog = ygtk_help_dialog_new (window);
+ g_signal_connect (G_OBJECT (dialog), "unmap",
G_CALLBACK (help_dialog_unmap_cb), wizard);
+ ygtk_help_text_sync (wizard->m_help, dialog);
}
help_button_silent_set_active (wizard, TRUE);
- gtk_window_present (GTK_WINDOW (wizard->m_help_dialog));
+ gtk_window_present (GTK_WINDOW (wizard->m_help->dialog));
}
static void more_clicked_cb (YGtkWizardHeader *header, YGtkWizard *wizard)
@@ -554,18 +691,14 @@
GTK_OBJECT_CLASS (ygtk_wizard_parent_class)->destroy (object);
YGtkWizard *wizard = YGTK_WIZARD (object);
+ wizard->help_button = NULL; // dialog unmap will try to access this
destroy_hash (&wizard->menu_ids, FALSE);
destroy_hash (&wizard->tree_ids, TRUE);
destroy_hash (&wizard->steps_ids, FALSE);
-
if (wizard->m_help) {
- g_free (wizard->m_help);
+ ygtk_help_text_destroy (wizard->m_help);
wizard->m_help = NULL;
}
- if (wizard->m_help_dialog) {
- gtk_widget_destroy (wizard->m_help_dialog);
- wizard->m_help_dialog = NULL;
- }
}
GtkWidget *ygtk_wizard_new (void)
@@ -672,11 +805,12 @@
void ygtk_wizard_set_help_text (YGtkWizard *wizard, const gchar *text)
{
- if (wizard->m_help)
- g_free (wizard->m_help);
- wizard->m_help = g_strdup (text);
- if (wizard->m_help_dialog)
- ygtk_help_dialog_set_text (YGTK_HELP_DIALOG (wizard->m_help_dialog), text);
+ if (!wizard->m_help)
+ wizard->m_help = ygtk_help_text_new();
+ const gchar *title = ygtk_wizard_header_get_title (YGTK_WIZARD_HEADER (wizard->m_title));
+ if (!strcmp (title, "YaST"))
+ title = 0;
+ ygtk_help_text_set (wizard->m_help, title, text);
ygtk_wizard_header_set_description (YGTK_WIZARD_HEADER (wizard->m_title), text);
ENABLE_WIDGET_STR (text, wizard->help_button);
}
Modified: trunk/gtk/src/ygtkwizard.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.h?rev=52350&r1=52349&r2=52350&view=diff
==============================================================================
--- trunk/gtk/src/ygtkwizard.h (original)
+++ trunk/gtk/src/ygtkwizard.h Sun Oct 19 19:23:17 2008
@@ -15,6 +15,17 @@
#include
G_BEGIN_DECLS
+typedef struct YGtkHelpText {
+ GList *history;
+ GtkWidget *dialog;
+} YGtkHelpText;
+
+YGtkHelpText *ygtk_help_text_new (void);
+void ygtk_help_text_destroy (YGtkHelpText *help);
+void ygtk_help_text_set (YGtkHelpText *help, const gchar *title, const gchar *text);
+const gchar *ygtk_help_text_get (YGtkHelpText *help, gint n);
+void ygtk_help_text_sync (YGtkHelpText *help, GtkWidget *dialog);
+
// YGtkHelpDialog (for showing help text)
/* Shows help text. It is GtkWindow-inherited, rather than GtkDialog, because
we want to place a search entry next to the buttons. */
@@ -35,10 +46,10 @@
{
GtkWindow parent;
- // parent:
+ // members:
GtkWidget *title_box, *title_label, *title_image;
GtkWidget *help_box, *help_text;
- GtkWidget *search_entry, *close_button;
+ GtkWidget *search_entry, *close_button, *history_combo;
GtkWidget *vbox;
} YGtkHelpDialog;
@@ -54,7 +65,7 @@
GtkWidget *ygtk_help_dialog_new (GtkWindow *parent);
GType ygtk_help_dialog_get_type (void) G_GNUC_CONST;
-void ygtk_help_dialog_set_text (YGtkHelpDialog *dialog, const char *text);
+void ygtk_help_dialog_set_text (YGtkHelpDialog *dialog, const gchar *text);
// YGtkWizard
@@ -90,8 +101,7 @@
*release_notes_button;
/* The help text. */
- gchar *m_help;
- GtkWidget *m_help_dialog;
+ YGtkHelpText *m_help;
} YGtkWizard;
typedef struct _YGtkWizardClass
@@ -158,3 +168,4 @@
G_END_DECLS
#endif /* YGTK_WIZARD_H */
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org