Author: rpmcruz
Date: Tue Oct 14 23:42:58 2008
New Revision: 52204
URL: http://svn.opensuse.org/viewcvs/yast?rev=52204&view=rev
Log:
* src/YGUI.h: enable rich text tables for webkit.
* src/ygtkhtmlwrap.c: replace it's popup which has entries like "go back" and
"reload" for one with only "copy" and "select all".
* src/YGPackageSelector.cc: use YGtkRichText for descriptions. WebKit
doesn't implement size_request and hacking it through seems futile. We'll
have to patch it up if we want that in the future.
* src/yzyppwrapper.h/.cc: added "rich" argument to requires() and provides(),
in order to escape html characters, responsible for the small size of those
lists ;) (they were being truncated).
* configure.in.in: it seems there are both the "WebKitGtk" and "webkit-1.0"
from OSS and Gnome-Community repos. Check for both.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/configure.in.in
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGUI.h
trunk/gtk/src/ygtkhtmlwrap.c
trunk/gtk/src/yzyppwrapper.cc
trunk/gtk/src/yzyppwrapper.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=52204&r1=52203&r2=52204&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Tue Oct 14 23:42:58 2008
@@ -1,3 +1,21 @@
+2008-10-14 Ricardo Cruz
+
+ * src/YGUI.h: enable rich text tables for webkit.
+
+ * src/ygtkhtmlwrap.c: replace it's popup which has entries like "go back" and
+ "reload" for one with only "copy" and "select all".
+
+ * src/YGPackageSelector.cc: use YGtkRichText for descriptions. WebKit
+ doesn't implement size_request and hacking it through seems futile. We'll
+ have to patch it up if we want that in the future.
+
+ * src/yzyppwrapper.h/.cc: added "rich" argument to requires() and provides(),
+ in order to escape html characters, responsible for the small size of those
+ lists ;) (they were being truncated).
+
+ * configure.in.in: it seems there are both the "WebKitGtk" and "webkit-1.0"
+ from OSS and Gnome-Community repos. Check for both.
+
2008-10-13 Ricardo Cruz
* src/YGUtils.h/cc & src/ygtkrichtext.h/c: moved convert_to_xhmtl
Modified: trunk/gtk/configure.in.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/configure.in.in?rev=52204&r1=52203&r2=52204&view=diff
==============================================================================
--- trunk/gtk/configure.in.in (original)
+++ trunk/gtk/configure.in.in Tue Oct 14 23:42:58 2008
@@ -48,8 +48,15 @@
if test "z$with_html_engine" = "zwebkit"; then
use_webkit=true
+ AC_MSG_CHECKING([pkg-config])
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+
AC_MSG_CHECKING([for webkit])
- PKG_CHECK_MODULES( WEBKIT, webkit-1.0 )
+ if $PKG_CONFIG --exists webkit-1.0 ; then
+ PKG_CHECK_MODULES( WEBKIT, webkit-1.0 )
+ else
+ PKG_CHECK_MODULES( WEBKIT, WebKitGtk )
+ fi
AC_SUBST(WEBKIT_CFLAGS)
AC_SUBST(WEBKIT_LIBS)
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=52204&r1=52203&r2=52204&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Tue Oct 14 23:42:58 2008
@@ -19,6 +19,7 @@
#include "ygtkscrolledwindow.h"
#include "ygtktogglebutton.h"
#include "ygtkhtmlwrap.h"
+#include "ygtkrichtext.h"
#include "ygtkhandlebox.h"
#include "ygtktooltip.h"
#include "ygtkzyppwrapper.h"
@@ -386,8 +387,9 @@
inner::appendItem (menu, 0, 0, GTK_STOCK_SELECT_ALL, 0,
true, inner::select_all_cb, this);
- gtk_widget_show_all (menu);
+ gtk_menu_attach_to_widget (GTK_MENU (menu), m_widget, NULL);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time);
+ gtk_widget_show_all (menu);
}
static gboolean popup_key_cb (GtkWidget *widget, View *pThis)
@@ -1941,25 +1943,26 @@
TextExpander (const char *name)
{
- text = ygtk_html_wrap_new();
-
+ text = ygtk_rich_text_new();
if (name) {
string str = string ("<b>") + name + "</b>";
expander = gtk_expander_new (str.c_str());
gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE);
gtk_container_add (GTK_CONTAINER (expander), text);
- }
+ }
else
expander = NULL;
}
void setText (const std::string &str)
{
- ygtk_html_wrap_set_text (text, str.c_str(), FALSE);
+ ygtk_rich_text_set_text (YGTK_RICH_TEXT (text), str.c_str(), FALSE);
if (expander)
str.empty() ? gtk_widget_hide (expander) : gtk_widget_show (expander);
}
};
+
+
struct DepExpander {
GtkWidget *expander, *table, *requires, *provides;
@@ -1967,8 +1970,8 @@
DepExpander (const char *name)
{
- requires = ygtk_html_wrap_new();
- provides = ygtk_html_wrap_new();
+ requires = ygtk_rich_text_new();
+ provides = ygtk_rich_text_new();
table = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (table), requires, TRUE, TRUE, 0);
@@ -1986,15 +1989,15 @@
std::string requires_str = _("Requires:");
std::string provides_str = _("Provides:");
requires_str += "<br><blockquote>";
- requires_str += package->requires();
+ requires_str += package->requires (true);
YGUtils::replace (provides_str, "\n", 1, "<br>");
requires_str += "</blockquote>";
provides_str += "<br><blockquote>";
- provides_str += package->provides();
+ provides_str += package->provides (true);
YGUtils::replace (requires_str, "\n", 1, "<br>");
provides_str += "</blockquote>";
- ygtk_html_wrap_set_text (requires, requires_str.c_str(), FALSE);
- ygtk_html_wrap_set_text (provides, provides_str.c_str(), FALSE);
+ ygtk_rich_text_set_text (YGTK_RICH_TEXT (requires), requires_str.c_str(), FALSE);
+ ygtk_rich_text_set_text (YGTK_RICH_TEXT (provides), provides_str.c_str(), FALSE);
gtk_widget_show (expander);
}
else
@@ -2022,16 +2025,12 @@
GtkWidget *hbox = gtk_hbox_new (FALSE, 6);
m_description = new TextExpander (NULL);
- ygtk_html_wrap_connect_link_clicked (m_description->text,
- G_CALLBACK (description_pressed_cb), this);
+ g_signal_connect (G_OBJECT (m_description->text), "link-clicked",
+ G_CALLBACK (link_pressed_cb), this);
gtk_box_pack_start (GTK_BOX (hbox), m_description->getWidget(), TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), createIconWidget (&m_icon, &m_icon_frame),
FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE /* debug */, TRUE, 0);
-// it looks like webkit and gtkhtml have no size_request ?!
-// they must have -- I guess it's just transmited somewhere else...
-
-// CHECK!!
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
if (!update_mode) {
m_filelist = new TextExpander (_("File List"));
@@ -2043,8 +2042,8 @@
gtk_box_pack_start (GTK_BOX (vbox), m_authors->getWidget(), FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), m_dependencies->getWidget(), FALSE, TRUE, 0);
if (CAN_OPEN_URIS())
- ygtk_html_wrap_connect_link_clicked (m_filelist->text,
- G_CALLBACK (path_pressed_cb), NULL);
+ g_signal_connect (G_OBJECT (m_filelist->text), "link-clicked",
+ G_CALLBACK (link_pressed_cb), this);
}
else {
m_filelist = m_changelog = m_authors = NULL;
@@ -2066,35 +2065,17 @@
return;
Ypp::Package *package = packages.front();
-// gtk_widget_hide (m_icon_frame);
+ gtk_widget_hide (m_icon_frame);
if (packages.single()) {
string description = "<b>" + package->name() + "</b><br>";
description += package->description (true);
m_description->setText (description);
-
-/*
-// TODO: WebKit doesn't implement size_request or many others (like gtkhtml)
-// what we want to do is to use set_scroll_adjustment like GtkScrolledWindow and
-//set our own (copy from scorlled window) to it, so we can read its values. Then
-// set_size_request() from there.
-
-
-GtkAdjustment hadj, vadj;
-WEBKIT_WEB_VIEW_CLASS (m_description->text)->set_scroll_adjustments (WEBKIT_WEB_VIEW, &hadj, &vadj);
-
-*/
-
-
-GtkRequisition req;
-gtk_widget_size_request (m_description->text, &req);
-fprintf (stderr, "description size: %d x %d\n", req.width, req.height);
-
if (m_filelist) m_filelist->setText (package->filelist (true));
if (m_changelog) m_changelog->setText (package->changelog());
if (m_authors) m_authors->setText (package->authors (true));
if (m_dependencies) m_dependencies->setPackage (package);
-#if 0
+
gtk_image_clear (GTK_IMAGE (m_icon));
GtkIconTheme *icons = gtk_icon_theme_get_default();
GdkPixbuf *pixbuf = gtk_icon_theme_load_icon (icons,
@@ -2104,7 +2085,7 @@
g_object_unref (G_OBJECT (pixbuf));
gtk_widget_show (m_icon_frame);
}
-#endif
+
scrollTop();
}
else {
@@ -2123,11 +2104,7 @@
}
private:
- static void path_pressed_cb (GtkWidget *text, const gchar *link)
- { OPEN_URI (link); }
-
- static void description_pressed_cb (GtkWidget *text, const gchar *link,
- PackageDetails *pThis)
+ static void link_pressed_cb (GtkWidget *text, const gchar *link, PackageDetails *pThis)
{
if (!strncmp (link, "pkg://", 6)) {
const gchar *pkg_name = link + 6;
Modified: trunk/gtk/src/YGUI.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.h?rev=52204&r1=52203&r2=52204&view=diff
==============================================================================
--- trunk/gtk/src/YGUI.h (original)
+++ trunk/gtk/src/YGUI.h Tue Oct 14 23:42:58 2008
@@ -229,7 +229,11 @@
virtual bool hasAnimationSupport() IMPL_RET (true)
virtual bool hasIconSupport() IMPL_RET (true)
virtual bool hasFullUtf8Support() IMPL_RET (true)
+#ifdef USE_WEBKIT
+ virtual bool richTextSupportsTable() IMPL_RET (true)
+#else
virtual bool richTextSupportsTable() IMPL_RET (false)
+#endif
private:
// for screenshots:
Modified: trunk/gtk/src/ygtkhtmlwrap.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkhtmlwrap.c?rev=52204&r1=52203&r2=52204&view=diff
==============================================================================
--- trunk/gtk/src/ygtkhtmlwrap.c (original)
+++ trunk/gtk/src/ygtkhtmlwrap.c Tue Oct 14 23:42:58 2008
@@ -13,35 +13,93 @@
// ygutils
#include
void ygutils_scrollAdj (GtkAdjustment *vadj, gboolean top);
+
GtkWidget *ygtk_html_wrap_new (void)
-{ return g_object_new (ygtk_html_wrap_get_type(), NULL); }
+{
+ GtkWidget *widget = g_object_new (ygtk_html_wrap_get_type(), NULL);
+ ygtk_html_wrap_init (widget);
+ return widget;
+}
//** WebKit
#ifdef USE_WEBKIT
-#include
+#include
GType ygtk_html_wrap_get_type()
{
return WEBKIT_TYPE_WEB_VIEW;
}
+static void copy_activate_cb (GtkMenuItem *item, WebKitWebView *view)
+{ webkit_web_view_copy_clipboard (view); }
+static void select_all_activate_cb (GtkMenuItem *item, WebKitWebView *view)
+{ webkit_web_view_select_all (view); }
+
+static gboolean button_press_event_cb (GtkWidget *widget, GdkEventButton *event,
+ WebKitWebView *view)
+{
+ if (event && event->button != 3)
+ return FALSE;
+ // GtkMenu API is horrible for non-persistant menus. Make it persistant.
+ static GtkWidget *menu = 0;
+ if (menu)
+ gtk_widget_destroy (menu);
+ menu = gtk_menu_new();
+ // add a couple of items (based on GtkTextView)
+ GtkWidget *item;
+ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ if (webkit_web_view_can_copy_clipboard (view))
+ g_signal_connect (item, "activate", G_CALLBACK (copy_activate_cb), widget);
+ else
+ gtk_widget_set_sensitive (item, FALSE);
+ item = gtk_separator_menu_item_new();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SELECT_ALL, NULL);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ g_signal_connect (item, "activate", G_CALLBACK (select_all_activate_cb), widget);
+
+ int button, event_time;
+ if (event) {
+ button = event->button;
+ event_time = event->time;
+ }
+ else {
+ button = 0;
+ event_time = gtk_get_current_event_time();
+ }
+ gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time);
+ gtk_widget_show_all (menu);
+ return TRUE;
+}
+
+static gboolean popup_menu_cb (GtkWidget *widget, WebKitWebView *view)
+{
+ button_press_event_cb (widget, NULL, view);
+ return TRUE;
+}
+
+static gboolean button_release_event_cb (GtkWidget *widget, GdkEventButton *event)
+{
+ if (event->button != 3) return FALSE;
+ return TRUE;
+}
+
void ygtk_html_wrap_init (GtkWidget *widget)
{
-// TODO: capture populate menu to get rid of "search web" entry
-#if 0
- webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup",
- G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_MENU);
-#endif
+ /* WebKit popup menu has entries such as "reload", "go back" and "search web"
+ that we rather not show. "popup-menu" isn't working, use gtkwidget stuff... */
+ g_signal_connect (G_OBJECT (widget), "popup-menu",
+ G_CALLBACK (popup_menu_cb), widget);
+ g_signal_connect (G_OBJECT (widget), "button-press-event",
+ G_CALLBACK (button_press_event_cb), widget);
+ // webkit crashes if we don't overload the release event as well
+ g_signal_connect (G_OBJECT (widget), "button-release-event",
+ G_CALLBACK (button_release_event_cb), widget);
}
-// CSS based on properties from YGtkRichText
+// CSS based on properties from YGtkRichText (from Yelp)
const char *CSS = "