[yast-commit] r62429 - in /trunk/gtk/src: ./ pkg/
Author: rpmcruz Date: Mon Aug 23 01:38:22 2010 New Revision: 62429 URL: http://svn.opensuse.org/viewcvs/yast?rev=62429&view=rev Log: * src/YGUI.cc & src/YGDialog.cc: bug fix 633498: set default window size as a proportion of both a constant number of characters and pixels. * src/YGUtils.cc, src/ygtkwizard.c, src/pkg/YGPackageSelector.cc: paned position now set in percent terms. Related to previous item. * src/YGPackageSelector.cc: bug fix 632377: when show-devel or show-debug disabled, then number count in the filters box was not always correct. * src/YGUI.cc: bug fix 633173: ensure file picking dialog doesn't crash when esoteric filename selected. Modified: trunk/gtk/src/YGDialog.cc trunk/gtk/src/YGDialog.h trunk/gtk/src/YGLayout.cc trunk/gtk/src/YGPushButton.cc trunk/gtk/src/YGUI.cc trunk/gtk/src/YGUI.h trunk/gtk/src/YGUtils.cc trunk/gtk/src/YGUtils.h trunk/gtk/src/pkg/YGPackageSelector.cc trunk/gtk/src/pkg/ygtkpkghistorydialog.cc trunk/gtk/src/pkg/ygtkpkgproductdialog.cc trunk/gtk/src/ygtkwizard.c Modified: trunk/gtk/src/YGDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.cc?rev=62429&r1=... ============================================================================== --- trunk/gtk/src/YGDialog.cc (original) +++ trunk/gtk/src/YGDialog.cc Mon Aug 23 01:38:22 2010 @@ -23,6 +23,13 @@ be a YGDialog and is swap-able. */ +//#define DEFAULT_WIDTH 750 +//#define DEFAULT_HEIGHT 650 +#define DEFAULT_CHAR_WIDTH 65 +#define DEFAULT_CHAR_HEIGHT 28 +#define DEFAULT_PIXEL_WIDTH 350 +#define DEFAULT_PIXEL_HEIGHT 200 + class YGWindow; static YGWindow *main_window = 0; @@ -89,24 +96,18 @@ gtk_window_set_decorated (window, FALSE); } - if (_main_window) { - static int width = 0, height; - if (!width) { - int char_width = YGUtils::getCharsWidth (m_widget, 1); - - fprintf (stderr, "char width: %d\n", char_width); - if (char_width < 7) - { width = 750; height = 650; } - else - { width = 800; height = 750; } - if (YGUI::ui()->isPkgSelector()) - height = width; - } + if (_main_window) { + // window default width is calculated as a proportion of a default + // char and pixel width to compensate for the fact that each widget's + // required size comes from a proportion of both parameters + int width = YGUtils::getCharsWidth (m_widget, DEFAULT_CHAR_WIDTH); + width += DEFAULT_PIXEL_WIDTH; + int height = YGUtils::getCharsHeight (m_widget, DEFAULT_CHAR_HEIGHT); + height += DEFAULT_PIXEL_HEIGHT; + + if (YGUI::ui()->isSwsingle()) + height += YGUtils::getCharsHeight (m_widget, 10); - if (YGUI::ui()->defaultWidth()) - width = YGUI::ui()->defaultWidth(); - if (YGUI::ui()->defaultHeight()) - height = YGUI::ui()->defaultHeight(); width = MIN (width, YUI::app()->displayWidth()); height = MIN (height, YUI::app()->displayHeight()); @@ -114,7 +115,7 @@ if (YGUI::ui()->setFullscreen()) gtk_window_fullscreen (window); else if (YUI::app()->displayWidth() <= 800 || YUI::app()->displayHeight() <= 600) - // maximize for small displays + // maximize window for small displays gtk_window_maximize (window); } @@ -364,7 +365,7 @@ m_window->setChild (this); } -void YGDialog::blink() +void YGDialog::present() { GtkWindow *window = GTK_WINDOW (m_window->getWidget()); if (!gtk_window_is_active (window)) @@ -519,7 +520,7 @@ g_free (str); m_stickyTitle = sticky; } - blink(); + present(); } extern "C" { Modified: trunk/gtk/src/YGDialog.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.h?rev=62429&r1=6... ============================================================================== --- trunk/gtk/src/YGDialog.h (original) +++ trunk/gtk/src/YGDialog.h Mon Aug 23 01:38:22 2010 @@ -38,7 +38,7 @@ virtual void openInternal(); virtual void activate(); - void blink(); + void present(); virtual YEvent *waitForEventInternal (int timeout_millisec); virtual YEvent *pollEventInternal(); Modified: trunk/gtk/src/YGLayout.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGLayout.cc?rev=62429&r1=... ============================================================================== --- trunk/gtk/src/YGLayout.cc (original) +++ trunk/gtk/src/YGLayout.cc Mon Aug 23 01:38:22 2010 @@ -77,7 +77,7 @@ virtual void doAddChild (YWidget *ychild, GtkWidget *container) { YGWidget::doAddChild (ychild, container); -// if (primary() == YD_HORIZ) + if (primary() == YD_HORIZ) group.addWidget (ychild); } Modified: trunk/gtk/src/YGPushButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPushButton.cc?rev=62429... ============================================================================== --- trunk/gtk/src/YGPushButton.cc (original) +++ trunk/gtk/src/YGPushButton.cc Mon Aug 23 01:38:22 2010 @@ -96,7 +96,7 @@ GtkButton *button = GTK_BUTTON (getWidget()); if (icon.empty()) { m_customIcon = false; - // can't remove image; just hide it + // no need to worry about freeing the image, let it live with button GtkWidget *image = gtk_button_get_image (button); if (image) gtk_widget_hide (image); Modified: trunk/gtk/src/YGUI.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.cc?rev=62429&r1=6242... ============================================================================== --- trunk/gtk/src/YGUI.cc (original) +++ trunk/gtk/src/YGUI.cc Mon Aug 23 01:38:22 2010 @@ -25,7 +25,8 @@ static void errorMsg (const char *msg) { GtkWidget* dialog = gtk_message_dialog_new (NULL, - GtkDialogFlags (0), GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", msg); + GtkDialogFlags (0), GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), msg); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } @@ -45,8 +46,7 @@ : YUI (with_threads), m_done_init (false), busy_timeout (0) { m_have_wm = true; - m_no_border = m_fullscreen = false; - m_default_width = (m_default_height = 0); + m_no_border = m_fullscreen = m_swsingle = false; YGUI::setTextdomain( TEXTDOMAIN ); @@ -454,11 +454,21 @@ std::string askForFileOrDirectory (GtkFileChooserAction action, const std::string &path, const std::string &filter, const std::string &title) { + GtkWindow *parent = YGDialog::currentWindow(); + const char *button; + switch (action) { + case GTK_FILE_CHOOSER_ACTION_SAVE: + button = GTK_STOCK_SAVE; break; + case GTK_FILE_CHOOSER_ACTION_OPEN: + button = GTK_STOCK_OPEN; break; + case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: + case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: + button = _("Choose"); break; + } GtkWidget *dialog; dialog = gtk_file_chooser_dialog_new (title.c_str(), - YGDialog::currentWindow(), action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - action == GTK_FILE_CHOOSER_ACTION_SAVE ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, - GTK_RESPONSE_ACCEPT, NULL); + parent, action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + button, GTK_RESPONSE_ACCEPT, NULL); GtkFileChooser *fileChooser = GTK_FILE_CHOOSER (dialog); gtk_file_chooser_set_local_only (fileChooser, TRUE); gtk_file_chooser_set_do_overwrite_confirmation (fileChooser, TRUE); @@ -508,8 +518,10 @@ std::string ret; if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { gchar *filename = gtk_file_chooser_get_filename (fileChooser); - ret = filename; - g_free (filename); + if (filename) { + ret = filename; + g_free (filename); + } } gtk_widget_destroy (dialog); return ret; Modified: trunk/gtk/src/YGUI.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.h?rev=62429&r1=62428... ============================================================================== --- trunk/gtk/src/YGUI.h (original) +++ trunk/gtk/src/YGUI.h Mon Aug 23 01:38:22 2010 @@ -63,17 +63,15 @@ static gboolean busy_timeout_cb (gpointer data); // window-related arguments - bool m_have_wm, m_no_border, m_fullscreen, m_swsingle; - int m_default_width, m_default_height; + bool m_have_wm, m_no_border, m_fullscreen; + bool m_swsingle; 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; } - bool isPkgSelector() const { return m_swsingle; } + bool isSwsingle() const { return m_swsingle; } }; // debug helpers. Modified: trunk/gtk/src/YGUtils.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=62429&r1=6... ============================================================================== --- trunk/gtk/src/YGUtils.cc (original) +++ trunk/gtk/src/YGUtils.cc Mon Aug 23 01:38:22 2010 @@ -493,6 +493,31 @@ void ygutils_setWidgetFont (GtkWidget *widget, PangoStyle style, PangoWeight weight, double scale) { YGUtils::setWidgetFont (widget, style, weight, scale); } +static void paned_allocate_cb (GtkWidget *paned, GtkAllocation *alloc, gpointer _rel) +{ + if (!g_object_get_data (G_OBJECT (paned), "init")) { // only once + gdouble rel = GPOINTER_TO_INT (_rel) / 100.; + gint parent_size; + if (gtk_orientable_get_orientation (GTK_ORIENTABLE (paned)) == GTK_ORIENTATION_HORIZONTAL) + parent_size = paned->allocation.width; + else + parent_size = paned->allocation.height; + int pos = parent_size * rel; + gtk_paned_set_position (GTK_PANED (paned), pos); + g_object_set_data (G_OBJECT (paned), "init", GINT_TO_POINTER (1)); + } +} + +void YGUtils::setPaneRelPosition (GtkWidget *paned, gdouble rel) +{ + gint _rel = rel * 100; + g_signal_connect_after (G_OBJECT (paned), "size-allocate", + G_CALLBACK (paned_allocate_cb), GINT_TO_POINTER (_rel)); +} + +void ygutils_setPaneRelPosition (GtkWidget *paned, gdouble rel) +{ YGUtils::setPaneRelPosition (paned, rel); } + GdkPixbuf *YGUtils::loadPixbuf (const string &filename) { GdkPixbuf *pixbuf = NULL; Modified: trunk/gtk/src/YGUtils.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.h?rev=62429&r1=62... ============================================================================== --- trunk/gtk/src/YGUtils.h (original) +++ trunk/gtk/src/YGUtils.h Mon Aug 23 01:38:22 2010 @@ -44,6 +44,9 @@ /* Sets some widget font proprities. */ void setWidgetFont (GtkWidget *widget, PangoStyle style, PangoWeight weight, double scale); + /* Instead of setting GtkPaned::position in pixels, do so in percents. */ + void setPaneRelPosition (GtkWidget *paned, gdouble rel); + /* Saves some code and standardizes the error. Returns NULL if failed. Don't forget to g_object_unref it! */ GdkPixbuf *loadPixbuf (const std::string &fileneme); @@ -66,6 +69,7 @@ extern "C" { void ygutils_setWidgetFont (GtkWidget *widget, PangoStyle style, PangoWeight weight, double scale); + void ygutils_setPaneRelPosition (GtkWidget *paned, gdouble rel); void ygutils_setFilter (GtkEntry *entry, const char *validChars); Modified: trunk/gtk/src/pkg/YGPackageSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/YGPackageSelector.cc?... ============================================================================== --- trunk/gtk/src/pkg/YGPackageSelector.cc (original) +++ trunk/gtk/src/pkg/YGPackageSelector.cc Mon Aug 23 01:38:22 2010 @@ -133,8 +133,7 @@ GtkWidget *vpaned = gtk_vpaned_new(); gtk_paned_pack1 (GTK_PANED (vpaned), list_vbox, TRUE, FALSE); gtk_paned_pack2 (GTK_PANED (vpaned), text, FALSE, TRUE); - g_signal_connect_after (G_OBJECT (vpaned), "size-allocate", - G_CALLBACK (vpaned_allocate_cb), this); + YGUtils::setPaneRelPosition (vpaned, .65); GtkWidget *_vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (_vbox), hbox, FALSE, TRUE, 0); @@ -177,14 +176,10 @@ status->select (3); m_queryWidgets.push_back (status); - GtkWidget *vpaned = gtk_vpaned_new(); gtk_paned_pack1 (GTK_PANED (vpaned), m_combo->getWidget(), TRUE, FALSE); gtk_paned_pack2 (GTK_PANED (vpaned), status->getWidget(), FALSE, FALSE); - if (YGUtils::getCharsWidth (vpaned, 1) < 7) - gtk_paned_set_position (GTK_PANED (vpaned), 485); - else - gtk_paned_set_position (GTK_PANED (vpaned), 500); + YGUtils::setPaneRelPosition (vpaned, .80); return vpaned; } @@ -197,10 +192,7 @@ GtkWidget *hpaned = gtk_hpaned_new(); gtk_paned_pack1 (GTK_PANED (hpaned), createSidebar(), FALSE, TRUE); gtk_paned_pack2 (GTK_PANED (hpaned), createMainArea(), TRUE, FALSE); - if (YGUtils::getCharsWidth (hpaned, 1) < 7) - gtk_paned_set_position (GTK_PANED (hpaned), 200); - else - gtk_paned_set_position (GTK_PANED (hpaned), 230); + YGUtils::setPaneRelPosition (hpaned, .28); m_widget = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (m_widget), hpaned, TRUE, TRUE, 0); @@ -458,6 +450,7 @@ continue; (*it)->writeQuery (query); } + query.addCriteria (new SuffixFilter (this)); Ypp::List list (query); widget->updateList (list); @@ -581,16 +574,6 @@ // YGPackageSelector complementary methods - static void vpaned_allocate_cb (GtkWidget *vpaned, GtkAllocation *alloc, Impl *pThis) - { - if (!g_object_get_data (G_OBJECT (vpaned), "init")) { // only once - int height = (YGUtils::getCharsWidth (vpaned, 1) < 7) ? 180 : 220; - int pos = MAX (alloc->height / 2, alloc->height - height); - gtk_paned_set_position (GTK_PANED (vpaned), pos); - g_object_set_data (G_OBJECT (vpaned), "init", GINT_TO_POINTER (1)); - } - } - static bool confirmCancel() { GtkWidget *dialog; Modified: trunk/gtk/src/pkg/ygtkpkghistorydialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/ygtkpkghistorydialog.... ============================================================================== --- trunk/gtk/src/pkg/ygtkpkghistorydialog.cc (original) +++ trunk/gtk/src/pkg/ygtkpkghistorydialog.cc Mon Aug 23 01:38:22 2010 @@ -12,6 +12,7 @@ #include "config.h" #include "ygtkpkghistorydialog.h" #include "YGDialog.h" +#include "YGUtils.h" #include "YGPackageSelector.h" #include "ygtkpkglistview.h" #include <gtk/gtk.h> @@ -630,7 +631,7 @@ GtkWidget *hpaned = gtk_hpaned_new(); gtk_paned_pack1 (GTK_PANED (hpaned), date_scroll, FALSE, FALSE); gtk_paned_pack2 (GTK_PANED (hpaned), log_scroll, TRUE, FALSE); - gtk_paned_set_position (GTK_PANED (hpaned), 180); + YGUtils::setPaneRelPosition (hpaned, .30); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hpaned); gtk_widget_show_all (dialog); Modified: trunk/gtk/src/pkg/ygtkpkgproductdialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/ygtkpkgproductdialog.... ============================================================================== --- trunk/gtk/src/pkg/ygtkpkgproductdialog.cc (original) +++ trunk/gtk/src/pkg/ygtkpkgproductdialog.cc Mon Aug 23 01:38:22 2010 @@ -11,6 +11,7 @@ #include "YGi18n.h" #include "config.h" #include "YGDialog.h" +#include "YGUtils.h" #include "ygtkpkgproductdialog.h" #include <gtk/gtk.h> #include "ygtkrichtext.h" @@ -165,7 +166,7 @@ GtkWidget *vpaned = gtk_vpaned_new(); gtk_paned_pack1 (GTK_PANED (vpaned), scroll, TRUE, FALSE); gtk_paned_pack2 (GTK_PANED (vpaned), description_scroll, FALSE, TRUE); - gtk_paned_set_position (GTK_PANED (vpaned), 250); + YGUtils::setPaneRelPosition (vpaned, .70); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vpaned); gtk_widget_show_all (dialog); Modified: trunk/gtk/src/ygtkwizard.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=62429&r1... ============================================================================== --- trunk/gtk/src/ygtkwizard.c (original) +++ trunk/gtk/src/ygtkwizard.c Mon Aug 23 01:38:22 2010 @@ -26,6 +26,7 @@ // YGUtils bridge extern void ygutils_setWidgetFont (GtkWidget *widget, PangoStyle style, PangoWeight weight, double scale); +extern void ygutils_setPaneRelPosition (GtkWidget *paned, gdouble rel); extern const char *ygutils_mapStockIcon (const char *label); extern const char *ygutils_setStockIcon (GtkWidget *button, const char *label, const char *fallbackIcon); @@ -820,7 +821,7 @@ gtk_widget_show_all (scroll); ygtk_wizard_set_control_widget (wizard, scroll); - gtk_paned_set_position (GTK_PANED (wizard->m_pane), 180); + ygutils_setPaneRelPosition (wizard->m_pane, .30); } #define ENABLE_WIDGET(enable, widget) \ -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rpmcruz@svn2.opensuse.org