Author: dmacvicar
Date: Tue Apr 19 00:04:21 2011
New Revision: 63811
URL: http://svn.opensuse.org/viewcvs/yast?rev=63811&view=rev
Log:
GTK2 -> GTK3
Added:
branches/tmp/dmacvicar/gtk/cmake/
branches/tmp/dmacvicar/gtk/cmake/modules/
branches/tmp/dmacvicar/gtk/cmake/modules/FindGTK3.cmake
Modified:
branches/tmp/dmacvicar/gtk/src/YGBarGraph.cc
branches/tmp/dmacvicar/gtk/src/YGProgressBar.cc
branches/tmp/dmacvicar/gtk/src/YGText.cc
branches/tmp/dmacvicar/gtk/src/YGTreeView.cc
branches/tmp/dmacvicar/gtk/src/YGUI.cc
branches/tmp/dmacvicar/gtk/src/YGUtils.cc
branches/tmp/dmacvicar/gtk/src/YGWidget.cc
branches/tmp/dmacvicar/gtk/src/ygtkbargraph.c
branches/tmp/dmacvicar/gtk/src/ygtkbargraph.h
branches/tmp/dmacvicar/gtk/src/ygtkfieldentry.c
branches/tmp/dmacvicar/gtk/src/ygtkfixed.c
branches/tmp/dmacvicar/gtk/src/ygtkimage.c
branches/tmp/dmacvicar/gtk/src/ygtklinklabel.c
branches/tmp/dmacvicar/gtk/src/ygtkmenubutton.c
branches/tmp/dmacvicar/gtk/src/ygtkratiobox.c
Added: branches/tmp/dmacvicar/gtk/cmake/modules/FindGTK3.cmake
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/cmake/modules/FindGTK3.cmake?rev=63811&view=auto
==============================================================================
--- branches/tmp/dmacvicar/gtk/cmake/modules/FindGTK3.cmake (added)
+++ branches/tmp/dmacvicar/gtk/cmake/modules/FindGTK3.cmake Tue Apr 19 00:04:21 2011
@@ -0,0 +1,47 @@
+# - Try to find GTK3
+# Once done this will define
+#
+# GTK3_FOUND - System has GTK3
+# GTK3_INCLUDE_DIR - The GTK3 include directory
+# GTK3_LIBRARIES - The libraries needed to use GTK3
+# GTK3_DEFINITIONS - Compiler switches required for using GTK3
+#=============================================================================
+# Copyright 2011 Duncan Mac-Vicar P.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+FIND_PACKAGE(PkgConfig)
+PKG_CHECK_MODULES(PC_GTK3 gtk+-3.0 QUIET)
+SET(GTK3_DEFINITIONS ${PC_GTK3_CFLAGS_OTHER})
+
+FIND_PATH(GTK3_INCLUDE_DIR NAMES "gtk/gtk.h"
+ HINTS
+ ${PC_GTK3_INCLUDEDIR}
+ ${PC_GTK3_INCLUDE_DIRS}
+ PATH_SUFFIXES "gtk-3.0"
+ )
+SET(GTK3_INCLUDE_DIRS ${PC_GTK3_INCLUDE_DIRS})
+
+FIND_LIBRARY(GTK3_LIBRARIES NAMES gtk-3 gtk3
+ HINTS
+ ${PC_GTK3_LIBDIR}
+ ${PC_GTK3_LIBRARY_DIRS}
+ )
+
+# handle the QUIETLY and REQUIRED arguments and set GTK3_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_LIBRARIES GTK3_INCLUDE_DIR)
+
+MARK_AS_ADVANCED(GTK3_INCLUDE_DIR GTK3_LIBRARIES)
+
Modified: branches/tmp/dmacvicar/gtk/src/YGBarGraph.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/YGBarGraph.cc?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/YGBarGraph.cc (original)
+++ branches/tmp/dmacvicar/gtk/src/YGBarGraph.cc Tue Apr 19 00:04:21 2011
@@ -26,19 +26,19 @@
const YBarGraphSegment &s = segment (i);
ygtk_bar_graph_setup_entry (graph, i, s.label().c_str(), s.value());
if (s.hasSegmentColor()) {
- GdkColor color = ycolorToGdk (s.segmentColor());
+ GdkRGBA color = ycolorToGdk (s.segmentColor());
ygtk_bar_graph_customize_bg (graph, i, &color);
}
if (s.hasTextColor()) {
- GdkColor color = ycolorToGdk (s.textColor());
+ GdkRGBA color = ycolorToGdk (s.textColor());
ygtk_bar_graph_customize_fg (graph, i, &color);
}
}
}
- static GdkColor ycolorToGdk (const YColor &ycolor)
+ static GdkRGBA ycolorToGdk (const YColor &ycolor)
{
- GdkColor color = { 0, guint16(ycolor.red() << 8), guint16(ycolor.green() << 8), guint16(ycolor.blue() << 8) };
+ GdkRGBA color = { 0, guint16(ycolor.red() << 8), guint16(ycolor.green() << 8), guint16(ycolor.blue() << 8) };
return color;
}
Modified: branches/tmp/dmacvicar/gtk/src/YGProgressBar.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/YGProgressBar.cc?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/YGProgressBar.cc (original)
+++ branches/tmp/dmacvicar/gtk/src/YGProgressBar.cc Tue Apr 19 00:04:21 2011
@@ -137,8 +137,8 @@
ygtk_ratio_box_set_spacing (YGTK_RATIO_BOX (getWidget()), 2);
for (int s = 0; s < segments(); s++) {
GtkWidget *bar = gtk_progress_bar_new();
- gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (bar),
- horizontal() ? GTK_PROGRESS_LEFT_TO_RIGHT : GTK_PROGRESS_BOTTOM_TO_TOP);
+ gtk_orientable_set_orientation(GTK_ORIENTABLE(bar), horizontal() ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
+ gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR (bar), horizontal() ? FALSE : TRUE);
// Progress bars would ask for too much size with weight...
const int min_size = 5;
if (horizontal())
Modified: branches/tmp/dmacvicar/gtk/src/YGText.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/YGText.cc?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/YGText.cc (original)
+++ branches/tmp/dmacvicar/gtk/src/YGText.cc Tue Apr 19 00:04:21 2011
@@ -74,7 +74,7 @@
void scrollToBottom()
{
#if 1
- YGUtils::scrollWidget (gtk_text_view_get_vadjustment(GTK_TEXT_VIEW (getWidget())), false);
+ YGUtils::scrollWidget (gtk_scrollable_get_vadjustment(GTK_SCROLLABLE (getWidget())), false);
#else
GtkTextBuffer *buffer = getBuffer();
GtkTextIter iter;
@@ -167,7 +167,7 @@
if (text.size() == m_text.size()) return;
// appending text: avoid flickering and allow user to scroll freely
- GtkAdjustment *vadj = gtk_text_view_get_vadjustment(GTK_TEXT_VIEW (getWidget()));
+ GtkAdjustment *vadj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE (getWidget()));
bool autoScroll = gtk_adjustment_get_value(vadj) >= gtk_adjustment_get_upper(vadj) - gtk_adjustment_get_page_size(vadj);
std::string diff (text.substr (m_text.size()));
Modified: branches/tmp/dmacvicar/gtk/src/YGTreeView.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/YGTreeView.cc?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/YGTreeView.cc (original)
+++ branches/tmp/dmacvicar/gtk/src/YGTreeView.cc Tue Apr 19 00:04:21 2011
@@ -514,7 +514,7 @@
static gboolean key_press_event_cb (GtkWidget *widget, GdkEventKey *event, YGTable *pThis)
{
- if (event->keyval == GDK_Delete) {
+ if (event->keyval == GDK_KEY_Delete) {
YWidget *button = YGDialog::currentDialog()->getFunctionWidget (5);
if (button)
activateButton (button);
Modified: branches/tmp/dmacvicar/gtk/src/YGUI.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/YGUI.cc?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/YGUI.cc (original)
+++ branches/tmp/dmacvicar/gtk/src/YGUI.cc Tue Apr 19 00:04:21 2011
@@ -361,9 +361,9 @@
GError *error = 0;
GdkPixbuf *shot =
- gdk_pixbuf_get_from_drawable (NULL, GDK_DRAWABLE (gtk_widget_get_window(widget)),
- gdk_colormap_get_system(), 0, 0, 0, 0, alloc.width,
- alloc.height);
+ gdk_pixbuf_get_from_window (gtk_widget_get_window(widget),
+ 0, 0, alloc.width,
+ alloc.height);
if (!shot) {
if (interactive)
@@ -643,7 +643,7 @@
};
GtkWidget *dialog = gtk_dialog_new_with_buttons ("YWidgets HTML", NULL,
- GtkDialogFlags (GTK_DIALOG_NO_SEPARATOR), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ GtkDialogFlags (0), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300);
inner::dumpYastHtml (widget, GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG (dialog))));
Modified: branches/tmp/dmacvicar/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/YGUtils.cc?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/YGUtils.cc (original)
+++ branches/tmp/dmacvicar/gtk/src/YGUtils.cc Tue Apr 19 00:04:21 2011
@@ -460,9 +460,10 @@
int YGUtils::getCharsWidth (GtkWidget *widget, int chars_nb)
{
+ GtkStyleContext *style_ctx = gtk_widget_get_style_context(widget);
PangoContext *context = gtk_widget_get_pango_context (widget);
PangoFontMetrics *metrics = pango_context_get_metrics (context,
- gtk_widget_get_style(widget)->font_desc, NULL);
+ gtk_style_context_get_font(style_ctx, GTK_STATE_FLAG_NORMAL), NULL);
int width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
@@ -472,9 +473,10 @@
int YGUtils::getCharsHeight (GtkWidget *widget, int chars_nb)
{
+ GtkStyleContext *style_ctx = gtk_widget_get_style_context(widget);
PangoContext *context = gtk_widget_get_pango_context (widget);
PangoFontMetrics *metrics = pango_context_get_metrics (context,
- gtk_widget_get_style(widget)->font_desc, NULL);
+ gtk_style_context_get_font(style_ctx, GTK_STATE_FLAG_NORMAL), NULL);
int height = pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics);
@@ -486,13 +488,15 @@
void YGUtils::setWidgetFont (GtkWidget *widget, PangoStyle style, PangoWeight weight,
double scale)
{
- PangoFontDescription *font_desc = gtk_widget_get_style(widget)->font_desc;
+ GtkStyleContext *style_ctx = gtk_widget_get_style_context(widget);
+ const PangoFontDescription *font_desc = gtk_style_context_get_font(style_ctx, GTK_STATE_FLAG_NORMAL);
+
int size = pango_font_description_get_size (font_desc);
PangoFontDescription* font = pango_font_description_new();
pango_font_description_set_weight (font, weight);
pango_font_description_set_size (font, (int)(size * scale));
pango_font_description_set_style (font, style);
- gtk_widget_modify_font (widget, font);
+ gtk_widget_override_font (widget, font);
pango_font_description_free (font);
}
@@ -714,10 +718,12 @@
const char *fallbackIcon)
{
const char *icon = mapStockIcon (label);
+ GtkStyleContext *ctx = gtk_widget_get_style_context(button);
+
if (!icon && label.size() < 22)
icon = fallbackIcon;
if (icon) {
- if (gtk_style_lookup_icon_set (gtk_widget_get_style(button), icon)) {
+ if (gtk_style_context_lookup_icon_set (ctx, 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);
@@ -734,19 +740,26 @@
void YGUtils::shrinkWidget (GtkWidget *widget)
{
static bool first_time = true;
+ GtkCssProvider *provider;
+
if (first_time) {
- first_time = false;
- gtk_rc_parse_string (
- "style \"small-widget-style\"\n"
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ "style \"small-widget-style\"\n"
"{\n"
" GtkWidget::focus-padding = 0\n"
" GtkWidget::focus-line-width = 0\n"
" xthickness = 0\n"
" ythickness = 0\n"
"}\n"
- "widget \"*.small-widget\" style \"small-widget-style\"");
- }
- gtk_widget_set_name (widget, "small-widget");
+ "widget \"*.small-widget\" style \"small-widget-style\"", -1, NULL);
+ gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+ gtk_widget_set_name (widget, "small-widget");
+ first_time = false;
+ }
}
/*
Modified: branches/tmp/dmacvicar/gtk/src/YGWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/YGWidget.cc?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/YGWidget.cc (original)
+++ branches/tmp/dmacvicar/gtk/src/YGWidget.cc Tue Apr 19 00:04:21 2011
@@ -157,7 +157,7 @@
{
// We might want to do some caching here..
GtkRequisition req;
- gtk_widget_size_request (m_adj_size, &req);
+ gtk_widget_get_preferred_size (m_adj_size, &req, NULL);
return dimension == YD_HORIZ ? req.width : req.height;
}
Modified: branches/tmp/dmacvicar/gtk/src/ygtkbargraph.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtkbargraph.c?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtkbargraph.c (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtkbargraph.c Tue Apr 19 00:04:21 2011
@@ -20,10 +20,24 @@
ygtk_bar_graph_set_style (bar, TRUE);
}
-static void ygtk_bar_graph_size_request (GtkWidget *widget, GtkRequisition *requisition)
+static void
+ygtk_bar_graph_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
{
- GTK_WIDGET_CLASS (ygtk_bar_graph_parent_class)->size_request (widget, requisition);
- requisition->height += 18; // give room for the labels
+
+ GTK_WIDGET_CLASS (ygtk_bar_graph_parent_class)->get_preferred_height (widget, minimal_height, natural_height);
+ *minimal_height = *minimal_height + 18; // give room for the labels
+ *natural_height = *minimal_height;
+}
+
+static void
+ygtk_bar_graph_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GTK_WIDGET_CLASS (ygtk_bar_graph_parent_class)->get_preferred_width (widget, minimal_width, natural_width);
+
}
GtkWidget *ygtk_bar_graph_new (void)
@@ -129,7 +143,7 @@
YGtkColoredLabel *color_label = YGTK_COLORED_LABEL (label);
const guint *color = palette [index % G_N_ELEMENTS (palette)];
- GdkColor gcolor = { 0, color[0] << 8, color[1] << 8, color[2] << 8 };
+ GdkRGBA gcolor = { 0, color[0] << 8, color[1] << 8, color[2] << 8 };
ygtk_colored_label_set_background (color_label, &gcolor);
}
@@ -140,13 +154,13 @@
gtk_frame_set_shadow_type (GTK_FRAME (bar), shadow);
}
-void ygtk_bar_graph_customize_bg (YGtkBarGraph *bar, int index, GdkColor *color)
+void ygtk_bar_graph_customize_bg (YGtkBarGraph *bar, int index, GdkRGBA *color)
{
GtkWidget *label = ygtk_bar_graph_get_label (bar, index, NULL);
ygtk_colored_label_set_background (YGTK_COLORED_LABEL (label), color);
}
-void ygtk_bar_graph_customize_fg (YGtkBarGraph *bar, int index, GdkColor *color)
+void ygtk_bar_graph_customize_fg (YGtkBarGraph *bar, int index, GdkRGBA *color)
{
GtkWidget *label = ygtk_bar_graph_get_label (bar, index, NULL);
ygtk_colored_label_set_foreground (YGTK_COLORED_LABEL (label), color);
@@ -157,7 +171,8 @@
ygtk_bar_graph_parent_class = g_type_class_peek_parent (klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->size_request = ygtk_bar_graph_size_request;
+ widget_class->get_preferred_width = ygtk_bar_graph_get_preferred_width;
+ widget_class->get_preferred_height = ygtk_bar_graph_get_preferred_height;
}
//** YGtkColoredLabel
@@ -172,25 +187,25 @@
static inline double pixel_clamp (double val)
{ return MAX (0, MIN (1, val)); }
-static gboolean ygtk_colored_label_expose_event (GtkWidget *widget, GdkEventExpose *event)
+static gboolean ygtk_colored_label_on_draw (GtkWidget *widget, cairo_t *cr)
{
- GtkAllocation alloc;
- gtk_widget_get_allocation(widget, &alloc);
+ GtkStyleContext *ctx;
+ ctx = gtk_widget_get_style_context(widget);
+
+ GdkRGBA bg_color;
+ gtk_style_context_get_background_color(ctx, GTK_STATE_NORMAL, &bg_color);
+ gdouble red = ((guint) bg_color.red >> 8) / 255.;
+ gdouble green = ((guint) bg_color.green >> 8) / 255.;
+ gdouble blue = ((guint) bg_color.blue >> 8) / 255.;
- GdkColor *bg_color = >k_widget_get_style(widget)->bg[GTK_STATE_NORMAL];
- double red = (bg_color->red >> 8) / 255.;
- double green = (bg_color->green >> 8) / 255.;
- double blue = (bg_color->blue >> 8) / 255.;
-
- cairo_t *cr = gdk_cairo_create (event->window);
- cairo_translate (cr, alloc.x, alloc.y);
- cairo_scale (cr, alloc.width, alloc.height);
+ //cairo_scale (cr, width, height);
double x, y, w, h;
- x = alloc.x;
- y = alloc.y;
- w = alloc.width;
- h = alloc.height;
+ x = 0;
+ y = 0;
+
+ w = gtk_widget_get_allocated_width (widget);
+ h = gtk_widget_get_allocated_height (widget);
cairo_pattern_t *grad = cairo_pattern_create_linear (0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (grad, 0, pixel_clamp (red+.3), pixel_clamp (green+.3), pixel_clamp (blue+.3), 1);
@@ -202,26 +217,25 @@
cairo_fill (cr);
cairo_pattern_destroy (grad);
+ GTK_WIDGET_CLASS (ygtk_colored_label_parent_class)->draw (widget, cr);
cairo_destroy (cr);
-
- GTK_WIDGET_CLASS (ygtk_colored_label_parent_class)->expose_event (widget, event);
return FALSE;
}
GtkWidget *ygtk_colored_label_new (void)
{ return g_object_new (YGTK_TYPE_COLORED_LABEL, NULL); }
-void ygtk_colored_label_set_background (YGtkColoredLabel *label, GdkColor *color)
-{ gtk_widget_modify_bg (GTK_WIDGET (label), GTK_STATE_NORMAL, color); }
+void ygtk_colored_label_set_background (YGtkColoredLabel *label, GdkRGBA *color)
+{ gtk_widget_override_background_color (GTK_WIDGET (label), GTK_STATE_NORMAL, color); }
-void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, GdkColor *color)
-{ gtk_widget_modify_fg (GTK_WIDGET (label), GTK_STATE_NORMAL, color); }
+void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, GdkRGBA *color)
+{ gtk_widget_override_color (GTK_WIDGET (label), GTK_STATE_NORMAL, color); }
static void ygtk_colored_label_class_init (YGtkColoredLabelClass *klass)
{
ygtk_colored_label_parent_class = g_type_class_peek_parent (klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->expose_event = ygtk_colored_label_expose_event;
+ widget_class->draw = ygtk_colored_label_on_draw;
}
Modified: branches/tmp/dmacvicar/gtk/src/ygtkbargraph.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtkbargraph.h?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtkbargraph.h (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtkbargraph.h Tue Apr 19 00:04:21 2011
@@ -46,8 +46,8 @@
void ygtk_bar_graph_setup_entry (YGtkBarGraph *bar, int index, const gchar *label_entry, int value);
void ygtk_bar_graph_set_style (YGtkBarGraph *bar, gboolean flat);
-void ygtk_bar_graph_customize_bg (YGtkBarGraph *bar, int index, GdkColor *color);
-void ygtk_bar_graph_customize_fg (YGtkBarGraph *bar, int index, GdkColor *color);
+void ygtk_bar_graph_customize_bg (YGtkBarGraph *bar, int index, GdkRGBA *color);
+void ygtk_bar_graph_customize_fg (YGtkBarGraph *bar, int index, GdkRGBA *color);
G_END_DECLS
#endif /*YGTK_BAR_GRAPH_H*/
@@ -87,8 +87,8 @@
// A convenience function (you may use gtk_widget_modify_fg() and
// gtk_widget_modify_bg() instead), where colors range is [0, 255]
-void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, GdkColor *color);
-void ygtk_colored_label_set_background (YGtkColoredLabel *label, GdkColor *color);
+void ygtk_colored_label_set_foreground (YGtkColoredLabel *label, GdkRGBA *color);
+void ygtk_colored_label_set_background (YGtkColoredLabel *label, GdkRGBA *color);
G_END_DECLS
#endif /*YGTK_COLORED_LABEL*/
Modified: branches/tmp/dmacvicar/gtk/src/ygtkfieldentry.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtkfieldentry.c?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtkfieldentry.c (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtkfieldentry.c Tue Apr 19 00:04:21 2011
@@ -7,7 +7,6 @@
#include
#include "ygtkfieldentry.h"
-#include
#include
#include
Modified: branches/tmp/dmacvicar/gtk/src/ygtkfixed.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtkfixed.c?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtkfixed.c (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtkfixed.c Tue Apr 19 00:04:21 2011
@@ -14,7 +14,7 @@
static void ygtk_fixed_init (YGtkFixed *fixed)
{
- gtk_widget_set_has_window(fixed, FALSE);
+ gtk_widget_set_has_window(GTK_WIDGET(fixed), FALSE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (fixed), FALSE);
}
@@ -92,12 +92,29 @@
}
}
-static void ygtk_fixed_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- YGtkFixed *fixed = YGTK_FIXED (widget);
- fixed->preferred_size_cb (fixed, &requisition->width, &requisition->height,
- fixed->data);
- GTK_WIDGET_CLASS (ygtk_fixed_parent_class)->size_request (widget, requisition);
+static void
+ygtk_fixed_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ YGtkFixed *fixed = YGTK_FIXED (widget);
+ gint dummy;
+ fixed->preferred_size_cb (fixed, minimal_width, &dummy, fixed->data);
+ *natural_width = *minimal_width;
+ GTK_WIDGET_CLASS (ygtk_fixed_parent_class)->get_preferred_width (widget, minimal_width, natural_width);
+}
+
+static void
+ygtk_fixed_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ YGtkFixed *fixed = YGTK_FIXED (widget);
+ gint dummy;
+ fixed->preferred_size_cb (fixed, &dummy, minimal_height, fixed->data);
+ *natural_height = *minimal_height;
+ GTK_WIDGET_CLASS (ygtk_fixed_parent_class)->get_preferred_height (widget, minimal_height, natural_height);
+
}
static void ygtk_fixed_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
@@ -134,7 +151,8 @@
container_class->child_type = ygtk_fixed_child_type;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->size_request = ygtk_fixed_size_request;
+ widget_class->get_preferred_width = ygtk_fixed_get_preferred_width;
+ widget_class->get_preferred_height = ygtk_fixed_get_preferred_height;
widget_class->size_allocate = ygtk_fixed_size_allocate;
}
Modified: branches/tmp/dmacvicar/gtk/src/ygtkimage.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtkimage.c?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtkimage.c (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtkimage.c Tue Apr 19 00:04:21 2011
@@ -35,14 +35,14 @@
}
}
-static void ygtk_image_destroy (GtkObject *object)
+static void ygtk_image_destroy (GObject *object)
{
YGtkImage *image = YGTK_IMAGE (object);
if (image->alt_text)
g_free (image->alt_text);
image->alt_text = NULL;
ygtk_image_free_pixbuf (image);
- GTK_OBJECT_CLASS (ygtk_image_parent_class)->destroy (object);
+ GTK_WIDGET_CLASS (ygtk_image_parent_class)->destroy (object);
}
static void ygtk_image_set_pixbuf (YGtkImage *image, GdkPixbuf *pixbuf, const char *error_msg)
@@ -190,6 +190,26 @@
requisition->height = height;
}
+static void
+ygtk_image_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+ ygtk_image_size_request (widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void
+ygtk_image_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+ ygtk_image_size_request (widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+
static GdkPixbuf *ygtk_image_render_state (GtkWidget *widget, GdkPixbuf *pixbuf)
{
// as in GtkImage
@@ -198,26 +218,20 @@
gtk_icon_source_set_pixbuf (source, pixbuf);
gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_icon_source_set_size_wildcarded (source, FALSE);
- rendered = gtk_style_render_icon (gtk_widget_get_style(widget), source,
- gtk_widget_get_direction (widget), gtk_widget_get_state (widget),
- /* arbitrary */ (GtkIconSize)-1, widget, "gtk-image");
+ rendered = gtk_render_icon_pixbuf (gtk_widget_get_style_context(widget), source, (GtkIconSize)-1);
gtk_icon_source_free (source);
return rendered;
}
-static gboolean ygtk_image_expose_event (GtkWidget *widget, GdkEventExpose *event)
+static gboolean ygtk_image_draw_event (GtkWidget *widget, cairo_t *cr)
{
YGtkImage *image = YGTK_IMAGE (widget);
int width, height;
- GtkAllocation alloc;
GtkRequisition req;
- gtk_widget_get_allocation(widget, &alloc);
gtk_widget_get_requisition(widget, &req);
- width = alloc.width;
- height = alloc.height;
-
- cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(widget));
+ width = gtk_widget_get_allocated_width(widget);
+ height = gtk_widget_get_allocated_height(widget);
if (!image->loaded) {
if (image->alt_text) {
@@ -290,10 +304,9 @@
static void ygtk_image_class_init (YGtkImageClass *klass)
{
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->expose_event = ygtk_image_expose_event;
- widget_class->size_request = ygtk_image_size_request;
-
- GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
- gtkobject_class->destroy = ygtk_image_destroy;
+ widget_class->draw = ygtk_image_draw_event;
+ widget_class->get_preferred_width = ygtk_image_get_preferred_width;
+ widget_class->get_preferred_height = ygtk_image_get_preferred_height;
+ widget_class->destroy = ygtk_image_destroy;
}
Modified: branches/tmp/dmacvicar/gtk/src/ygtklinklabel.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtklinklabel.c?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtklinklabel.c (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtklinklabel.c Tue Apr 19 00:04:21 2011
@@ -41,12 +41,8 @@
label->link_window = gdk_window_new (gtk_widget_get_window(widget), &attributes, attributes_mask);
gdk_window_set_user_data (label->link_window, widget);
GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
-
- if (!gdk_colormap_alloc_color (gtk_widget_get_colormap (widget),
- &white, FALSE, TRUE))
- return;
gdk_window_set_background (label->link_window, &white);
- gdk_cursor_unref (attributes.cursor);
+ g_object_unref (G_OBJECT(attributes.cursor));
}
static void ygtk_link_label_unrealize (GtkWidget *widget)
@@ -113,13 +109,15 @@
YGtkLinkLabel *label = YGTK_LINK_LABEL (widget);
ygtk_link_label_ensure_layout (label);
requisition->width = requisition->height = 0;
+ GtkStyleContext *style_ctx;
+ style_ctx = gtk_widget_get_style_context(widget);
// if (label->text && *label->text)
{
PangoContext *context;
PangoFontMetrics *metrics;
gint ascent, descent;
context = pango_layout_get_context (label->layout);
- metrics = pango_context_get_metrics (context, gtk_widget_get_style(widget)->font_desc,
+ metrics = pango_context_get_metrics (context, gtk_style_context_get_font(style_ctx, GTK_STATE_FLAG_NORMAL),
pango_context_get_language (context));
ascent = pango_font_metrics_get_ascent (metrics);
descent = pango_font_metrics_get_descent (metrics);
@@ -128,6 +126,26 @@
}
}
+static void
+ygtk_link_label_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+ ygtk_link_label_size_request (widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void
+ygtk_link_label_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+ ygtk_link_label_size_request (widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+
#define SPACING 4
static void ygtk_link_label_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
@@ -163,7 +181,7 @@
}
}
-static gboolean ygtk_link_label_expose_event (GtkWidget *widget, GdkEventExpose *event)
+static gboolean ygtk_link_label_on_draw (GtkWidget *widget, cairo_t *cr)
{
YGtkLinkLabel *label = YGTK_LINK_LABEL (widget);
ygtk_link_label_ensure_layout (label);
@@ -172,7 +190,7 @@
PangoLayout *layout = 0;
GtkAllocation alloc;
gtk_widget_get_allocation(widget, &alloc);
- if (event->window == gtk_widget_get_window(widget)) {
+ if (gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget))) {
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
PangoRectangle extent;
pango_layout_get_extents (label->layout, NULL, &extent);
@@ -182,12 +200,13 @@
y += alloc.y;
layout = label->layout;
}
- else if (event->window == label->link_window)
+ else if (gtk_cairo_should_draw_window(cr, label->link_window))
layout = label->link_layout;
- if (layout)
- gtk_paint_layout (gtk_widget_get_style(widget), event->window, gtk_widget_get_state (widget),
- FALSE, &event->area, widget, "label", x, y, layout);
+ if (layout) {
+ GtkStyleContext *ctx = gtk_widget_get_style_context(widget);
+ gtk_render_layout (ctx, cr, x, y, layout);
+ }
return FALSE;
}
@@ -226,9 +245,12 @@
widget_class->realize = ygtk_link_label_realize;
widget_class->unrealize = ygtk_link_label_unrealize;
widget_class->map = ygtk_link_label_map;
- widget_class->size_request = ygtk_link_label_size_request;
+
+ widget_class->get_preferred_height = ygtk_link_label_get_preferred_height;
+ widget_class->get_preferred_width = ygtk_link_label_get_preferred_width;
+
widget_class->size_allocate = ygtk_link_label_size_allocate;
- widget_class->expose_event = ygtk_link_label_expose_event;
+ widget_class->draw = ygtk_link_label_on_draw;
widget_class->button_press_event = ygtk_link_label_button_press_event;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
Modified: branches/tmp/dmacvicar/gtk/src/ygtkmenubutton.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtkmenubutton.c?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtkmenubutton.c (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtkmenubutton.c Tue Apr 19 00:04:21 2011
@@ -33,7 +33,7 @@
static gboolean ygtk_popup_window_key_press_event (GtkWidget *widget, GdkEventKey *event)
{
- if (event->keyval == GDK_Escape) {
+ if (event->keyval == GDK_KEY_Escape) {
gtk_widget_hide (widget);
return TRUE;
}
Modified: branches/tmp/dmacvicar/gtk/src/ygtkratiobox.c
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/gtk/src/ygtkratiobox.c?rev=63811&r1=63810&r2=63811&view=diff
==============================================================================
--- branches/tmp/dmacvicar/gtk/src/ygtkratiobox.c (original)
+++ branches/tmp/dmacvicar/gtk/src/ygtkratiobox.c Tue Apr 19 00:04:21 2011
@@ -93,10 +93,9 @@
/* We put size_request and _allocate in the same functions for both
orientations because it's just easier to maintain having the
logic in the same place. */
-
-static void ygtk_ratio_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition,
- GtkOrientation orientation)
+static void ygtk_ratio_box_get_preferred_size (GtkWidget *widget,
+ GtkRequisition *requisition,
+ GtkOrientation orientation)
{
requisition->width = requisition->height = 0;
@@ -108,12 +107,13 @@
if (!gtk_widget_get_visible (child->widget))
continue;
- GtkRequisition child_req;
- gtk_widget_size_request (child->widget, &child_req);
+ GtkRequisition min_child_req;
+ GtkRequisition nat_child_req;
+ gtk_widget_get_preferred_size (child->widget, &min_child_req, &nat_child_req);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- requisition->height = MAX (requisition->height, child_req.height);
+ requisition->height = MAX (requisition->height, min_child_req.height);
else
- requisition->width = MAX (requisition->width, child_req.width);
+ requisition->width = MAX (requisition->width, min_child_req.width);
children_nb++;
}
gint spacing = children_nb ? box->spacing*(children_nb-1) : 0;
@@ -164,8 +164,9 @@
if (!gtk_widget_get_visible (child->widget))
continue;
- GtkRequisition child_req;
- gtk_widget_get_child_requisition (child->widget, &child_req);
+ //GtkRequisition min_child_req;
+ //GtkRequisition nat_child_req;
+ //gtk_widget_get_preferred_size (child->widget, &min_child_req, &nat_child_req);
gint child_length = (child->ratio * length) / ratios_sum;
if (!i->next) // last takes rest (any residual length)
@@ -199,7 +200,7 @@
if (child_info) {
gtk_widget_freeze_child_notify (child);
child_info->ratio = ratio;
- if (gtk_widget_get_visible (child) && gtk_widget_get_visible (box))
+ if (gtk_widget_get_visible (child) && gtk_widget_get_visible (GTK_WIDGET(box)))
gtk_widget_queue_resize (child);
gtk_widget_thaw_child_notify (child);
@@ -229,9 +230,29 @@
static void ygtk_ratio_hbox_init (YGtkRatioHBox *box)
{ }
-static void ygtk_ratio_hbox_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{ ygtk_ratio_box_size_request (widget, requisition, GTK_ORIENTATION_HORIZONTAL); }
+static void ygtk_ratio_hbox_get_preferred_size (GtkWidget *widget,
+ GtkRequisition *requisition)
+{ ygtk_ratio_box_get_preferred_size (widget, requisition, GTK_ORIENTATION_HORIZONTAL); }
+
+static void
+ygtk_ratio_hbox_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+ ygtk_ratio_hbox_get_preferred_size (widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void
+ygtk_ratio_hbox_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+ ygtk_ratio_hbox_get_preferred_size (widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
static void ygtk_ratio_hbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -249,7 +270,9 @@
ygtk_ratio_hbox_parent_class = (YGtkRatioBoxClass*) g_type_class_peek_parent (klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->size_request = ygtk_ratio_hbox_size_request;
+ widget_class->get_preferred_width = ygtk_ratio_hbox_get_preferred_width;
+ widget_class->get_preferred_height = ygtk_ratio_hbox_get_preferred_height;
+
widget_class->size_allocate = ygtk_ratio_hbox_size_allocate;
}
@@ -260,9 +283,29 @@
static void ygtk_ratio_vbox_init (YGtkRatioVBox *box)
{ }
-static void ygtk_ratio_vbox_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{ ygtk_ratio_box_size_request (widget, requisition, GTK_ORIENTATION_VERTICAL); }
+static void ygtk_ratio_vbox_get_preferred_size (GtkWidget *widget,
+ GtkRequisition *requisition)
+{ ygtk_ratio_box_get_preferred_size (widget, requisition, GTK_ORIENTATION_VERTICAL); }
+
+static void
+ygtk_ratio_vbox_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+ ygtk_ratio_vbox_get_preferred_size (widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void
+ygtk_ratio_vbox_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+ ygtk_ratio_vbox_get_preferred_size (widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
static void ygtk_ratio_vbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -280,7 +323,8 @@
ygtk_ratio_vbox_parent_class = g_type_class_peek_parent (klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->size_request = ygtk_ratio_vbox_size_request;
+ widget_class->get_preferred_width = ygtk_ratio_vbox_get_preferred_width;
+ widget_class->get_preferred_height = ygtk_ratio_vbox_get_preferred_height;
widget_class->size_allocate = ygtk_ratio_vbox_size_allocate;
}
@@ -294,8 +338,8 @@
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (adj_size), FALSE);
}
-static void ygtk_adj_size_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+static void ygtk_adj_size_get_preferredsize (GtkWidget *widget,
+ GtkRequisition *requisition)
{
GtkWidget *child = gtk_bin_get_child(GTK_BIN (widget));
requisition->width = requisition->height = 0;
@@ -327,6 +371,27 @@
}
}
+static void
+ygtk_adj_size_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+ ygtk_adj_size_get_preferred_size (widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void
+ygtk_adj_size_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+ ygtk_adj_size_get_preferred_size (widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+
+
static void ygtk_adj_size_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
@@ -378,7 +443,8 @@
ygtk_adj_size_parent_class = g_type_class_peek_parent (klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->size_request = ygtk_adj_size_size_request;
+ widget_class->get_preferred_width = ygtk_adj_size_get_preferred_width;
+ widget_class->get_preferred_height = ygtk_adj_size_get_preferred_height;
widget_class->size_allocate = ygtk_adj_size_size_allocate;
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org