Mailinglist Archive: yast-commit (683 mails)

< Previous Next >
[yast-commit] r42853 - in /trunk/gtk/unstable-libyui: ChangeLog src/YGTable.cc src/ygtkcellrenderertextpixbuf.c
  • From: rpmcruz@xxxxxxxxxxxxxxxx
  • Date: Sat, 08 Dec 2007 17:12:24 -0000
  • Message-id: <20071208171224.DDBE032CC7@xxxxxxxxxxxxxxxx>
Author: rpmcruz
Date: Sat Dec 8 18:12:24 2007
New Revision: 42853

URL: http://svn.opensuse.org/viewcvs/yast?rev=42853&view=rev
Log:
* src/ygtkcellrenderertextpixbuf.c: fix: honor align for icons too.

* src/YGTable.cc: simplified table sorting code; GTK+ has convinience
functions for these, I was doing all the work myself, connecting header
clicks, providing a sort callback, changing sort icons, .. :P Honored
YTable::setKeepSorting().

Modified:
trunk/gtk/unstable-libyui/ChangeLog
trunk/gtk/unstable-libyui/src/YGTable.cc
trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c

Modified: trunk/gtk/unstable-libyui/ChangeLog
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/ChangeLog?rev=42853&r1=42852&r2=42853&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/ChangeLog (original)
+++ trunk/gtk/unstable-libyui/ChangeLog Sat Dec 8 18:12:24 2007
@@ -1,5 +1,14 @@
2007-12-07 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>

+ * src/ygtkcellrenderertextpixbuf.c: fix: honor align for icons too.
+
+ * src/YGTable.cc: simplified table sorting code; GTK+ has convinience
+ functions for these, I was doing all the work myself, connecting header
+ clicks, providing a sort callback, changing sort icons, .. :P Honored
+ YTable::setKeepSorting().
+
+2007-12-07 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>
+
* Some fixes overall. YGTree and YGMultiSelectionBox were not working.
Polished YGSelectionModel. Fixed support for icons.


Modified: trunk/gtk/unstable-libyui/src/YGTable.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGTable.cc?rev=42853&r1=42852&r2=42853&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGTable.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGTable.cc Sat Dec 8 18:12:24 2007
@@ -226,16 +226,12 @@
if (immediateMode())
g_signal_connect (G_OBJECT (getWidget()),
"cursor-changed",
G_CALLBACK (selected_cb),
(YGTableView*) this);
-
- setSortable (0);
+ setSortable (true);
}

virtual void setKeepSorting (bool keepSorting)
{
-fprintf (stderr, "setKeepSorting!\n");
- // FIXME: GTK doesn't let us get back to unsorted mode...
-/* if (!keepSorting)
- YGUtils::tree_view_set_sortable (getView(), 0);*/
+ setSortable (keepSorting);
YTable::setKeepSorting (keepSorting);
}

@@ -267,70 +263,17 @@
setCellLabel (iter, index+1, cell->label());
}

- // Goes through all GtkTreeView columns, making them sortable.
- void setSortable (int default_col)
+ void setSortable (bool sortable)
{
IMPL
- struct inner {
- static gint sort_cb (GtkTreeModel *model, GtkTreeIter
*a,
- GtkTreeIter *b, gpointer data)
- {
- gchar *s1 = 0, *s2 = 0;
- gint col = GPOINTER_TO_INT (data);
- gtk_tree_model_get (model, a, col, &s1, -1);
- gtk_tree_model_get (model, b, col, &s2, -1);
-
- gint cmp = 0;
- if (s1 && s2)
- cmp = YGUtils::strcmp (s1, s2);
-
- if (s1) g_free (s1);
- if (s2) g_free (s2);
- return cmp;
- }
-
- static void header_clicked_cb (GtkTreeViewColumn
*column, GtkTreeSortable *sortable)
- {
- IMPL
- GtkTreeViewColumn *last_sorted =
- (GtkTreeViewColumn *) g_object_get_data
(G_OBJECT (sortable), "last-sorted");
- int id = GPOINTER_TO_INT (g_object_get_data
(G_OBJECT (column), "id"));
-
- GtkSortType sort = GTK_SORT_ASCENDING;
- if (last_sorted != column) {
- if (last_sorted)
-
gtk_tree_view_column_set_sort_indicator (last_sorted, FALSE);
- gtk_tree_view_column_set_sort_indicator
(column, TRUE);
- g_object_set_data (G_OBJECT (sortable),
"last-sorted", column);
- }
- else {
- sort =
gtk_tree_view_column_get_sort_order (column);
- sort = sort == GTK_SORT_ASCENDING ?
GTK_SORT_DESCENDING : GTK_SORT_ASCENDING;
- }
-
- gtk_tree_view_column_set_sort_order (column,
sort);
- gtk_tree_sortable_set_sort_column_id (sortable,
id, sort);
- }
- };
-
- GtkTreeView *view = getView();
- GtkTreeSortable *sortable = GTK_TREE_SORTABLE
(gtk_tree_view_get_model (view));
- // keep a pointer to currently sorted, so next can disable it
- g_object_set_data (G_OBJECT (sortable), "last-sorted", NULL);
-
int n = 0;
- GList *columns = gtk_tree_view_get_columns (view);
+ GList *columns = gtk_tree_view_get_columns (getView());
for (GList *i = columns; i; i = i->next, n++) {
GtkTreeViewColumn *column = (GtkTreeViewColumn *)
i->data;
- gtk_tree_sortable_set_sort_func (sortable, n,
inner::sort_cb,
- GINT_TO_POINTER
((n*2)+1), NULL);
-
- g_object_set_data (G_OBJECT (column), "id",
GINT_TO_POINTER (n));
- gtk_tree_view_column_set_clickable (column, TRUE);
- g_signal_connect (G_OBJECT (column), "clicked",
- G_CALLBACK
(inner::header_clicked_cb), sortable);
-/* if (col_nb == default_sort_col)
- header_clicked_cb (column, sortable);*/
+ int index = (n*2)+1;
+ if (!sortable)
+ index = -1;
+ gtk_tree_view_column_set_sort_column_id (column, index);
}
g_list_free (columns);
}

Modified: trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c?rev=42853&r1=42852&r2=42853&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c (original)
+++ trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c Sat Dec 8
18:12:24 2007
@@ -149,15 +149,23 @@

int x = cell_area->x, y = cell_area->y;

+ gfloat xalign = cell->xalign, yalign = cell->yalign;
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ xalign = 1.0 - xalign;
+
if (tpcell->pixbuf) {
int w, h;
w = gdk_pixbuf_get_width (tpcell->pixbuf);
h = gdk_pixbuf_get_height (tpcell->pixbuf);

+ int xoffset, yoffset;
+ xoffset = xalign * (cell_area->width - (w + (2*cell->xpad)));
+ yoffset = yalign * (cell_area->height - (h + (2*cell->ypad)));
+
cairo_t *cr = gdk_cairo_create (window);
- gdk_cairo_set_source_pixbuf (cr, tpcell->pixbuf, x, y);
+ gdk_cairo_set_source_pixbuf (cr, tpcell->pixbuf, x+xoffset,
y+yoffset);

- cairo_rectangle (cr, x, y, w, h);
+ cairo_rectangle (cr, x+xoffset, y+yoffset, w, h);
cairo_fill (cr);
cairo_destroy (cr);

@@ -170,11 +178,7 @@
PangoRectangle rect;
pango_layout_get_pixel_extents (layout, NULL, &rect);

- gfloat xalign = cell->xalign, yalign = cell->yalign;
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- xalign = 1.0 - xalign;
-
- gint xoffset, yoffset;
+ int xoffset, yoffset;
xoffset = xalign * (cell_area->width - (rect.width +
(2*cell->xpad)));
yoffset = yalign * (cell_area->height - (rect.height +
(2*cell->ypad)));


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

< Previous Next >
This Thread
  • No further messages