Author: rpmcruz Date: Thu Dec 6 13:42:24 2007 New Revision: 42756 URL: http://svn.opensuse.org/viewcvs/yast?rev=42756&view=rev Log: * Fixed previous crash, some other problems and some improvements. * Weird problems left: + it hangs when suposedly the code is already terminated. + crashes on sw_single (says we are calling a pure virtual func) sometimes, it just exists normally right after the selector widget appears + there could be layout probs... test that + radio buttons are not working Modified: trunk/gtk/unstable-libyui/ChangeLog trunk/gtk/unstable-libyui/src/Makefile.am trunk/gtk/unstable-libyui/src/YGBarGraph.cc trunk/gtk/unstable-libyui/src/YGComboBox.cc trunk/gtk/unstable-libyui/src/YGDialog.cc trunk/gtk/unstable-libyui/src/YGDumbTab.cc trunk/gtk/unstable-libyui/src/YGFrame.cc trunk/gtk/unstable-libyui/src/YGImage.cc trunk/gtk/unstable-libyui/src/YGInputField.cc trunk/gtk/unstable-libyui/src/YGIntField.cc trunk/gtk/unstable-libyui/src/YGLabel.cc trunk/gtk/unstable-libyui/src/YGLayout.cc trunk/gtk/unstable-libyui/src/YGMenuButton.cc trunk/gtk/unstable-libyui/src/YGMultiLineEdit.cc trunk/gtk/unstable-libyui/src/YGPackageSelector.cc trunk/gtk/unstable-libyui/src/YGProgressBar.cc trunk/gtk/unstable-libyui/src/YGPushButton.cc trunk/gtk/unstable-libyui/src/YGRadioButton.cc trunk/gtk/unstable-libyui/src/YGSelectionModel.cc trunk/gtk/unstable-libyui/src/YGSelectionModel.h trunk/gtk/unstable-libyui/src/YGTable.cc trunk/gtk/unstable-libyui/src/YGUI.cc trunk/gtk/unstable-libyui/src/YGUI.h trunk/gtk/unstable-libyui/src/YGWidget.cc trunk/gtk/unstable-libyui/src/YGWidget.h trunk/gtk/unstable-libyui/src/YGWizard.cc trunk/gtk/unstable-libyui/src/ygtkfieldentry.c trunk/gtk/unstable-libyui/src/ygtkfieldentry.h trunk/gtk/unstable-libyui/src/ygtkrichtext.c trunk/gtk/unstable-libyui/src/ygtkwizard.c trunk/gtk/unstable-libyui/src/ygtkwizard.h Modified: trunk/gtk/unstable-libyui/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/ChangeLog?rev... ============================================================================== --- trunk/gtk/unstable-libyui/ChangeLog (original) +++ trunk/gtk/unstable-libyui/ChangeLog Thu Dec 6 13:42:24 2007 @@ -1,3 +1,20 @@ +2007-12-06 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> + + * Fixed previous crash, some other problems and some improvements. + * Weird problems left: + + it hangs when suposedly the code is already terminated. + + crashes on sw_single (says we are calling a pure virtual func) + sometimes, it just exists normally right after the selector widget + appears + + there could be layout probs... test that + + radio buttons are not working + +2007-12-05 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> + + * First version: ported the all thing; getting a crash due to child + being added to container at the YWidget() constructor, before we get to + setup the reference to then use on the layout widget. + 2007-12-04 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> * src/ygtkimage.h/c: moved YGImage stuff to an actual widget impl. Added Modified: trunk/gtk/unstable-libyui/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/Makefile.... ============================================================================== --- trunk/gtk/unstable-libyui/src/Makefile.am (original) +++ trunk/gtk/unstable-libyui/src/Makefile.am Thu Dec 6 13:42:24 2007 @@ -38,7 +38,6 @@ YGBarGraph.cc \ YGDumbTab.cc \ YGWizard.cc \ - YGTime.cc \ YGPackageSelector.cc \ ygtkratiobox.c \ ygtkbargraph.c \ Modified: trunk/gtk/unstable-libyui/src/YGBarGraph.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGBarGrap... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGBarGraph.cc (original) +++ trunk/gtk/unstable-libyui/src/YGBarGraph.cc Thu Dec 6 13:42:24 2007 @@ -14,7 +14,7 @@ { public: YGBarGraph (YWidget *parent) - : YBarGraph (parent) + : YBarGraph (NULL) , YGWidget (this, parent, true, YGTK_TYPE_BAR_GRAPH, NULL) {} @@ -27,7 +27,7 @@ ygtk_bar_graph_setup_entry (YGTK_BAR_GRAPH (getWidget()), i, s.label().c_str(), s.value()); } - // FIXME: new libyui colors segments ... We probably should honor it + // FIXME: new libyui colors segments ... We probably should honor that } YGWIDGET_IMPL_COMMON @@ -49,7 +49,7 @@ YGPartitionSplitter (YWidget *parent, int usedSize, int totalFreeSize, int newPartSize, int minNewPartSize, int minFreeSize, const string &usedLabel, const string &freeLabel, const string &newPartLabel, const string &freeFieldLabel, const string &newPartFieldLabel) - : YPartitionSplitter (parent, usedSize, totalFreeSize, newPartSize, minNewPartSize, + : YPartitionSplitter (NULL, usedSize, totalFreeSize, newPartSize, minNewPartSize, minFreeSize, usedLabel, freeLabel, newPartLabel, freeFieldLabel, newPartFieldLabel) , YGWidget (this, parent, true, GTK_TYPE_VBOX, NULL) { Modified: trunk/gtk/unstable-libyui/src/YGComboBox.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGComboBo... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGComboBox.cc (original) +++ trunk/gtk/unstable-libyui/src/YGComboBox.cc Thu Dec 6 13:42:24 2007 @@ -14,7 +14,7 @@ { public: YGComboBox (YWidget *parent, const string &label, bool editable) - : YComboBox (parent, label, editable) + : YComboBox (NULL, label, editable) , YGLabeledWidget (this, parent, label, YD_HORIZ, true, editable ? GTK_TYPE_COMBO_BOX_ENTRY : GTK_TYPE_COMBO_BOX, NULL) , YGSelectionModel (true, false) @@ -33,6 +33,7 @@ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (getWidget()), cell, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (getWidget()), cell, "pixbuf", YGSelectionModel::ICON_COLUMN, NULL); + gtk_combo_box_set_model (getComboBox(), getModel()); g_signal_connect (G_OBJECT (getWidget()), "changed", G_CALLBACK (selected_changed_cb), this); @@ -41,11 +42,6 @@ inline GtkComboBox *getComboBox() { return GTK_COMBO_BOX (getWidget()); } - virtual void setModel (GtkTreeModel *model) - { - gtk_combo_box_set_model (getComboBox(), model); - } - GtkEntry *getEntry() { if (!GTK_IS_COMBO_BOX_ENTRY (getWidget())) { Modified: trunk/gtk/unstable-libyui/src/YGDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGDialog.... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGDialog.cc (original) +++ trunk/gtk/unstable-libyui/src/YGDialog.cc Thu Dec 6 13:42:24 2007 @@ -69,6 +69,9 @@ gtk_window_set_default_size (window, w, h); } + if (YGUI::ui()->setFullscreen()) + gtk_window_fullscreen (window); + gtk_window_set_role (window, "yast-gtk"); if (!YGUI::ui()->hasWM()) g_signal_connect (G_OBJECT (m_widget), "expose-event", @@ -258,22 +261,12 @@ : YDialog (dialogType, colorMode), YGWidget (this, NULL, FALSE, GTK_TYPE_HBOX, NULL) { -fprintf(stderr, "ygdialog()\n"); setBorder (0); -fprintf(stderr, "border\n"); m_containee = gtk_event_box_new(); -fprintf(stderr, "containee\n"); if (dialogType == YMainDialog && main_window) -{ -fprintf(stderr, "use main window\n"); m_window = main_window; -} else -{ -fprintf(stderr, "create window\n"); m_window = new YGWindow (dialogType == YMainDialog); -} -fprintf(stderr, "ygdialog start window: %p\n", m_window); YGWindow::ref (m_window); if (colorMode != YDialogNormalColor) { @@ -351,7 +344,7 @@ YGDialog *YGDialog::currentDialog() { - YDialog *ydialog = YDialog::currentDialog(); + YDialog *ydialog = YDialog::currentDialog (false); if (ydialog) return static_cast <YGDialog *> (ydialog); return NULL; @@ -360,10 +353,8 @@ GtkWindow *YGDialog::currentWindow() { YGDialog *ydialog = YGDialog::currentDialog(); - if (ydialog) { -fprintf(stderr, "m_window: %p\n", ydialog->m_window); + if (ydialog) return GTK_WINDOW (ydialog->m_window->getWidget()); - } return NULL; } @@ -398,7 +389,6 @@ YDialog *YGWidgetFactory::createDialog (YDialogType dialogType, YDialogColorMode colorMode) { IMPL -fprintf(stderr, "create dialog\n"); return new YGDialog (dialogType, colorMode); } Modified: trunk/gtk/unstable-libyui/src/YGDumbTab.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGDumbTab... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGDumbTab.cc (original) +++ trunk/gtk/unstable-libyui/src/YGDumbTab.cc Thu Dec 6 13:42:24 2007 @@ -18,14 +18,13 @@ public: YGDumbTab (YWidget *parent) - : YDumbTab (parent), + : YDumbTab (NULL), YGWidget (this, parent, true, GTK_TYPE_NOTEBOOK, NULL) { IMPL m_containee = gtk_event_box_new(); gtk_widget_show (m_containee); - g_object_ref (G_OBJECT (m_containee)); - gtk_object_sink (GTK_OBJECT (m_containee)); + g_object_ref_sink (G_OBJECT (m_containee)); m_last_tab = 0; // GTK+ keeps the notebook size set to the biggset page. We can't @@ -33,8 +32,8 @@ // reduce its size. ygtk_adj_size_set_only_expand (YGTK_ADJ_SIZE (m_adj_size), TRUE); - g_signal_connect (G_OBJECT (getWidget()), "switch-page", - G_CALLBACK (changed_tab_cb), this); + g_signal_connect_after (G_OBJECT (getWidget()), "switch-page", + G_CALLBACK (changed_tab_cb), this); } ~YGDumbTab() @@ -49,7 +48,7 @@ GtkWidget *tab_label, *image = 0, *label; string str = YGUtils::mapKBAccel (item->label()); - label = gtk_label_new (str.c_str()); + label = gtk_label_new_with_mnemonic (str.c_str()); gtk_widget_show (label); if (item->hasIconName()) { @@ -70,15 +69,15 @@ GtkNotebook *notebook = GTK_NOTEBOOK (getWidget()); g_signal_handlers_block_by_func (notebook, (gpointer) changed_tab_cb, this); - GtkWidget *empty = gtk_event_box_new(); + GtkWidget *page = gtk_event_box_new(); + gtk_widget_show (page); + item->setData ((void *) page); + g_object_set_data (G_OBJECT (page), "yitem", item); - g_object_set_data (G_OBJECT (empty), "yitem", item); - gtk_widget_show (empty); + gtk_notebook_append_page (notebook, page, tab_label); - gtk_notebook_append_page (notebook, empty, tab_label); - - if (!m_last_tab) - change_tab (0); + if (!m_last_tab) /*first tab*/ + syncTabPage(); g_signal_handlers_unblock_by_func (notebook, (gpointer) changed_tab_cb, this); } @@ -86,16 +85,14 @@ virtual void deleteAllItems() { GList *children = gtk_container_get_children (GTK_CONTAINER (getWidget())); - for (GList *i = children; i; i = i->next) { - GtkWidget *child = (GtkWidget *) i->data; - gtk_container_remove (GTK_CONTAINER (getWidget()), child); - } + for (GList *i = children; i; i = i->next) + gtk_container_remove (GTK_CONTAINER (getWidget()), (GtkWidget *) i->data); g_list_free (children); } // to re-use the same widget in all tabs (m_fixed), we will remove and // add to the tabs' child as tabs are changed - void change_tab (int tab_nb) + void syncTabPage() { if (m_last_tab) gtk_container_remove (GTK_CONTAINER (m_last_tab), m_containee); @@ -121,22 +118,15 @@ { IMPL if (selected) { - GList *children = gtk_container_get_children (GTK_CONTAINER (getWidget())); - int nb = 0; - for (GList *i = children; i; i = i->next) { - GtkWidget *child = (GtkWidget *) i->data; - if (g_object_get_data (G_OBJECT (child), "yitem") == item) { - change_tab (nb); - g_signal_handlers_block_by_func (getWidget(), - (gpointer) changed_tab_cb, this); - gtk_notebook_set_current_page (GTK_NOTEBOOK (getWidget()), nb); - g_signal_handlers_unblock_by_func (getWidget(), - (gpointer) changed_tab_cb, this); - break; - } - nb++; - } - g_list_free (children); + GtkWidget *child = (GtkWidget *) item->data(); + int page = gtk_notebook_page_num (GTK_NOTEBOOK (getWidget()), child); + + g_signal_handlers_block_by_func (getWidget(), + (gpointer) changed_tab_cb, this); + gtk_notebook_set_current_page (GTK_NOTEBOOK (getWidget()), page); + g_signal_handlers_unblock_by_func (getWidget(), + (gpointer) changed_tab_cb, this); + syncTabPage(); } } @@ -147,7 +137,7 @@ YItem *item = (YItem *) g_object_get_data (G_OBJECT (child), "yitem"); YGUI::ui()->sendEvent (new YMenuEvent (item)); - pThis->change_tab (tab_nb); + pThis->syncTabPage(); } YGWIDGET_IMPL_COMMON Modified: trunk/gtk/unstable-libyui/src/YGFrame.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGFrame.c... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGFrame.cc (original) +++ trunk/gtk/unstable-libyui/src/YGFrame.cc Thu Dec 6 13:42:24 2007 @@ -37,7 +37,7 @@ { public: YGFrame (YWidget *parent, const string &label) - : YFrame (parent, label), + : YFrame (NULL, label), YGBaseFrame (this, parent) { GtkWidget *label_widget = gtk_label_new (""); @@ -86,7 +86,7 @@ { public: YGCheckBoxFrame (YWidget *parent, const string &label, bool checked) - : YCheckBoxFrame (parent, label, checked), + : YCheckBoxFrame (NULL, label, checked), YGBaseFrame (this, parent) { IMPL Modified: trunk/gtk/unstable-libyui/src/YGImage.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGImage.c... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGImage.cc (original) +++ trunk/gtk/unstable-libyui/src/YGImage.cc Thu Dec 6 13:42:24 2007 @@ -14,7 +14,7 @@ { public: YGImage (YWidget *parent, const string &filename, bool animated) - : YImage (parent, filename, animated), + : YImage (NULL, filename, animated), YGWidget (this, parent, true, YGTK_TYPE_IMAGE, NULL) { IMPL Modified: trunk/gtk/unstable-libyui/src/YGInputField.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGInputFi... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGInputField.cc (original) +++ trunk/gtk/unstable-libyui/src/YGInputField.cc Thu Dec 6 13:42:24 2007 @@ -14,44 +14,54 @@ { public: YGInputField (YWidget *parent, const string &label, bool passwordMode) - : YInputField (parent, label, passwordMode), + : YInputField (NULL, label, passwordMode), YGLabeledWidget (this, parent, label, YD_HORIZ, true, - GTK_TYPE_ENTRY, NULL) + YGTK_TYPE_FIELD_ENTRY, NULL) { - gtk_entry_set_activates_default (GTK_ENTRY (getWidget()), TRUE); + YGtkFieldEntry *field = YGTK_FIELD_ENTRY (getWidget()); + ygtk_field_entry_add_field (field, 0); + + GtkEntry *entry = ygtk_field_entry_get_field_widget (field, 0); + gtk_entry_set_activates_default (entry, TRUE); if (passwordMode) - gtk_entry_set_visibility (GTK_ENTRY (getWidget()), FALSE); + gtk_entry_set_visibility (entry, FALSE); - // Signals to know of any text modification - g_signal_connect (G_OBJECT (getWidget()), "changed", - G_CALLBACK (text_changed_cb), this); + g_signal_connect (G_OBJECT (getWidget()), "field-entry-changed", + G_CALLBACK (value_changed_cb), this); } - // YTextEntry + // YInputField virtual string value() { - return gtk_entry_get_text (GTK_ENTRY (getWidget())); + YGtkFieldEntry *field = YGTK_FIELD_ENTRY (getWidget()); + return ygtk_field_entry_get_field_text (field, 0); } virtual void setValue (const string &text) { - /* No need to check for valid chars as that's the responsible of the YCP - application programmer. */ - gtk_entry_set_text (GTK_ENTRY (getWidget()), text.c_str()); + YGtkFieldEntry *field = YGTK_FIELD_ENTRY (getWidget()); + ygtk_field_entry_set_field_text (field, 0, text.c_str()); } - virtual void setInputMaxLength (int nb) + void updateProps() { - gtk_entry_set_width_chars (GTK_ENTRY (getWidget()), nb); + YGtkFieldEntry *field = YGTK_FIELD_ENTRY (getWidget()); + ygtk_field_entry_setup_field (field, 0, inputMaxLength(), validChars().c_str()); + } + + virtual void setInputMaxLength (int len) + { + YInputField::setInputMaxLength (len); + updateProps(); } virtual void setValidChars (const string &validChars) { - YGUtils::setFilter (GTK_ENTRY (getWidget()), validChars); YInputField::setValidChars (validChars); + updateProps(); } - static void text_changed_cb (GtkEditable *editable, YGInputField *pThis) + static void value_changed_cb (YGtkFieldEntry *entry, gint field_nb, YGInputField *pThis) { pThis->emitEvent (YEvent::ValueChanged); } @@ -66,3 +76,210 @@ return new YGInputField (parent, label, passwordMode); } +#include "YTimeField.h" + +class YGTimeField : public YTimeField, public YGLabeledWidget +{ +public: + YGTimeField (YWidget *parent, const string &label) + : YTimeField (NULL, label), + YGLabeledWidget (this, parent, label, YD_HORIZ, true, + YGTK_TYPE_FIELD_ENTRY, NULL) + { + IMPL + YGtkFieldEntry *field = YGTK_FIELD_ENTRY (getWidget()); + ygtk_field_entry_add_field (field, ':'); + ygtk_field_entry_add_field (field, ':'); + ygtk_field_entry_setup_field (field, 0, 2, "0123456789"); + ygtk_field_entry_setup_field (field, 1, 2, "0123456789"); + + g_signal_connect (G_OBJECT (getWidget()), "field-entry-changed", + G_CALLBACK (value_changed_cb), this); + } + + // YTimeField + virtual void setValue (const string &time) + { + IMPL + char hours[3], mins[3]; + sscanf (time.c_str(), "%2s:%2s", hours, mins); + + YGtkFieldEntry *entry = YGTK_FIELD_ENTRY (getWidget()); + ygtk_field_entry_set_field_text (entry, 0, hours); + ygtk_field_entry_set_field_text (entry, 1, mins); + } + + virtual string value() + { + IMPL + const gchar *hours, *mins; + YGtkFieldEntry *entry = YGTK_FIELD_ENTRY (getWidget()); + hours = ygtk_field_entry_get_field_text (entry, 0); + mins = ygtk_field_entry_get_field_text (entry, 1); + + gchar *time = g_strdup_printf ("%02d:%02d:00", atoi (hours), atoi (mins)); + string str (time); + g_free (time); + return str; + } + + // callbacks + static void value_changed_cb (YGtkFieldEntry *entry, gint field_nb, + YGTimeField *pThis) + { IMPL; pThis->emitEvent (YEvent::ValueChanged); } + + YGWIDGET_IMPL_COMMON + YGLABEL_WIDGET_IMPL_SET_LABEL_CHAIN (YTimeField) +}; + +YTimeField *YGOptionalWidgetFactory::createTimeField (YWidget *parent, const string &label) +{ + IMPL + return new YGTimeField (parent, label); +} + +#include "YDateField.h" +#include "ygtkmenubutton.h" + +class YGDateField : public YDateField, public YGLabeledWidget +{ +GtkWidget *m_calendar, *m_popup_calendar; + +public: + YGDateField (YWidget *parent, const string &label) + : YDateField (NULL, label), + YGLabeledWidget (this, parent, label, YD_HORIZ, true, YGTK_TYPE_FIELD_ENTRY, NULL) + { + IMPL + ygtk_field_entry_add_field (getField(), '-'); + ygtk_field_entry_add_field (getField(), '-'); + ygtk_field_entry_add_field (getField(), '-'); + ygtk_field_entry_setup_field (getField(), 0, 4, "0123456789"); + ygtk_field_entry_setup_field (getField(), 1, 2, "0123456789"); + ygtk_field_entry_setup_field (getField(), 2, 2, "0123456789"); + + GtkWidget *menu_button = ygtk_menu_button_new(); + m_calendar = gtk_calendar_new(); + gtk_widget_show (m_calendar); + GtkWidget *popup = ygtk_popup_window_new (m_calendar); + ygtk_menu_button_set_popup (YGTK_MENU_BUTTON (menu_button), popup); + gtk_widget_show_all (popup); + gtk_widget_show_all (menu_button); + + gtk_box_pack_start (GTK_BOX (getWidget()), menu_button, FALSE, TRUE, 6); + + g_signal_connect (G_OBJECT (getField()), "field-entry-changed", + G_CALLBACK (value_changed_cb), this); + + g_signal_connect (G_OBJECT (m_calendar), "day-selected", + G_CALLBACK (calendar_changed_cb), this); + g_signal_connect (G_OBJECT (m_calendar), "day-selected-double-click", + G_CALLBACK (double_click_cb), popup); + } + + inline GtkCalendar *getCalendar() + { return GTK_CALENDAR (m_calendar); } + inline YGtkFieldEntry *getField() + { return YGTK_FIELD_ENTRY (getWidget()); } + + // YDateField + virtual void setValue (const string &date) + { + IMPL + char year[5], month[3], day[3]; + sscanf (date.c_str(), "%4s-%2s-%2s", year, month, day); + + gtk_calendar_select_month (getCalendar(), atoi (month)-1, atoi (year)); + gtk_calendar_select_day (getCalendar(), atoi (day)); + + ygtk_field_entry_set_field_text (getField(), 0, year); + ygtk_field_entry_set_field_text (getField(), 1, month); + ygtk_field_entry_set_field_text (getField(), 2, day); + } + + virtual string value() + { + IMPL + const gchar *year, *month, *day; + year = ygtk_field_entry_get_field_text (getField(), 0); + month = ygtk_field_entry_get_field_text (getField(), 1); + day = ygtk_field_entry_get_field_text (getField(), 2); + + gchar *time = g_strdup_printf ("%04d-%02d-%02d", atoi (year), + atoi (month), atoi (day)); + string str (time); + g_free (time); + return str; + } + + // callbacks + static void value_changed_cb (YGtkFieldEntry *entry, gint field_nb, + YGDateField *pThis) + { + IMPL + int year, month, day; + year = atoi (ygtk_field_entry_get_field_text (pThis->getField(), 0)); + month = atoi (ygtk_field_entry_get_field_text (pThis->getField(), 1)); + day = atoi (ygtk_field_entry_get_field_text (pThis->getField(), 2)); + + if (day < 1 || day > 31 || month < 1 || month > 12) + return; // avoid GtkCalendar warnings + + g_signal_handlers_block_by_func (pThis->getCalendar(), + (gpointer) calendar_changed_cb, pThis); + + gtk_calendar_select_month (pThis->getCalendar(), month-1, year); + gtk_calendar_select_day (pThis->getCalendar(), day); + + g_signal_handlers_unblock_by_func (pThis->getCalendar(), + (gpointer) calendar_changed_cb, pThis); + + pThis->emitEvent (YEvent::ValueChanged); + } + + static void calendar_changed_cb (GtkCalendar *calendar, YGDateField *pThis) + { + IMPL + guint year, month, day; + gtk_calendar_get_date (calendar, &year, &month, &day); + month += 1; // GTK calendar months go from 0 to 11 + + gchar *year_str, *month_str, *day_str; + year_str = g_strdup_printf ("%d", year); + month_str = g_strdup_printf ("%d", month); + day_str = g_strdup_printf ("%d", day); + + g_signal_handlers_block_by_func (pThis->getField(), + (gpointer) value_changed_cb, pThis); + + YGtkFieldEntry *entry = pThis->getField(); + ygtk_field_entry_set_field_text (entry, 0, year_str); + ygtk_field_entry_set_field_text (entry, 1, month_str); + ygtk_field_entry_set_field_text (entry, 2, day_str); + + g_signal_handlers_unblock_by_func (pThis->getField(), + (gpointer) value_changed_cb, pThis); + + g_free (year_str); + g_free (month_str); + g_free (day_str); + + pThis->emitEvent (YEvent::ValueChanged); + } + + static void double_click_cb (GtkCalendar *calendar, YGtkPopupWindow *popup) + { + // close popup + gtk_widget_hide (GTK_WIDGET (popup)); + } + + YGWIDGET_IMPL_COMMON + YGLABEL_WIDGET_IMPL_SET_LABEL_CHAIN (YDateField) +}; + +YDateField *YGOptionalWidgetFactory::createDateField (YWidget *parent, const string &label) +{ + IMPL + return new YGDateField (parent, label); +} + Modified: trunk/gtk/unstable-libyui/src/YGIntField.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGIntFiel... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGIntField.cc (original) +++ trunk/gtk/unstable-libyui/src/YGIntField.cc Thu Dec 6 13:42:24 2007 @@ -112,7 +112,7 @@ public: YGIntField (YWidget *parent, const string &label, int minValue, int maxValue, int initialValue) - : YIntField (parent, label, minValue, maxValue) + : YIntField (NULL, label, minValue, maxValue) , YGSpinBox (this, parent, label, minValue, maxValue, initialValue, false) {} @@ -134,7 +134,7 @@ public: YGSlider (YWidget *parent, const string &label, int minValue, int maxValue, int initialValue) - : YSlider (parent, label, minValue, maxValue) + : YSlider (NULL, label, minValue, maxValue) , YGSpinBox (this, parent, label, minValue, maxValue, initialValue, true) {} Modified: trunk/gtk/unstable-libyui/src/YGLabel.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGLabel.c... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGLabel.cc (original) +++ trunk/gtk/unstable-libyui/src/YGLabel.cc Thu Dec 6 13:42:24 2007 @@ -14,7 +14,7 @@ { public: YGLabel (YWidget *parent, const string &text, bool heading, bool outputField) - : YLabel (parent, text, heading, outputField), + : YLabel (NULL, text, heading, outputField), YGWidget (this, parent, true, GTK_TYPE_LABEL, NULL) { IMPL Modified: trunk/gtk/unstable-libyui/src/YGLayout.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGLayout.... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGLayout.cc (original) +++ trunk/gtk/unstable-libyui/src/YGLayout.cc Thu Dec 6 13:42:24 2007 @@ -22,7 +22,7 @@ public: YGLayoutBox (YWidget *parent, YUIDimension dim) - : YLayoutBox (parent, dim), + : YLayoutBox (NULL, dim), YGWidget (this, parent, true, dim == YD_HORIZ ? YGTK_TYPE_RATIO_HBOX : YGTK_TYPE_RATIO_VBOX, NULL) { @@ -36,14 +36,13 @@ g_object_unref (G_OBJECT (m_labels_group)); } - virtual void addChild (YWidget *ychild) + virtual string getDebugLabel() const + { return primary() == YD_HORIZ ? "horizontal" : "vertical"; } + + virtual void doAddChild (YWidget *ychild, GtkWidget *container) { IMPL - YLayoutBox::addChild (ychild); - YGWidget *ygchild = YGWidget::get (ychild); - - gtk_container_add (GTK_CONTAINER (getWidget()), ygchild->getLayout()); - sync_stretchable (ychild); + YGWidget::doAddChild (ychild, container); // set labels of YGLabeledWidgets to the same width // we have to do quite some work due to over-clutter on YCP progs @@ -60,7 +59,7 @@ } } else { - ygchild = YGWidget::get (ychild); + YGWidget *ygchild = YGWidget::get (ychild); YGLabeledWidget *labeled_child = dynamic_cast <YGLabeledWidget *> (ygchild); if (labeled_child && labeled_child->orientation() == YD_HORIZ) { if (!m_labels_group) @@ -72,6 +71,8 @@ } } } + + YGWIDGET_IMPL_CHILD_ADDED (getWidget()) YGWIDGET_IMPL_CHILD_REMOVED (getWidget()) virtual void sync_stretchable (YWidget *ychild) @@ -108,7 +109,7 @@ public: YGAlignment (YWidget *parent, YAlignmentType halign, YAlignmentType valign) - : YAlignment (parent, halign, valign), + : YAlignment (NULL, halign, valign), YGWidget (this, parent, true, GTK_TYPE_ALIGNMENT, NULL) { setBorder (0); @@ -121,26 +122,24 @@ g_object_unref (G_OBJECT (m_background_pixbuf)); } - virtual void childAdded (YWidget *ychild) + virtual void doAddChild (YWidget *ychild, GtkWidget *container) { - YGWidget *child = YGWidget::get (ychild); - gtk_container_add (GTK_CONTAINER (getWidget()), child->getLayout()); + YGWidget::doAddChild (ychild, container); /* The padding is used for stuff like making YCP progs nicer for yast-qt wizard, so it hurts us -- it's disabled. */ //child->setPadding (topMargin(), bottomMargin(), // leftMargin(), rightMargin()); setMinSize (minWidth(), minHeight()); - - sync_stretchable (ychild); // alignment will be set here } + YGWIDGET_IMPL_CHILD_ADDED (m_widget) YGWIDGET_IMPL_CHILD_REMOVED (m_widget) virtual void sync_stretchable (YWidget *child) { IMPL setAlignment (alignment (YD_HORIZ), alignment (YD_VERT)); - YGWidget::sync_stretchable (m_ywidget); + YGWidget::sync_stretchable(); } void setAlignment (YAlignmentType halign, YAlignmentType valign) @@ -273,7 +272,7 @@ { public: YGEmpty (YWidget *parent) - : YEmpty (parent), + : YEmpty (NULL), YGWidget (this, parent, true, GTK_TYPE_EVENT_BOX, NULL) { setBorder (0); @@ -295,7 +294,7 @@ { public: YGSpacing (YWidget *parent, YUIDimension dim, bool stretchable, YLayoutSize_t size) - : YSpacing (parent, dim, stretchable, size), + : YSpacing (NULL, dim, stretchable, size), YGWidget (this, parent, true, GTK_TYPE_EVENT_BOX, NULL) { setBorder (0); @@ -314,12 +313,15 @@ #include "YReplacePoint.h" +//TEMP: +#include "YPushButton.h" + // an empty space that will get replaced class YGReplacePoint : public YReplacePoint, public YGWidget { public: YGReplacePoint (YWidget *parent) - : YReplacePoint (parent), + : YReplacePoint (NULL), YGWidget (this, parent, true, GTK_TYPE_EVENT_BOX, NULL) { setBorder (0); @@ -343,7 +345,7 @@ { public: YGSquash (YWidget *parent, bool hsquash, bool vsquash) - : YSquash (parent, hsquash, vsquash), + : YSquash (NULL, hsquash, vsquash), YGWidget (this, parent, true, GTK_TYPE_EVENT_BOX, NULL) { setBorder (0); Modified: trunk/gtk/unstable-libyui/src/YGMenuButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGMenuBut... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGMenuButton.cc (original) +++ trunk/gtk/unstable-libyui/src/YGMenuButton.cc Thu Dec 6 13:42:24 2007 @@ -14,7 +14,7 @@ { public: YGMenuButton (YWidget *parent, const string &label) - : YMenuButton (parent, label), + : YMenuButton (NULL, label), YGWidget (this, parent, true, YGTK_TYPE_MENU_BUTTON, NULL) { IMPL Modified: trunk/gtk/unstable-libyui/src/YGMultiLineEdit.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGMultiLi... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGMultiLineEdit.cc (original) +++ trunk/gtk/unstable-libyui/src/YGMultiLineEdit.cc Thu Dec 6 13:42:24 2007 @@ -102,7 +102,7 @@ { public: YGMultiLineEdit (YWidget *parent, const string &label) - : YMultiLineEdit (parent, label) + : YMultiLineEdit (NULL, label) , YGTextView (this, parent, label, true) {} @@ -134,7 +134,7 @@ { public: YGLogView (YWidget *parent, const string &label, int visibleLines, int maxLines) - : YLogView (parent, label, visibleLines, maxLines) + : YLogView (NULL, label, visibleLines, maxLines) , YGTextView (this, parent, label, false) {} @@ -163,7 +163,7 @@ public: YGPlainText(YWidget *parent, const string &text) - : YRichText (parent, text) + : YRichText (NULL, text) , YGTextView (this, parent, string(), false) { if (shrinkable()) @@ -189,7 +189,7 @@ { public: YGRichText (YWidget *parent, const string &text) - : YRichText (parent, text) + : YRichText (NULL, text) , YGScrolledWidget (this, parent, true, ygtk_html_wrap_get_type(), NULL) { IMPL Modified: trunk/gtk/unstable-libyui/src/YGPackageSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGPackage... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGPackageSelector.cc (original) +++ trunk/gtk/unstable-libyui/src/YGPackageSelector.cc Thu Dec 6 13:42:24 2007 @@ -10,6 +10,7 @@ #include "YGi18n.h" #include "YGDialog.h" +#if 1 #include "ygtkwizard.h" #include "ygtkfindentry.h" #include "ygtkhtmlwrap.h" @@ -1381,9 +1382,10 @@ public: YGPackageSelector (YWidget *parent, long mode) - : YPackageSelector (parent, mode), + : YPackageSelector (NULL, mode), YGWidget (this, parent, true, YGTK_TYPE_WIZARD, NULL) { +fprintf (stderr, "YGPackageSelector()\n"); setBorder (0); YGDialog *dialog = YGDialog::currentDialog(); dialog->setCloseCallback (confirm_cb, this); @@ -1392,6 +1394,7 @@ gtk_window_resize (window, GTK_WIDGET (window)->allocation.width, MAX (580, GTK_WIDGET (window)->allocation.height)); +fprintf (stderr, "wizard setup\n"); YGtkWizard *wizard = YGTK_WIZARD (getWidget()); ygtk_wizard_set_header_icon (wizard, window, THEMEDIR "/icons/32x32/apps/yast-software.png"); @@ -1400,18 +1403,22 @@ _("TO WRITE") ); +fprintf (stderr, "buttons strings\n"); ygtk_wizard_set_abort_button_label (wizard, _("_Cancel")); - ygtk_wizard_set_abort_button_id (wizard, g_strdup ("cancel"), g_free); + ygtk_wizard_set_abort_button_str_id (wizard, "cancel"); ygtk_wizard_set_back_button_label (wizard, ""); ygtk_wizard_set_next_button_label (wizard, _("_Accept")); - ygtk_wizard_set_next_button_id (wizard, g_strdup ("accept"), g_free); + ygtk_wizard_set_next_button_str_id (wizard, "accept"); g_signal_connect (G_OBJECT (getWidget()), "action-triggered", G_CALLBACK (wizard_action_cb), this); +fprintf (stderr, "create package selector\n"); m_package_selector = new PackageSelector(); gtk_container_add (GTK_CONTAINER (wizard), m_package_selector->getWidget()); +fprintf (stderr, "ypp::set interface()\n"); Ypp::get()->setInterface (this); +fprintf (stderr, "done()\n"); } virtual ~YGPackageSelector() @@ -1425,7 +1432,9 @@ gint id_type, YGPackageSelector *pThis) { IMPL +fprintf (stderr, "wizard action\n"); const gchar *action = (gchar *) id; +fprintf (stderr, "action: %s\n", action); if (!strcmp (action, "accept")) { y2milestone ("Closing PackageSelector with 'accept'"); @@ -1674,7 +1683,6 @@ gtk_container_add (GTK_CONTAINER (scroll), view); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), scroll); - #if 0 // version that uses viewport, labels and radio buttons -- unfortunately, // gtk+ enforces that one radio button per group to be selected -- we don't @@ -1748,6 +1756,20 @@ YGWIDGET_IMPL_COMMON }; +#else +#include "YPackageSelector.h" +class YGPackageSelector : public YPackageSelector, public YGWidget +{ +public: + YGPackageSelector (YWidget *parent, long mode) + : YPackageSelector (NULL, mode), + YGWidget (this, parent, true, GTK_TYPE_EVENT_BOX, NULL) + { + } + YGWIDGET_IMPL_COMMON +}; +#endif + YPackageSelector *YGWidgetFactory::createPackageSelector (YWidget *parent, long mode) { /* if (opt.youMode.value()) Modified: trunk/gtk/unstable-libyui/src/YGProgressBar.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGProgres... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGProgressBar.cc (original) +++ trunk/gtk/unstable-libyui/src/YGProgressBar.cc Thu Dec 6 13:42:24 2007 @@ -13,16 +13,13 @@ { public: YGProgressBar (YWidget *parent, const string &label, int maxValue) - : YProgressBar (parent, label, maxValue) + : YProgressBar (NULL, label, maxValue) // NOTE: its label widget is positionated at the vertical, because its label // may change often and so will its size, which will look odd (we may want // to make the label widget to only grow). , YGLabeledWidget (this, parent, label, YD_VERT, true, GTK_TYPE_PROGRESS_BAR, NULL) - { - } - - virtual ~YGProgressBar() {} + {} // YProgressBar virtual void setValue (int value) @@ -53,7 +50,7 @@ public: YGDownloadProgress (YWidget *parent, const string &label, const string &filename, YFileSize_t expectedFileSize) - : YDownloadProgress (parent, label, filename, expectedFileSize) + : YDownloadProgress (NULL, label, filename, expectedFileSize) , YGLabeledWidget (this, parent, label, YD_HORIZ, true, GTK_TYPE_PROGRESS_BAR, NULL) { @@ -98,7 +95,7 @@ { public: YGMultiProgressMeter (YWidget *parent, YUIDimension dim, const vector<float> &maxValues) - : YMultiProgressMeter (parent, dim, maxValues) + : YMultiProgressMeter (NULL, dim, maxValues) , YGWidget (this, parent, true, horizontal() == YD_HORIZ ? YGTK_TYPE_RATIO_HBOX : YGTK_TYPE_RATIO_VBOX, NULL) { Modified: trunk/gtk/unstable-libyui/src/YGPushButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGPushBut... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGPushButton.cc (original) +++ trunk/gtk/unstable-libyui/src/YGPushButton.cc Thu Dec 6 13:42:24 2007 @@ -15,7 +15,7 @@ public: YGPushButton (YWidget *parent, const string &label) - : YPushButton (parent, label), + : YPushButton (NULL, label), YGWidget (this, parent, true, GTK_TYPE_BUTTON, "can-default", TRUE, NULL) { IMPL Modified: trunk/gtk/unstable-libyui/src/YGRadioButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGRadioBu... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGRadioButton.cc (original) +++ trunk/gtk/unstable-libyui/src/YGRadioButton.cc Thu Dec 6 13:42:24 2007 @@ -39,7 +39,7 @@ { public: YGRadioButton (YWidget *parent, const std::string &label, bool isChecked) - : YRadioButton (parent, label), + : YRadioButton (NULL, label), YGWidget (this, parent, true, getCheckRadioButtonType(), NULL) { IMPL @@ -73,10 +73,11 @@ virtual void setValue (bool checked) { IMPL + fprintf (stderr, "setValue: %d to %s\n", checked, getDebugLabel().c_str()); g_signal_handlers_block_by_func (getWidget(), (gpointer) toggled_cb, this); - if (value()) - buttonGroup()->uncheckOtherButtons (this); + if (checked) + buttonGroup()->uncheckOtherButtons ((YRadioButton *) this); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (getWidget()), checked); g_signal_handlers_unblock_by_func (getWidget(), (gpointer) toggled_cb, this); @@ -89,15 +90,20 @@ static void toggled_cb (GtkButton *button, YGRadioButton *pThis) { IMPL +fprintf(stderr, "toggled\n"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - pThis->buttonGroup()->uncheckOtherButtons (pThis); +{ +fprintf(stderr, "uncheck others\n"); + pThis->buttonGroup()->uncheckOtherButtons ((YRadioButton *) pThis); +// pThis->emitEvent (YEvent::ValueChanged); +} else { + // leave it active g_signal_handlers_block_by_func (button, (gpointer) toggled_cb, pThis); +fprintf(stderr, "set active\n"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); g_signal_handlers_unblock_by_func (button, (gpointer) toggled_cb, pThis); } - - pThis->emitEvent (YEvent::ValueChanged); } }; @@ -114,7 +120,7 @@ { public: YGRadioButtonGroup(YWidget *parent) - : YRadioButtonGroup (parent), + : YRadioButtonGroup (NULL), YGWidget (this, parent, true, GTK_TYPE_EVENT_BOX, NULL) {} @@ -136,7 +142,7 @@ public: YGCheckBox(YWidget *parent, const string &label, bool isChecked) - : YCheckBox (parent, label), + : YCheckBox (NULL, label), YGWidget (this, parent, true, GTK_TYPE_CHECK_BUTTON, NULL) { IMPL Modified: trunk/gtk/unstable-libyui/src/YGSelectionModel.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGSelecti... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGSelectionModel.cc (original) +++ trunk/gtk/unstable-libyui/src/YGSelectionModel.cc Thu Dec 6 13:42:24 2007 @@ -20,7 +20,7 @@ } YGSelectionModel::~YGSelectionModel() -{ g_object_unref (G_OBJECT (model)); } +{ g_object_unref (G_OBJECT (m_model)); } void YGSelectionModel::createModel (const vector <GType> &types) { @@ -32,19 +32,17 @@ types_array[colsNb-1] = G_TYPE_POINTER; if (isTree) - model = GTK_TREE_MODEL (gtk_tree_store_newv (colsNb, types_array)); + m_model = GTK_TREE_MODEL (gtk_tree_store_newv (colsNb, types_array)); else - model = GTK_TREE_MODEL (gtk_list_store_newv (colsNb, types_array)); - setModel (model); + m_model = GTK_TREE_MODEL (gtk_list_store_newv (colsNb, types_array)); } GtkTreeModel *YGSelectionModel::getModel() -{ return model; } - +{ return m_model; } GtkListStore *YGSelectionModel::getListStore() -{ return model ? GTK_LIST_STORE (model) : NULL; } +{ return m_model ? GTK_LIST_STORE (m_model) : NULL; } GtkTreeStore *YGSelectionModel::getTreeStore() -{ return model ? GTK_TREE_STORE (model) : NULL; } +{ return m_model ? GTK_TREE_STORE (m_model) : NULL; } bool YGSelectionModel::isEmpty() { @@ -82,13 +80,28 @@ if (!gtk_tree_model_get_iter_first (getModel(), iter)) return false; - do { - gpointer ptr; - gtk_tree_model_get (getModel(), iter, getPtrCol(), &ptr, -1); - if (ptr == item) - return true; - } while (gtk_tree_model_iter_next (getModel(), iter)); - return false; + struct inner { + static bool getIter (GtkTreeModel *model, int col, YItem *item, GtkTreeIter *iter) + { + gpointer ptr; + gtk_tree_model_get (model, iter, col, &ptr, -1); + if (((YItem *) ptr)->index() == item->index()) + return true; + + GtkTreeIter child; + if (gtk_tree_model_iter_children (model, &child, iter)) { + if (getIter (model, col, item, &child)) { + *iter = child; + return true; + } + } + if (gtk_tree_model_iter_next (model, iter)) + return getIter (model, col, item, iter); + return false; + } + }; + + return inner::getIter (getModel(), getPtrCol(), item, iter); } void YGSelectionModel::implFocusItem (YItem *item) Modified: trunk/gtk/unstable-libyui/src/YGSelectionModel.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGSelecti... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGSelectionModel.h (original) +++ trunk/gtk/unstable-libyui/src/YGSelectionModel.h Thu Dec 6 13:42:24 2007 @@ -23,9 +23,7 @@ YGSelectionModel (bool ordinaryModel, bool isTree); virtual ~YGSelectionModel(); - // the model may not necessarly be created at construction GtkTreeModel *getModel(); - virtual void setModel (GtkTreeModel *model) = 0; void createModel (const vector <GType> &types); void doAddItem (YItem *item); @@ -47,7 +45,7 @@ protected: void implFocusItem (YItem *item); private: - GtkTreeModel *model; + GtkTreeModel *m_model; bool isTree; GtkListStore *getListStore(); GtkTreeStore *getTreeStore(); Modified: trunk/gtk/unstable-libyui/src/YGTable.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGTable.c... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGTable.cc (original) +++ trunk/gtk/unstable-libyui/src/YGTable.cc Thu Dec 6 13:42:24 2007 @@ -27,14 +27,15 @@ if (ordinaryModel) { addColumn (G_TYPE_STRING, "", YAlignUnchanged, YGSelectionModel::LABEL_COLUMN); addColumn (GDK_TYPE_PIXBUF, "", YAlignUnchanged, YGSelectionModel::ICON_COLUMN); + gtk_tree_view_set_model (getView(), getModel()); } gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (getWidget()), FALSE); /* Yast tools expect the user to be unable to un-select the row. They generally don't check to see if the returned value is -1. So, just disallow un-selection. */ - gtk_tree_selection_set_mode (gtk_tree_view_get_selection ( - GTK_TREE_VIEW (getWidget())), GTK_SELECTION_BROWSE); + GtkTreeSelection *selection = gtk_tree_view_get_selection (getView()); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); // let the derivates do the event hooks. They have subtile differences. } @@ -49,10 +50,10 @@ GtkTreeViewColumn *column = 0; // The allignment of the column items - gfloat xalign = 0.0; + gfloat xalign = -1; switch (header_align) { - case YAlignUnchanged: case YAlignBegin: + xalign = 0.0; break; case YAlignCenter: xalign = 0.5; @@ -60,11 +61,13 @@ case YAlignEnd: xalign = 1.0; break; + case YAlignUnchanged: + break; } + GtkCellRenderer *renderer = 0; if (type == G_TYPE_STRING) { - GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); - g_object_set (renderer, "xalign", xalign, NULL); + renderer = gtk_cell_renderer_text_new(); // set the last column, the expandable one, as wrapable if (isEllipsize) g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); @@ -72,15 +75,13 @@ renderer, "text", col_nb, NULL); } else if (type == GDK_TYPE_PIXBUF) { - GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); - g_object_set (renderer, "xalign", xalign, NULL); + renderer = gtk_cell_renderer_pixbuf_new(); column = gtk_tree_view_column_new_with_attributes (header.c_str(), renderer, "pixbuf", col_nb, NULL); } else if (type == G_TYPE_BOOLEAN) { // toggle button - GtkCellRenderer *renderer = gtk_cell_renderer_toggle_new(); + renderer = gtk_cell_renderer_toggle_new(); g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (col_nb)); - g_object_set (renderer, "xalign", xalign, NULL); column = gtk_tree_view_column_new_with_attributes (header.c_str(), renderer, "active", col_nb, NULL); @@ -90,6 +91,9 @@ else g_error ("YGTable: no support for column of given type"); + if (renderer && xalign != -1) + g_object_set (renderer, "xalign", xalign, NULL); + gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (getView(), column); } @@ -190,15 +194,27 @@ class YGTable : public YTable, public YGTableView { public: - YGTable (YWidget *parent, YTableHeader *header) - : YTable (parent, header) + YGTable (YWidget *parent, YTableHeader *_header) + : YTable (NULL, _header) , YGTableView (this, parent, string(), false, false) { IMPL - gtk_tree_view_set_headers_visible (getView(), FALSE); + gtk_tree_view_set_headers_visible (getView(), TRUE); if (columns() >= 3) gtk_tree_view_set_rules_hint (getView(), TRUE); + vector <GType> types; + types.assign (columns(), G_TYPE_STRING); +/* for (int i = 0; i < columns(); i++) + if (item->hasIconName (i)) + types[i] = GDK_TYPE_PIXBUF;*/ + createModel (types); + for (int i = 0; i < columns(); i++) { + bool ellipsize = columns() >= 3 && i == columns()-1; + addColumn (types[i], header (i), alignment (i), i, ellipsize); + } + gtk_tree_view_set_model (getView(), getModel()); + g_signal_connect (G_OBJECT (getWidget()), "row-activated", G_CALLBACK (activated_cb), (YGTableView*) this); if (immediateMode()) @@ -217,25 +233,12 @@ { YTableItem *item = dynamic_cast <YTableItem *> (_item); if (item) { - if (!getModel()) { - vector <GType> types; - types.assign (columns(), G_TYPE_STRING); - for (int i = 0; i < columns(); i++) - if (item->hasIconName (i)) - types[i] = GDK_TYPE_PIXBUF; - createModel (types); - for (int i = 0; i < columns(); i++) { - bool ellipsize = columns() >= 3 && i == columns()-1; - addColumn (types[i], header (i), alignment (i), i, ellipsize); - } - } - GtkTreeIter iter; addRow (&iter, _item); for (int i = 0; i < columns(); i++) { - if (item->hasIconName (i)) +/* if (item->hasIconName (i)) setCellIcon (&iter, i, item->iconName (i)); - else + else*/ setCellLabel (&iter, i, item->label (i)); } } @@ -272,7 +275,7 @@ { public: YGSelectionBox (YWidget *parent, const string &label) - : YSelectionBox (parent, label), + : YSelectionBox (NULL, label), YGTableView (this, parent, label, true, false) { g_signal_connect (G_OBJECT (getWidget()), "row-activated", @@ -301,7 +304,7 @@ { public: YGMultiSelectionBox (YWidget *parent, const string &label) - : YMultiSelectionBox (parent, label), + : YMultiSelectionBox (NULL, label), YGTableView (this, parent, label, false, false) { vector <GType> types; @@ -312,6 +315,7 @@ addColumn (G_TYPE_BOOLEAN, "", YAlignUnchanged, 0); addColumn (GDK_TYPE_PIXBUF, "", YAlignUnchanged, 1); addColumn (G_TYPE_STRING, "", YAlignUnchanged, 2); + gtk_tree_view_set_model (getView(), getModel()); g_signal_connect (G_OBJECT (getWidget()), "cursor-changed", G_CALLBACK (selected_cb), (YGTableView*) this); @@ -385,7 +389,7 @@ { public: YGTree (YWidget *parent, const string &label) - : YTree (parent, label) + : YTree (NULL, label) , YGTableView (this, parent, label, false, true) { // Events Modified: trunk/gtk/unstable-libyui/src/YGUI.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGUI.cc?r... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGUI.cc (original) +++ trunk/gtk/unstable-libyui/src/YGUI.cc Thu Dec 6 13:42:24 2007 @@ -112,6 +112,7 @@ void YGUI::idleLoop (int fd_ycp) { IMPL +//fprintf (stderr, "idleLoop()\n"); // The rational for this is that we need somewhere to run // the magic 'main' thread, that can process thread unsafe // incoming CORBA messages for us @@ -130,6 +131,7 @@ g_source_remove (watch_tag); g_io_channel_unref (wakeup); +//fprintf (stderr, "no more idle\n"); } static gboolean user_input_timeout_cb (YGUI *pThis) @@ -150,7 +152,8 @@ YEvent *YGUI::waitInput (unsigned long timeout_ms, bool block) { IMPL - if (!YDialog::currentDialog()) +//fprintf (stderr, "waitInput()\n"); + if (!YDialog::currentDialog (false)) return NULL; if (block) @@ -180,6 +183,7 @@ if (block) // if YCP keeps working for more than X time, set busy cursor busy_timeout = g_timeout_add (BUSY_CURSOR_TIMEOUT, busy_timeout_cb, this); +//fprintf (stderr, "returning event: %s\n", !event ? "(none)" : YEvent::toString (event->eventType())); return event; } @@ -207,9 +211,9 @@ int YGUI::getDefaultWidth() { if (!m_default_size.width) { - if (m_fullscreen) +/* if (m_fullscreen) m_default_size.width = getDisplayWidth(); - else + else*/ m_default_size.width = MIN (600, getDisplayWidth()); } return m_default_size.width; @@ -218,9 +222,9 @@ int YGUI::getDefaultHeight() { if (!m_default_size.height) { - if (m_fullscreen) +/* if (m_fullscreen) m_default_size.height = getDisplayHeight(); - else + else*/ m_default_size.height = MIN (450, getDisplayHeight()); } return m_default_size.height; Modified: trunk/gtk/unstable-libyui/src/YGUI.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGUI.h?re... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGUI.h (original) +++ trunk/gtk/unstable-libyui/src/YGUI.h Thu Dec 6 13:42:24 2007 @@ -44,12 +44,12 @@ bool with_threads, const char *macro_file); virtual ~YGUI(); - static YGUI *ui() { return (YGUI *)YUI::ui(); } + static YGUI *ui() { return (YGUI *) YUI::ui(); } protected: - virtual YWidgetFactory * createWidgetFactory(); - virtual YOptionalWidgetFactory * createOptionalWidgetFactory(); - virtual YApplication * createApplication(); + virtual YWidgetFactory *createWidgetFactory(); + virtual YOptionalWidgetFactory *createOptionalWidgetFactory(); + virtual YApplication *createApplication(); public: YEvent *waitInput (unsigned long timeout_ms, bool block); @@ -129,7 +129,7 @@ public: // Helpers for internal use [ visibility hidden ] int getDefaultSize (YUIDimension dim); - bool setFullscreen() const { return m_fullscreen || !m_have_wm; } + bool setFullscreen() const { return m_fullscreen; } bool hasWM() const { return m_have_wm; } bool unsetBorder() const { return m_no_border; } }; @@ -225,7 +225,6 @@ virtual bool hasSimplePatchSelector() IMPL_RET (false) virtual YWidget *createSimplePatchSelector (YWidget *parent, long modeFlags) IMPL_RET (NULL) - virtual bool hasPatternSelector() IMPL_RET (false) virtual YWidget *createPatternSelector (YWidget *parent, long modeFlags) IMPL_RET (NULL) Modified: trunk/gtk/unstable-libyui/src/YGWidget.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGWidget.... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGWidget.cc (original) +++ trunk/gtk/unstable-libyui/src/YGWidget.cc Thu Dec 6 13:42:24 2007 @@ -38,15 +38,16 @@ gtk_container_add (GTK_CONTAINER (m_adj_size), m_widget); } -fprintf (stderr, "set widget rep\n"); - ywidget->setWidgetRep ((void *) this); - if (yparent) - ywidget->setParent (yparent); - // Split by two so that with another widget it will have full border... setBorder (DEFAULT_BORDER / 2); if (_show) show(); + + ywidget->setWidgetRep ((void *) this); + if (yparent) { + ywidget->setParent (yparent); + yparent->addChild (ywidget); + } } YGWidget::~YGWidget() @@ -63,7 +64,6 @@ YGWidget *YGWidget::get (YWidget *ywidget) { - g_assert (ywidget != NULL); g_assert (ywidget->widgetRep() != NULL); return (YGWidget *) ywidget->widgetRep(); } @@ -79,6 +79,26 @@ gtk_widget_set_sensitive (getWidget(), enabled); } +void YGWidget::doAddChild (YWidget *ychild, GtkWidget *container) +{ + GtkWidget *child = YGWidget::get (ychild)->getLayout(); + gtk_container_add (GTK_CONTAINER (container), child); +} + +void YGWidget::doRemoveChild (YWidget *ychild, GtkWidget *container) +{ + /* Note: removeChild() is generally a result of a widget being removed as it + will remove itself from the parent. But YGWidget deconstructor would run + before the YWidget one, as that's the order we have been using, so we + can't use it, we can't retrieve the GTK widget then. However, this is a + non-issue, as ~YGWidget will destroy the widget, and GTK will remove it + from the parent. */ + if (!ychild->beingDestroyed()) { + GtkWidget *child = YGWidget::get (ychild)->getLayout(); + gtk_container_remove (GTK_CONTAINER (container), child); + } +} + void YGWidget::emitEvent(YEvent::EventReason reason, bool if_notify, bool if_not_pending, bool immediate) { @@ -132,7 +152,6 @@ IMPL YWidget *parent = m_ywidget->parent(); if (parent) - // tell parent to sync too! YGWidget::get (parent)->sync_stretchable (m_ywidget); } Modified: trunk/gtk/unstable-libyui/src/YGWidget.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGWidget.... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGWidget.h (original) +++ trunk/gtk/unstable-libyui/src/YGWidget.h Thu Dec 6 13:42:24 2007 @@ -34,6 +34,8 @@ // for YWidget virtual bool doSetKeyboardFocus(); virtual void doSetEnabling (bool enabled); + virtual void doAddChild (YWidget *child, GtkWidget *container); + virtual void doRemoveChild (YWidget *child, GtkWidget *container); // Event handling void emitEvent(YEvent::EventReason reason, bool if_notify = true, @@ -78,7 +80,7 @@ #define YGWIDGET_IMPL_USE_BOLD(ParentClass) \ virtual void setUseBoldFont (bool useBold) { \ PangoWeight weight = useBold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL; \ - YGUtils::setWidgetFont (getWidget(), weight, PANGO_SCALE_MEDIUM); \ + YGUtils::setWidgetFont (getWidget(), weight, PANGO_SCALE_MEDIUM); \ ParentClass::setUseBoldFont (useBold); \ } @@ -86,15 +88,13 @@ #define YGWIDGET_IMPL_CHILD_ADDED(container) \ virtual void addChild (YWidget *ychild) { \ YWidget::addChild (ychild); \ - GtkWidget *child = YGWidget::get (ychild)->getLayout(); \ - gtk_container_add (GTK_CONTAINER (container), child); \ - sync_stretchable(); \ + doAddChild (ychild, container); \ + sync_stretchable (ychild); \ } -#define YGWIDGET_IMPL_CHILD_REMOVED(container) \ - virtual void removeChild (YWidget *ychild) { \ - YWidget::removeChild (ychild); \ - GtkWidget *child = YGWidget::get (ychild)->getLayout(); \ - gtk_container_remove (GTK_CONTAINER (container), child); \ +#define YGWIDGET_IMPL_CHILD_REMOVED(container) \ + virtual void removeChild (YWidget *ychild) { \ + YWidget::removeChild (ychild); \ + doRemoveChild (ychild, container); \ } /* This is a convenience class that allows for a label next to the Modified: trunk/gtk/unstable-libyui/src/YGWizard.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGWizard.... ============================================================================== --- trunk/gtk/unstable-libyui/src/YGWizard.cc (original) +++ trunk/gtk/unstable-libyui/src/YGWizard.cc Thu Dec 6 13:42:24 2007 @@ -14,6 +14,13 @@ #include "YReplacePoint.h" #include "YGDialog.h" + +// FIXME: wizard events need to be ported +// We'll probably want to also make YGtkWizard buttons actual YGPushButtons... +// (let's just create them and pass button->getWidget() to the wizard...) +// (or let's just improve on the wrapper and id.) + + class YGWizard : public YWizard, public YGWidget { bool m_verboseCommands; @@ -33,7 +40,7 @@ of id change. */ YGWButton (YWidget *parent, GtkWidget *widget, const std::string &label) : YPushButton (parent, label) - { m_widget = widget; setLabel (label); } + { setWidgetRep (NULL); m_widget = widget; setLabel (label); } void setLabel (const string &label) { string str = YGUtils::mapKBAccel (label.c_str()); @@ -56,7 +63,7 @@ GtkWidget *m_widget; }; - YGWButton *m_back_button, *m_abort_button, *m_next_button; + YGWButton *m_back_button, *m_abort_button, *m_next_button, *m_notes_button; // release notes button would be a little more hassle to support; yast-qt // doesn't support it too anyway. @@ -64,7 +71,7 @@ YGWizard (YWidget *parent, const string &backButtonLabel, const string &abortButtonLabel, const string &nextButtonLabel, YWizardMode wizardMode) - : YWizard (parent, backButtonLabel, abortButtonLabel, nextButtonLabel, wizardMode) + : YWizard (NULL, backButtonLabel, abortButtonLabel, nextButtonLabel, wizardMode) , YGWidget (this, parent, true, YGTK_TYPE_WIZARD, NULL) { IMPL @@ -97,9 +104,15 @@ ygtk_wizard_enable_tree (getWizard()); //** Setting the bottom buttons - m_back_button = new YGWButton (this, getWizard()->m_back_button, backButtonLabel); + m_back_button = new YGWButton (this, getWizard()->m_back_button, backButtonLabel); m_abort_button = new YGWButton (this, getWizard()->m_abort_button, abortButtonLabel); - m_next_button = new YGWButton (this, getWizard()->m_next_button, nextButtonLabel); + m_next_button = new YGWButton (this, getWizard()->m_next_button, nextButtonLabel); + m_notes_button = new YGWButton (this, getWizard()->m_release_notes_button, string()); + + ygtk_wizard_set_back_button_ptr_id (getWizard(), (gpointer) m_back_button); + ygtk_wizard_set_next_button_ptr_id (getWizard(), (gpointer) m_next_button); + ygtk_wizard_set_abort_button_ptr_id (getWizard(), (gpointer) m_abort_button); + ygtk_wizard_set_release_notes_button_ptr_id (getWizard(), (gpointer) m_notes_button); //** All event are sent through this signal together with an id g_signal_connect (G_OBJECT (getWidget()), "action-triggered", @@ -240,8 +253,8 @@ virtual void showReleaseNotesButton (const string &label, const string &id) { string str = YGUtils::mapKBAccel (label.c_str()); - ygtk_wizard_set_release_notes_button_label (getWizard(), label.c_str(), - g_strdup (id.c_str()), free_string_cb); + ygtk_wizard_set_release_notes_button_label (getWizard(), str.c_str()); + ygtk_wizard_set_release_notes_button_str_id (getWizard(), id.c_str()); } virtual void hideReleaseNotesButton() @@ -259,12 +272,15 @@ if ((GType) id_type == G_TYPE_STRING) YGUI::ui()->sendEvent (new YMenuEvent ((char *) id)); else - YGUI::ui()->sendEvent (new YMenuEvent (*((YCPValue *) id))); + YGUI::ui()->sendEvent (new YWidgetEvent ((YWidget *) id, YEvent::Activated)); } - static void free_string_cb (gpointer data) - { g_free (data); } - + virtual void doAddChild (YWidget *ychild, GtkWidget *container) + { + if (ychild->widgetRep()) + // don't actually add the button wrappers + YGWidget::doAddChild (ychild, container); + } YGWIDGET_IMPL_COMMON YGWIDGET_IMPL_CHILD_ADDED (getWidget()) Modified: trunk/gtk/unstable-libyui/src/ygtkfieldentry.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkfield... ============================================================================== --- trunk/gtk/unstable-libyui/src/ygtkfieldentry.c (original) +++ trunk/gtk/unstable-libyui/src/ygtkfieldentry.c Thu Dec 6 13:42:24 2007 @@ -81,19 +81,38 @@ g_signal_emit (fields, filter_entry_signal, 0, nb); } -void ygtk_field_entry_add_field (YGtkFieldEntry *fields, gchar separator, - guint max_length, const gchar *valid_chars) +static guint ygtk_field_entry_length (YGtkFieldEntry *fields) { + guint length; + GList *children = gtk_container_get_children (GTK_CONTAINER (fields)); + length = g_list_length (children); + g_list_free (children); + return length; +} + +static inline guint child_to_index (YGtkFieldEntry *fields, guint child_i) +{ return child_i / 2; } +static inline guint index_to_child (YGtkFieldEntry *fields, guint index) +{ return index * 2; } + +GtkEntry *ygtk_field_entry_get_field_widget (YGtkFieldEntry *fields, guint index) +{ + GtkEntry *entry; + GList *children = gtk_container_get_children (GTK_CONTAINER (fields)); + entry = g_list_nth_data (children, index_to_child (fields, index)); + g_list_free (children); + return entry; +} +guint ygtk_field_entry_add_field (YGtkFieldEntry *fields, gchar separator) +{ + guint new_index = child_to_index (fields, ygtk_field_entry_length (fields)); + GtkWidget *label = 0, *entry; - if (fields->use_separator) { + if (new_index > 0) { const gchar str[2] = { separator, '\0' }; label = gtk_label_new (str); } entry = gtk_entry_new(); - gtk_entry_set_max_length (GTK_ENTRY (entry), max_length); - gtk_entry_set_width_chars (GTK_ENTRY (entry), (max_length == 0) ? -1 : max_length); - ygutils_setFilter (GTK_ENTRY (entry), valid_chars); - g_signal_connect (G_OBJECT (entry), "insert-text", G_CALLBACK (ygtk_field_entry_insert_text), fields); g_signal_connect (G_OBJECT (entry), "move-cursor", @@ -103,25 +122,29 @@ G_CALLBACK (ygtk_field_entry_entry_changed), fields); GtkBox *box = GTK_BOX (fields); - if (label) + if (label) { gtk_box_pack_start (box, label, FALSE, FALSE, 0); + gtk_widget_show (label); + } gtk_box_pack_start (box, entry, TRUE, TRUE, 0); + gtk_widget_show (entry); - fields->use_separator = TRUE; + return new_index; } -static GtkEntry *ygtk_field_entry_get_field (YGtkFieldEntry *fields, guint nb) +void ygtk_field_entry_setup_field (YGtkFieldEntry *fields, guint index, + gint max_length, const gchar *valid_chars) { - GtkEntry *entry; - GList *children = gtk_container_get_children (GTK_CONTAINER (fields)); - entry = g_list_nth_data (children, nb * 2); - g_list_free (children); - return entry; + GtkEntry *entry = ygtk_field_entry_get_field_widget (fields, index); + gtk_entry_set_max_length (entry, max_length == -1 ? 0 : max_length); + gtk_entry_set_width_chars (entry, max_length); + ygutils_setFilter (entry, valid_chars); } -void ygtk_field_entry_set_field_text (YGtkFieldEntry *fields, guint nb, const gchar *text) +void ygtk_field_entry_set_field_text (YGtkFieldEntry *fields, guint index, const gchar *text) { - GtkEntry *entry = ygtk_field_entry_get_field (fields, nb); + GtkEntry *entry = ygtk_field_entry_get_field_widget (fields, index); + g_signal_handlers_block_by_func (entry, (gpointer) ygtk_field_entry_entry_changed, fields); g_signal_handlers_block_by_func (entry, @@ -135,9 +158,9 @@ (gpointer) ygtk_field_entry_insert_text, fields); } -const gchar *ygtk_field_entry_get_field_text (YGtkFieldEntry *fields, guint nb) +const gchar *ygtk_field_entry_get_field_text (YGtkFieldEntry *fields, guint index) { - GtkEntry *entry = ygtk_field_entry_get_field (fields, nb); + GtkEntry *entry = ygtk_field_entry_get_field_widget (fields, index); return gtk_entry_get_text (entry); } Modified: trunk/gtk/unstable-libyui/src/ygtkfieldentry.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkfield... ============================================================================== --- trunk/gtk/unstable-libyui/src/ygtkfieldentry.h (original) +++ trunk/gtk/unstable-libyui/src/ygtkfieldentry.h Thu Dec 6 13:42:24 2007 @@ -13,6 +13,7 @@ #define YGTK_FIELD_ENTRY_H #include <gtk/gtkhbox.h> +#include <gtk/gtkentry.h> G_BEGIN_DECLS #define YGTK_TYPE_FIELD_ENTRY (ygtk_field_entry_get_type ()) @@ -30,10 +31,6 @@ typedef struct _YGtkFieldEntry { GtkHBox parent; - - // private: - // used to disable separator for the first field - gboolean use_separator; } YGtkFieldEntry; typedef struct _YGtkFieldEntryClass @@ -46,14 +43,16 @@ GtkWidget* ygtk_field_entry_new (void); GType ygtk_field_entry_get_type (void) G_GNUC_CONST; -// if this is the first field, separator will be ignored. max_length can be 0 to -// disable it. valids_chars can be NULL to disable it. -void ygtk_field_entry_add_field (YGtkFieldEntry *entry, gchar separator, - guint max_length, const gchar *valid_chars); - -// convinience -void ygtk_field_entry_set_field_text (YGtkFieldEntry *entry, guint nb, const gchar *text); -const gchar *ygtk_field_entry_get_field_text (YGtkFieldEntry *entry, guint nb); +// if this is the first field, separator will be ignored. +guint ygtk_field_entry_add_field (YGtkFieldEntry *entry, gchar separator); +//max_length can be 0 to disable it. valids_chars can be NULL to disable it. +void ygtk_field_entry_setup_field (YGtkFieldEntry *entry, guint index, + gint max_length, const gchar *valid_chars); + +void ygtk_field_entry_set_field_text (YGtkFieldEntry *entry, guint index, const gchar *text); +const gchar *ygtk_field_entry_get_field_text (YGtkFieldEntry *entry, guint index); + +GtkEntry *ygtk_field_entry_get_field_widget (YGtkFieldEntry *entry, guint index); G_END_DECLS #endif /*YGTK_FIELD_ENTRY_H*/ Modified: trunk/gtk/unstable-libyui/src/ygtkrichtext.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkricht... ============================================================================== --- trunk/gtk/unstable-libyui/src/ygtkrichtext.c (original) +++ trunk/gtk/unstable-libyui/src/ygtkrichtext.c Thu Dec 6 13:42:24 2007 @@ -539,28 +539,36 @@ } /* String preparation methods. */ - -#define IS_WHITE(c) (g_ascii_isspace (c) || (c) == '\t') - static char *elide_whitespace (const char *instr, int len) { GString *dest = g_string_new (""); if (len < 0) len = strlen (instr); gboolean last_white = FALSE; + // transform breaklines in whitespace if in the middle of the text + gboolean special_white = FALSE, start_text = TRUE; int i; -// FIXME: whitespace elision needs to happen across tags [urk] -// FIXME: perhaps post-process non-pre sections when they are complete ? for (i = 0; i < len; i++) { char ch = instr[i]; - if (ch == '\r' || ch == '\n') + if (ch == '\n') { + if (!start_text) + special_white = TRUE; continue; + } if (ch == '\t') ch = ' '; - gboolean cur_white = IS_WHITE (ch); + gboolean cur_white = ch == ' '; + if (!cur_white) { + start_text = FALSE; + if (special_white) { + g_string_append_c (dest, ' '); + special_white = FALSE; + } + } if (!cur_white || !last_white) g_string_append_c (dest, ch); + last_white = cur_white; } Modified: trunk/gtk/unstable-libyui/src/ygtkwizard.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkwizar... ============================================================================== --- trunk/gtk/unstable-libyui/src/ygtkwizard.c (original) +++ trunk/gtk/unstable-libyui/src/ygtkwizard.c Thu Dec 6 13:42:24 2007 @@ -265,8 +265,13 @@ static void button_clicked_cb (GtkButton *button, YGtkWizard *wizard) { - gpointer id = g_object_get_data (G_OBJECT (button), "id"); - g_signal_emit (wizard, action_triggered_signal, 0, id, G_TYPE_POINTER); + gpointer id; + id = g_object_get_data (G_OBJECT (button), "ptr-id"); + if (id) + g_signal_emit (wizard, action_triggered_signal, 0, id, G_TYPE_POINTER); + id = g_object_get_data (G_OBJECT (button), "str-id"); + if (id) + g_signal_emit (wizard, action_triggered_signal, 0, id, G_TYPE_STRING); } static GtkWidget *button_new (YGtkWizard *wizard) @@ -645,31 +650,53 @@ ygutils_setStockIcon (wizard->m_next_button, text); } -void ygtk_wizard_set_back_button_id (YGtkWizard *wizard, gpointer id, - GDestroyNotify destroy_cb) +void ygtk_wizard_set_back_button_ptr_id (YGtkWizard *wizard, gpointer id) +{ + g_object_set_data (G_OBJECT (wizard->m_back_button), "ptr-id", id); +} + +void ygtk_wizard_set_next_button_ptr_id (YGtkWizard *wizard, gpointer id) +{ + g_object_set_data (G_OBJECT (wizard->m_next_button), "ptr-id", id); +} + +void ygtk_wizard_set_abort_button_ptr_id (YGtkWizard *wizard, gpointer id) +{ + g_object_set_data (G_OBJECT (wizard->m_abort_button), "ptr-id", id); +} + +void ygtk_wizard_set_release_notes_button_ptr_id (YGtkWizard *wizard, gpointer id) +{ + g_object_set_data (G_OBJECT (wizard->m_release_notes_button), "ptr-id", id); +} + +void ygtk_wizard_set_back_button_str_id (YGtkWizard *wizard, const char *id) +{ + g_object_set_data_full (G_OBJECT (wizard->m_back_button), "str-id", + g_strdup (id), g_free); +} + +void ygtk_wizard_set_next_button_str_id (YGtkWizard *wizard, const char *id) { - g_object_set_data_full (G_OBJECT (wizard->m_back_button), "id", id, destroy_cb); + g_object_set_data_full (G_OBJECT (wizard->m_next_button), "str-id", + g_strdup (id), g_free); } -void ygtk_wizard_set_next_button_id (YGtkWizard *wizard, gpointer id, - GDestroyNotify destroy_cb) +void ygtk_wizard_set_abort_button_str_id (YGtkWizard *wizard, const char *id) { - g_object_set_data_full (G_OBJECT (wizard->m_next_button), "id", id, destroy_cb); + g_object_set_data_full (G_OBJECT (wizard->m_abort_button), "str-id", + g_strdup (id), g_free); } -void ygtk_wizard_set_abort_button_id (YGtkWizard *wizard, gpointer id, - GDestroyNotify destroy_cb) +void ygtk_wizard_set_release_notes_button_str_id (YGtkWizard *wizard, const char *id) { - g_object_set_data_full (G_OBJECT (wizard->m_abort_button), "id", id, destroy_cb); + g_object_set_data_full (G_OBJECT (wizard->m_release_notes_button), "str-id", + g_strdup (id), g_free); } -void ygtk_wizard_set_release_notes_button_label (YGtkWizard *wizard, - const gchar *text, gpointer id, - GDestroyNotify destroy_cb) +void ygtk_wizard_set_release_notes_button_label (YGtkWizard *wizard, const gchar *text) { gtk_button_set_label (GTK_BUTTON (wizard->m_release_notes_button), text); - g_object_set_data_full (G_OBJECT (wizard->m_release_notes_button), "id", - id, destroy_cb); gtk_widget_show (wizard->m_release_notes_button); } Modified: trunk/gtk/unstable-libyui/src/ygtkwizard.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkwizar... ============================================================================== --- trunk/gtk/unstable-libyui/src/ygtkwizard.h (original) +++ trunk/gtk/unstable-libyui/src/ygtkwizard.h Thu Dec 6 13:42:24 2007 @@ -129,12 +129,14 @@ void ygtk_wizard_set_back_button_label (YGtkWizard *wizard, const char *text); void ygtk_wizard_set_abort_button_label (YGtkWizard *wizard, const char *text); void ygtk_wizard_set_next_button_label (YGtkWizard *wizard, const char *text); -void ygtk_wizard_set_back_button_id (YGtkWizard *wizard, gpointer id, - GDestroyNotify destroy_cb); -void ygtk_wizard_set_next_button_id (YGtkWizard *wizard, gpointer id, - GDestroyNotify destroy_cb); -void ygtk_wizard_set_abort_button_id (YGtkWizard *wizard, gpointer id, - GDestroyNotify destroy_cb); +void ygtk_wizard_set_back_button_str_id (YGtkWizard *wizard, const char *id); +void ygtk_wizard_set_next_button_str_id (YGtkWizard *wizard, const char *id); +void ygtk_wizard_set_abort_button_str_id (YGtkWizard *wizard, const char *id); +void ygtk_wizard_set_release_notes_button_str_id (YGtkWizard *wizard, const char *id); +void ygtk_wizard_set_back_button_ptr_id (YGtkWizard *wizard, gpointer id); +void ygtk_wizard_set_next_button_ptr_id (YGtkWizard *wizard, gpointer id); +void ygtk_wizard_set_abort_button_ptr_id (YGtkWizard *wizard, gpointer id); +void ygtk_wizard_set_release_notes_button_ptr_id (YGtkWizard *wizard, gpointer id); void ygtk_wizard_enable_back_button (YGtkWizard *wizard, gboolean enable); void ygtk_wizard_enable_next_button (YGtkWizard *wizard, gboolean enable); void ygtk_wizard_enable_abort_button (YGtkWizard *wizard, gboolean enable); @@ -163,9 +165,7 @@ gboolean ygtk_wizard_select_tree_item (YGtkWizard *wizard, const char *id); const gchar *ygtk_wizard_get_tree_selection (YGtkWizard *wizard); -void ygtk_wizard_set_release_notes_button_label (YGtkWizard *wizard, - const gchar *text, gpointer id, - GDestroyNotify destroy_cb); +void ygtk_wizard_set_release_notes_button_label (YGtkWizard *wizard, const gchar *text); void ygtk_wizard_show_release_notes_button (YGtkWizard *wizard, gboolean enable); // You should call this method rather than GtkWidget's if you want -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org