gtksourceview r2282 - in branches/gtksourcecompletion: gtksourceview tests
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gtksourceview r2282 - in branches/gtksourcecompletion: gtksourceview tests
- Date: Mon, 13 Apr 2009 23:45:12 +0000 (UTC)
Author: jessevdk
Date: Mon Apr 13 23:45:11 2009
New Revision: 2282
URL: http://svn.gnome.org/viewvc/gtksourceview?rev=2282&view=rev
Log:
Fixed showing custom info widget
Implemented custom devhelp widget showing proposal information
Modified:
branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c
branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c
branches/gtksourcecompletion/tests/gsc-provider-devhelp.c
Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c (original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c Mon Apr 13 23:45:11 2009
@@ -682,6 +682,7 @@
{
GtkWidget *info_widget;
const gchar *text;
+ gboolean prov_update_info = FALSE;
if (proposal == NULL)
{
@@ -702,10 +703,21 @@
gtk_label_set_markup (GTK_LABEL (info_widget), text != NULL ? text : "");
}
+ else
+ {
+ prov_update_info = TRUE;
+ }
}
gtk_source_completion_info_set_widget (GTK_SOURCE_COMPLETION_INFO (completion->priv->info_window),
info_widget);
+
+ if (prov_update_info)
+ {
+ gtk_source_completion_provider_update_info (provider,
+ proposal,
+ GTK_SOURCE_COMPLETION_INFO (completion->priv->info_window));
+ }
}
static void
@@ -1430,7 +1442,7 @@
/**
* GtkSourceCompletion:auto-complete-delay:
*
- * The auto completion delay when typing
+ * The auto completion delay (in milliseconds)
*/
g_object_class_install_property (object_class,
PROP_AUTO_COMPLETE_DELAY,
@@ -1439,7 +1451,7 @@
_("Auto completion delay when typing"),
0,
G_MAXUINT,
- 500,
+ 250,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/**
* GtkSourceCompletion:min-len:
@@ -1761,6 +1773,10 @@
/* Info window */
completion->priv->info_window = GTK_WIDGET (gtk_source_completion_info_new ());
+ gtk_window_set_default_size (GTK_WINDOW (completion->priv->info_window),
+ 500,
+ 400);
+
g_signal_connect (completion,
"notify::transient-for",
G_CALLBACK (update_transient_for_info),
Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c (original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletioninfo.c Mon Apr 13 23:45:11 2009
@@ -453,7 +453,8 @@
if (self->priv->widget != NULL)
{
child = gtk_bin_get_child (GTK_BIN (self->priv->scroll));
-
+ g_signal_handler_disconnect (self->priv->widget, self->priv->request_id);
+
if (child != self->priv->widget)
{
gtk_container_remove (GTK_CONTAINER (child), self->priv->widget);
@@ -464,8 +465,6 @@
gtk_container_remove (GTK_CONTAINER (self->priv->scroll),
self->priv->widget);
}
-
- g_signal_handler_disconnect (self->priv->widget, self->priv->request_id);
}
self->priv->widget = widget;
@@ -485,11 +484,11 @@
child = gtk_viewport_new (NULL, NULL);
gtk_widget_show (child);
+ /* Keep it alive */
+ g_object_ref (widget);
gtk_container_add (GTK_CONTAINER (child), widget);
}
-
-
gtk_container_add (GTK_CONTAINER (self->priv->scroll), child);
gtk_widget_show (widget);
}
Modified: branches/gtksourcecompletion/tests/gsc-provider-devhelp.c
==============================================================================
--- branches/gtksourcecompletion/tests/gsc-provider-devhelp.c (original)
+++ branches/gtksourcecompletion/tests/gsc-provider-devhelp.c Mon Apr 13 23:45:11 2009
@@ -1,6 +1,7 @@
#include "gsc-provider-devhelp.h"
#include <devhelp/dh-base.h>
#include <devhelp/dh-link.h>
+#include <devhelp/dh-html.h>
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourcecompletionitem.h>
@@ -9,6 +10,8 @@
struct _GscProviderDevhelpPrivate
{
DhBase *dhbase;
+ DhHtml *dhhtml;
+
GList *proposals;
};
@@ -53,6 +56,27 @@
return TRUE;
}
+static GtkWidget *
+gsc_provider_devhelp_get_info_widget (GtkSourceCompletionProvider *provider,
+ GtkSourceCompletionProposal *proposal)
+{
+ return dh_html_get_widget (GSC_PROVIDER_DEVHELP (provider)->priv->dhhtml);
+}
+
+static void
+gsc_provider_devhelp_update_info (GtkSourceCompletionProvider *provider,
+ GtkSourceCompletionProposal *proposal,
+ GtkSourceCompletionInfo *info)
+{
+ GscProviderDevhelp *self = GSC_PROVIDER_DEVHELP (provider);
+ const gchar *uri;
+
+ uri = gtk_source_completion_proposal_get_info (proposal);
+
+ dh_html_open_uri (GSC_PROVIDER_DEVHELP (provider)->priv->dhhtml, uri);
+ dh_html_set_zoom (self->priv->dhhtml, 0.5);
+}
+
static void
gsc_provider_devhelp_iface_init (GtkSourceCompletionProviderIface *iface)
{
@@ -60,6 +84,9 @@
iface->get_proposals = gsc_provider_devhelp_get_proposals;
iface->can_auto_complete = gsc_provider_devhelp_can_auto_complete;
iface->filter_proposal = gsc_provider_devhelp_filter_proposal;
+
+ iface->get_info_widget = gsc_provider_devhelp_get_info_widget;
+ iface->update_info = gsc_provider_devhelp_update_info;
}
static void
@@ -68,6 +95,7 @@
GscProviderDevhelp *provider = GSC_PROVIDER_DEVHELP (object);
g_object_unref (provider->priv->dhbase);
+ g_object_unref (provider->priv->dhhtml);
g_list_foreach (provider->priv->proposals, (GFunc)g_object_unref, NULL);
G_OBJECT_CLASS (gsc_provider_devhelp_parent_class)->finalize (object);
@@ -83,14 +111,6 @@
g_type_class_add_private (object_class, sizeof(GscProviderDevhelpPrivate));
}
-static gchar *
-name_from_link (gpointer data)
-{
- DhLink *link = (DhLink *)data;
-
- return link->name;
-}
-
static void
gsc_provider_devhelp_init (GscProviderDevhelp *self)
{
@@ -110,6 +130,9 @@
ret = g_list_prepend (ret, gtk_source_completion_item_new (link->name, NULL, link->uri));
}
+
+ self->priv->dhhtml = dh_html_new ();
+
self->priv->proposals = g_list_reverse (ret);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]