Author: rpmcruz
Date: Mon Aug 23 01:35:34 2010
New Revision: 62428
URL: http://svn.opensuse.org/viewcvs/yast?rev=62428&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:
branches/SuSE-Linux-11_3-Branch/gtk/ChangeLog
branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.cc
branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.h
branches/SuSE-Linux-11_3-Branch/gtk/src/YGPackageSelectorPluginStub.cc
branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.cc
branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.h
branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.cc
branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.h
branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/YGPackageSelector.cc
branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkghistorydialog.cc
branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkgproductdialog.cc
branches/SuSE-Linux-11_3-Branch/gtk/src/ygtkwizard.c
Modified: branches/SuSE-Linux-11_3-Branch/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/ChangeLog?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/ChangeLog (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/ChangeLog Mon Aug 23 01:35:34 2010
@@ -1,3 +1,20 @@
+2010-08-23 Ricardo Cruz
+
+ * 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.
+
2010-07-26 Ricardo Cruz
* src/pkg/ygtkpkgmenubar.cc: bug fix 624310: file >
Modified: branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.cc?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.cc (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.cc Mon Aug 23 01:35:34 2010
@@ -23,8 +23,12 @@
be a YGDialog and is swap-able.
*/
-#define DEFAULT_WIDTH 750
-#define DEFAULT_HEIGHT 650
+//#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;
@@ -92,12 +96,18 @@
gtk_window_set_decorated (window, FALSE);
}
- if (_main_window) {
- int width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT;
- if (YGUI::ui()->defaultWidth())
- width = YGUI::ui()->defaultWidth();
- if (YGUI::ui()->defaultHeight())
- height = YGUI::ui()->defaultHeight();
+ 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);
+
width = MIN (width, YUI::app()->displayWidth());
height = MIN (height, YUI::app()->displayHeight());
@@ -105,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);
}
@@ -429,16 +439,6 @@
}
}
-void YGDialog::setMinSize (int width, int height)
-{
- GtkWidget *window = m_window->getWidget();
- width = MIN (width, YUI::app()->displayWidth());
- height = MIN (height, YUI::app()->displayHeight());
- width = MAX (width, window->allocation.width),
- height = MAX (height, window->allocation.height);
- gtk_window_resize (GTK_WINDOW (window), width, height);
-}
-
void YGDialog::highlight (YWidget *ywidget)
{
struct inner {
Modified: branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.h?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.h (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/YGDialog.h Mon Aug 23 01:35:34 2010
@@ -35,7 +35,6 @@
static GtkWindow *currentWindow();
virtual void doSetSize (int width, int height);
- void setMinSize (int width, int height); // used internally by YGPackageSelector.cc
virtual void openInternal();
virtual void activate();
Modified: branches/SuSE-Linux-11_3-Branch/gtk/src/YGPackageSelectorPluginStub.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/YGPackageSelectorPluginStub.cc?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/YGPackageSelectorPluginStub.cc (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/YGPackageSelectorPluginStub.cc Mon Aug 23 01:35:34 2010
@@ -11,12 +11,6 @@
#include
#include
-bool YGUI::pkgSelectorParse (const char *arg)
-{ return false; }
-
-void YGUI::pkgSelectorSize (int *width, int *height)
-{ *width = 750; *height = 750; }
-
class YGPackageSelectorPluginStub : public YPackageSelectorPlugin
{
YGPackageSelectorPluginIf *impl;
Modified: branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.cc?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.cc (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.cc Mon Aug 23 01:35:34 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 );
@@ -118,7 +118,7 @@
const char *argp = argv[i];
if (argp[0] != '-') {
if (!strcmp (argp, "sw_single") || !strcmp (argp, "online_update"))
- YGUI::pkgSelectorSize (&m_default_width, &m_default_height);
+ m_swsingle = true;
continue;
}
argp++;
@@ -143,7 +143,6 @@
));
exit (0);
}
- else if (pkgSelectorParse (argp)) ;
}
gtk_init (&argc, &argv);
@@ -455,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);
@@ -509,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: branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.h?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.h (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/YGUI.h Mon Aug 23 01:35:34 2010
@@ -64,19 +64,14 @@
// window-related arguments
bool m_have_wm, m_no_border, m_fullscreen;
- int m_default_width, m_default_height;
-
- bool pkgSelectorParse (const char *arg);
+ bool m_swsingle;
public:
- void pkgSelectorSize (int *width, int *height);
-
// 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 isSwsingle() const { return m_swsingle; }
};
// debug helpers.
Modified: branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.cc?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.cc (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.cc Mon Aug 23 01:35:34 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: branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.h?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.h (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/YGUtils.h Mon Aug 23 01:35:34 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: branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/YGPackageSelector.cc?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/YGPackageSelector.cc (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/YGPackageSelector.cc Mon Aug 23 01:35:34 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);
@@ -180,7 +179,7 @@
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);
- gtk_paned_set_position (GTK_PANED (vpaned), 485);
+ YGUtils::setPaneRelPosition (vpaned, .80);
return vpaned;
}
@@ -193,7 +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);
- gtk_paned_set_position (GTK_PANED (hpaned), 200);
+ YGUtils::setPaneRelPosition (hpaned, .28);
m_widget = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (m_widget), hpaned, TRUE, TRUE, 0);
@@ -451,6 +450,7 @@
continue;
(*it)->writeQuery (query);
}
+ query.addCriteria (new SuffixFilter (this));
Ypp::List list (query);
widget->updateList (list);
@@ -574,15 +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 pos = MAX (alloc->height / 2, alloc->height - 180);
- 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;
@@ -668,9 +659,6 @@
setBorder (0);
YGDialog *dialog = YGDialog::currentDialog();
dialog->setCloseCallback (confirm_cb, this);
- int width, height;
- YGUI::ui()->pkgSelectorSize (&width, &height);
- dialog->setMinSize (width, height);
const char *icon, *title, **help;
if (onlineUpdateMode()) {
Modified: branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkghistorydialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkghistorydialog.cc?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkghistorydialog.cc (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkghistorydialog.cc Mon Aug 23 01:35:34 2010
@@ -12,6 +12,7 @@
#include "config.h"
#include "ygtkpkghistorydialog.h"
#include "YGDialog.h"
+#include "YGUtils.h"
#include "YGPackageSelector.h"
#include "ygtkpkglistview.h"
#include
@@ -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: branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkgproductdialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkgproductdialog.cc?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkgproductdialog.cc (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/pkg/ygtkpkgproductdialog.cc Mon Aug 23 01:35:34 2010
@@ -11,6 +11,7 @@
#include "YGi18n.h"
#include "config.h"
#include "YGDialog.h"
+#include "YGUtils.h"
#include "ygtkpkgproductdialog.h"
#include
#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: branches/SuSE-Linux-11_3-Branch/gtk/src/ygtkwizard.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_3-Branch/gtk/src/ygtkwizard.c?rev=62428&r1=62427&r2=62428&view=diff
==============================================================================
--- branches/SuSE-Linux-11_3-Branch/gtk/src/ygtkwizard.c (original)
+++ branches/SuSE-Linux-11_3-Branch/gtk/src/ygtkwizard.c Mon Aug 23 01:35:34 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