Added info buttons and apis to enable/disable them + signals emitted to

* src/glade-editor-property.[ch]: Added info buttons and
	  apis to enable/disable them + signals emitted to say what
	  doc book, page and searchstring should be used

	* src/glade-editor.[ch]: Same as glade-editor-property

	* src/glade-utils.c: Added functions for detecting and launching devhelp

	* src/glade-project-window.c: Check if we have devhelp installed; if we do
	  then show help buttons and launch devhelp upon "gtk-doc-search" signals

	* pixmaps/devhelp.png, pixmaps/Makefile.am: Added devhelp book icon

	* src/glade-app.c: Replace a gtk_widget_show_all with a gtk_widget_show
	  on the editor (to avoid needlessly showing hidden buttons).

	* src/glade-project.c: translated property nicks and blurbs.

	* src/glade-property-class.[ch]: Added 'virtual' member and resolve
	  it at initialization.

	* src/glade-widget-class.c: use g_build_filename instead of
	  g_strdup_printf for icon loading.
dified Files:
This commit is contained in:
Tristan Van Berkom 2006-04-28 02:05:35 +00:00
parent 1b58a8af1b
commit dd9622eed8
17 changed files with 638 additions and 32 deletions

View File

@ -1,3 +1,29 @@
2006-04-26 Tristan Van Berkom <tvb@gnome.org>
* src/glade-editor-property.[ch]: Added info buttons and
apis to enable/disable them + signals emitted to say what
doc book, page and searchstring should be used
* src/glade-editor.[ch]: Same as glade-editor-property
* src/glade-utils.c: Added functions for detecting and launching devhelp
* src/glade-project-window.c: Check if we have devhelp installed; if we do
then show help buttons and launch devhelp upon "gtk-doc-search" signals
* pixmaps/devhelp.png, pixmaps/Makefile.am: Added devhelp book icon
* src/glade-app.c: Replace a gtk_widget_show_all with a gtk_widget_show
on the editor (to avoid needlessly showing hidden buttons).
* src/glade-project.c: translated property nicks and blurbs.
* src/glade-property-class.[ch]: Added 'virtual' member and resolve
it at initialization.
* src/glade-widget-class.c: use g_build_filename instead of
g_strdup_printf for icon loading.
2006-04-26 Tristan Van Berkom <tvb@gnome.org>
* configure.in: Relesed 2.91.1, now we are working on 2.91.2
@ -24,6 +50,21 @@
* src/glade-widget.c: Synonymous '-' and '_' in glade_widget_get_[packing_]property().
2006-04-25 Tristan Van Berkom <tvb@gnome.org>
* src/Makefile.am: added atk.xpm to $(libgladeuiinclude_HEADERS)
* doc/gladeui-sections.txt: Updated with new apis.
* widgets/gtk+.xml.in: Listed all atk action properties needed for the gtk
catalog.
* src/glade-property-class.c, src/glade.h: Added GLADE_TAG_ATK_ACTION &
GLADE_TAG_ATK_PROPERTY tag support and stripped out introspection on atk
properties.
* src/main.c: backed out the "GTK_MODULES=$GTK_MODULES:gail" module loading thing.
2006-04-25 Tristan Van Berkom <tvb@gnome.org>
* src/glade-builtins.c: Allowed negative custom integer specs.

View File

@ -56,6 +56,7 @@ pixmaps_DATA = \
vscale.png \
vscrollbar.png \
vseparator.png \
window.png
window.png \
devhelp.png
EXTRA_DIST = $(pixmaps_DATA)

BIN
pixmaps/devhelp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

View File

@ -369,7 +369,7 @@ glade_app_init (GladeApp *app)
app->priv->editor = GLADE_EDITOR (glade_editor_new ());
g_object_ref (app->priv->editor);
gtk_object_sink (GTK_OBJECT (app->priv->editor));
gtk_widget_show_all (GTK_WIDGET (app->priv->editor));
gtk_widget_show (GTK_WIDGET (app->priv->editor));
glade_editor_refresh (app->priv->editor);
/* Create clipboard */

View File

@ -36,13 +36,19 @@
#include "glade-command.h"
#include "glade-project.h"
#include "glade-builtins.h"
#include "glade-marshallers.h"
enum {
PROP_0,
PROP_PROPERTY_CLASS,
PROP_USE_COMMAND
PROP_USE_COMMAND,
PROP_SHOW_INFO
};
enum {
GTK_DOC_SEARCH,
LAST_SIGNAL
};
static GtkTableClass *table_class;
static GladeEditorPropertyClass *editor_property_class;
@ -53,6 +59,7 @@ static GladeEditorPropertyClass *editor_property_class;
static GdkColor *insensitive_colour = NULL;
static GdkColor *normal_colour = NULL;
static guint glade_editor_property_signals[LAST_SIGNAL] = { 0 };
#define GLADE_PROPERTY_TABLE_ROW_SPACING 2
#define FLAGS_COLUMN_SETTING 0
@ -224,6 +231,60 @@ glade_editor_property_enabled_toggled_cb (GtkWidget *check,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
}
static const gchar *
glade_editor_property_guess_bookname (GladeEditorProperty *eprop)
{
gchar *guess = NULL;
GladeWidget *gwidget;
g_return_val_if_fail (GLADE_IS_PROPERTY (eprop->property), NULL);
g_return_val_if_fail (GLADE_IS_WIDGET (eprop->property->widget), NULL);
gwidget = eprop->property->widget;
if (GTK_IS_WIDGET (gwidget->object))
guess = "gtk";
return guess;
}
static void
glade_editor_property_info_clicked_cb (GtkWidget *info,
GladeEditorProperty *eprop)
{
gchar *search;
search = g_strdup_printf ("The %s property", eprop->property->class->id);
g_signal_emit (G_OBJECT (eprop),
glade_editor_property_signals[GTK_DOC_SEARCH],
0,
glade_editor_property_guess_bookname (eprop),
g_type_name (eprop->class->pspec->owner_type), search);
g_free (search);
}
static GtkWidget *
glade_editor_property_create_info_button (GladeEditorProperty *eprop)
{
GtkWidget *image, *button;
gchar *path;
path = g_build_filename (glade_pixmaps_dir, "devhelp.png", NULL);
button = gtk_button_new ();
image = gtk_image_new_from_file (path);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_container_set_border_width (GTK_CONTAINER (button), 1);
g_free (path);
return button;
}
static GObject *
glade_editor_property_constructor (GType type,
guint n_construct_properties,
@ -261,9 +322,22 @@ glade_editor_property_constructor (GType type,
G_CALLBACK (glade_editor_property_enabled_toggled_cb), eprop);
}
/* Create the class specific input widget and add it */
eprop->input = GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->create_input (eprop);
gtk_widget_show (eprop->input);
gtk_box_pack_start (GTK_BOX (eprop), eprop->input, TRUE, TRUE, 0);
/* Create the informational button and add it */
eprop->info = glade_editor_property_create_info_button (eprop);
gtk_widget_show (eprop->info);
g_signal_connect (G_OBJECT (eprop->info), "clicked",
G_CALLBACK (glade_editor_property_info_clicked_cb), eprop);
gtk_box_pack_start (GTK_BOX (eprop), eprop->info, FALSE, FALSE, 2);
return obj;
}
@ -294,6 +368,12 @@ glade_editor_property_set_property (GObject *object,
case PROP_USE_COMMAND:
eprop->use_command = g_value_get_boolean (value);
break;
case PROP_SHOW_INFO:
if (g_value_get_boolean (value))
glade_editor_property_show_info (eprop);
else
glade_editor_property_hide_info (eprop);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -316,6 +396,8 @@ glade_editor_property_get_property (GObject *object,
case PROP_USE_COMMAND:
g_value_set_boolean (value, eprop->use_command);
break;
case PROP_SHOW_INFO:
g_value_set_boolean (value, eprop->show_info);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -439,6 +521,18 @@ glade_editor_property_class_init (GladeEditorPropertyClass *eprop_class)
eprop_class->load = glade_editor_property_load_common;
eprop_class->create_input = NULL;
/* Signals */
glade_editor_property_signals[GTK_DOC_SEARCH] =
g_signal_new ("gtk-doc-search",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GladeEditorPropertyClass,
gtk_doc_search),
NULL, NULL,
glade_marshal_VOID__STRING_STRING_STRING,
G_TYPE_NONE, 3,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
/* Properties */
g_object_class_install_property
(object_class, PROP_PROPERTY_CLASS,
@ -454,6 +548,13 @@ glade_editor_property_class_init (GladeEditorPropertyClass *eprop_class)
_("Whether we should use the command API for the undo/redo stack"),
FALSE, G_PARAM_READWRITE));
g_object_class_install_property
(object_class, PROP_SHOW_INFO,
g_param_spec_boolean
("show-info", _("Show Info"),
_("Whether we should show an informational button"),
FALSE, G_PARAM_READWRITE));
/* Resolve label colors once class wide.
*/
label = gtk_label_new ("");
@ -602,7 +703,8 @@ glade_eprop_numeric_create_input (GladeEditorProperty *eprop)
G_IS_PARAM_SPEC_FLOAT (eprop->class->pspec) ||
G_IS_PARAM_SPEC_DOUBLE (eprop->class->pspec)
? 2 : 0);
gtk_widget_show (eprop_numeric->spin);
g_signal_connect (G_OBJECT (eprop_numeric->spin), "value_changed",
G_CALLBACK (glade_eprop_numeric_changed),
eprop);
@ -755,6 +857,8 @@ glade_eprop_enum_create_input (GladeEditorProperty *eprop)
eprop_enum->option_menu = gtk_option_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (eprop_enum->option_menu), menu);
gtk_widget_show_all (eprop_enum->option_menu);
g_type_class_unref (eclass);
return eprop_enum->option_menu;
@ -1017,9 +1121,10 @@ glade_eprop_flags_create_input (GladeEditorProperty *eprop)
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
button = gtk_button_new_with_label ("...");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show_all (hbox);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (glade_eprop_flags_show_dialog),
eprop);
@ -1472,17 +1577,19 @@ glade_eprop_text_create_input (GladeEditorProperty *eprop)
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow), GTK_SHADOW_IN);
eprop_text->text_entry = gtk_text_view_new ();
gtk_widget_show (eprop_text->text_entry);
gtk_container_add (GTK_CONTAINER (swindow), eprop_text->text_entry);
gtk_container_add (GTK_CONTAINER (swindow), eprop_text->text_entry);
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (swindow), TRUE, TRUE, 0);
gtk_widget_show_all (swindow);
g_signal_connect (G_OBJECT (eprop_text->text_entry), "focus-out-event",
G_CALLBACK (glade_eprop_text_text_view_focus_out),
eprop);
} else {
eprop_text->text_entry = gtk_entry_new ();
gtk_widget_show (eprop_text->text_entry);
gtk_box_pack_start (GTK_BOX (hbox), eprop_text->text_entry, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (eprop_text->text_entry), "activate",
@ -1496,6 +1603,7 @@ glade_eprop_text_create_input (GladeEditorProperty *eprop)
if (class->translatable) {
GtkWidget *button = gtk_button_new_with_label ("...");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (glade_eprop_text_show_i18n_dialog),
@ -2769,12 +2877,14 @@ glade_eprop_adjustment_create_input (GladeEditorProperty *eprop)
glade_eprop_adjustment_table_add_label (table, 5, _("Page size :"),
_("The page size (in a GtkScrollbar this is the size of the area which is currently visible)"));
gtk_table_attach_defaults (table, eprop_adj->value, 1, 2, 0, 1);
gtk_table_attach_defaults (table, eprop_adj->lower, 1, 2, 1, 2);
gtk_table_attach_defaults (table, eprop_adj->upper, 1, 2, 2, 3);
gtk_table_attach_defaults (table, eprop_adj->value, 1, 2, 0, 1);
gtk_table_attach_defaults (table, eprop_adj->lower, 1, 2, 1, 2);
gtk_table_attach_defaults (table, eprop_adj->upper, 1, 2, 2, 3);
gtk_table_attach_defaults (table, eprop_adj->step_increment, 1, 2, 3, 4);
gtk_table_attach_defaults (table, eprop_adj->page_increment, 1, 2, 4, 5);
gtk_table_attach_defaults (table, eprop_adj->page_size, 1, 2, 5, 6);
gtk_table_attach_defaults (table, eprop_adj->page_size, 1, 2, 5, 6);
gtk_widget_show_all (widget);
return widget;
}
@ -2961,3 +3071,33 @@ glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
}
glade_editor_property_load (eprop, property);
}
void
glade_editor_property_show_info (GladeEditorProperty *eprop)
{
g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
/* Just pretend to show these properties.
*/
if (eprop->class->virtual == FALSE)
gtk_widget_show (eprop->info);
else
{
gtk_widget_show (eprop->info);
gtk_widget_set_sensitive (eprop->info, FALSE);
}
eprop->show_info = TRUE;
g_object_notify (G_OBJECT (eprop), "show-info");
}
void
glade_editor_property_hide_info (GladeEditorProperty *eprop)
{
g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
gtk_widget_hide (eprop->info);
eprop->show_info = FALSE;
g_object_notify (G_OBJECT (eprop), "show-info");
}

View File

@ -33,6 +33,8 @@ struct _GladeEditorProperty {
GtkWidget *check; /* Check button for optional properties.
*/
GtkWidget *info; /* Informational button
*/
gulong tooltip_id; /* signal connection id for tooltip changes */
gulong sensitive_id; /* signal connection id for sensitivity changes */
@ -48,6 +50,10 @@ struct _GladeEditorProperty {
* or skip directly to GladeProperty interface.
* (used for query dialogs).
*/
gboolean show_info; /* Whether we should show an informational button for this
* property
*/
};
struct _GladeEditorPropertyClass {
@ -57,6 +63,12 @@ struct _GladeEditorPropertyClass {
/* private */
GtkWidget *(* create_input) (GladeEditorProperty *);
void (* gtk_doc_search)(GladeEditorProperty *,
const gchar *,
const gchar *,
const gchar *);
};
@ -66,6 +78,10 @@ LIBGLADEUI_API
GladeEditorProperty *glade_editor_property_new (GladePropertyClass *class,
gboolean use_command);
LIBGLADEUI_API
GladeEditorProperty *glade_editor_property_new_from_widget (GladeWidget *widget,
const gchar *property,
gboolean use_command);
LIBGLADEUI_API
void glade_editor_property_load (GladeEditorProperty *eprop,
GladeProperty *property);
LIBGLADEUI_API
@ -73,10 +89,9 @@ void glade_editor_property_load_by_widget (GladeEditorProperty *
GladeWidget *widget);
LIBGLADEUI_API
gboolean glade_editor_property_supported (GParamSpec *pspec);
LIBGLADEUI_API
GladeEditorProperty *glade_editor_property_new_from_widget (GladeWidget *widget,
const gchar *property,
gboolean use_command);
void glade_editor_property_show_info (GladeEditorProperty *eprop);
LIBGLADEUI_API
void glade_editor_property_hide_info (GladeEditorProperty *eprop);
#endif // __GLADE_EDITOR_PROPERTY_H__

View File

@ -45,14 +45,128 @@
#include "glade-editor-property.h"
#include "atk.xpm"
enum
{
PROP_0,
PROP_SHOW_INFO,
PROP_SHOW_CONTEXT_INFO
};
enum {
GTK_DOC_SEARCH,
LAST_SIGNAL
};
static GtkVBoxClass *parent_class = NULL;
static guint glade_editor_signals[LAST_SIGNAL] = { 0 };
static void glade_editor_reset_dialog (GladeEditor *editor);
static void
glade_editor_gtk_doc_search_cb (GladeEditorProperty *eprop,
const gchar *book,
const gchar *page,
const gchar *search,
GladeEditor *editor)
{
/* Just act as a hub for search signals here */
g_signal_emit (G_OBJECT (editor),
glade_editor_signals[GTK_DOC_SEARCH],
0, book, page, search);
}
static void
glade_editor_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GladeEditor *editor = GLADE_EDITOR (object);
switch (prop_id)
{
case PROP_SHOW_INFO:
if (g_value_get_boolean (value))
glade_editor_show_info (editor);
else
glade_editor_hide_info (editor);
break;
case PROP_SHOW_CONTEXT_INFO:
if (g_value_get_boolean (value))
glade_editor_show_context_info (editor);
else
glade_editor_hide_context_info (editor);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
glade_editor_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GladeEditor *editor = GLADE_EDITOR (object);
switch (prop_id)
{
case PROP_SHOW_INFO:
g_value_set_boolean (value, editor->show_info);
break;
case PROP_SHOW_CONTEXT_INFO:
g_value_set_boolean (value, editor->show_context_info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
glade_editor_class_init (GladeEditorClass *class)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (class);
object_class = G_OBJECT_CLASS (class);
object_class->set_property = glade_editor_set_property;
object_class->get_property = glade_editor_get_property;
class->gtk_doc_search = NULL;
/* Properties */
g_object_class_install_property
(object_class, PROP_SHOW_INFO,
g_param_spec_boolean ("show-info",
_("Show info"),
_("Whether to show an informational "
"button for the loaded widget"),
FALSE, G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_SHOW_CONTEXT_INFO,
g_param_spec_boolean ("show-context-info",
_("Show context info"),
_("Whether to show an informational button for "
"each property and signal in the editor"),
FALSE, G_PARAM_READABLE));
/* Signals */
glade_editor_signals[GTK_DOC_SEARCH] =
g_signal_new ("gtk-doc-search",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GladeEditorClass,
gtk_doc_search),
NULL, NULL,
glade_marshal_VOID__STRING_STRING_STRING,
G_TYPE_NONE, 3,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
}
static GtkWidget *
@ -115,6 +229,58 @@ glade_editor_on_launch_click (GtkButton *button,
glade_widget_launch_editor (editor->loaded_widget);
}
static const gchar *
glade_editor_guess_bookname (GladeEditor *editor)
{
gchar *guess = NULL;
g_return_val_if_fail (GLADE_IS_WIDGET (editor->loaded_widget), NULL);
if (GTK_IS_WIDGET (editor->loaded_widget->object))
guess = "gtk";
return guess;
}
static void
glade_editor_on_docs_click (GtkButton *button,
GladeEditor *editor)
{
if (editor->loaded_widget)
g_signal_emit (G_OBJECT (editor),
glade_editor_signals[GTK_DOC_SEARCH],
0, glade_editor_guess_bookname (editor),
editor->loaded_widget->widget_class->name,
editor->loaded_widget->widget_class->name);
}
static GtkWidget *
glade_editor_create_info_button (void)
{
GtkWidget *image, *button;
GtkWidget *hbox, *label;
gchar *path;
path = g_build_filename (glade_pixmaps_dir, "devhelp.png", NULL);
button = gtk_button_new ();
hbox = gtk_hbox_new (FALSE, 0);
label = gtk_label_new_with_mnemonic ("_Documentation");
image = gtk_image_new_from_file (path);
gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_widget_show_all (hbox);
gtk_container_add (GTK_CONTAINER (button), hbox);
g_free (path);
return button;
}
static void
glade_editor_init (GladeEditor *editor)
{
@ -162,6 +328,24 @@ glade_editor_init (GladeEditor *editor)
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (glade_editor_on_reset_click), editor);
/* Documentation button
*/
editor->info_button = glade_editor_create_info_button ();
gtk_container_set_border_width (GTK_CONTAINER (editor->info_button),
GLADE_GENERIC_BORDER_WIDTH);
gtk_box_pack_start (GTK_BOX (hbox), editor->info_button, FALSE, TRUE, 0);
g_signal_connect (G_OBJECT (editor->info_button), "clicked",
G_CALLBACK (glade_editor_on_docs_click), editor);
gtk_widget_show_all (GTK_WIDGET (editor));
if (editor->show_info)
gtk_widget_show (editor->info_button);
else
gtk_widget_hide (editor->info_button);
gtk_widget_hide (editor);
}
GType
@ -253,6 +437,17 @@ glade_editor_table_append_item (GladeEditorTable *table,
GladeEditorProperty *property;
property = glade_editor_property_new (class, from_query_dialog == FALSE);
gtk_widget_show (GTK_WIDGET (property));
gtk_widget_show_all (property->eventbox);
if (table->editor->show_context_info)
glade_editor_property_show_info (property);
else
glade_editor_property_hide_info (property);
g_signal_connect (G_OBJECT (property), "gtk-doc-search",
G_CALLBACK (glade_editor_gtk_doc_search_cb),
table->editor);
glade_editor_table_attach (table->table_widget, property->eventbox, 0, table->rows);
glade_editor_table_attach (table->table_widget, GTK_WIDGET (property), 1, table->rows);
@ -385,7 +580,7 @@ glade_editor_table_create (GladeEditor *editor,
if (!glade_editor_table_append_items (table, class, type))
return NULL;
gtk_widget_show_all (table->table_widget);
gtk_widget_show (table->table_widget);
return table;
}
@ -548,7 +743,7 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
glade_editor_property_load (editor_property, property);
}
gtk_widget_show_all (editor->packing_etable->table_widget);
gtk_widget_show (editor->packing_etable->table_widget);
gtk_box_pack_start (GTK_BOX (editor->vbox_packing),
editor->packing_etable->table_widget,
@ -1153,3 +1348,95 @@ glade_editor_reset_dialog (GladeEditor *editor)
}
gtk_widget_destroy (dialog);
}
void
glade_editor_show_info (GladeEditor *editor)
{
g_return_if_fail (GLADE_IS_EDITOR (editor));
if (editor->show_info != TRUE)
{
editor->show_info = TRUE;
gtk_widget_show (editor->info_button);
g_object_notify (G_OBJECT (editor), "show-info");
}
}
void
glade_editor_hide_info (GladeEditor *editor)
{
g_return_if_fail (GLADE_IS_EDITOR (editor));
if (editor->show_info == TRUE)
{
editor->show_info = FALSE;
gtk_widget_hide (editor->info_button);
g_object_notify (G_OBJECT (editor), "show-info");
}
}
void
glade_editor_show_context_info (GladeEditor *editor)
{
GList *list, *props;
GladeEditorTable *etable;
g_return_if_fail (GLADE_IS_EDITOR (editor));
if (editor->show_context_info != TRUE)
{
editor->show_context_info = TRUE;
for (list = editor->widget_tables; list; list = list->next)
{
etable = list->data;
for (props = etable->properties; props; props = props->next)
glade_editor_property_show_info
(GLADE_EDITOR_PROPERTY (list->data));
}
if (editor->packing_etable)
{
etable = editor->packing_etable;
for (props = etable->properties; props; props = props->next)
glade_editor_property_show_info
(GLADE_EDITOR_PROPERTY (list->data));
}
g_object_notify (G_OBJECT (editor), "show-context-info");
}
}
void
glade_editor_hide_context_info (GladeEditor *editor)
{
GList *list, *props;
GladeEditorTable *etable;
g_return_if_fail (GLADE_IS_EDITOR (editor));
if (editor->show_context_info != TRUE)
{
editor->show_context_info = TRUE;
for (list = editor->widget_tables; list; list = list->next)
{
etable = list->data;
for (props = etable->properties; props; props = props->next)
glade_editor_property_hide_info
(GLADE_EDITOR_PROPERTY (list->data));
}
if (editor->packing_etable)
{
etable = editor->packing_etable;
for (props = etable->properties; props; props = props->next)
glade_editor_property_hide_info
(GLADE_EDITOR_PROPERTY (list->data));
}
g_object_notify (G_OBJECT (editor), "show-context-info");
}
}

View File

@ -108,6 +108,15 @@ struct _GladeEditor
gulong project_closed_signal_id; /* Unload widget when widget's project closes.
*/
GtkWidget *info_button; /* The actual informational button
*/
gboolean show_info; /* Whether or not to show an informational button
*/
gboolean show_context_info; /* Whether or not to show an informational
* button for each property and signal.
*/
};
struct _GladeEditorClass
@ -117,6 +126,12 @@ struct _GladeEditorClass
void (*add_signal) (GladeEditor *editor, const char *id_widget,
GType type_widget, guint id_signal,
const char *callback_name);
void (*gtk_doc_search) (GladeEditor *,
const gchar *,
const gchar *,
const gchar *);
};
/* For each glade widget class that we have modified, we create a
@ -179,6 +194,16 @@ void glade_editor_update_widget_name (GladeEditor *editor);
LIBGLADEUI_API
gboolean glade_editor_query_dialog (GladeEditor *editor,
GladeWidget *widget);
LIBGLADEUI_API
void glade_editor_show_info (GladeEditor *editor);
LIBGLADEUI_API
void glade_editor_show_context_info (GladeEditor *editor);
LIBGLADEUI_API
void glade_editor_hide_info (GladeEditor *editor);
LIBGLADEUI_API
void glade_editor_hide_context_info (GladeEditor *editor);
G_END_DECLS

View File

@ -4,3 +4,4 @@ OBJECT:POINTER
BOOLEAN:OBJECT
BOOLEAN:OBJECT,POINTER
VOID:OBJECT
VOID:STRING,STRING,STRING

View File

@ -964,6 +964,16 @@ gpw_hijack_editor_key_press (GtkWidget *editor_win,
return FALSE;
}
static void
gpw_doc_search_cb (GladeEditor *editor,
const gchar *book,
const gchar *page,
const gchar *search,
GladeProjectWindow *gpw)
{
glade_util_search_devhelp (book, page, search);
}
static void
gpw_create_editor (GladeProjectWindow *gpw)
{
@ -992,6 +1002,14 @@ gpw_create_editor (GladeProjectWindow *gpw)
editor_item = gtk_ui_manager_get_widget (gpw->priv->ui,
"/MenuBar/ViewMenu/PropertyEditor");
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (editor_item), TRUE);
if (glade_util_have_devhelp())
{
glade_editor_show_info (glade_app_get_editor ());
glade_editor_show_context_info (glade_app_get_editor ());
g_signal_connect (G_OBJECT (glade_app_get_editor ()), "gtk-doc-search",
G_CALLBACK (gpw_doc_search_cb), gpw);
}
}
static void

View File

@ -275,24 +275,24 @@ glade_project_class_init (GladeProjectClass *class)
g_object_class_install_property (object_class,
PROP_HAS_UNSAVED_CHANGES,
g_param_spec_boolean ("has-unsaved-changes",
"Has Unsaved Changes",
"Whether project has unsaved changes",
_("Has Unsaved Changes"),
_("Whether project has unsaved changes"),
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_HAS_SELECTION,
g_param_spec_boolean ("has-selection",
"Has Selection",
"Whether project has a selection",
_("Has Selection"),
_("Whether project has a selection"),
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_READ_ONLY,
g_param_spec_boolean ("read-only",
"Read Only",
"Whether project is read only or not",
_("Read Only"),
_("Whether project is read only or not"),
FALSE,
G_PARAM_READABLE));

View File

@ -168,6 +168,8 @@ glade_property_class_new (void)
property_class->resource = FALSE;
property_class->translatable = FALSE;
property_class->atk_type = GPC_ATK_NONE;
property_class->virtual = TRUE;
return property_class;
}
@ -1059,10 +1061,13 @@ glade_property_class_new_from_spec (GParamSpec *spec)
g_return_val_if_fail (spec != NULL, NULL);
gtk_widget_class = g_type_class_ref (GTK_TYPE_WIDGET);
property_class = glade_property_class_new ();
/* Only properties that are _new_from_spec() are
* not virtual properties
*/
property_class = glade_property_class_new ();
property_class->virtual = FALSE;
property_class->pspec = spec;
property_class->pspec = spec;
/* We only use the writable properties */
if ((spec->flags & G_PARAM_WRITABLE) == 0)
goto failed;

View File

@ -82,6 +82,12 @@ struct _GladePropertyClass
*/
gchar *tooltip; /* The default tooltip for the property editor rows.
*/
gboolean virtual; /* Whether this is a virtual property with its pspec supplied
* via the catalog (or hard code-paths); or FALSE if its a real
* GObject introspected property
*/
GValue *def; /* The default value for this property (this will exist
* as a copy of orig_def if not specified by the catalog)
*/

View File

@ -616,7 +616,7 @@ glade_property_klass_init (GladePropertyKlass *prop_class)
_("Whether or not the translatable string has a context prefix"),
FALSE, G_PARAM_READWRITE));
/* Signals */
/* Signal */
glade_property_signals[VALUE_CHANGED] =
g_signal_new ("value-changed",
G_TYPE_FROM_CLASS (object_class),

View File

@ -1605,3 +1605,64 @@ glade_util_file_is_writeable (const gchar *path)
}
return FALSE;
}
/**
* glade_util_have_devhelp:
*
* FIXME: This should also parse the output of devhelp --version
* and check if it supports the search features we need.
*
* Returns: whether we can use devhelp
*/
gboolean
glade_util_have_devhelp (void)
{
gboolean have_devhelp = FALSE;
gchar *path;
if ((path = g_find_program_in_path ("devhelp")) != NULL)
{
have_devhelp = TRUE;
g_free (path);
}
return have_devhelp;
}
/**
* glade_util_search_devhep:
* @book: the devhelp book (or %NULL)
* @page: the page in the book (or %NULL)
* @search: the search string (or %NULL)
*
* Launches the devhelp program with a search string
*
*/
void
glade_util_search_devhelp (const gchar *book,
const gchar *page,
const gchar *search)
{
GError *error = NULL;
gchar *book_comm = NULL, *page_comm = NULL;
gchar *command;
if (book) book_comm = g_strdup_printf ("book:%s ", book);
if (page) page_comm = g_strdup_printf ("page:%s ", page);
command = g_strdup_printf ("devhelp -s \"%s%s %s\"",
book_comm ? book_comm : "",
page_comm ? page_comm : "",
search ? search : "");
if (g_spawn_command_line_async (command, &error) == FALSE)
{
g_critical ("Unable to spawn devhelp (%s)",
error->message);
g_error_free (error);
}
g_free (command);
if (book_comm) g_free (book_comm);
if (page_comm) g_free (page_comm);
}

View File

@ -131,6 +131,12 @@ GModule *glade_util_load_library (const gchar *library_name);
LIBGLADEUI_API
gboolean glade_util_file_is_writeable (const gchar *path);
LIBGLADEUI_API
gboolean glade_util_have_devhelp (void);
LIBGLADEUI_API
void glade_util_search_devhelp (const gchar *book,
const gchar *page,
const gchar *search);
G_END_DECLS

View File

@ -276,14 +276,13 @@ glade_widget_class_create_icon (GladeWidgetClass *class)
{
GdkPixbuf *icon = NULL;
GError *error = NULL;
gchar *icon_path;
gchar *icon_path, *icon_name;
if (class->generic_name)
{
icon_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s.png",
glade_pixmaps_dir,
icon_name = g_strdup_printf ("%s.png", class->generic_name);
icon_path = g_build_filename (glade_pixmaps_dir, icon_name, NULL);
class->generic_name);
if ((icon =
gdk_pixbuf_new_from_file (icon_path, &error)) == NULL)
{
@ -306,6 +305,7 @@ glade_widget_class_create_icon (GladeWidgetClass *class)
error = (g_error_free (error), NULL);
}
}
g_free (icon_name);
g_free (icon_path);
}
return icon;