Commit 02f61cef authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

Added GladePropertyShell:disable-check proxy property and the corresponding accessors API.

Simplified code in GtkAboutDialog editor using new API.
parent cfaa8261
......@@ -227,6 +227,32 @@ glade_editor_property_get_custom_text (GladeEditorProperty *eprop)
return eprop->priv->custom_text;
}
void
glade_editor_property_set_disable_check (GladeEditorProperty *eprop,
gboolean disable_check)
{
GladeEditorPropertyPrivate *priv;
g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
priv = eprop->priv;
if (priv->disable_check != disable_check)
{
priv->disable_check = disable_check;
gtk_widget_set_visible (priv->check, !disable_check);
g_object_notify (G_OBJECT (eprop), "disable-check");
}
}
gboolean
glade_editor_property_get_disable_check (GladeEditorProperty *eprop)
{
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop), FALSE);
return eprop->priv->disable_check;
}
GtkWidget *
glade_editor_property_get_item_label (GladeEditorProperty *eprop)
{
......@@ -444,15 +470,7 @@ glade_editor_property_set_property (GObject *object,
eprop->priv->use_command = g_value_get_boolean (value);
break;
case PROP_DISABLE_CHECK:
eprop->priv->disable_check = g_value_get_boolean (value);
if (eprop->priv->check)
{
if (eprop->priv->disable_check)
gtk_widget_hide (eprop->priv->check);
else
gtk_widget_show (eprop->priv->check);
}
glade_editor_property_set_disable_check (eprop, g_value_get_boolean (value));
break;
case PROP_CUSTOM_TEXT:
glade_editor_property_set_custom_text (eprop, g_value_get_string (value));
......
......@@ -97,42 +97,45 @@ struct _GladeEditorPropertyClass {
GType glade_editor_property_get_type (void) G_GNUC_CONST;
GType glade_editor_property_get_type (void) G_GNUC_CONST;
void glade_editor_property_load (GladeEditorProperty *eprop,
GladeProperty *property);
void glade_editor_property_load (GladeEditorProperty *eprop,
GladeProperty *property);
void glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
GladeWidget *widget);
void glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
GladeWidget *widget);
void glade_editor_property_commit (GladeEditorProperty *eprop,
GValue *value);
void glade_editor_property_commit (GladeEditorProperty *eprop,
GValue *value);
void glade_editor_property_commit_no_callback (GladeEditorProperty *eprop,
GValue *value);
void glade_editor_property_set_custom_text(GladeEditorProperty *eprop,
const gchar *custom_text);
const gchar *glade_editor_property_get_custom_text(GladeEditorProperty *eprop);
GtkWidget *glade_editor_property_get_item_label (GladeEditorProperty *eprop);
GladePropertyClass *glade_editor_property_get_pclass (GladeEditorProperty *eprop);
GladeProperty *glade_editor_property_get_property (GladeEditorProperty *eprop);
gboolean glade_editor_property_loading (GladeEditorProperty *eprop);
gboolean glade_editor_property_show_i18n_dialog (GtkWidget *parent,
gchar **text,
gchar **context,
gchar **comment,
gboolean *translatable);
gboolean glade_editor_property_show_resource_dialog (GladeProject *project,
GtkWidget *parent,
gchar **filename);
gboolean glade_editor_property_show_object_dialog (GladeProject *project,
const gchar *title,
GtkWidget *parent,
GType object_type,
GladeWidget *exception,
GladeWidget **object);
void glade_editor_property_set_custom_text (GladeEditorProperty *eprop,
const gchar *custom_text);
const gchar *glade_editor_property_get_custom_text (GladeEditorProperty *eprop);
void glade_editor_property_set_disable_check (GladeEditorProperty *eprop,
gboolean disable_check);
gboolean glade_editor_property_get_disable_check (GladeEditorProperty *eprop);
GtkWidget *glade_editor_property_get_item_label (GladeEditorProperty *eprop);
GladePropertyClass *glade_editor_property_get_pclass (GladeEditorProperty *eprop);
GladeProperty *glade_editor_property_get_property (GladeEditorProperty *eprop);
gboolean glade_editor_property_loading (GladeEditorProperty *eprop);
gboolean glade_editor_property_show_i18n_dialog (GtkWidget *parent,
gchar **text,
gchar **context,
gchar **comment,
gboolean *translatable);
gboolean glade_editor_property_show_resource_dialog (GladeProject *project,
GtkWidget *parent,
gchar **filename);
gboolean glade_editor_property_show_object_dialog (GladeProject *project,
const gchar *title,
GtkWidget *parent,
GType object_type,
GladeWidget *exception,
GladeWidget **object);
/* Generic eprops */
#define GLADE_TYPE_EPROP_NUMERIC (glade_eprop_numeric_get_type())
......
......@@ -60,6 +60,7 @@ struct _GladePropertyShellPrivate
gchar *custom_text;
guint packing : 1;
guint use_command : 1;
guint disable_check : 1;
};
enum {
......@@ -68,7 +69,8 @@ enum {
PROP_PACKING,
PROP_USE_COMMAND,
PROP_EDITOR_TYPE,
PROP_CUSTOM_TEXT
PROP_CUSTOM_TEXT,
PROP_DISABLE_CHECK
};
enum
......@@ -94,6 +96,7 @@ glade_property_shell_init (GladePropertyShell *shell)
shell->priv->packing = FALSE;
shell->priv->use_command = TRUE;
shell->priv->disable_check = FALSE;
}
static void
......@@ -134,7 +137,13 @@ glade_property_shell_class_init (GladePropertyShellClass *klass)
g_param_spec_string ("custom-text", _("Custom Text"),
_("Custom Text to display in the property label"),
NULL, G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class, PROP_DISABLE_CHECK,
g_param_spec_boolean ("disable-check", _("Disable Check"),
_("Whether to explicitly disable the check button"),
FALSE, G_PARAM_READWRITE));
/**
* GladePropertyShell::pre-commit:
* @gladeeditorproperty: the #GladeEditorProperty which changed value
......@@ -220,6 +229,9 @@ glade_property_shell_set_real_property (GObject *object,
case PROP_CUSTOM_TEXT:
glade_property_shell_set_custom_text (shell, g_value_get_string (value));
break;
case PROP_DISABLE_CHECK:
glade_property_shell_set_disable_check (shell, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -248,6 +260,9 @@ glade_property_shell_get_real_property (GObject *object,
case PROP_CUSTOM_TEXT:
g_value_set_string (value, glade_property_shell_get_custom_text (shell));
break;
case PROP_DISABLE_CHECK:
g_value_set_boolean (value, glade_property_shell_get_disable_check (shell));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -296,7 +311,8 @@ glade_property_shell_set_eprop (GladePropertyShell *shell,
if (priv->property_editor)
{
glade_editor_property_set_custom_text (priv->property_editor, priv->custom_text);
glade_editor_property_set_disable_check (priv->property_editor, priv->disable_check);
priv->pre_commit_id = g_signal_connect (priv->property_editor, "commit",
G_CALLBACK (propagate_pre_commit), shell);
priv->post_commit_id = g_signal_connect_after (priv->property_editor, "commit",
......@@ -521,3 +537,32 @@ glade_property_shell_get_use_command (GladePropertyShell *shell)
return shell->priv->use_command;
}
void
glade_property_shell_set_disable_check (GladePropertyShell *shell,
gboolean disable_check)
{
GladePropertyShellPrivate *priv;
g_return_if_fail (GLADE_IS_PROPERTY_SHELL (shell));
priv = shell->priv;
if (priv->disable_check != disable_check)
{
priv->disable_check = disable_check;
if (priv->property_editor)
g_object_set (priv->property_editor, "disable-check", disable_check, NULL);
g_object_notify (G_OBJECT (shell), "disable-check");
}
}
gboolean
glade_property_shell_get_disable_check (GladePropertyShell *shell)
{
g_return_val_if_fail (GLADE_IS_PROPERTY_SHELL (shell), FALSE);
return shell->priv->disable_check;
}
......@@ -68,6 +68,9 @@ gboolean glade_property_shell_get_packing (GladePropertyShell *shell
void glade_property_shell_set_use_command (GladePropertyShell *shell,
gboolean use_command);
gboolean glade_property_shell_get_use_command (GladePropertyShell *shell);
void glade_property_shell_set_disable_check (GladePropertyShell *shell,
gboolean disable_check);
gboolean glade_property_shell_get_disable_check (GladePropertyShell *shell);
G_END_DECLS
......
......@@ -45,8 +45,6 @@ struct _GladeAboutDialogEditorPrivate
GtkWidget *license_label;
GtkWidget *license_editor;
GtkWidget *wrap_license_editor;
GtkWidget *logo_file_editor;
GtkWidget *logo_icon_editor;
GtkWidget *logo_file_radio;
GtkWidget *logo_icon_radio;
......@@ -69,8 +67,6 @@ glade_about_dialog_editor_class_init (GladeAboutDialogEditorClass * klass)
gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, license_label);
gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, license_editor);
gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, wrap_license_editor);
gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_file_editor);
gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_icon_editor);
gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_file_radio);
gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_icon_radio);
......@@ -88,13 +84,6 @@ glade_about_dialog_editor_init (GladeAboutDialogEditor *self)
gtk_widget_init_template (GTK_WIDGET (self));
}
static void
glade_eprop_disable_check (GtkWidget *child, gpointer data)
{
if (GLADE_IS_EDITOR_PROPERTY (child))
g_object_set (child, "disable-check", TRUE, NULL);
}
static void
glade_about_dialog_editor_load (GladeEditable *editable, GladeWidget *widget)
{
......@@ -120,9 +109,6 @@ glade_about_dialog_editor_load (GladeEditable *editable, GladeWidget *widget)
/* Set the radio button state to our virtual property */
glade_widget_property_get (widget, "glade-logo-as-file", &as_file);
gtk_container_forall (GTK_CONTAINER (priv->logo_file_editor), glade_eprop_disable_check, NULL);
gtk_container_forall (GTK_CONTAINER (priv->logo_icon_editor), glade_eprop_disable_check, NULL);
glade_widget_property_set_enabled (widget, "logo-icon-name", !as_file);
glade_widget_property_set_enabled (widget, "logo", as_file);
......
......@@ -253,6 +253,7 @@ Author: Tristan Van Berkom <tvb@gnome.org>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">False</property>
<property name="disable_check">True</property>
<property name="property_name">logo-icon-name</property>
</object>
<packing>
......@@ -267,6 +268,7 @@ Author: Tristan Van Berkom <tvb@gnome.org>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">False</property>
<property name="disable_check">True</property>
<property name="property_name">logo</property>
</object>
<packing>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment