Author: rpmcruz Date: Thu Nov 26 18:14:14 2009 New Revision: 59804 URL: http://svn.opensuse.org/viewcvs/yast?rev=59804&view=rev Log: * Reverted to development state. Added: trunk/gtk/src/CMakeLists.txt Removed: trunk/gtk/src/YGPackageSelector.cc trunk/gtk/src/ygtkhandlebox.c trunk/gtk/src/ygtkhandlebox.h trunk/gtk/src/ygtknotebook.c trunk/gtk/src/ygtknotebook.h trunk/gtk/src/ygtktogglebutton.c trunk/gtk/src/ygtktogglebutton.h trunk/gtk/src/ygtktreemodel.cc trunk/gtk/src/ygtktreemodel.h trunk/gtk/src/ygtkzyppview.cc trunk/gtk/src/ygtkzyppview.h trunk/gtk/src/ygtkzyppwrapper.cc trunk/gtk/src/ygtkzyppwrapper.h trunk/gtk/src/yzypptags.cc trunk/gtk/src/yzypptags.h trunk/gtk/src/yzyppwrapper.cc trunk/gtk/src/yzyppwrapper.h Modified: trunk/gtk/src/YGComboBox.cc trunk/gtk/src/YGDialog.cc trunk/gtk/src/YGDumbTab.cc trunk/gtk/src/YGFrame.cc trunk/gtk/src/YGImage.cc trunk/gtk/src/YGInputField.cc trunk/gtk/src/YGIntField.cc trunk/gtk/src/YGLabel.cc trunk/gtk/src/YGLayout.cc trunk/gtk/src/YGMenuButton.cc trunk/gtk/src/YGProgressBar.cc trunk/gtk/src/YGPushButton.cc trunk/gtk/src/YGRadioButton.cc trunk/gtk/src/YGSelectionModel.cc trunk/gtk/src/YGTable.cc trunk/gtk/src/YGText.cc trunk/gtk/src/YGUI.cc trunk/gtk/src/YGUI.h trunk/gtk/src/YGUtils.cc trunk/gtk/src/YGWidget.cc trunk/gtk/src/YGWizard.cc trunk/gtk/src/YGi18n.h trunk/gtk/src/test.cc trunk/gtk/src/ygtkbargraph.c trunk/gtk/src/ygtkbargraph.h trunk/gtk/src/ygtkcellrenderertextpixbuf.c trunk/gtk/src/ygtkcellrenderertextpixbuf.h trunk/gtk/src/ygtkfindentry.c trunk/gtk/src/ygtkfindentry.h trunk/gtk/src/ygtkhtmlwrap.c trunk/gtk/src/ygtkhtmlwrap.h trunk/gtk/src/ygtkratiobox.c trunk/gtk/src/ygtkrichtext.c trunk/gtk/src/ygtkrichtext.h trunk/gtk/src/ygtkscrolledwindow.h trunk/gtk/src/ygtksteps.c trunk/gtk/src/ygtksteps.h trunk/gtk/src/ygtktextview.c trunk/gtk/src/ygtktreeview.c trunk/gtk/src/ygtkwizard.c trunk/gtk/src/ygtkwizard.h Added: trunk/gtk/src/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/CMakeLists.txt?rev=59804&... ============================================================================== --- trunk/gtk/src/CMakeLists.txt (added) +++ trunk/gtk/src/CMakeLists.txt Thu Nov 26 18:14:14 2009 @@ -0,0 +1,96 @@ +## Makefile.am + +set (gtk_yast_plugin_SRCS + YGBarGraph.cc + YGComboBox.cc + YGDialog.cc + YGDumbTab.cc + YGFrame.cc + YGInputField.cc + YGIntField.cc + YGImage.cc + YGMenuButton.cc + YGLabel.cc + YGLayout.cc + YGPackageSelectorPluginStub.cc + YGPushButton.cc + YGProgressBar.cc + YGRadioButton.cc + YGSelectionModel.cc + YGTable.cc + YGText.cc + YGUtils.cc + YGUI.cc + YGWidget.cc + YGWizard.cc + ygdkmngloader.c + ygtkcellrenderertextpixbuf.c + ygtkbargraph.c + ygtkfieldentry.c + ygtkhtmlwrap.c + ygtkmenubutton.c + ygtklinklabel.c + ygtkfindentry.c + ygtkfixed.c + ygtkimage.c + ygtkratiobox.c + ygtkrichtext.c + ygtksteps.c + ygtktextview.c + ygtktimezonepicker.c + ygtktreeview.c + ygtkwizard.c + ) + +# if you tell cmake to install the icons/ directory +# it will make room for the .svn dir as well... +set (gtk_yast_plugin_DATA + icons/harddisk.png + icons/harddisk-full.png + icons/pkg-available.png + icons/pkg-available-locked.png + icons/pkg-installed.png + icons/pkg-install.png + icons/pkg-install-auto.png + icons/pkg-installed-locked.png + icons/pkg-installed-upgradable.png + icons/pkg-installed-upgradable-locked.png + icons/pkg-remove.png + icons/pkg-remove-auto.png + icons/pkg-locked.png + icons/pkg-unlocked.png + icons/pkg-upgrade.png + ) + +## includes: + +include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories (${GTK2_INCLUDE_DIRS}) +include_directories (${LIBYUI_INCLUDE_DIR}) + +## target: + +add_library (py2gtk SHARED ${gtk_yast_plugin_SRCS}) + +## libraries: + +target_link_libraries (py2gtk ${GTK2_LIBRARIES}) +target_link_libraries (py2gtk ${LIBYUI_LIBRARY}) +set_target_properties (py2gtk PROPERTIES SOVERSION 2) +set_target_properties (py2gtk PROPERTIES LINK_FLAGS "--no-undefined") + +## install: + +install (TARGETS py2gtk LIBRARY DESTINATION ${UI_PLUGIN_DIR}) +install (FILES ${gtk_yast_plugin_DATA} DESTINATION ${DATADIR}) + +add_subdirectory (pkg) + +## test: + +link_directories (${CMAKE_BINARY_DIR}/src) +add_executable (test test.cc) +target_link_libraries (test libpy2gtk.so) +target_link_libraries (test ${GTK2_LIBRARIES}) +target_link_libraries (test ${LIBYUI_LIBRARY}) + Modified: trunk/gtk/src/YGComboBox.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGComboBox.cc?rev=59804&a... ============================================================================== --- trunk/gtk/src/YGComboBox.cc (original) +++ trunk/gtk/src/YGComboBox.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include <YGUI.h> #include "YGUtils.h" #include "YComboBox.h" Modified: trunk/gtk/src/YGDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGDialog.cc (original) +++ trunk/gtk/src/YGDialog.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include "YGUI.h" #include "YGDialog.h" #include "YGUtils.h" @@ -22,8 +23,8 @@ be a YGDialog and is swap-able. */ -#define DEFAULT_WIDTH 650 -#define DEFAULT_HEIGHT 600 +#define DEFAULT_WIDTH 700 +#define DEFAULT_HEIGHT 650 class YGWindow; static YGWindow *main_window = 0; @@ -36,6 +37,7 @@ // (ie. dump yast tree) YWidget *m_child; GdkCursor *m_busyCursor; + bool m_isBusy; public: YGWindowCloseFn m_canClose; @@ -51,6 +53,7 @@ m_child = NULL; m_canClose = NULL; m_busyCursor = NULL; + m_isBusy = false; { std::stack<YDialog *> &stack = YDialog::_dialogStack; @@ -90,7 +93,13 @@ } if (_main_window) { - gtk_window_set_default_size (window, DEFAULT_WIDTH, DEFAULT_HEIGHT); + int width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT; + if (YGUI::ui()->defaultWidth()) + width = YGUI::ui()->defaultWidth(); + if (YGUI::ui()->defaultHeight()) + height = YGUI::ui()->defaultHeight(); + + gtk_window_set_default_size (window, width, height); if (YGUI::ui()->setFullscreen()) gtk_window_fullscreen (window); else if (YUI::app()->displayWidth() <= 800 || YUI::app()->displayHeight() <= 600) @@ -115,7 +124,6 @@ ~YGWindow() { - IMPL setChild (NULL); if (m_busyCursor) gdk_cursor_unref (m_busyCursor); @@ -128,23 +136,26 @@ void normalCursor() { - gdk_window_set_cursor (m_widget->window, NULL); + if (m_isBusy) + gdk_window_set_cursor (m_widget->window, NULL); + m_isBusy = false; } void busyCursor() { - GdkDisplay *display = gtk_widget_get_display (m_widget); if (!m_busyCursor) { + GdkDisplay *display = gtk_widget_get_display (m_widget); m_busyCursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_cursor_ref (m_busyCursor); } - gdk_window_set_cursor (m_widget->window, m_busyCursor); + if (!m_isBusy) + gdk_window_set_cursor (m_widget->window, m_busyCursor); + m_isBusy = true; } void setChild (YWidget *new_child) { - IMPL - GtkWidget *child = gtk_bin_get_child (GTK_BIN (m_widget)); + GtkWidget *child = gtk_bin_get_child (GTK_BIN (m_widget)); if (child) gtk_container_remove (GTK_CONTAINER (m_widget), child); if (new_child) { @@ -183,7 +194,6 @@ static gboolean close_window_cb (GtkWidget *widget, GdkEvent *event, YGWindow *pThis) { - IMPL // never let GTK+ destroy the window! just inform YCP, and let it // do its thing. pThis->close(); @@ -193,7 +203,6 @@ static gboolean key_pressed_cb (GtkWidget *widget, GdkEventKey *event, YGWindow *pThis) { - IMPL // if not main dialog, close it on escape if (event->keyval == GDK_Escape && /* not main window */ main_window != pThis) { @@ -438,7 +447,7 @@ cairo_t *cr = gdk_cairo_create (widget->window); cairo_rectangle (cr, x, y, w, h); - cairo_set_source_rgb (cr, (0xff/255.0), (0x88)/255.0, 0); + cairo_set_source_rgb (cr, 0xff/255.0, 0x88/255.0, 0); cairo_fill (cr); cairo_destroy (cr); return FALSE; @@ -563,10 +572,7 @@ } YDialog *YGWidgetFactory::createDialog (YDialogType dialogType, YDialogColorMode colorMode) -{ - IMPL - return new YGDialog (dialogType, colorMode); -} +{ return new YGDialog (dialogType, colorMode); } YEvent *YGDialog::waitForEventInternal (int timeout_millisec) { return YGUI::ui()->waitInput (timeout_millisec, true); } Modified: trunk/gtk/src/YGDumbTab.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDumbTab.cc?rev=59804&am... ============================================================================== --- trunk/gtk/src/YGDumbTab.cc (original) +++ trunk/gtk/src/YGDumbTab.cc Thu Nov 26 18:14:14 2009 @@ -2,8 +2,9 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include "YGWidget.h" #include "YGUtils.h" #include "YDumbTab.h" @@ -20,10 +21,9 @@ : YDumbTab (NULL), YGWidget (this, parent, GTK_TYPE_NOTEBOOK, NULL) { - IMPL m_containee = gtk_event_box_new(); - gtk_widget_show (m_containee); g_object_ref_sink (G_OBJECT (m_containee)); + gtk_widget_show (m_containee); m_last_tab = 0; // GTK+ keeps the notebook size set to the biggset page. We can't @@ -34,9 +34,8 @@ connect (getWidget(), "switch-page", G_CALLBACK (changed_tab_cb), this); } - ~YGDumbTab() + virtual ~YGDumbTab() { - IMPL gtk_widget_destroy (m_containee); g_object_unref (G_OBJECT (m_containee)); } @@ -84,11 +83,11 @@ virtual void deleteAllItems() { - YDumbTab::deleteAllItems(); GList *children = gtk_container_get_children (GTK_CONTAINER (getWidget())); for (GList *i = children; i; i = i->next) gtk_container_remove (GTK_CONTAINER (getWidget()), (GtkWidget *) i->data); g_list_free (children); + YDumbTab::deleteAllItems(); } // to re-use the same widget in all tabs (m_fixed), we will remove and @@ -100,15 +99,12 @@ GtkNotebook *notebook = GTK_NOTEBOOK (getWidget()); int nb = gtk_notebook_get_current_page (notebook); - GtkWidget *tab = gtk_notebook_get_nth_page (notebook, nb); - - gtk_container_add (GTK_CONTAINER (tab), m_containee); - m_last_tab = tab; + m_last_tab = gtk_notebook_get_nth_page (notebook, nb); + gtk_container_add (GTK_CONTAINER (m_last_tab), m_containee); } virtual YItem *selectedItem() { - IMPL GtkNotebook *notebook = GTK_NOTEBOOK (getWidget()); int nb = gtk_notebook_get_current_page (notebook); if (nb < 0) return NULL; @@ -126,6 +122,7 @@ gtk_notebook_set_current_page (GTK_NOTEBOOK (getWidget()), page); syncTabPage(); } + YDumbTab::selectItem (item, selected); } virtual void shortcutChanged() @@ -150,6 +147,7 @@ GtkWidget *child = gtk_notebook_get_nth_page (notebook, tab_nb); YItem *item = (YItem *) g_object_get_data (G_OBJECT (child), "yitem"); + pThis->YDumbTab::selectItem (item); YGUI::ui()->sendEvent (new YMenuEvent (item)); pThis->syncTabPage(); } @@ -158,8 +156,5 @@ }; YDumbTab *YGOptionalWidgetFactory::createDumbTab (YWidget *parent) -{ - IMPL - return new YGDumbTab (parent); -} +{ return new YGDumbTab (parent); } Modified: trunk/gtk/src/YGFrame.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGFrame.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGFrame.cc (original) +++ trunk/gtk/src/YGFrame.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include "YGUI.h" #include "YGWidget.h" #include "YGUtils.h" @@ -20,9 +21,8 @@ public: YGBaseFrame (YWidget *ywidget, YWidget *parent) : YGWidget (ywidget, parent, - GTK_TYPE_FRAME, "shadow-type", GTK_SHADOW_NONE, NULL) + GTK_TYPE_FRAME, /*"shadow-type", GTK_SHADOW_NONE, */NULL) { - IMPL m_containee = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (m_containee), 0, 0, CHILD_INDENTATION, 0); @@ -87,10 +87,8 @@ } // YFrame - virtual void setLabel (const string &_str) { - IMPL GtkWidget *label = gtk_frame_get_label_widget (GTK_FRAME (getWidget())); string str (YGUtils::mapKBAccel (_str)); gtk_label_set_text_with_mnemonic (GTK_LABEL (label), str.c_str()); @@ -100,17 +98,13 @@ YGWIDGET_IMPL_CONTAINER (YFrame) // YGWidget - virtual string getDebugLabel() const { return label(); } }; YFrame *YGWidgetFactory::createFrame (YWidget *parent, const string &label) -{ - IMPL - return new YGFrame (parent, label); -} +{ return new YGFrame (parent, label); } #include "YCheckBoxFrame.h" @@ -121,7 +115,6 @@ : YCheckBoxFrame (NULL, label, checked), YGBaseFrame (this, parent) { - IMPL GtkWidget *button = gtk_check_button_new_with_mnemonic(""); YGUtils::setWidgetFont (gtk_bin_get_child (GTK_BIN (button)), PANGO_STYLE_NORMAL, PANGO_WEIGHT_BOLD, PANGO_SCALE_MEDIUM); @@ -134,7 +127,6 @@ } // YCheckBoxFrame - virtual void setLabel (const string &_str) { GtkWidget *button = gtk_frame_get_label_widget (GTK_FRAME (getWidget())); @@ -159,7 +151,6 @@ } // YGWidget - virtual void doSetEnabled (bool enabled) { GtkWidget *frame = getWidget(); @@ -185,10 +176,7 @@ } }; -YCheckBoxFrame *YGWidgetFactory::createCheckBoxFrame (YWidget *parent, const string &label, - bool checked) -{ - IMPL - return new YGCheckBoxFrame (parent, label, checked); -} +YCheckBoxFrame *YGWidgetFactory::createCheckBoxFrame ( + YWidget *parent, const string &label, bool checked) +{ return new YGCheckBoxFrame (parent, label, checked); } Modified: trunk/gtk/src/YGImage.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGImage.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGImage.cc (original) +++ trunk/gtk/src/YGImage.cc Thu Nov 26 18:14:14 2009 @@ -2,15 +2,16 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ +#define YUILogComponent "gtk" +#include "config.h" #include "ygdkmngloader.h" -#include <config.h> #include "YGUI.h" #include "YGWidget.h" #include "YImage.h" #include "ygtkimage.h" #include <string.h> -static bool endsWith (const std::string &str1, const char *str2) +static inline bool endsWith (const std::string &str1, const char *str2) { size_t len = strlen (str2); if (str1.size() < len) return false; @@ -24,7 +25,6 @@ : YImage (NULL, filename, animated), YGWidget (this, parent, YGTK_TYPE_IMAGE, NULL) { - IMPL YGtkImage *image = YGTK_IMAGE (getWidget()); const char *stock = NULL; if (endsWith (filename, "/msg_question.png")) @@ -55,7 +55,5 @@ }; YImage *YGWidgetFactory::createImage (YWidget *parent, const string &filename, bool animated) -{ - return new YGImage (parent, filename, animated); -} +{ return new YGImage (parent, filename, animated); } Modified: trunk/gtk/src/YGInputField.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGInputField.cc?rev=59804... ============================================================================== --- trunk/gtk/src/YGInputField.cc (original) +++ trunk/gtk/src/YGInputField.cc Thu Nov 26 18:14:14 2009 @@ -2,8 +2,9 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include "YGWidget.h" #include "YGUtils.h" #include "ygtkfieldentry.h" @@ -95,7 +96,6 @@ YGLabeledWidget (this, parent, label, YD_HORIZ, YGTK_TYPE_FIELD_ENTRY, NULL) { - IMPL YGtkFieldEntry *field = YGTK_FIELD_ENTRY (getWidget()); ygtk_field_entry_add_field (field, ':'); ygtk_field_entry_add_field (field, ':'); @@ -120,7 +120,6 @@ virtual string value() { - IMPL const gchar *hours, *mins; YGtkFieldEntry *entry = YGTK_FIELD_ENTRY (getWidget()); hours = ygtk_field_entry_get_field_text (entry, 0); @@ -141,10 +140,7 @@ }; YTimeField *YGOptionalWidgetFactory::createTimeField (YWidget *parent, const string &label) -{ - IMPL - return new YGTimeField (parent, label); -} +{ return new YGTimeField (parent, label); } #include "YDateField.h" #include "ygtkmenubutton.h" @@ -158,7 +154,6 @@ : YDateField (NULL, label), YGLabeledWidget (this, parent, label, YD_HORIZ, YGTK_TYPE_FIELD_ENTRY, NULL) { - IMPL ygtk_field_entry_add_field (getField(), '-'); ygtk_field_entry_add_field (getField(), '-'); ygtk_field_entry_add_field (getField(), '-'); @@ -204,7 +199,6 @@ 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); @@ -280,10 +274,7 @@ }; YDateField *YGOptionalWidgetFactory::createDateField (YWidget *parent, const string &label) -{ - IMPL - return new YGDateField (parent, label); -} +{ return new YGDateField (parent, label); } #include "YTimezoneSelector.h" #include "ygtktimezonepicker.h" @@ -296,7 +287,6 @@ : YTimezoneSelector (NULL, pixmap, timezones), YGWidget (this, parent, YGTK_TYPE_TIME_ZONE_PICKER, NULL) { - IMPL setStretchable (YD_HORIZ, true); setStretchable (YD_VERT, true); ygtk_time_zone_picker_set_map (YGTK_TIME_ZONE_PICKER (getWidget()), @@ -345,7 +335,5 @@ YTimezoneSelector *YGOptionalWidgetFactory::createTimezoneSelector (YWidget *parent, const std::string &pixmap, const std::map <std::string, std::string> &timezones) -{ - return new YGTimezoneSelector (parent, pixmap, timezones); -} +{ return new YGTimezoneSelector (parent, pixmap, timezones); } Modified: trunk/gtk/src/YGIntField.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGIntField.cc?rev=59804&a... ============================================================================== --- trunk/gtk/src/YGIntField.cc (original) +++ trunk/gtk/src/YGIntField.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,7 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" #include "YGUI.h" #include "YGUtils.h" #include "YGWidget.h" @@ -114,9 +114,7 @@ YIntField *YGWidgetFactory::createIntField (YWidget *parent, const string &label, int minValue, int maxValue, int initialValue) -{ - return new YGIntField (parent, label, minValue, maxValue, initialValue); -} +{ return new YGIntField (parent, label, minValue, maxValue, initialValue); } #include "YSlider.h" @@ -138,8 +136,5 @@ YSlider *YGOptionalWidgetFactory::createSlider (YWidget *parent, const string &label, int minValue, int maxValue, int initialValue) -{ - IMPL - return new YGSlider (parent, label, minValue, maxValue, initialValue); -} +{ return new YGSlider (parent, label, minValue, maxValue, initialValue); } Modified: trunk/gtk/src/YGLabel.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGLabel.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGLabel.cc (original) +++ trunk/gtk/src/YGLabel.cc Thu Nov 26 18:14:14 2009 @@ -2,35 +2,33 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "YGUI.h" #include "YGUtils.h" #include "YGWidget.h" - #include "YLabel.h" class YGLabel : public YLabel, public YGWidget { public: - YGLabel (YWidget *parent, const string &text, bool heading, bool outputField) - : YLabel (NULL, text, heading, outputField), - YGWidget (this, parent, GTK_TYPE_LABEL, NULL) + YGLabel (YWidget *parent, const std::string &text, bool heading, bool outputField) + : YLabel (NULL, text, heading, outputField), + YGWidget (this, parent, GTK_TYPE_LABEL, NULL) { - IMPL gtk_misc_set_alignment (GTK_MISC (getWidget()), 0.0, 0.5); if (outputField) { gtk_label_set_selectable (GTK_LABEL (getWidget()), TRUE); gtk_label_set_single_line_mode (GTK_LABEL (getWidget()), TRUE); YGUtils::setWidgetFont (getWidget(), PANGO_STYLE_ITALIC, PANGO_WEIGHT_NORMAL, - PANGO_SCALE_MEDIUM); + PANGO_SCALE_MEDIUM); } if (heading) YGUtils::setWidgetFont (getWidget(), PANGO_STYLE_NORMAL, PANGO_WEIGHT_BOLD, - PANGO_SCALE_LARGE); + PANGO_SCALE_LARGE); setLabel (text); } - virtual void setText (const string &label) + virtual void setText (const std::string &label) { YLabel::setText (label); gtk_label_set_label (GTK_LABEL (getWidget()), label.c_str()); @@ -51,9 +49,7 @@ YGWIDGET_IMPL_USE_BOLD (YLabel) }; -YLabel *YGWidgetFactory::createLabel (YWidget *parent, const string &text, bool heading, - bool outputField) -{ - return new YGLabel (parent, text, heading, outputField); -} +YLabel *YGWidgetFactory::createLabel (YWidget *parent, + const std::string &text, bool heading, bool outputField) +{ return new YGLabel (parent, text, heading, outputField); } Modified: trunk/gtk/src/YGLayout.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGLayout.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGLayout.cc (original) +++ trunk/gtk/src/YGLayout.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include "YGWidget.h" #include "YGUtils.h" @@ -86,10 +87,7 @@ }; YLayoutBox *YGWidgetFactory::createLayoutBox (YWidget *parent, YUIDimension dimension) -{ - IMPL - return new YGLayoutBox (parent, dimension); -} +{ return new YGLayoutBox (parent, dimension); } #if YAST2_VERSION >= 2017006 #include <YButtonBox.h> @@ -121,10 +119,7 @@ }; YButtonBox *YGWidgetFactory::createButtonBox (YWidget *parent) -{ - IMPL - return new YGButtonBox (parent); -} +{ return new YGButtonBox (parent); } #endif @@ -154,11 +149,11 @@ YGLAYOUT_PREFERRED_SIZE_IMPL (YAlignment) YGLAYOUT_SET_SIZE_IMPL (YAlignment) - virtual void setBackgroundPixmap (string filename) + virtual void setBackgroundPixmap (const std::string &_filename) { + YAlignment::setBackgroundPixmap (_filename); // YAlignment will prepend a path to the image - YAlignment::setBackgroundPixmap (filename); - filename = YAlignment::backgroundPixmap(); + std::string filename (YAlignment::backgroundPixmap()); if (m_background_pixbuf) g_object_unref (G_OBJECT (m_background_pixbuf)); @@ -202,10 +197,7 @@ YAlignment *YGWidgetFactory::createAlignment (YWidget *parent, YAlignmentType halign, YAlignmentType valign) -{ - IMPL - return new YGAlignment (parent, halign, valign); -} +{ return new YGAlignment (parent, halign, valign); } #include <YEmpty.h> @@ -224,10 +216,7 @@ }; YEmpty *YGWidgetFactory::createEmpty (YWidget *parent) -{ - IMPL - return new YGEmpty (parent); -} +{ return new YGEmpty (parent); } #include <YSpacing.h> @@ -272,9 +261,7 @@ }; YReplacePoint *YGWidgetFactory::createReplacePoint (YWidget *parent) -{ - return new YGReplacePoint (parent); -} +{ return new YGReplacePoint (parent); } #include <YSquash.h> @@ -294,8 +281,5 @@ }; YSquash *YGWidgetFactory::createSquash (YWidget *parent, bool hsquash, bool vsquash) -{ - IMPL - return new YGSquash (parent, hsquash, vsquash); -} +{ return new YGSquash (parent, hsquash, vsquash); } Modified: trunk/gtk/src/YGMenuButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGMenuButton.cc?rev=59804... ============================================================================== --- trunk/gtk/src/YGMenuButton.cc (original) +++ trunk/gtk/src/YGMenuButton.cc Thu Nov 26 18:14:14 2009 @@ -2,13 +2,53 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include "YGUtils.h" #include "YGWidget.h" #include "YMenuButton.h" #include "ygtkmenubutton.h" +static void selected_item_cb (GtkMenuItem *menuitem, YItem *item) +{ + YGUI::ui()->sendEvent (new YMenuEvent (item)); +} + +static void doCreateMenu (GtkWidget *parent, YItemIterator begin, YItemIterator end) +{ + for (YItemIterator it = begin; it != end; it++) { + GtkWidget *entry, *image = 0; + string str = YGUtils::mapKBAccel ((*it)->label()); + + if ((*it)->hasIconName()) { + GdkPixbuf *pixbuf = YGUtils::loadPixbuf ((*it)->iconName()); + if (pixbuf) { + image = gtk_image_new_from_pixbuf (pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + } + } + + if (image) { + entry = gtk_image_menu_item_new_with_mnemonic (str.c_str()); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (entry), image); + } + else + entry = gtk_menu_item_new_with_mnemonic (str.c_str()); + + gtk_menu_shell_append (GTK_MENU_SHELL (parent), entry); + + if ((*it)->hasChildren()) { + GtkWidget *submenu = gtk_menu_new(); + doCreateMenu (submenu, (*it)->childrenBegin(), (*it)->childrenEnd()); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (entry), submenu); + } + else + g_signal_connect (G_OBJECT (entry), "activate", + G_CALLBACK (selected_item_cb), *it); + } +} + class YGMenuButton : public YMenuButton, public YGWidget { public: @@ -16,7 +56,6 @@ : YMenuButton (NULL, label), YGWidget (this, parent, YGTK_TYPE_MENU_BUTTON, NULL) { - IMPL string str = YGUtils::mapKBAccel (label.c_str()); ygtk_menu_button_set_label (YGTK_MENU_BUTTON (getWidget()), str.c_str()); } @@ -24,56 +63,52 @@ // YMenuButton virtual void rebuildMenuTree() { - GtkWidget *menu = doCreateMenu (itemsBegin(), itemsEnd()); + GtkWidget *menu = gtk_menu_new(); + doCreateMenu (menu, itemsBegin(), itemsEnd()); gtk_widget_show_all (menu); ygtk_menu_button_set_popup (YGTK_MENU_BUTTON (getWidget()), menu); } - static GtkWidget* doCreateMenu (YItemIterator begin, YItemIterator end) - { - GtkWidget *menu = gtk_menu_new(); - for (YItemIterator it = begin; it != end; it++) { - GtkWidget *entry, *image = 0; - string str = YGUtils::mapKBAccel ((*it)->label()); - - if ((*it)->hasIconName()) { - GdkPixbuf *pixbuf = YGUtils::loadPixbuf ((*it)->iconName()); - if (pixbuf) { - image = gtk_image_new_from_pixbuf (pixbuf); - g_object_unref (G_OBJECT (pixbuf)); - } - } - - if (image) { - entry = gtk_image_menu_item_new_with_mnemonic (str.c_str()); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (entry), image); - } - else - entry = gtk_menu_item_new_with_mnemonic (str.c_str()); + YGWIDGET_IMPL_COMMON (YMenuButton) +}; - gtk_menu_shell_append (GTK_MENU_SHELL (menu), entry); +YMenuButton *YGWidgetFactory::createMenuButton (YWidget *parent, const string &label) +{ return new YGMenuButton (parent, label); } - if ((*it)->hasChildren()) - gtk_menu_item_set_submenu (GTK_MENU_ITEM (entry), - doCreateMenu ((*it)->childrenBegin(), (*it)->childrenEnd())); - else - g_signal_connect (G_OBJECT (entry), "activate", - G_CALLBACK (selected_item_cb), *it); - } +#if YAST2_VERSION > 2018003 +#include <YContextMenu.h> - return menu; +class YGContextMenu : public YContextMenu, public YGWidget +{ +public: + YGContextMenu() + : YContextMenu(), + YGWidget (this, NULL, GTK_TYPE_MENU, NULL) + { + connect (getWidget(), "cancel", G_CALLBACK (cancel_cb), this); } - static void selected_item_cb (GtkMenuItem *menuitem, YItem *item) + // YContextMenu + virtual void rebuildMenuTree() { - YGUI::ui()->sendEvent (new YMenuEvent (item)); + GtkWidget *menu = getWidget(); + doCreateMenu (menu, itemsBegin(), itemsEnd()); + gtk_widget_show_all (menu); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, gtk_get_current_event_time()); } - YGWIDGET_IMPL_COMMON (YMenuButton) + // callbacks + static void cancel_cb (GtkMenuShell *menu, YGContextMenu *pThis) + { YGUI::ui()->sendEvent (new YCancelEvent()); } + + YGWIDGET_IMPL_COMMON (YContextMenu) }; -YMenuButton *YGWidgetFactory::createMenuButton (YWidget *parent, const string &label) +bool YGApplication::openContextMenu (const YItemCollection &itemCollection) { - return new YGMenuButton (parent, label); + YGContextMenu *menu = new YGContextMenu(); + menu->addItems (itemCollection); + return true; } +#endif Modified: trunk/gtk/src/YGProgressBar.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGProgressBar.cc?rev=5980... ============================================================================== --- trunk/gtk/src/YGProgressBar.cc (original) +++ trunk/gtk/src/YGProgressBar.cc Thu Nov 26 18:14:14 2009 @@ -6,8 +6,9 @@ Textdomain "yast2-gtk" */ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include "YGWidget.h" #include "YGi18n.h" @@ -51,7 +52,6 @@ // YProgressBar virtual void setValue (int value) { - IMPL YProgressBar::setValue (value); GtkProgressBar *bar = GTK_PROGRESS_BAR (getWidget()); float fraction = CLAMP ((float) value / maxValue(), 0, 1); @@ -121,10 +121,7 @@ YDownloadProgress *YGOptionalWidgetFactory::createDownloadProgress (YWidget *parent, const string &label, const string &filename, YFileSize_t expectedFileSize) -{ - IMPL - return new YGDownloadProgress (parent, label, filename, expectedFileSize); -} +{ return new YGDownloadProgress (parent, label, filename, expectedFileSize); } #include "ygtkratiobox.h" #include "YMultiProgressMeter.h" @@ -187,9 +184,7 @@ YMultiProgressMeter *YGOptionalWidgetFactory::createMultiProgressMeter (YWidget *parent, YUIDimension dim, const vector <float> &maxValues) -{ - return new YGMultiProgressMeter (parent, dim, maxValues); -} +{ return new YGMultiProgressMeter (parent, dim, maxValues); } #include "YBusyIndicator.h" @@ -258,8 +253,5 @@ }; YBusyIndicator *YGWidgetFactory::createBusyIndicator (YWidget *parent, const string &label, int timeout) -{ - IMPL - return new YGBusyIndicator (parent, label, timeout); -} +{ return new YGBusyIndicator (parent, label, timeout); } Modified: trunk/gtk/src/YGPushButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPushButton.cc?rev=59804... ============================================================================== --- trunk/gtk/src/YGPushButton.cc (original) +++ trunk/gtk/src/YGPushButton.cc Thu Nov 26 18:14:14 2009 @@ -2,8 +2,9 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include <YPushButton.h> #include "YGUtils.h" #include "YGWidget.h" @@ -19,12 +20,10 @@ : YPushButton (NULL, label), YGWidget (this, parent, GTK_TYPE_BUTTON, "can-default", TRUE, NULL) { - IMPL m_customIcon = m_labelIcon = false; gtk_button_set_use_underline (GTK_BUTTON (getWidget()), TRUE); setLabel (label); connect (getWidget(), "clicked", G_CALLBACK (clicked_cb), this); - g_signal_connect (G_OBJECT (getWidget()), "expose-event", G_CALLBACK (treat_icon_cb), this); } void setStockIcon (const std::string &label) @@ -41,7 +40,7 @@ case 7: stock = GTK_STOCK_PREFERENCES; break; // Expert case 8: stock = GTK_STOCK_GO_BACK; break; case 9: stock = GTK_STOCK_CANCEL; break; -// case 10: stock = GTK_STOCK_GO_FORWARD; break; + case 10: stock = GTK_STOCK_OK; break; // Next/Finish/OK default: break; } #if YAST2_VERSION >= 2017006 @@ -60,7 +59,6 @@ // YPushButton virtual void setLabel (const string &label) { - IMPL YPushButton::setLabel (label); string str = YGUtils::mapKBAccel (label); gtk_button_set_label (GTK_BUTTON (getWidget()), str.c_str()); @@ -92,7 +90,6 @@ virtual void setIcon (const string &icon) { - IMPL GtkButton *button = GTK_BUTTON (getWidget()); if (icon.empty()) { m_customIcon = false; @@ -149,7 +146,7 @@ } return true; } -#if 1 +#if 0 static gboolean treat_icon_cb (GtkWidget *widget, GdkEventExpose *event, YGPushButton *pThis) { @@ -201,7 +198,5 @@ }; YPushButton *YGWidgetFactory::createPushButton (YWidget *parent, const string &label) -{ - return new YGPushButton (parent, label); -} +{ return new YGPushButton (parent, label); } Modified: trunk/gtk/src/YGRadioButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGRadioButton.cc?rev=5980... ============================================================================== --- trunk/gtk/src/YGRadioButton.cc (original) +++ trunk/gtk/src/YGRadioButton.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include "YGUI.h" #include "YGUtils.h" #include "YGWidget.h" @@ -51,7 +52,6 @@ : YRadioButton (NULL, label), YGWidget (this, parent, getCheckRadioButtonType(), NULL) { - IMPL if (!is_horizontal_box (parent)) setStretchable (YD_HORIZ, true); setLabel (label); @@ -66,21 +66,16 @@ { // NOTE: we can't just set a gtk_widget_modify() at the initialization // because each gtk_button_set_label() creates a new label - IMPL string str = YGUtils::mapKBAccel(text.c_str()); gtk_button_set_label (GTK_BUTTON (getWidget()), str.c_str()); YRadioButton::setLabel (text); } virtual bool value() - { - IMPL - return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (getWidget())); - } + { return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (getWidget())); } virtual void setValue (bool checked) { - IMPL BlockEvents block (this); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (getWidget()), checked); if (checked) { @@ -105,7 +100,6 @@ YRadioButton *YGWidgetFactory::createRadioButton (YWidget *parent, const string &label, bool isChecked) { - IMPL YRadioButton *button = new YGRadioButton (parent, label, isChecked); // libyui instructs us to do it here due to vfuncs craziness @@ -145,7 +139,6 @@ : YCheckBox (NULL, label), YGWidget (this, parent, GTK_TYPE_CHECK_BUTTON, NULL) { - IMPL if (!is_horizontal_box (parent)) setStretchable (YD_HORIZ, true); setLabel (label); @@ -158,7 +151,6 @@ // YCheckButton virtual void setLabel (const string &text) { - IMPL string str = YGUtils::mapKBAccel(text); gtk_button_set_label (GTK_BUTTON (getWidget()), str.c_str()); YCheckBox::setLabel (text); @@ -166,7 +158,6 @@ virtual YCheckBoxState value() { - IMPL GtkToggleButton *button = GTK_TOGGLE_BUTTON (getWidget()); if (gtk_toggle_button_get_inconsistent (button)) @@ -176,7 +167,6 @@ virtual void setValue (YCheckBoxState value) { - IMPL BlockEvents block (this); GtkToggleButton *button = GTK_TOGGLE_BUTTON (getWidget()); switch (value) { @@ -208,8 +198,5 @@ YCheckBox *YGWidgetFactory::createCheckBox (YWidget *parent, const string &label, bool isChecked) -{ - IMPL - return new YGCheckBox (parent, label, isChecked); -} +{ return new YGCheckBox (parent, label, isChecked); } Modified: trunk/gtk/src/YGSelectionModel.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGSelectionModel.cc?rev=5... ============================================================================== --- trunk/gtk/src/YGSelectionModel.cc (original) +++ trunk/gtk/src/YGSelectionModel.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include <gtk/gtk.h> #include <YTreeItem.h> #include "YGSelectionModel.h" Modified: trunk/gtk/src/YGTable.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGTable.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGTable.cc (original) +++ trunk/gtk/src/YGTable.cc Thu Nov 26 18:14:14 2009 @@ -2,22 +2,22 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include "YGUtils.h" #include "YGWidget.h" #include "YSelectionWidget.h" #include "YGSelectionModel.h" #include "ygtkcellrenderertextpixbuf.h" -#include "ygtkscrolledwindow.h" -#include <time.h> +#include "ygtktreeview.h" /* A generic widget for table related widgets. */ class YGTableView : public YGScrolledWidget, public YGSelectionModel { protected: int m_colsNb; - time_t m_blockTime; // GtkTreeSelection signals act weird + guint m_blockTimeout; public: YGTableView (YWidget *ywidget, YWidget *parent, const string &label, @@ -26,8 +26,6 @@ YGTK_TYPE_TREE_VIEW, NULL) , YGSelectionModel ((YSelectionWidget *) ywidget, ordinaryModel, isTree) { - IMPL - m_blockTime = time (NULL); if (ordinaryModel) { appendIconTextColumn ("", YAlignUnchanged, YGSelectionModel::ICON_COLUMN, YGSelectionModel::LABEL_COLUMN); @@ -41,6 +39,14 @@ gtk_tree_selection_set_mode (getSelection(), GTK_SELECTION_BROWSE); // let the derivates do the event hooks. They have subtile differences. + + m_blockTimeout = 0; // GtkTreeSelection idiotically fires when showing widget + g_signal_connect (getWidget(), "map", G_CALLBACK (block_init_cb), this); + } + + virtual ~YGTableView() + { + if (m_blockTimeout) g_source_remove (m_blockTimeout); } inline GtkTreeView *getView() @@ -50,7 +56,6 @@ void appendIconTextColumn (string header, YAlignmentType align, int icon_col, int text_col) { - IMPL GtkTreeViewColumn *column; GtkCellRenderer *renderer; @@ -108,12 +113,24 @@ virtual bool immediateEvent() { return true; } - // YGSelectionModel + static gboolean block_selected_timeout_cb (gpointer data) + { + YGTableView *pThis = (YGTableView *) data; + pThis->m_blockTimeout = 0; + return FALSE; + } + void blockSelected() + { // GtkTreeSelection only fires when idle; so set a timeout + if (m_blockTimeout) g_source_remove (m_blockTimeout); + m_blockTimeout = g_timeout_add_full (G_PRIORITY_LOW, 250, block_selected_timeout_cb, this, NULL); + } + + // YGSelectionModel virtual void doSelectItem (GtkTreeIter *iter) { if (!gtk_tree_selection_iter_is_selected (getSelection(), iter)) { - m_blockTime = time (NULL); + blockSelected(); GtkTreePath *path = gtk_tree_model_get_path (getModel(), iter); gtk_tree_view_expand_to_path (getView(), path); @@ -128,7 +145,7 @@ virtual void doUnselectAll() { if (gtk_tree_selection_count_selected_rows (getSelection())) { - m_blockTime = time (NULL); + blockSelected(); gtk_tree_selection_unselect_all (getSelection()); } } @@ -156,10 +173,13 @@ return 80; } + // GTK callbacks + static void block_init_cb (GtkWidget *widget, YGTableView *pThis) + { pThis->blockSelected(); } + // toggled by user (through clicking on the renderer or some other action) void toggle (GtkTreePath *path, gint column) { - IMPL GtkTreeIter iter; if (!gtk_tree_model_get_iter (getModel(), &iter, path)) return; @@ -174,7 +194,7 @@ static void selection_changed_cb (GtkTreeSelection *selection, YGTableView *pThis) { - if (time (NULL) - pThis->m_blockTime <= 2) + if (pThis->m_blockTimeout) return; if (!pThis->toggleMode()) { GtkTreeSelection *selection = pThis->getSelection(); @@ -199,12 +219,18 @@ static void toggled_cb (GtkCellRendererToggle *renderer, gchar *path_str, YGTableView *pThis) { - IMPL GtkTreePath *path = gtk_tree_path_new_from_string (path_str); gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "column")); pThis->toggle (path, column); gtk_tree_path_free (path); } + +#if YAST2_VERSION > 2018003 + static void right_click_cb (YGtkTreeView *view, gboolean outreach, YGTableView *pThis) + { + pThis->emitEvent (YEvent::ContextMenuActivated); + } +#endif }; #include "YTable.h" @@ -223,7 +249,6 @@ #endif , YGTableView (this, parent, string(), false, false) { - IMPL gtk_tree_view_set_headers_visible (getView(), TRUE); gtk_tree_view_set_rules_hint (getView(), columns() > 1); #if YAST2_VERSION >= 2017005 @@ -250,7 +275,7 @@ connect (getWidget(), "row-activated", G_CALLBACK (activated_cb), (YGTableView *) this); connect (getSelection(), "changed", G_CALLBACK (selection_changed_cb), (YGTableView *) this); - connect (getWidget(), "right-click", G_CALLBACK (right_click_cb), this); + connect (getWidget(), "right-click", G_CALLBACK (hack_right_click_cb), this); connect (getWidget(), "key-press-event", G_CALLBACK (key_press_event_cb), this); } @@ -284,7 +309,6 @@ void setSortable (bool sortable) { - IMPL if (!sortable && !GTK_WIDGET_REALIZED (getWidget())) return; int n = 0; @@ -342,8 +366,12 @@ YGUI::ui()->sendEvent (event); } - static void right_click_cb (YGtkTreeView *view, gboolean outreach, YGTable *pThis) + static void hack_right_click_cb (YGtkTreeView *view, gboolean outreach, YGTable *pThis) { +#if YAST2_VERSION > 2018003 + if (pThis->notifyContextMenu()) + return YGTableView::right_click_cb (view, outreach, pThis); +#endif if (!YGDialog::currentDialog()->getFunctionWidget (5) || // undetermined case -- more than one table exists YGDialog::currentDialog()->getClassWidgets ("YTable").size() > 1) { @@ -416,6 +444,9 @@ { connect (getWidget(), "row-activated", G_CALLBACK (activated_cb), (YGTableView *) this); connect (getSelection(), "changed", G_CALLBACK (selection_changed_cb), (YGTableView *) this); +#if YAST2_VERSION > 2018003 + connect (getWidget(), "right-click", G_CALLBACK (right_click_cb), this); +#endif } virtual bool isShrinkable() { return shrinkable(); } @@ -425,10 +456,7 @@ }; YSelectionBox *YGWidgetFactory::createSelectionBox (YWidget *parent, const string &label) -{ - IMPL - return new YGSelectionBox (parent, label); -} +{ return new YGSelectionBox (parent, label); } #include "YMultiSelectionBox.h" @@ -446,11 +474,15 @@ createModel (types); appendCheckColumn ("", 0); appendIconTextColumn ("", YAlignUnchanged, 1, 2); + gtk_tree_view_set_search_column (getView(), 2); setModel(); connect (getSelection(), "changed", G_CALLBACK (selection_changed_cb), (YGTableView *) this); // Let the user toggle, using space/enter or double click (not an event). connect (getWidget(), "row-activated", G_CALLBACK (multi_activated_cb), this); +#if YAST2_VERSION > 2018003 + connect (getWidget(), "right-click", G_CALLBACK (right_click_cb), this); +#endif } // YMultiSelectionBox @@ -483,7 +515,6 @@ { pThis->toggle (path, 0); } // YGSelectionModel - virtual void doSelectItem (GtkTreeIter *iter) { setCellToggle (iter, 0, true); @@ -500,18 +531,13 @@ } // YGWidget - virtual bool isShrinkable() { return shrinkable(); } YGWIDGET_IMPL_COMMON (YMultiSelectionBox) YGSELECTION_WIDGET_IMPL (YMultiSelectionBox) }; -YMultiSelectionBox *YGWidgetFactory::createMultiSelectionBox (YWidget *parent, - const string &label) -{ - IMPL - return new YGMultiSelectionBox (parent, label); -} +YMultiSelectionBox *YGWidgetFactory::createMultiSelectionBox (YWidget *parent, const string &label) +{ return new YGMultiSelectionBox (parent, label); } #include "YTree.h" #include "YTreeItem.h" @@ -527,6 +553,9 @@ connect (getWidget(), "row-expanded", G_CALLBACK (row_expanded_cb), this); connect (getWidget(), "cursor-changed", G_CALLBACK (row_selected_cb), this); connect (getWidget(), "row-activated", G_CALLBACK (activated_cb), (YGTableView *) this); +#if YAST2_VERSION > 2018003 + connect (getWidget(), "right-click", G_CALLBACK (right_click_cb), this); +#endif } // YTree @@ -596,7 +625,7 @@ GtkTreeIter iter; if (gtk_tree_selection_get_selected (selection, NULL, &iter)) pThis->expand (&iter); - YGTableView::selection_changed_cb (selection, pThis); + YGTable::selection_changed_cb (selection, pThis); } virtual unsigned int getMinSize (YUIDimension dim) Modified: trunk/gtk/src/YGText.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGText.cc?rev=59804&r... ============================================================================== --- trunk/gtk/src/YGText.cc (original) +++ trunk/gtk/src/YGText.cc Thu Nov 26 18:14:14 2009 @@ -2,8 +2,9 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include <string> #include "YGUtils.h" #include "YGWidget.h" @@ -19,7 +20,6 @@ YGTK_TYPE_TEXT_VIEW, "wrap-mode", GTK_WRAP_WORD_CHAR, "editable", editable, NULL) { - IMPL setPolicy (GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); maxChars = -1; connect (getBuffer(), "changed", G_CALLBACK (text_changed_cb), this); @@ -29,14 +29,10 @@ { return gtk_text_view_get_buffer (GTK_TEXT_VIEW (getWidget())); } int getCharsNb() - { - IMPL - return gtk_text_buffer_get_char_count (getBuffer()); - } + { return gtk_text_buffer_get_char_count (getBuffer()); } void setCharsNb (int max_chars) { - IMPL maxChars = max_chars; if (maxChars != -1 && getCharsNb() > maxChars) truncateText (maxChars); @@ -53,19 +49,17 @@ void setText (const string &text) { - IMPL BlockEvents block (this); gtk_text_buffer_set_text (getBuffer(), text.c_str(), -1); } - string getText() + std::string getText() { - IMPL GtkTextIter start_it, end_it; gtk_text_buffer_get_bounds (getBuffer(), &start_it, &end_it); gchar* text = gtk_text_buffer_get_text (getBuffer(), &start_it, &end_it, FALSE); - string str (text); + std::string str (text); g_free (text); return str; } @@ -120,11 +114,6 @@ return 30; } - virtual void doSetEnabled (bool enabled) - { - gtk_text_view_set_editable(GTK_TEXT_VIEW (getWidget()), enabled); - } - YGLABEL_WIDGET_IMPL (YMultiLineEdit) }; @@ -144,7 +133,6 @@ {} // YLogView - virtual void displayLogText (const string &text) { setText (text); @@ -152,7 +140,6 @@ } // YGWidget - virtual unsigned int getMinSize (YUIDimension dim) { if (dim == YD_VERT) { @@ -181,9 +168,8 @@ : YRichText (NULL, text, plainText) , YGScrolledWidget (this, parent, ygtk_html_wrap_get_type(), NULL) { - IMPL ygtk_html_wrap_init (getWidget()); - ygtk_html_wrap_connect_link_clicked (getWidget(), G_CALLBACK (link_clicked_cb), this); + ygtk_html_wrap_connect_link_clicked (getWidget(), link_clicked_cb, this); setText (text, plainText); } @@ -236,13 +222,10 @@ } // callbacks - static void link_clicked_cb (GtkWidget *widget, const char *url, YGRichText *pThis) - { - YGUI::ui()->sendEvent (new YMenuEvent (url)); - } + static void link_clicked_cb (GtkWidget *widget, const char *url, gpointer data) + { YGUI::ui()->sendEvent (new YMenuEvent (url)); } // YGWidget - virtual unsigned int getMinSize (YUIDimension dim) { return shrinkable() ? 10 : 100; } Modified: trunk/gtk/src/YGUI.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.cc?rev=59804&r1=... ============================================================================== --- trunk/gtk/src/YGUI.cc (original) +++ trunk/gtk/src/YGUI.cc Thu Nov 26 18:14:14 2009 @@ -6,7 +6,6 @@ Textdomain "yast2-gtk" */ -#include <config.h> #include <string.h> #include <stdio.h> #include <sys/stat.h> @@ -34,15 +33,28 @@ #define DEFAULT_MACRO_FILE_NAME "macro.ycp" #define BUSY_CURSOR_TIMEOUT 250 +YUI *createUI( bool withThreads ) +{ + static YGUI *ui = 0; + if (!ui) + ui = new YGUI (withThreads); + return ui; +} + YGUI::YGUI (bool with_threads) : YUI (with_threads), m_done_init (false), busy_timeout (0) { - IMPL m_have_wm = true; m_no_border = m_fullscreen = false; + m_default_width = (m_default_height = 0); YGUI::setTextdomain( TEXTDOMAIN ); + // If we're running without threads, initialize Gtk stuff + // This enables standalone libyui use Gtk interface + if (!with_threads) + checkInit(); + // without this none of the (default) threading action works ... topmostConstructorHasFinished(); } @@ -84,7 +96,12 @@ // intern the domain - that can be allocated (or belong to a transient // plugin's address space). const char *component = domain ? g_intern_string (domain) : "yast2-gtk"; - YUILog::instance()->log (ylevel, component, "yast2-gtk", 0, "") << message; + YUILog::instance()->log (ylevel, component, "yast2-gtk", 0, "") << message << std::endl; +#if 0 // uncomment to put a stop to gdb + static int bugStop = 0; + if (bugStop-- <= 0) + abort(); +#endif } void YGUI::checkInit() @@ -97,12 +114,11 @@ YCommandLine cmdLine; int argc = cmdLine.argc(); char **argv = cmdLine.argv(); - for (int i = 1; i < argc; i++) { const char *argp = argv[i]; - if (!argp) continue; if (argp[0] != '-') { - //printf ("Warning: Unknown argument '%s'\n", argp); + if (!strcmp (argp, "sw_single") || !strcmp (argp, "online_update")) + YGUI::pkgSelectorSize (&m_default_width, &m_default_height); continue; } argp++; @@ -116,22 +132,18 @@ m_no_border = true; else if (!strcmp (argp, "help")) { printf ( - "Command line options for the YaST2 Gtk UI:\n" - "\n" + "Command line options for the YaST2 Gtk UI:\n\n" "--no-wm assume no window manager is running\n" "--noborder no window manager border for main dialogs\n" "--fullscreen use full screen for main dialogs\n" -// "--geomtry WxH sets a default size of W per H to main dialogs\n" +// "--geometry WxH sets a default size of W per H to main dialogs\n" "--nothreads run without additional UI threads\n" "--help prints this help text\n" "\n" ); exit (0); } -/* - else - printf ("Warning: Unknown argument '--%s'\n", argp); -*/ + else if (pkgSelectorParse (argp)) ; } gtk_init (&argc, &argv); @@ -152,7 +164,6 @@ void YGUI::idleLoop (int fd_ycp) { - IMPL // 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 @@ -175,7 +186,6 @@ static gboolean user_input_timeout_cb (YGUI *pThis) { - IMPL if (!pThis->pendingEvent()) pThis->sendEvent (new YTimeoutEvent()); return FALSE; @@ -184,7 +194,6 @@ // utility that implements both userInput() and pollInput() YEvent *YGUI::waitInput (unsigned long timeout_ms, bool block) { - IMPL checkInit(); if (!YDialog::currentDialog (false)) return NULL; @@ -212,8 +221,11 @@ if (timeout) g_source_remove (timeout); - if (block) // if YCP keeps working for more than X time, set busy cursor + if (block) { // if YCP keeps working for more than X time, set busy cursor + if (busy_timeout) + g_source_remove (busy_timeout); busy_timeout = g_timeout_add (BUSY_CURSOR_TIMEOUT, busy_timeout_cb, this); + } return event; } @@ -325,14 +337,16 @@ //** YGApplication +#define ICONDIR THEMEDIR "/icons/22x22/apps/" + YGApplication::YGApplication() { - setIconBasePath (ICON_DIR); + setIconBasePath (ICONDIR); } -void YGApplication::makeScreenShot (string filename) +void YGApplication::makeScreenShot (const std::string &_filename) { - IMPL + std::string filename (_filename); bool interactive = filename.empty(); GtkWidget *widget = GTK_WIDGET (YGDialog::currentWindow()); @@ -435,7 +449,6 @@ std::string askForFileOrDirectory (GtkFileChooserAction action, const std::string &path, const std::string &filter, const std::string &title) { - IMPL GtkWidget *dialog; dialog = gtk_file_chooser_dialog_new (title.c_str(), YGDialog::currentWindow(), action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, @@ -499,45 +512,35 @@ std::string YGApplication::askForExistingDirectory ( const std::string &path, const std::string &title) -{ - IMPL - return askForFileOrDirectory (GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, path, - "", title); -} +{ return askForFileOrDirectory (GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, path, "", title); } std::string YGApplication::askForExistingFile ( const std::string &path, const std::string &filter, const std::string &title) -{ - IMPL - return askForFileOrDirectory (GTK_FILE_CHOOSER_ACTION_OPEN, path, filter, title); -} +{ return askForFileOrDirectory (GTK_FILE_CHOOSER_ACTION_OPEN, path, filter, title); } std::string YGApplication::askForSaveFileName ( const std::string &path, const std::string &filter, const std::string &title) -{ - IMPL - return askForFileOrDirectory (GTK_FILE_CHOOSER_ACTION_SAVE, path, filter, title); -} +{ return askForFileOrDirectory (GTK_FILE_CHOOSER_ACTION_SAVE, path, filter, title); } std::string YGApplication::glyph (const std::string &sym) { bool reverse = gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL; if (sym == YUIGlyph_ArrowLeft) - return reverse ? "\u2192" : "\u2190"; + return reverse ? "\u25b6" : "\u25c0"; if (sym == YUIGlyph_ArrowRight) - return reverse ? "\u2190" : "\u2192"; + return reverse ? "\u25c0" : "\u25b6"; if (sym == YUIGlyph_ArrowUp) - return "\u2191"; + return "\u25b2"; if (sym == YUIGlyph_ArrowDown) - return "\u2193"; + return "\u25bc"; if (sym == YUIGlyph_CheckMark) return "\u2714"; if (sym == YUIGlyph_BulletArrowRight) return reverse ? "\u21e6" : "\u279c"; if (sym == YUIGlyph_BulletCircle) - return "\u274d"; + return "\u26ab"; if (sym == YUIGlyph_BulletSquare) - return "\u274f"; + return "\u25fe"; return ""; } @@ -792,7 +795,6 @@ { gtk_widget_destroy (GTK_WIDGET (dialog)); } }; - IMPL GtkWidget *dialog = gtk_dialog_new_with_buttons ("YWidgets HTML", NULL, GtkDialogFlags (GTK_DIALOG_NO_SEPARATOR), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300); Modified: trunk/gtk/src/YGUI.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.h?rev=59804&r1=5... ============================================================================== --- trunk/gtk/src/YGUI.h (original) +++ trunk/gtk/src/YGUI.h Thu Nov 26 18:14:14 2009 @@ -5,26 +5,16 @@ #ifndef YGUI_H #define YGUI_H -#include <gtk/gtk.h> -#include <YSimpleEventHandler.h> -#include <map> - +#include "config.h" +#include <YUI.h> #define YUILogComponent "gtk" #include <YUILog.h> - -#define ICON_DIR THEMEDIR "/icons/22x22/apps/" +#include <YSimpleEventHandler.h> +#include <map> +#include <gtk/gtk.h> /* Comment the following line to disable debug messages */ -// #define IMPL_DEBUG -#define LOC fprintf (stderr, "%s (%s)\n", G_STRLOC, G_STRFUNC) -#ifdef IMPL_DEBUG - #define IMPL { LOC; } -#else - #define IMPL { } -#endif -#define IMPL_RET(a) { IMPL; return (a); } - -#include <YUI.h> +#define RET(a) { return (a); } class YGUI: public YUI { @@ -40,7 +30,7 @@ virtual YApplication *createApplication(); public: - static void setTextdomain( const char * domain ); + static void setTextdomain (const char *domain); virtual void idleLoop (int fd_ycp); // called by YDialog::waitInput() / pollEvent()... @@ -74,12 +64,18 @@ // window-related arguments bool m_have_wm, m_no_border, m_fullscreen; + int m_default_width, m_default_height; + + bool pkgSelectorParse (const char *arg); + void pkgSelectorSize (int *width, int *height); public: // Helpers for internal use [ visibility hidden ] bool setFullscreen() const { return m_fullscreen; } bool hasWM() const { return m_have_wm; } bool unsetBorder() const { return m_no_border; } + int defaultWidth() const { return m_default_width; } + int defaultHeight() const { return m_default_height; } }; // debug helpers. @@ -117,8 +113,7 @@ virtual YMultiSelectionBox *createMultiSelectionBox (YWidget *parent, const string &label); virtual YPackageSelector *createPackageSelector (YWidget * parent, long ModeFlags); - virtual YWidget *createPkgSpecial (YWidget * parent, const string & subwidgetName) - IMPL_RET (NULL) // for ncurses + virtual YWidget *createPkgSpecial (YWidget * parent, const string & subwidgetName) RET (NULL) // for ncurses virtual YLayoutBox *createLayoutBox (YWidget *parent, YUIDimension dimension); #if YAST2_VERSION >= 2017006 @@ -142,52 +137,52 @@ class YGOptionalWidgetFactory : public YOptionalWidgetFactory { public: - virtual bool hasWizard() IMPL_RET (true) + virtual bool hasWizard() RET (true) virtual YWizard *createWizard (YWidget *parent, const string &backButtonLabel, const string &abortButtonLabel, const string &nextButtonLabel, YWizardMode wizardMode); - virtual bool hasDumbTab() IMPL_RET (true) + virtual bool hasDumbTab() RET (true) virtual YDumbTab *createDumbTab (YWidget *parent); - virtual bool hasSlider() IMPL_RET (true) + virtual bool hasSlider() RET (true) virtual YSlider *createSlider (YWidget *parent, const string &label, int minVal, int maxVal, int initialVal); - virtual bool hasDateField() IMPL_RET (true) + virtual bool hasDateField() RET (true) virtual YDateField *createDateField (YWidget *parent, const string &label); - virtual bool hasTimeField() IMPL_RET (true) + virtual bool hasTimeField() RET (true) virtual YTimeField *createTimeField (YWidget *parent, const string &label); - virtual bool hasTimezoneSelector() IMPL_RET (true) + virtual bool hasTimezoneSelector() RET (true) virtual YTimezoneSelector *createTimezoneSelector (YWidget *parent, const string &pixmap, const map <string, string> &timezones); - virtual bool hasBarGraph() IMPL_RET (true) + virtual bool hasBarGraph() RET (true) virtual YBarGraph *createBarGraph (YWidget *parent); - virtual bool hasMultiProgressMeter() IMPL_RET (true) + virtual bool hasMultiProgressMeter() RET (true) virtual YMultiProgressMeter *createMultiProgressMeter (YWidget *parent, YUIDimension dim, const vector<float> &maxValues); - virtual bool hasPartitionSplitter() IMPL_RET (true) + virtual bool hasPartitionSplitter() RET (true) virtual YPartitionSplitter *createPartitionSplitter (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); - virtual bool hasDownloadProgress() IMPL_RET (true) + virtual bool hasDownloadProgress() RET (true) virtual YDownloadProgress *createDownloadProgress (YWidget *parent, const string &label, const string & filename, YFileSize_t expectedFileSize); - 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) + virtual bool hasContextMenu() RET (true) + + virtual bool hasSimplePatchSelector() RET (false) + virtual YWidget *createSimplePatchSelector (YWidget *parent, long modeFlags) RET (NULL) + virtual bool hasPatternSelector() RET (false) + virtual YWidget *createPatternSelector (YWidget *parent, long modeFlags) RET (NULL) }; #include <YApplication.h> @@ -209,7 +204,7 @@ virtual void busyCursor() { YGUI::ui()->busyCursor(); } virtual void normalCursor() { YGUI::ui()->normalCursor(); } - virtual void makeScreenShot (string filename); + virtual void makeScreenShot (const std::string &filename); virtual void beep(); virtual int deviceUnits (YUIDimension dim, float layout_units); @@ -222,17 +217,21 @@ virtual int defaultWidth(); // internally, use _defaultWidth / Height() virtual int defaultHeight(); - virtual bool isTextMode() IMPL_RET (false) - virtual bool leftHandedMouse() IMPL_RET (false) - virtual bool hasImageSupport() IMPL_RET (true) - virtual bool hasLocalImageSupport() IMPL_RET (true) - virtual bool hasAnimationSupport() IMPL_RET (true) - virtual bool hasIconSupport() IMPL_RET (true) - virtual bool hasFullUtf8Support() IMPL_RET (true) + virtual bool isTextMode() RET (false) + virtual bool leftHandedMouse() RET (false) + virtual bool hasImageSupport() RET (true) + virtual bool hasLocalImageSupport() RET (true) + virtual bool hasAnimationSupport() RET (true) + virtual bool hasIconSupport() RET (true) + virtual bool hasFullUtf8Support() RET (true) #ifdef USE_WEBKIT - virtual bool richTextSupportsTable() IMPL_RET (true) + virtual bool richTextSupportsTable() RET (true) #else - virtual bool richTextSupportsTable() IMPL_RET (false) + virtual bool richTextSupportsTable() RET (false) +#endif + +#if YAST2_VERSION > 2018003 + virtual bool openContextMenu (const YItemCollection &itemCollection); #endif private: @@ -241,5 +240,7 @@ std::string screenShotNameTemplate; }; +#undef RET + #endif /*YGUI_H*/ Modified: trunk/gtk/src/YGUtils.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGUtils.cc (original) +++ trunk/gtk/src/YGUtils.cc Thu Nov 26 18:14:14 2009 @@ -1,11 +1,16 @@ /******************************************************************** * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ +/* + Textdomain "yast2-gtk" + */ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include <string.h> -#include "YGUI.h" #include "YGUtils.h" +#include "YGUI.h" +#include "YGi18n.h" static inline void skipSpace (const char *instr, int *i) { while (g_ascii_isspace (instr[*i])) (*i)++; } @@ -395,15 +400,15 @@ gtk_adjustment_set_value (vadj, vadj->upper - vadj->page_size); return FALSE; } + void YGUtils::scrollWidget (GtkAdjustment *vadj, bool top) { - // for some widgets, we need to change adjustment before moving down... - gtk_adjustment_set_value (vadj, vadj->lower); - if (!top) { + if (top) + gtk_adjustment_set_value (vadj, vadj->lower); + else // since we usually want to call this together with a text change, we // must wait till that gets in effect - g_timeout_add_full (G_PRIORITY_LOW, 25, scroll_down_cb, vadj, NULL); - } + g_idle_add_full (G_PRIORITY_LOW, scroll_down_cb, vadj, NULL); } void ygutils_scrollAdj (GtkAdjustment *vadj, gboolean top) @@ -568,6 +573,9 @@ { static bool firstTime = true; static std::map <std::string, std::string> stockMap; if (firstTime) { + firstTime = false; + + // match GTK stock labels to yast ones GSList *list = gtk_stock_list_ids(); for (GSList *i = list; i; i = i->next) { gchar *id = (gchar *) i->data; @@ -585,7 +593,20 @@ g_free (id); } g_slist_free (list); - firstTime = false; + + stockMap [_("Apply")] = GTK_STOCK_APPLY; + stockMap [_("Accept")] = GTK_STOCK_APPLY; + stockMap [_("OK")] = GTK_STOCK_OK; + stockMap [_("Cancel")] = GTK_STOCK_CANCEL; + stockMap [_("Yes")] = GTK_STOCK_YES; + stockMap [_("No")] = GTK_STOCK_NO; + stockMap [_("Add")] = GTK_STOCK_ADD; + stockMap [_("Edit")] = GTK_STOCK_EDIT; + stockMap [_("Delete")] = GTK_STOCK_DELETE; + stockMap [_("Up")] = GTK_STOCK_GO_UP; + stockMap [_("Down")] = GTK_STOCK_GO_DOWN; + stockMap [_("Enable")] = GTK_STOCK_YES; + stockMap [_("Disable")] = GTK_STOCK_NO; } std::string id = cutUnderline (label); @@ -605,8 +626,8 @@ if (gtk_style_lookup_icon_set (button->style, icon)) { // we want to use GtkImage stock mode so it honors sensitive GtkWidget *image = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (button), image); gtk_widget_show (image); + gtk_button_set_image (GTK_BUTTON (button), image); } } else { Modified: trunk/gtk/src/YGWidget.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGWidget.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGWidget.cc (original) +++ trunk/gtk/src/YGWidget.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include <stdarg.h> #include "YGWidget.h" #include "YGUtils.h" @@ -67,7 +68,7 @@ { m_widget = GTK_WIDGET (g_object_new_valist (type, property_name, args)); - if (type == GTK_TYPE_WINDOW) + if (type == GTK_TYPE_WINDOW || type == GTK_TYPE_MENU) m_adj_size = m_widget; else { m_adj_size = ygtk_adj_size_new(); @@ -91,7 +92,6 @@ YGWidget::~YGWidget() { - IMPL delete m_signals; m_signals = 0; if (YGUI::ui()->eventPendingFor (m_ywidget)) @@ -193,6 +193,10 @@ } }; +#if YAST2_VERSION > 2018003 + if (reason == YEvent::ContextMenuActivated && !m_ywidget->notifyContextMenu()) + ; // cancel +#endif if (flags & IGNORE_NOTIFY_EVENT || m_ywidget->notify()) { YWidgetEvent *event = new YWidgetEvent (m_ywidget, reason); if (flags & DELAY_EVENT) @@ -216,10 +220,7 @@ { if (m_signals) m_signals->unblock(); } void YGWidget::setBorder (unsigned int border) -{ - IMPL - gtk_container_set_border_width (GTK_CONTAINER (m_adj_size), border); -} +{ gtk_container_set_border_width (GTK_CONTAINER (m_adj_size), border); } /* YGLabeledWidget follows */ Modified: trunk/gtk/src/YGWizard.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGWizard.cc?rev=59804&... ============================================================================== --- trunk/gtk/src/YGWizard.cc (original) +++ trunk/gtk/src/YGWizard.cc Thu Nov 26 18:14:14 2009 @@ -2,8 +2,9 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> -#include <YGUI.h> +#define YUILogComponent "gtk" +#include "config.h" +#include "YGUI.h" #include "YGWidget.h" #include "YGUtils.h" #include "ygtkwizard.h" @@ -84,7 +85,6 @@ : YWizard (NULL, backButtonLabel, abortButtonLabel, nextButtonLabel, wizardMode) , YGWidget (this, parent, YGTK_TYPE_WIZARD, NULL) { - IMPL setBorder (0); YGtkWizard *wizard = getWizard(); @@ -118,6 +118,7 @@ m_abort_button = new YGWButton (this, wizard->abort_button, abortButtonLabel); m_next_button = new YGWButton (this, wizard->next_button, nextButtonLabel); m_notes_button = new YGWButton (this, wizard->release_notes_button, string()); + ygtk_wizard_set_default_button (wizard, wizard->next_button); //** All event are sent through this signal together with an id g_signal_connect (G_OBJECT (getWidget()), "action-triggered", @@ -278,7 +279,6 @@ static void action_triggered_cb (YGtkWizard *wizard, gpointer id, gint id_type, YGWizard *pThis) { - IMPL if ((GType) id_type == G_TYPE_STRING) YGUI::ui()->sendEvent (new YMenuEvent ((char *) id)); else Modified: trunk/gtk/src/YGi18n.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGi18n.h?rev=59804&r1... ============================================================================== --- trunk/gtk/src/YGi18n.h (original) +++ trunk/gtk/src/YGi18n.h Thu Nov 26 18:14:14 2009 @@ -1,43 +1,20 @@ -/*---------------------------------------------------------------------\ -| | -| __ __ ____ _____ ____ | -| \ \ / /_ _/ ___|_ _|___ \ | -| \ V / _` ___ \ | | __) | | -| | | (_| |___) || | / __/ | -| |_|__,_|____/ |_| |_____| | -| | -| core system | -| (C) SuSE GmbH | -----------------------------------------------------------------------/ - - File: YGi18n.h - - Author: Jiri Srain <jsrain@suse.cz> - -/-*/ - -// -*- c++ -*- +/******************************************************************** + * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * + ********************************************************************/ #ifndef YGi18n_h #define YGi18n_h #include <libintl.h> - #define TEXTDOMAIN "yast2-gtk" -// tag for translation but don't translate; no N_ in y2makepot ... -#define __(a) (a) - -static inline const char * _( const char * msgid ) -{ - return ( !msgid || !*msgid ) ? "" : dgettext( TEXTDOMAIN, msgid ); -} +static inline const char *_(const char *msgid) +{ return dgettext (TEXTDOMAIN, msgid); } #ifndef YGI18N_C -static inline const char * _( const char * msgid1, const char * msgid2, unsigned long int n ) -{ - return dngettext( TEXTDOMAIN, msgid1, msgid2, n ); -} +static inline const char * _(const char * msgid1, const char *msgid2, unsigned long int n) +{ return dngettext(TEXTDOMAIN, msgid1, msgid2, n); } #endif -#endif // YGi18n_h +#endif /*YGi18n_h*/ + Modified: trunk/gtk/src/test.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/test.cc?rev=59804&r1=... ============================================================================== --- trunk/gtk/src/test.cc (original) +++ trunk/gtk/src/test.cc Thu Nov 26 18:14:14 2009 @@ -2,7 +2,8 @@ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK * ********************************************************************/ -#include <config.h> +#define YUILogComponent "gtk" +#include "config.h" #include <stdio.h> #include <string.h> #include <YUI.h> Modified: trunk/gtk/src/ygtkbargraph.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkbargraph.c?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtkbargraph.c (original) +++ trunk/gtk/src/ygtkbargraph.c Thu Nov 26 18:14:14 2009 @@ -6,15 +6,18 @@ // check the header file for information about this widget #include <config.h> +#include "ygtkratiobox.h" #include "ygtkbargraph.h" #include <gtk/gtk.h> -G_DEFINE_TYPE (YGtkBarGraph, ygtk_bar_graph, YGTK_TYPE_RATIO_HBOX) +G_DEFINE_TYPE (YGtkBarGraph, ygtk_bar_graph, GTK_TYPE_FRAME) static void ygtk_bar_graph_init (YGtkBarGraph *bar) { -// ygtk_ratio_box_set_homogeneous (YGTK_RATIO_BOX (bar), TRUE); - gtk_container_set_border_width (GTK_CONTAINER (bar), 12); + GtkWidget *box = ygtk_ratio_hbox_new (0); + gtk_widget_show (box); + gtk_container_add (GTK_CONTAINER (bar), box); + ygtk_bar_graph_set_style (bar, TRUE); } static void ygtk_bar_graph_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -30,7 +33,7 @@ void ygtk_bar_graph_create_entries (YGtkBarGraph *bar, guint entries) { - YGtkRatioBox *box = YGTK_RATIO_BOX (bar); + YGtkRatioBox *box = YGTK_RATIO_BOX (GTK_BIN (bar)->child); // Remove the ones in excess guint i; @@ -56,8 +59,8 @@ static GtkWidget *ygtk_bar_graph_get_label (YGtkBarGraph *bar, int index, GtkWidget **b) { - GtkWidget *box = ((YGtkRatioBoxChild *) g_list_nth_data ( - YGTK_RATIO_BOX (bar)->children, index))->widget; + YGtkRatioBox *hbox = YGTK_RATIO_BOX (GTK_BIN (bar)->child); + GtkWidget *box = ((YGtkRatioBoxChild *) g_list_nth_data (hbox->children, index))->widget; if (b) *b = box; return gtk_bin_get_child (GTK_BIN (box)); } @@ -92,7 +95,8 @@ // Set proportion gtk_widget_set_size_request (box, 0, -1); - ygtk_ratio_box_set_child_packing (YGTK_RATIO_BOX (bar), box, MAX (value, 1)); + YGtkRatioBox *hbox = YGTK_RATIO_BOX (GTK_BIN (bar)->child); + ygtk_ratio_box_set_child_packing (hbox, box, MAX (value, 1)); // Set background color // The Tango palette @@ -135,6 +139,8 @@ void ygtk_bar_graph_set_style (YGtkBarGraph *bar, gboolean flat) { bar->flat = flat; + GtkShadowType shadow = flat ? GTK_SHADOW_OUT : GTK_SHADOW_NONE; + gtk_frame_set_shadow_type (GTK_FRAME (bar), shadow); } void ygtk_bar_graph_customize_bg (YGtkBarGraph *bar, int index, GdkColor *color) Modified: trunk/gtk/src/ygtkbargraph.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkbargraph.h?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtkbargraph.h (original) +++ trunk/gtk/src/ygtkbargraph.h Thu Nov 26 18:14:14 2009 @@ -9,7 +9,7 @@ #ifndef YGTK_BAR_GRAPH_H #define YGTK_BAR_GRAPH_H -#include "ygtkratiobox.h" +#include <gtk/gtkframe.h> G_BEGIN_DECLS #define YGTK_TYPE_BAR_GRAPH (ygtk_bar_graph_get_type ()) @@ -29,14 +29,14 @@ struct _YGtkBarGraph { - YGtkRatioHBox parent; + GtkFrame parent; // members: guint flat : 2; }; struct _YGtkBarGraphClass { - YGtkRatioHBoxClass parent_class; + GtkFrameClass parent_class; }; GtkWidget *ygtk_bar_graph_new (void); Modified: trunk/gtk/src/ygtkcellrenderertextpixbuf.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkcellrenderertextpixbu... ============================================================================== --- trunk/gtk/src/ygtkcellrenderertextpixbuf.c (original) +++ trunk/gtk/src/ygtkcellrenderertextpixbuf.c Thu Nov 26 18:14:14 2009 @@ -8,11 +8,15 @@ #include <config.h> #include "ygtkcellrenderertextpixbuf.h" +extern GdkPixbuf *ygutils_setOpacity (const GdkPixbuf *src, int opacity, gboolean alpha); + #define PIXBUF_TEXT_SPACING 4 enum { PROP_0, - PROP_PIXBUF + PROP_PIXBUF, + PROP_STOCK_ID, + PROP_STOCK_SIZE, }; G_DEFINE_TYPE (YGtkCellRendererTextPixbuf, ygtk_cell_renderer_text_pixbuf, GTK_TYPE_CELL_RENDERER_TEXT) @@ -21,19 +25,28 @@ { GtkCellRenderer *cell = GTK_CELL_RENDERER (tpcell); cell->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; - cell->xalign = 0.0; + cell->xpad = cell->ypad = 0; + cell->xalign = 0; cell->yalign = 0.5; - cell->xpad = 0; - cell->ypad = 0; + tpcell->stock_size = GTK_ICON_SIZE_MENU; +} + +static void unset_image_properties (YGtkCellRendererTextPixbuf *cell) +{ + if (cell->stock_id) { + g_free (cell->stock_id); + cell->stock_id = NULL; + } + if (cell->pixbuf) { + g_object_unref (cell->pixbuf); + cell->pixbuf = NULL; + } } static void ygtk_cell_renderer_text_pixbuf_finalize (GObject *object) { YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (object); - if (tpcell->pixbuf) { - g_object_unref (G_OBJECT (tpcell->pixbuf)); - tpcell->pixbuf = NULL; - } + unset_image_properties (tpcell); G_OBJECT_CLASS (ygtk_cell_renderer_text_pixbuf_parent_class)->finalize (object); } @@ -46,6 +59,12 @@ case PROP_PIXBUF: g_value_set_object (value, G_OBJECT (tpcell->pixbuf)); break; + case PROP_STOCK_ID: + g_value_set_string (value, tpcell->stock_id); + break; + case PROP_STOCK_SIZE: + g_value_set_uint (value, tpcell->stock_size); + break; } } else @@ -60,10 +79,16 @@ YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (object); switch (param_id) { case PROP_PIXBUF: - if (tpcell->pixbuf) - g_object_unref (G_OBJECT (tpcell->pixbuf)); + unset_image_properties (tpcell); tpcell->pixbuf = (GdkPixbuf *) g_value_dup_object (value); break; + case PROP_STOCK_ID: + unset_image_properties (tpcell); + tpcell->stock_id = g_value_dup_string (value); + break; + case PROP_STOCK_SIZE: + tpcell->stock_size = g_value_get_uint (value); + break; } } else @@ -79,42 +104,82 @@ return NULL; } -#define XPAD 1 -#define YPAD 0 +static void ensure_pixbuf (YGtkCellRendererTextPixbuf *cell, GtkWidget *widget) +{ + if (cell->stock_id && !cell->pixbuf) + cell->pixbuf = gtk_widget_render_icon (widget, cell->stock_id, cell->stock_size, NULL); +} -static void ygtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell, - GtkWidget *widget, GdkRectangle *cell_area, gint *xoffset, gint *yoffset, - gint *width, gint *height) +static void ygtk_cell_renderer_text_pixbuf_get_size_full (GtkCellRenderer *cell, + GtkWidget *widget, GdkRectangle *cell_area, gint *_xoffset, gint *_yoffset, + gint *_width, gint *_height, gint *_pixbuf_xoffset, gint *_pixbuf_yoffset, + gint *_pixbuf_width, gint *_pixbuf_height, gint *_text_xoffset, gint *_text_yoffset) { - GtkCellRendererText *tcell = GTK_CELL_RENDERER_TEXT (cell); YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (cell); + ensure_pixbuf (tpcell, widget); - // will be calculated at expose, as both pixbuf and text have their offsets... - if (xoffset) *xoffset = 0; - if (yoffset) *yoffset = 0; - if (!width || !height) - return; - *width = 0; - *height = 0; - + int pixbuf_width = 0, pixbuf_height = 0; if (tpcell->pixbuf) { - *width += gdk_pixbuf_get_width (tpcell->pixbuf); - *height = MAX (*height, gdk_pixbuf_get_height (tpcell->pixbuf)); + pixbuf_width = gdk_pixbuf_get_width (tpcell->pixbuf); + pixbuf_height = gdk_pixbuf_get_height (tpcell->pixbuf); } - if (tcell->text) { - if (tpcell->pixbuf) - *width += PIXBUF_TEXT_SPACING; - - PangoLayout *layout = create_layout (tpcell, widget); - int lw, lh; - pango_layout_get_pixel_size (layout, &lw, &lh); - *width += lw; - *height = MAX (*height, lh); - g_object_unref (G_OBJECT (layout)); + PangoLayout *layout = create_layout (tpcell, widget); + int text_width = 0, text_height = 0; + if (layout) { + PangoRectangle rect; + pango_layout_get_pixel_extents (layout, NULL, &rect); + text_width = rect.x + rect.width; + text_height = rect.y + rect.height; } - *width += (cell->xpad+XPAD)*2; - *height += (cell->ypad+YPAD)*2; + + int width, height; + width = pixbuf_width + text_width; + if (pixbuf_width && text_width) + width += PIXBUF_TEXT_SPACING; + height = MAX (pixbuf_height, text_height); + + if (cell_area) { + gboolean reverse = gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL; + gfloat xalign = cell->xalign, yalign = cell->yalign; + if (reverse) + xalign = 1.0 - xalign; + + int cell_width = cell_area->width - cell->xpad*2, + cell_height = cell_area->height - cell->ypad*2; + int xoffset = (xalign * (cell_width - width)) + cell->xpad; + int yoffset = (yalign * (cell_height - height)) + cell->ypad; + if (_xoffset) *_xoffset = xoffset; + if (_yoffset) *_yoffset = yoffset; + + int text_x = xoffset, text_y; + if (pixbuf_width && !reverse) + text_x += (pixbuf_width + PIXBUF_TEXT_SPACING); + text_y = (yalign * (cell_height - text_height)) + cell->ypad; + + int pixbuf_x = xoffset, pixbuf_y; + if (text_width && reverse) + pixbuf_x += (text_width + PIXBUF_TEXT_SPACING); + pixbuf_y = (yalign * (cell_height - pixbuf_height)) + cell->ypad; + + if (_pixbuf_xoffset) *_pixbuf_xoffset = pixbuf_x; + if (_pixbuf_yoffset) *_pixbuf_yoffset = pixbuf_y; + if (_pixbuf_width) *_pixbuf_width = pixbuf_width; + if (_pixbuf_height) *_pixbuf_height = pixbuf_height; + if (_text_xoffset) *_text_xoffset = text_x; + if (_text_yoffset) *_text_yoffset = text_y; + } + + if (_width) *_width = width + (cell->xpad * 2); + if (_height) *_height = height + (cell->ypad * 2); +} + +static void ygtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell, + GtkWidget *widget, GdkRectangle *cell_area, gint *xoffset, gint *yoffset, + gint *width, gint *height) +{ + ygtk_cell_renderer_text_pixbuf_get_size_full (cell, widget, cell_area, + xoffset, yoffset, width, height, NULL, NULL, NULL, NULL, NULL, NULL); } static void ygtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell, @@ -142,55 +207,28 @@ state = GTK_STATE_NORMAL; } - // positioning - - gboolean reverse = gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL; - gfloat xalign = cell->xalign, yalign = cell->yalign; - if (reverse) - xalign = 1.0 - xalign; - - GdkPixbuf *pixbuf = tpcell->pixbuf; - int pixbuf_width = 0, pixbuf_height = 0; - if (pixbuf) { - pixbuf_width = gdk_pixbuf_get_width (pixbuf); - pixbuf_height = gdk_pixbuf_get_height (pixbuf); - } - - PangoLayout *layout = create_layout (tpcell, widget); - int text_width = 0, text_height = 0; - if (layout) { - PangoRectangle rect; - pango_layout_get_pixel_extents (layout, NULL, &rect); - text_width = rect.width; - text_height = rect.height; - } - - int spacing = (text_width && pixbuf_width) ? PIXBUF_TEXT_SPACING : 0; - int offset_x = xalign * (cell_area->width - (text_width + pixbuf_width + spacing)); - - int text_x = offset_x, text_y; - if (pixbuf_width && !reverse) - text_x += (pixbuf_width + spacing); - text_y = yalign * (cell_area->height - text_height); - - int pixbuf_x = offset_x, pixbuf_y; - if (text_width && reverse) - pixbuf_x += (text_width + spacing); - pixbuf_y = yalign * (cell_area->height - pixbuf_height); + int text_xoffset, text_yoffset, pixbuf_xoffset, pixbuf_yoffset, pixbuf_width, + pixbuf_height; + ygtk_cell_renderer_text_pixbuf_get_size_full (cell, widget, cell_area, + NULL, NULL, NULL, NULL, &pixbuf_xoffset, &pixbuf_yoffset, &pixbuf_width, + &pixbuf_height, &text_xoffset, &text_yoffset); // paint - int x = cell_area->x + cell->xpad+XPAD, y = cell_area->y + cell->ypad+YPAD; - if (pixbuf) { + ensure_pixbuf (tpcell, widget); + if (tpcell->pixbuf) { + int x = cell_area->x + pixbuf_xoffset, y = cell_area->y + pixbuf_yoffset; cairo_t *cr = gdk_cairo_create (window); - gdk_cairo_set_source_pixbuf (cr, pixbuf, pixbuf_x+x, pixbuf_y+y); - cairo_rectangle (cr, pixbuf_x+x, pixbuf_y+y, pixbuf_width, pixbuf_height); + gdk_cairo_set_source_pixbuf (cr, tpcell->pixbuf, x, y); + cairo_rectangle (cr, x, y, pixbuf_width, pixbuf_height); cairo_fill (cr); cairo_destroy (cr); } + PangoLayout *layout = create_layout (tpcell, widget); if (layout) { + int x = cell_area->x + text_xoffset, y = cell_area->y + text_yoffset; GtkStyle *style = gtk_widget_get_style (widget); gtk_paint_layout (style, window, state, TRUE, expose_area, widget, - "cellrenderertext", text_x+x, text_y+y, layout); + "cellrenderertext", x, y, layout); g_object_unref (G_OBJECT (layout)); } } @@ -211,8 +249,14 @@ cell_class->get_size = ygtk_cell_renderer_text_pixbuf_get_size; cell_class->render = ygtk_cell_renderer_text_pixbuf_render; + GParamFlags readwrite_flag = + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB; g_object_class_install_property (object_class, PROP_PIXBUF, - g_param_spec_object ("pixbuf", "Image", "Side image", GDK_TYPE_PIXBUF, - G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); + g_param_spec_object ("pixbuf", "Image", "Side image", GDK_TYPE_PIXBUF, readwrite_flag)); + g_object_class_install_property (object_class, PROP_STOCK_ID, + g_param_spec_string ("stock-id", "Stock ID", "Stock icon to render", NULL, readwrite_flag)); + g_object_class_install_property (object_class, PROP_STOCK_SIZE, + g_param_spec_uint ("stock-size", "Size", "GtkIconSize of the rendered icon", + 0, G_MAXUINT, GTK_ICON_SIZE_MENU, readwrite_flag)); } Modified: trunk/gtk/src/ygtkcellrenderertextpixbuf.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkcellrenderertextpixbu... ============================================================================== --- trunk/gtk/src/ygtkcellrenderertextpixbuf.h (original) +++ trunk/gtk/src/ygtkcellrenderertextpixbuf.h Thu Nov 26 18:14:14 2009 @@ -33,6 +33,8 @@ // private: GdkPixbuf *pixbuf; + gchar *stock_id; + GtkIconSize stock_size; } YGtkCellRendererTextPixbuf; typedef struct _YGtkCellRendererTextPixbufClass Modified: trunk/gtk/src/ygtkfindentry.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkfindentry.c?rev=59804... ============================================================================== --- trunk/gtk/src/ygtkfindentry.c (original) +++ trunk/gtk/src/ygtkfindentry.c Thu Nov 26 18:14:14 2009 @@ -301,7 +301,7 @@ if (entry->find_icon) { left_border = gdk_pixbuf_get_width (entry->find_icon) + 2; if (entry->context_menu) - left_border += ARROW_SIZE - 1; + left_border += ARROW_SIZE; } if (entry->clear_icon) right_border = gdk_pixbuf_get_width (entry->clear_icon) + 2; @@ -346,6 +346,19 @@ gdk_window_hide (eentry->right_window); // show when text is inserted } +static void ygtk_find_entry_unrealize (GtkWidget *widget) +{ + GTK_WIDGET_CLASS (ygtk_find_entry_parent_class)->unrealize (widget); + + YGtkFindEntry *fentry = YGTK_FIND_ENTRY (widget); + generate_icon (NULL, NULL, &fentry->find_icon, &fentry->find_hover_icon); + generate_icon (NULL, NULL, &fentry->clear_icon, &fentry->clear_hover_icon); + + YGtkExtEntry *eentry = YGTK_EXT_ENTRY (widget); + ygtk_ext_entry_set_border_window_size (eentry, YGTK_EXT_ENTRY_LEFT_WIN, 0); + ygtk_ext_entry_set_border_window_size (eentry, YGTK_EXT_ENTRY_RIGHT_WIN, 0); +} + static void ygtk_find_entry_map (GtkWidget *widget) { GTK_WIDGET_CLASS (ygtk_find_entry_parent_class)->map (widget); @@ -365,17 +378,22 @@ GdkWindow *hover_window = gdk_display_get_window_at_pointer ( gtk_widget_get_display (widget), NULL, NULL); - if (event->window == eentry->left_window || - event->window == eentry->right_window) { + if (event->window == eentry->left_window || event->window == eentry->right_window) { gboolean hover = hover_window == event->window; + int win_width, win_height; + gdk_drawable_get_size (event->window, &win_width, &win_height); + +/* if (fentry->context_menu && event->window == eentry->left_window) + gtk_paint_box (widget->style, event->window, GTK_STATE_NORMAL, + GTK_SHADOW_OUT, &event->area, widget, "combobox", + 0, 0, win_width, win_height);*/ + GdkPixbuf *pixbuf; if (event->window == eentry->left_window) pixbuf = hover ? fentry->find_hover_icon : fentry->find_icon; else pixbuf = hover ? fentry->clear_hover_icon : fentry->clear_icon; - - int pix_height = gdk_pixbuf_get_height (pixbuf), win_width, win_height, y; - gdk_drawable_get_size (event->window, &win_width, &win_height); + int pix_height = gdk_pixbuf_get_height (pixbuf), y; y = (win_height - pix_height) / 2; gdk_draw_pixbuf (event->window, widget->style->fg_gc[0], pixbuf, @@ -383,10 +401,8 @@ if (fentry->context_menu && event->window == eentry->left_window) gtk_paint_arrow (widget->style, event->window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, &event->area, widget, NULL, - GTK_ARROW_DOWN, FALSE, - win_width - ARROW_SIZE - 1, win_height - ARROW_SIZE, - ARROW_SIZE, ARROW_SIZE); + GTK_SHADOW_NONE, &event->area, widget, NULL, GTK_ARROW_DOWN, FALSE, + win_width - ARROW_SIZE-1, (win_height - ARROW_SIZE)/2, ARROW_SIZE, ARROW_SIZE); } else GTK_WIDGET_CLASS (ygtk_find_entry_parent_class)->expose_event (widget, event); @@ -630,6 +646,7 @@ { GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass); gtkwidget_class->realize = ygtk_find_entry_realize; + gtkwidget_class->unrealize = ygtk_find_entry_unrealize; gtkwidget_class->map = ygtk_find_entry_map; gtkwidget_class->expose_event = ygtk_find_entry_expose; gtkwidget_class->enter_notify_event = ygtk_find_entry_enter_leave_notify_event; Modified: trunk/gtk/src/ygtkfindentry.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkfindentry.h?rev=59804... ============================================================================== --- trunk/gtk/src/ygtkfindentry.h (original) +++ trunk/gtk/src/ygtkfindentry.h Thu Nov 26 18:14:14 2009 @@ -14,6 +14,8 @@ YGtkFindEntry is a convinience widget that has a find icon, with an optional menu, at the left, and an erase icon at the right. It can interact with an option image menu, and does auto-completion. + + TODO: deprecate in favor of using GtkEntry 2.16 new APIs. */ #ifndef YGTK_FIND_ENTRY_H Modified: trunk/gtk/src/ygtkhtmlwrap.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkhtmlwrap.c?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtkhtmlwrap.c (original) +++ trunk/gtk/src/ygtkhtmlwrap.c Thu Nov 26 18:14:14 2009 @@ -182,7 +182,7 @@ } static WebKitNavigationResponse ygtk_webkit_navigation_requested_cb ( - WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *request, void (*callback) (GtkWidget *widget, const gchar *uri, gpointer d)) + WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *request, LinkClickedCb callback) { const gchar *uri = webkit_network_request_get_uri (request); // look for set_text to see why we need to cut the uri in some cases @@ -194,7 +194,7 @@ return WEBKIT_NAVIGATION_RESPONSE_IGNORE; } -void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, GCallback callback, gpointer data) +void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, LinkClickedCb callback, gpointer data) { g_object_set_data (G_OBJECT (widget), "pointer", data); g_signal_connect (G_OBJECT (widget), "navigation-requested", @@ -279,9 +279,9 @@ return gtk_html_engine_search_next (GTK_HTML (widget)); } -void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, GCallback callback, gpointer data) +void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, LinkClickedCb callback, gpointer data) { - g_signal_connect (G_OBJECT (widget), "link-clicked", callback, data); + g_signal_connect (G_OBJECT (widget), "link-clicked", G_CALLBACK (callback), data); } void ygtk_html_wrap_set_background (GtkWidget *widget, GdkPixbuf *pixbuf, const gchar *filename) @@ -304,7 +304,11 @@ void ygtk_html_wrap_set_text (GtkWidget *widget, const gchar* text, gboolean plain_mode) { - ygtk_rich_text_set_text (YGTK_RICH_TEXT (widget), text, plain_mode); + YGtkRichText *rtext = YGTK_RICH_TEXT (widget); + if (plain_mode) + ygtk_rich_text_set_plain_text (rtext, text); + else + ygtk_rich_text_set_text (rtext, text); } void ygtk_html_wrap_scroll (GtkWidget *widget, gboolean top) @@ -324,9 +328,9 @@ return ygtk_rich_text_forward_mark (YGTK_RICH_TEXT (widget), text); } -void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, GCallback callback, gpointer data) +void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, LinkClickedCb callback, gpointer data) { - g_signal_connect (G_OBJECT (widget), "link-clicked", callback, data); + g_signal_connect (G_OBJECT (widget), "link-clicked", G_CALLBACK (callback), data); } void ygtk_html_wrap_set_background (GtkWidget *widget, GdkPixbuf *pixbuf, const gchar *filename) Modified: trunk/gtk/src/ygtkhtmlwrap.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkhtmlwrap.h?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtkhtmlwrap.h (original) +++ trunk/gtk/src/ygtkhtmlwrap.h Thu Nov 26 18:14:14 2009 @@ -22,8 +22,8 @@ void ygtk_html_wrap_set_text (GtkWidget *widget, const gchar* text, gboolean plain_mode); void ygtk_html_wrap_scroll (GtkWidget *widget, gboolean top /* or bottom */); -// callback of type: void (GtkWidget *htmlwrap, const gchar *url, gpointer data) -void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, GCallback callback, gpointer data); +typedef void (*LinkClickedCb) (GtkWidget *htmlwrap, const gchar *url, gpointer data); +void ygtk_html_wrap_connect_link_clicked (GtkWidget *widget, LinkClickedCb callback, gpointer data); // not supported on plain text gboolean ygtk_html_wrap_search (GtkWidget *widget, const gchar *text); Modified: trunk/gtk/src/ygtkratiobox.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkratiobox.c?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtkratiobox.c (original) +++ trunk/gtk/src/ygtkratiobox.c Thu Nov 26 18:14:14 2009 @@ -121,6 +121,10 @@ requisition->width += spacing; else requisition->height += spacing; + + int border = GTK_CONTAINER (box)->border_width; + requisition->width += border*2; + requisition->height += border*2; } static void ygtk_ratio_box_size_allocate (GtkWidget *widget, @@ -144,11 +148,15 @@ gint spacing = children_nb ? box->spacing*(children_nb-1) : 0; + int border = GTK_CONTAINER (box)->border_width; + int x = allocation->x + border, y = allocation->y + border, + width = allocation->width - border*2, height = allocation->height - border*2; + gint length; if (orientation == GTK_ORIENTATION_HORIZONTAL) - length = allocation->width - spacing; + length = width - spacing; else - length = allocation->height - spacing; + length = height - spacing; gint child_pos = 0; for (i = box->children; i; i = i->next) { @@ -160,18 +168,20 @@ gtk_widget_get_child_requisition (child->widget, &child_req); gint child_length = (child->ratio * length) / ratios_sum; + if (!i->next) // last takes rest (any residual length) + child_length = length - child_pos; GtkAllocation child_alloc; if (orientation == GTK_ORIENTATION_HORIZONTAL) { - child_alloc.x = allocation->x + child_pos; - child_alloc.y = allocation->y; + child_alloc.x = x + child_pos; + child_alloc.y = y; child_alloc.width = child_length; - child_alloc.height = allocation->height; + child_alloc.height = height; } else { // GTK_ORIENTATION_VERTICAL - child_alloc.x = allocation->x; - child_alloc.y = allocation->y + child_pos; - child_alloc.width = allocation->width; + child_alloc.x = x; + child_alloc.y = y + child_pos; + child_alloc.width = width; child_alloc.height = child_length; } Modified: trunk/gtk/src/ygtkrichtext.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkrichtext.c?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtkrichtext.c (original) +++ trunk/gtk/src/ygtkrichtext.c Thu Nov 26 18:14:14 2009 @@ -24,13 +24,10 @@ // utilities // Looks at all tags covering the position of iter in the text view, // and returns the link the text points to, in case that text is a link. -static const char *get_link (GtkTextView *text_view, gint x, gint y) +static const char *get_link_at_iter (GtkTextView *text_view, GtkTextIter *iter) { - GtkTextIter iter; - gtk_text_view_get_iter_at_location (text_view, &iter, x, y); - char *link = NULL; - GSList *tags = gtk_text_iter_get_tags (&iter), *tagp; + GSList *tags = gtk_text_iter_get_tags (iter), *tagp; for (tagp = tags; tagp != NULL; tagp = tagp->next) { GtkTextTag *tag = (GtkTextTag*) tagp->data; link = (char*) g_object_get_data (G_OBJECT (tag), "link"); @@ -42,23 +39,27 @@ g_slist_free (tags); return link; } +static const char *get_link (GtkTextView *text_view, gint win_x, gint win_y) +{ + gint buffer_x, buffer_y; + gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), + GTK_TEXT_WINDOW_WIDGET, win_x, win_y, &buffer_x, &buffer_y); + GtkTextIter iter; + gtk_text_view_get_iter_at_location (text_view, &iter, buffer_x, buffer_y); + return get_link_at_iter (text_view, &iter); +} // callbacks // Links can also be activated by clicking. static gboolean event_after (GtkWidget *text_view, GdkEvent *ev) { - GtkTextIter start, end; - GtkTextBuffer *buffer; - GdkEventButton *event; - gint x, y; - if (ev->type != GDK_BUTTON_RELEASE) return FALSE; - - event = (GdkEventButton *)ev; + GtkTextIter start, end; + GtkTextBuffer *buffer; + GdkEventButton *event = (GdkEventButton *) ev; if (event->button != 1) return FALSE; - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); // We shouldn't follow a link if the user is selecting something. @@ -66,10 +67,7 @@ if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end)) return FALSE; - gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), - GTK_TEXT_WINDOW_WIDGET, (gint) event->x, (gint) event->y, &x, &y); - - const char *link = get_link (GTK_TEXT_VIEW (text_view), x, y); + const char *link = get_link (GTK_TEXT_VIEW (text_view), event->x, event->y); if (link) // report link g_signal_emit (YGTK_RICH_TEXT (text_view), link_clicked_signal, 0, link); return FALSE; @@ -180,12 +178,9 @@ wy >= widget->allocation.height) return; } - gint bx, by; - gtk_text_view_window_to_buffer_coords (view, GTK_TEXT_WINDOW_WIDGET, - wx, wy, &bx, &by); static gboolean hovering_over_link = FALSE; - gboolean hovering = get_link (view, bx, by) != NULL; + gboolean hovering = get_link (view, wx, wy) != NULL; if (hovering != hovering_over_link) { hovering_over_link = hovering; @@ -382,8 +377,8 @@ // for tags like <br/>, GMarkup will pass them through the end // tag callback too, so we'll deal with them there - else if (!g_ascii_strcasecmp (element_name, "br")) - ; + else if (!g_ascii_strcasecmp (element_name, "br")) ; + else if (!g_ascii_strcasecmp (element_name, "hr")) ; else { @@ -553,18 +548,16 @@ } while (!gtk_text_iter_is_end (&iter)); } -void ygtk_rich_text_set_text (YGtkRichText* rtext, const gchar* text, gboolean plain_mode) +void ygtk_rich_text_set_plain_text (YGtkRichText* rtext, const gchar* text) { - GtkTextBuffer *buffer; - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (rtext)); - - if (plain_mode) { - gtk_text_buffer_set_text (buffer, text, -1); - return; - } + GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (rtext)); + gtk_text_buffer_set_text (buffer, text, -1); +} - // remove any possible existing text - gtk_text_buffer_set_text (buffer, "", 0); +void ygtk_rich_text_set_text (YGtkRichText* rtext, const gchar* text) +{ + GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (rtext)); + gtk_text_buffer_set_text (buffer, "", 0); // remove any existing text GRTParseState state; GRTParseState_init (&state, buffer); @@ -691,7 +684,7 @@ g_object_ref (G_OBJECT (pixbuf)); } -void ygtk_rich_text_class_init (YGtkRichTextClass *klass) +static void ygtk_rich_text_class_init (YGtkRichTextClass *klass) { GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass); gtkwidget_class->motion_notify_event = ygtk_rich_text_motion_notify_event; Modified: trunk/gtk/src/ygtkrichtext.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkrichtext.h?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtkrichtext.h (original) +++ trunk/gtk/src/ygtkrichtext.h Thu Nov 26 18:14:14 2009 @@ -46,7 +46,8 @@ /* Sets some text to YGtkRichText, may be HTML or plain text, as indicated by rich_text. */ -void ygtk_rich_text_set_text (YGtkRichText* rtext, const gchar* text, gboolean plain_mode); +void ygtk_rich_text_set_text (YGtkRichText* rtext, const gchar* text); +void ygtk_rich_text_set_plain_text (YGtkRichText* rtext, const gchar* text); // To be used together with an entry box to search for text gboolean ygtk_rich_text_mark_text (YGtkRichText *rtext, const gchar *text); Modified: trunk/gtk/src/ygtkscrolledwindow.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkscrolledwindow.h?rev=... ============================================================================== --- trunk/gtk/src/ygtkscrolledwindow.h (original) +++ trunk/gtk/src/ygtkscrolledwindow.h Thu Nov 26 18:14:14 2009 @@ -49,45 +49,3 @@ G_END_DECLS #endif /*YGTK_SCROLLED_WINDOW_H*/ -/* YGtkTreeView hacks support for a right-click signal. -*/ - -#ifndef YGTK_TREE_VIEW_H -#define YGTK_TREE_VIEW_H - -#include <gtk/gtktreeview.h> -G_BEGIN_DECLS - -#define YGTK_TYPE_TREE_VIEW (ygtk_tree_view_get_type ()) -#define YGTK_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - YGTK_TYPE_TREE_VIEW, YGtkScrolledWindow)) -#define YGTK_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ - YGTK_TYPE_TREE_VIEW, YGtkScrolledWindowClass)) -#define YGTK_IS_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - YGTK_TYPE_TREE_VIEW)) -#define YGTK_IS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - YGTK_TYPE_TREE_VIEW)) -#define YGTK_TREE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - YGTK_TYPE_TREE_VIEW, YGtkScrolledWindowClass)) - -typedef struct _YGtkTreeView -{ - GtkTreeView parent; -} YGtkTreeView; - -typedef struct _YGtkTreeViewClass -{ - GtkTreeViewClass parent_class; - - // signals: - void (*right_click) (YGtkTreeView *view, gboolean outreach); -} YGtkTreeViewClass; - -GtkWidget* ygtk_tree_view_new (void); -GType ygtk_tree_view_get_type (void) G_GNUC_CONST; - -void ygtk_tree_view_popup_menu (YGtkTreeView *view, GtkWidget *menu); - -G_END_DECLS -#endif /*YGTK_TREE_VIEW_H*/ - Modified: trunk/gtk/src/ygtksteps.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtksteps.c?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtksteps.c (original) +++ trunk/gtk/src/ygtksteps.c Thu Nov 26 18:14:14 2009 @@ -26,15 +26,16 @@ gtk_box_set_spacing (GTK_BOX (steps), 8); gtk_container_set_border_width (GTK_CONTAINER (steps), 4); + const gchar *check = "\u2714", *current = "\u25b6", *todo = "\u26ab"; + if (gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL) + current = "\u25c0"; PangoContext *context = gtk_widget_get_pango_context (GTK_WIDGET (steps)); steps->check_mark_layout = pango_layout_new (context); steps->current_mark_layout = pango_layout_new (context); - - const gchar *check = "\u2714", *current = "<b>\u2192</b>"; - if (gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL) - current = "<b>\u2190</b>"; - pango_layout_set_markup (steps->check_mark_layout, check, -1); - pango_layout_set_markup (steps->current_mark_layout, current, -1); + steps->todo_mark_layout = pango_layout_new (context); + pango_layout_set_text (steps->check_mark_layout, check, -1); + pango_layout_set_text (steps->current_mark_layout, current, -1); + pango_layout_set_text (steps->todo_mark_layout, todo, -1); steps->current_mark_timeout_id = steps->current_mark_frame = 0; } @@ -50,7 +51,9 @@ steps->check_mark_layout = NULL; if (steps->current_mark_layout) g_object_unref (steps->current_mark_layout); - steps->current_mark_layout = NULL; + if (steps->todo_mark_layout) + g_object_unref (steps->todo_mark_layout); + steps->todo_mark_layout = NULL; GTK_OBJECT_CLASS (ygtk_steps_parent_class)->destroy (object); } @@ -82,38 +85,44 @@ YGtkSteps *steps = YGTK_STEPS (widget); gboolean reverse = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; - GtkStyle *style = gtk_widget_get_style (widget); GList *children = gtk_container_get_children (GTK_CONTAINER (widget)), *i; + + cairo_t *cr = gdk_cairo_create (event->window); + cairo_set_source_rgb (cr, 0, 0, 0); int n = 0; for (i = children; i; i = i->next, n++) { - if (n <= steps->current_step) { - GtkWidget *label = i->data; - if (g_object_get_data (G_OBJECT (label), "is-header")) - continue; - PangoLayout *mark = (n == steps->current_step) ? - steps->current_mark_layout : steps->check_mark_layout; - int x = label->allocation.x, y = label->allocation.y; - if (reverse) { - PangoRectangle rect; - pango_layout_get_pixel_extents (mark, NULL, &rect); - x += label->allocation.width - rect.width - 4; - } + GtkWidget *label = i->data; + if (g_object_get_data (G_OBJECT (label), "is-header")) + continue; + PangoLayout *layout; + if (n < steps->current_step) + layout = steps->check_mark_layout; + else if (n == steps->current_step) + layout = steps->current_mark_layout; + else //if (n > steps->current_step) + layout = steps->todo_mark_layout; + int x = label->allocation.x, y = label->allocation.y; + if (reverse) { + PangoRectangle rect; + pango_layout_get_pixel_extents (layout, NULL, &rect); + x += label->allocation.width - rect.width - 4; + } + else + x += 4; + if (n == steps->current_step) { + int offset; + if (steps->current_mark_frame < CURRENT_MARK_FRAMES_NB/2) + offset = steps->current_mark_frame * CURRENT_MARK_ANIMATION_OFFSET; else - x += 4; - if (n == steps->current_step) { - int offset; - if (steps->current_mark_frame < CURRENT_MARK_FRAMES_NB/2) - offset = steps->current_mark_frame * CURRENT_MARK_ANIMATION_OFFSET; - else - offset = (CURRENT_MARK_FRAMES_NB - steps->current_mark_frame) * - CURRENT_MARK_ANIMATION_OFFSET; - x += offset * (reverse ? 1 : -1); - } - - gtk_paint_layout (style, widget->window, GTK_STATE_NORMAL, TRUE, - NULL, /*event->area,*/ widget, NULL, x, y, mark); + offset = (CURRENT_MARK_FRAMES_NB - steps->current_mark_frame) * + CURRENT_MARK_ANIMATION_OFFSET; + x += offset * (reverse ? 1 : -1); } + + cairo_move_to (cr, x, y); + pango_cairo_show_layout (cr, layout); } + cairo_destroy (cr); g_list_free (children); return FALSE; } @@ -126,6 +135,8 @@ gint ygtk_steps_append (YGtkSteps *steps, const gchar *text) { GtkWidget *label = gtk_label_new (text); + GdkColor black = { 0, 0, 0, 0 }; + gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &black); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); int mark_width = 10; pango_layout_get_pixel_size (steps->check_mark_layout, &mark_width, NULL); @@ -138,6 +149,8 @@ void ygtk_steps_append_heading (YGtkSteps *steps, const gchar *heading) { GtkWidget *label = gtk_label_new (heading); + GdkColor black = { 0, 0, 0, 0 }; + gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &black); g_object_set_data (G_OBJECT (label), "is-header", GINT_TO_POINTER (1)); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); Modified: trunk/gtk/src/ygtksteps.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtksteps.h?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtksteps.h (original) +++ trunk/gtk/src/ygtksteps.h Thu Nov 26 18:14:14 2009 @@ -39,7 +39,7 @@ // private: gint current_step; - PangoLayout *check_mark_layout, *current_mark_layout; + PangoLayout *check_mark_layout, *current_mark_layout, *todo_mark_layout; // for current_mark little animation guint current_mark_timeout_id, current_mark_frame; Modified: trunk/gtk/src/ygtktextview.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtktextview.c?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtktextview.c (original) +++ trunk/gtk/src/ygtktextview.c Thu Nov 26 18:14:14 2009 @@ -65,6 +65,40 @@ gtk_widget_show_all (GTK_WIDGET (menu)); } +static inline gboolean is_space (gunichar ch) +{ return g_unichar_isspace (ch) || ch == 0xfffc; } + +static gboolean ygtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event) +{ // on right-click, select word under cursor if there is no selection + if (event->button == 3) { + GtkTextView *view = GTK_TEXT_VIEW (widget); + GtkTextBuffer *buffer = gtk_text_view_get_buffer (view); + if (!gtk_text_buffer_get_has_selection (buffer)) { + gint buffer_x, buffer_y; + gtk_text_view_window_to_buffer_coords (view, + GTK_TEXT_WINDOW_WIDGET, (gint) event->x, (gint) event->y, &buffer_x, &buffer_y); + GtkTextIter iter; + gtk_text_view_get_iter_at_location (view, &iter, buffer_x, buffer_y); + + if (!is_space (gtk_text_iter_get_char (&iter))) { + GtkTextIter start, end = iter, temp = iter; + do { + start = temp; + if (!gtk_text_iter_backward_char (&temp)) + break; + } while (!is_space (gtk_text_iter_get_char (&temp))); + do { + if (!gtk_text_iter_forward_char (&end)) + break; + } while (!is_space (gtk_text_iter_get_char (&end))); + + gtk_text_buffer_select_range (buffer, &start, &end); + } + } + } + return GTK_WIDGET_CLASS (ygtk_text_view_parent_class)->button_press_event (widget, event); +} + GtkWidget *ygtk_text_view_new (gboolean editable) { return g_object_new (YGTK_TYPE_TEXT_VIEW, "editable", editable, NULL); } @@ -75,5 +109,6 @@ GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass); gtkwidget_class->realize = ygtk_text_view_realize; + gtkwidget_class->button_press_event = ygtk_text_view_button_press_event; } Modified: trunk/gtk/src/ygtktreeview.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtktreeview.c?rev=59804&... ============================================================================== --- trunk/gtk/src/ygtktreeview.c (original) +++ trunk/gtk/src/ygtktreeview.c Thu Nov 26 18:14:14 2009 @@ -74,7 +74,7 @@ static void ygtk_tree_view_size_allocate (GtkWidget *widget, GtkAllocation *alloc) { GTK_WIDGET_CLASS (ygtk_tree_view_parent_class)->size_allocate (widget, alloc); - +#if 0 // this doesn't work so well on gtk 2.18.1 GtkTreeView *view = GTK_TREE_VIEW (widget); GtkTreeSelection *selection = gtk_tree_view_get_selection (view); GList *paths; @@ -86,6 +86,7 @@ } g_list_foreach (paths, (GFunc) gtk_tree_path_free, 0); g_list_free (paths); +#endif } Modified: trunk/gtk/src/ygtkwizard.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=59804&am... ============================================================================== --- trunk/gtk/src/ygtkwizard.c (original) +++ trunk/gtk/src/ygtkwizard.c Thu Nov 26 18:14:14 2009 @@ -66,7 +66,7 @@ GTK_WIDGET (dialog), GTK_STOCK_HELP, GTK_ICON_SIZE_MENU, NULL); gtk_window_set_icon (GTK_WINDOW (dialog), icon); g_object_unref (G_OBJECT (icon)); - gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 350); + gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 450); // help text dialog->help_box = gtk_scrolled_window_new (NULL, NULL); @@ -491,16 +491,12 @@ static GtkWidget *create_help_button() { - GtkWidget *button, *image = 0; + GtkWidget *button, *image; button = gtk_toggle_button_new(); gtk_button_set_label (GTK_BUTTON (button), _("Help")); gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); - GdkPixbuf *pixbuf = gtk_widget_render_icon (button, GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON, NULL); - if (pixbuf) { - image = gtk_image_new_from_pixbuf (pixbuf); - g_object_unref (G_OBJECT (pixbuf)); - gtk_button_set_image (GTK_BUTTON (button), image); - } + image = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image (GTK_BUTTON (button), image); return button; } @@ -612,6 +608,7 @@ gtk_widget_set_size_request (wizard->m_buttons, 0, -1); g_signal_connect_after (G_OBJECT (wizard->m_buttons), "size-allocate", G_CALLBACK (buttons_size_allocate_cb), buttons_group); + wizard->m_default_button = NULL; //** The menu and the navigation widgets will be created when requested. // space for them @@ -644,8 +641,10 @@ { GTK_WIDGET_CLASS (ygtk_wizard_parent_class)->realize (widget); YGtkWizard *wizard = YGTK_WIZARD (widget); - gtk_widget_grab_default (wizard->next_button); - gtk_widget_grab_focus (wizard->next_button); + if (wizard->m_default_button) { + gtk_widget_grab_default (wizard->m_default_button); + gtk_widget_grab_focus (wizard->m_default_button); + } } static void ygtk_wizard_map (GtkWidget *widget) @@ -671,10 +670,8 @@ *hash = NULL; } -static void ygtk_wizard_destroy (GtkObject *object) +static void ygtk_wizard_finalize (GObject *object) { - 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); @@ -684,6 +681,7 @@ ygtk_help_text_destroy (wizard->m_help); wizard->m_help = NULL; } + G_OBJECT_CLASS (ygtk_wizard_parent_class)->finalize (object); } GtkWidget *ygtk_wizard_new (void) @@ -702,10 +700,13 @@ g_signal_emit (wizard, action_triggered_signal, 0, id, G_TYPE_STRING); } -void ygtk_wizard_set_child (YGtkWizard *wizard, GtkWidget *widget) +void ygtk_wizard_set_child (YGtkWizard *wizard, GtkWidget *child) { - wizard->m_child = widget; - gtk_paned_pack2 (GTK_PANED (wizard->m_pane), widget, TRUE, TRUE); + if (wizard->m_child) + gtk_container_remove (GTK_CONTAINER (wizard->m_pane), wizard->m_child); + wizard->m_child = child; + if (child) + gtk_paned_pack2 (GTK_PANED (wizard->m_pane), child, TRUE, TRUE); } static gboolean ygtk_wizard_set_information_expose_cb (GtkWidget *widget, GdkEventExpose *event, @@ -899,6 +900,9 @@ g_object_set_data (G_OBJECT (button), "ptr-id", id); } +void ygtk_wizard_set_default_button (YGtkWizard *wizard, GtkWidget *button) +{ wizard->m_default_button = button; } + void ygtk_wizard_enable_button (YGtkWizard *wizard, GtkWidget *button, gboolean enable) { gtk_widget_set_sensitive (button, enable); @@ -1075,8 +1079,8 @@ widget_class->realize = ygtk_wizard_realize; widget_class->map = ygtk_wizard_map; - GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass); - gtkobject_class->destroy = ygtk_wizard_destroy; + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = ygtk_wizard_finalize; action_triggered_signal = g_signal_new ("action-triggered", G_TYPE_FROM_CLASS (G_OBJECT_CLASS (klass)), G_SIGNAL_RUN_LAST, Modified: trunk/gtk/src/ygtkwizard.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.h?rev=59804&am... ============================================================================== --- trunk/gtk/src/ygtkwizard.h (original) +++ trunk/gtk/src/ygtkwizard.h Thu Nov 26 18:14:14 2009 @@ -105,7 +105,7 @@ /* Widgets we need to access. */ GtkWidget *tree_view, *steps, *menu, *back_button, *abort_button, *next_button, *help_button, - *release_notes_button; + *release_notes_button, *m_default_button; /* The help text. */ YGtkHelpText *m_help; @@ -150,6 +150,7 @@ const char *id); void ygtk_wizard_set_button_ptr_id (YGtkWizard *wizard, GtkWidget *button, gpointer id); +void ygtk_wizard_set_default_button (YGtkWizard *wizard, GtkWidget *button); // before realize void ygtk_wizard_set_extra_button (YGtkWizard *wizard, GtkWidget *widget); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org