Mailinglist Archive: yast-commit (723 mails)

< Previous Next >
[yast-commit] r47481 - in /trunk/gtk: ChangeLog src/Makefile.am src/YGDialog.cc src/YGPackageSelector.cc src/YGUI.cc src/YGUI.h src/ygtkratiobox.c src/ygtkwizard.c
  • From: michael_meeks@xxxxxxxxxxxxxxxx
  • Date: Tue, 13 May 2008 11:22:06 -0000
  • Message-id: <20080513112206.495C931400@xxxxxxxxxxxxxxxx>
Author: michael_meeks
Date: Tue May 13 13:22:05 2008
New Revision: 47481

URL: http://svn.opensuse.org/viewcvs/yast?rev=47481&view=rev
Log:
2008-05-13 Michael Meeks <michael.meeks@xxxxxxxxxx>

* src/ygtkwizard.c (ygtk_wizard_enable_tree): don't let
the tree-paned shrink below it's minimum size request:
cf. firewall->'broadcast' oddness otherwise.

2008-05-13 Michael Meeks <michael.meeks@xxxxxxxxxx>

Tested at 800x600 & much larger too.

* src/YGDialog.cc (YGtkWindow): impl. new toplevel window class
to crop size allocations to the size of the screen: ie. force no
oversize windows with a hammer: bug 373159

* src/ygtkratiobox.c: try to gracefully handle cases where
we are in a corner: not enough space to hand out to people
asking for it: shrink everyone just enough.

* src/Makefile.am (libpy2gtk_la_LIBADD): link with -lm.

* src/YGPackageSelector.cc (YGPackageSelector): don't try to
resize the beastie larger than the screensize: (useful) for
640x480 screens.

* src/YGUI.cc (dumpGtkTree): add more debugging code, and
re-factor existing debug code a little.


Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/Makefile.am
trunk/gtk/src/YGDialog.cc
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGUI.cc
trunk/gtk/src/YGUI.h
trunk/gtk/src/ygtkratiobox.c
trunk/gtk/src/ygtkwizard.c

Modified: trunk/gtk/ChangeLog
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Tue May 13 13:22:05 2008
@@ -1,3 +1,30 @@
+2008-05-13 Michael Meeks <michael.meeks@xxxxxxxxxx>
+
+ * src/ygtkwizard.c (ygtk_wizard_enable_tree): don't let
+ the tree-paned shrink below it's minimum size request:
+ cf. firewall->'broadcast' oddness otherwise.
+
+2008-05-13 Michael Meeks <michael.meeks@xxxxxxxxxx>
+
+ Tested at 800x600 & much larger too.
+
+ * src/YGDialog.cc (YGtkWindow): impl. new toplevel window class
+ to crop size allocations to the size of the screen: ie. force no
+ oversize windows with a hammer: bug 373159
+
+ * src/ygtkratiobox.c: try to gracefully handle cases where
+ we are in a corner: not enough space to hand out to people
+ asking for it: shrink everyone just enough.
+
+ * src/Makefile.am (libpy2gtk_la_LIBADD): link with -lm.
+
+ * src/YGPackageSelector.cc (YGPackageSelector): don't try to
+ resize the beastie larger than the screensize: (useful) for
+ 640x480 screens.
+
+ * src/YGUI.cc (dumpGtkTree): add more debugging code, and
+ re-factor existing debug code a little.
+
2007-05-12 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>

* src/YGUtils.cc: feature request 388068: stock icon for

Modified: trunk/gtk/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/Makefile.am?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/src/Makefile.am (original)
+++ trunk/gtk/src/Makefile.am Tue May 13 13:22:05 2008
@@ -13,7 +13,7 @@
plugin_LTLIBRARIES = libpy2gtk.la

libpy2gtk_la_LDFLAGS = -version-info 2:0 -Wl,--no-undefined
-libpy2gtk_la_LIBADD = -L$(plugindir) -L$(libdir) -lycp -ly2 -lyui \
+libpy2gtk_la_LIBADD = -L$(plugindir) -L$(libdir) -lycp -ly2 -lyui -lm \
$(GTK_LIBS) $(ZYPP_LIBS) $(GTKHTML_LIBS) -ly2util
libpy2gtk_la_SOURCES = \
Y2CCGtk.cc \

Modified: trunk/gtk/src/YGDialog.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.cc?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/src/YGDialog.cc (original)
+++ trunk/gtk/src/YGDialog.cc Tue May 13 13:22:05 2008
@@ -1,13 +1,96 @@
/********************************************************************
* YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
********************************************************************/
-
#include <config.h>
#include "YGUI.h"
#include "YGDialog.h"
#include <gdk/gdkkeysyms.h>
#include <math.h> // easter

+/*
+ * GtkWindow sub-class to ensure we can't get a size-allocation
+ * that is larger than the screen.
+ */
+typedef struct {
+ GtkWindow parent;
+ gboolean fullscreen;
+} YGtkWindow;
+
+typedef struct {
+ GtkWindowClass parent_class;
+} YGtkWindowClass;
+
+G_DEFINE_TYPE (YGtkWindow, ygtk_window, GTK_TYPE_WINDOW)
+
+static void ygtk_window_set_fullscreen (YGtkWindow *window,
+ gboolean fullscreen)
+{
+ window->fullscreen = fullscreen;
+}
+
+static void ygtk_window_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ YGtkWindow *ywindow = (YGtkWindow *) widget;
+
+ GTK_WIDGET_CLASS (ygtk_window_parent_class)->size_request (widget,
requisition);
+
+// fprintf (stderr, "ygtk_window_size_request: %d %d\n",
+// requisition->width, requisition->height);
+
+ GdkScreen *screen = gtk_widget_get_screen (widget);
+ int max_screen_width = gdk_screen_get_width (screen);
+ int max_screen_height = gdk_screen_get_height (screen);
+
+ /*
+ * FIXME: do we want to call gdk_window_get_frame_extents
+ * on the root window ? - will that tell us about panels etc. ?
+ *
+ * FIXME: do we want to defer 'map' until we can get our
+ * frame size from the realized window to do better here ?
+ */
+
+ // in the meantime shrink ourselves a little, to account for
+ // window decoration / panels etc.
+ if (!ywindow->fullscreen)
+ {
+ max_screen_height = 0.90 * max_screen_height;
+ max_screen_width = 0.90 * max_screen_width;
+ }
+
+ if (requisition->width > max_screen_width)
+ {
+// fprintf (stderr, "cropping width from %d to %d\n",
+// requisition->width, max_screen_width);
+ requisition->width = max_screen_width;
+ }
+ if (requisition->height > max_screen_height)
+ {
+// fprintf (stderr, "cropping height from %d to %d\n",
+// requisition->height, max_screen_height);
+ requisition->height = max_screen_height;
+ }
+}
+
+static void ygtk_window_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+/* fprintf (stderr, "YGDialog size alloc %d %d\n",
+ allocation->width, allocation->height); */
+ GTK_WIDGET_CLASS (ygtk_window_parent_class)->size_allocate (widget,
allocation);
+}
+
+static void ygtk_window_init (YGtkWindow *) {}
+static void ygtk_window_class_init (YGtkWindowClass *klass)
+{
+ GtkWidgetClass *wklass = (GtkWidgetClass *) klass;
+
+ ygtk_window_parent_class = g_type_class_peek_parent (klass);
+
+ wklass->size_request = ygtk_window_size_request;
+ wklass->size_allocate = ygtk_window_size_allocate;
+}
+
/* In the main dialog case, it doesn't necessarly have a window of its own. If
there is already a main window, it should replace its content -- and when
closed,
the previous dialog restored.
@@ -17,6 +100,7 @@
be a YGDialog and is swap-able.
*/

+
class YGWindow;
static YGWindow *main_window = 0;

@@ -29,12 +113,12 @@
YWidget *m_child;

public:
- YGWindowCloseFn m_canClose;
- void *m_canCloseData;
+ YGWindowCloseFn m_canClose;
+ void *m_canCloseData;

YGWindow (bool _main_window)
{
- m_widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ m_widget = GTK_WIDGET (g_object_new (ygtk_window_get_type(),
NULL));
g_object_ref (G_OBJECT (m_widget));
gtk_object_sink (GTK_OBJECT (m_widget));

@@ -66,8 +150,10 @@
h = YGUI::ui()->_getDefaultHeight();
gtk_window_set_default_size (window, w, h);

- if (YGUI::ui()->setFullscreen())
- gtk_window_fullscreen (window);
+ if (YGUI::ui()->setFullscreen()) {
+ gtk_window_fullscreen (window);
+ ygtk_window_set_fullscreen ((YGtkWindow *)window,
TRUE);
+ }
}

gtk_window_set_role (window, "yast-gtk");
@@ -211,6 +297,7 @@
return TRUE;
case GDK_T:
dumpYastTree (pThis->getChild());
+ dumpGtkTree (pThis->m_widget);
return TRUE;
case GDK_H:
dumpYastHtml (pThis->getChild());

Modified: trunk/gtk/src/YGPackageSelector.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Tue May 13 13:22:05 2008
@@ -2350,10 +2350,12 @@
setBorder (0);
YGTK_WIZARD (getWidget())->child_border_width = 0;

- GtkWindow *window = YGDialog::currentWindow();
+ GtkWindow *window = YGDialog::currentWindow();
+ int enlarge_width = MIN (0.95 * YUI::app()->displayWidth(),
650);
+ int enlarge_height = MIN (0.95 * YUI::app()->displayHeight(),
600);
gtk_window_resize (window,
- MAX (650, GTK_WIDGET (window)->allocation.width),
- MAX (600, GTK_WIDGET (window)->allocation.height));
+ MAX (enlarge_width, GTK_WIDGET
(window)->allocation.width),
+ MAX (enlarge_height, GTK_WIDGET
(window)->allocation.height));

YGtkWizard *wizard = YGTK_WIZARD (getWidget());
ygtk_wizard_set_header_icon (wizard, window,

Modified: trunk/gtk/src/YGUI.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.cc?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/src/YGUI.cc (original)
+++ trunk/gtk/src/YGUI.cc Tue May 13 13:22:05 2008
@@ -584,6 +584,35 @@

//** debug dialogs

+static GtkTreeView *debug_dialog_create (const char *title, GtkTreeStore
*store,
+ GCallback response_cb, void
*response_data)
+{
+ GtkWidget *dialog = gtk_dialog_new_with_buttons (title, NULL,
+ GtkDialogFlags (GTK_DIALOG_NO_SEPARATOR), GTK_STOCK_REFRESH, 1,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 400);
+ g_signal_connect (G_OBJECT (dialog), "response", response_cb,
response_data);
+
+ GtkWidget *view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+ gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (view), TRUE);
+
+ GtkWidget *scroll_win = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll_win),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_win),
+ GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
+
+ gtk_container_add (GTK_CONTAINER (scroll_win), view);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
scroll_win);
+
+ g_object_set_data (G_OBJECT (dialog), "view", view);
+ g_object_set_data (G_OBJECT (dialog), "store", store);
+
+ gtk_widget_show_all (dialog);
+
+ return GTK_TREE_VIEW (view);
+}
+
//#define IS_VALID_COL
void dumpYastTree (YWidget *widget)
{
@@ -644,12 +673,10 @@
#endif
);

- GtkWidget *dialog = gtk_dialog_new_with_buttons ("YWidgets Tree", NULL,
- GtkDialogFlags (GTK_DIALOG_NO_SEPARATOR), GTK_STOCK_REFRESH, 1,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
- gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 400);
+ GtkTreeView *view;
+ view = debug_dialog_create ("YWidget tree", store,
+ G_CALLBACK (inner::dialog_response_cb),
widget);

- GtkWidget *view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
gtk_tree_view_append_column (GTK_TREE_VIEW (view),
gtk_tree_view_column_new_with_attributes ("Type",
gtk_cell_renderer_text_new(), "text", 0, NULL));
@@ -669,26 +696,63 @@
gtk_tree_view_column_new_with_attributes ("Valid",
gtk_cell_renderer_toggle_new(), "active", 4, NULL));
#endif
- gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (view), TRUE);
-
- GtkWidget *scroll_win = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll_win),
- GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_win),
- GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
-
- gtk_container_add (GTK_CONTAINER (scroll_win), view);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
scroll_win);

inner::dumpYastTree (widget, store, NULL);
gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
+}

- g_object_set_data (G_OBJECT (dialog), "view", view);
- g_object_set_data (G_OBJECT (dialog), "store", store);
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (inner::dialog_response_cb), widget);
+void dumpGtkTree (GtkWidget *widget)
+{
+ IMPL
+ struct inner {
+ static void dumpGtkTree (GtkWidget *widget, GtkTreeStore *store,
+ GtkTreeIter *parent_node)
+ {
+ if (!widget) return;

- gtk_widget_show_all (dialog);
+ GtkTreeIter iter;
+ gtk_tree_store_append (store, &iter, parent_node);
+
+ gtk_tree_store_set (store, &iter,
+ 0, g_type_name_from_instance
((GTypeInstance *) widget),
+ -1);
+
+ if (GTK_IS_CONTAINER (widget)) {
+ GList *children = gtk_container_get_children
(GTK_CONTAINER (widget));
+ for (GList *l = children; l; l = l->next)
+ dumpGtkTree (GTK_WIDGET (l->data), store,
&iter);
+ }
+ }
+ /* FIXME: re-factor this & share code [!] */
+ static void dialog_response_cb (GtkDialog *dialog, gint
response, GtkWidget *widget)
+ {
+ if (response == 1) {
+ GtkTreeStore *store;
+ GtkTreeView *view;
+ store = (GtkTreeStore *) g_object_get_data
(G_OBJECT (dialog), "store");
+ view = (GtkTreeView *) g_object_get_data
(G_OBJECT (dialog), "view");
+ gtk_tree_store_clear (store);
+ dumpGtkTree (widget, store, NULL);
+ gtk_tree_view_expand_all (view);
+ }
+ else
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
+ };
+
+ int cols = 1;
+ GtkTreeView *view;
+ GtkTreeStore *store;
+
+ store = gtk_tree_store_new (cols, G_TYPE_STRING);
+ view = debug_dialog_create ("gtk widget tree", store,
+ G_CALLBACK (inner::dialog_response_cb),
widget);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view),
+ gtk_tree_view_column_new_with_attributes ("Type",
+ gtk_cell_renderer_text_new(), "text", 0, NULL));
+
+ inner::dumpGtkTree (widget, store, NULL);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
}

#include <YRichText.h>

Modified: trunk/gtk/src/YGUI.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.h?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/src/YGUI.h (original)
+++ trunk/gtk/src/YGUI.h Tue May 13 13:22:05 2008
@@ -102,6 +102,7 @@
// debug helpers.
void dumpYastTree (YWidget *widget);
void dumpYastHtml (YWidget *widget);
+void dumpGtkTree (GtkWidget *widget);

#include <YWidgetFactory.h>


Modified: trunk/gtk/src/ygtkratiobox.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkratiobox.c?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/src/ygtkratiobox.c (original)
+++ trunk/gtk/src/ygtkratiobox.c Tue May 13 13:22:05 2008
@@ -6,6 +6,7 @@
// check the header file for information about this widget

#include <config.h>
+#include <math.h>
#include "ygtkratiobox.h"

G_DEFINE_ABSTRACT_TYPE (YGtkRatioBox, ygtk_ratio_box, GTK_TYPE_CONTAINER)
@@ -164,12 +165,6 @@
requisition->width = secondary_req;
requisition->height = primary_req;
}
-
- // hack for bug #373159 -- we'll want to use the new layout stuff to
- // get nice window default sizes, and eliminate the minSize hacks
- #define MAX_SIZE 400
-// requisition->width = MIN (MAX_SIZE, requisition->width);
-// requisition->height = MIN (MAX_SIZE, requisition->height);
}

static void ygtk_ratio_box_size_allocate (GtkWidget *widget,
@@ -182,7 +177,7 @@
// a first loop to get some data for expansibles (ie. childs with
weight)
gfloat ratios_sum = 0;
gint expand_num = 0, max_ratio = 0;
- gint expansable_length;
+ gint expansable_length, num_children = 0;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
expansable_length = allocation->width - border*2;
else
@@ -212,8 +207,14 @@
expansable_length -= child_req.height;
}
expansable_length -= box->spacing - box_child->padding;
+ num_children++;
}
expansable_length -= box->weight_length;
+/* fprintf (stderr, "%p: expansible length %d allocation %d num children
%d\n",
+ box, expansable_length,
+ (orientation == GTK_ORIENTATION_HORIZONTAL ?
+ allocation->width : allocation->height),
+ num_children); */

gint child_pos = 0;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -227,6 +228,11 @@
if (!GTK_WIDGET_VISIBLE (box_child->widget))
continue;

+/* fprintf (stderr, "%p: ratio box child: ratio %g expand %d
must_expand %d "
+ "xfill %d yfill %d\n", box,
+ box_child->ratio, box_child->expand,
box_child->must_expand,
+ box_child->xfill, box_child->yfill); */
+
GtkAllocation child_alloc;
gint length;

@@ -251,12 +257,29 @@
}
else if (box_child->expand && (ratios_sum == 0 ||
box_child->must_expand))
{
- // FIXME: something is wrong for expansable_length
being < 0 at times
- // we aren't asking for enough size!
if (expansable_length > 0)
length += expansable_length / expand_num;
}

+ gint spacing_to_next = length + box->spacing +
box_child->padding;
+ if (!box_child->ratio && expansable_length < 0)
+ {
+ // oh dear - we can't shrink anything, but we didn't
get the size
+ // we requested this can happen with some large text
entry fields.
+ // try to shrink everything just a bit & hope. Should
we shrink
+ // things marked 'expandable' instead ? - what if there
are none ?
+ double scale;
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ scale = (double)(allocation->width +
expansable_length) / allocation->width;
+ else
+ scale = (double)(allocation->height +
expansable_length) / allocation->height;
+// fprintf (stderr, "%p: trunc length %d -> %d by scale
%g\n",
+// box, length, (int) floor (scale * length),
scale);
+ length = floor (scale * length);
+ spacing_to_next = floor (scale * spacing_to_next);
+ }
+
+
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
child_alloc.x = child_pos;
child_alloc.y = allocation->y + border;
@@ -286,7 +309,7 @@
child_alloc.x = allocation->width - child_alloc.x -
child_alloc.width;

gtk_widget_size_allocate (box_child->widget, &child_alloc);
- child_pos += length + box->spacing + box_child->padding;
+ child_pos += spacing_to_next;
}
}


Modified: trunk/gtk/src/ygtkwizard.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=47481&r1=47480&r2=47481&view=diff
==============================================================================
--- trunk/gtk/src/ygtkwizard.c (original)
+++ trunk/gtk/src/ygtkwizard.c Tue May 13 13:22:05 2008
@@ -490,7 +490,7 @@

GtkWidget *child = wizard->m_child, *pane;
pane = gtk_hpaned_new();
- gtk_paned_pack1 (GTK_PANED (pane), wizard->m_tree, TRUE, TRUE);
+ gtk_paned_pack1 (GTK_PANED (pane), wizard->m_tree, TRUE, FALSE);
gtk_widget_show_all (pane);
ygtk_wizard_set_child (wizard, pane);
wizard->m_pane = pane;

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages