shortcuts: Some property hygiene

Bring property notification for some of the new shortcuts widgets
up to the standards of our testsuite.
This commit is contained in:
Matthias Clasen
2015-10-27 08:48:08 -04:00
parent 71b31c84c0
commit bb5b711d4b
5 changed files with 25 additions and 14 deletions

View File

@ -228,7 +228,7 @@ gtk_shortcuts_gesture_class_init (GtkShortcutsGestureClass *klass)
g_param_spec_string ("title", g_param_spec_string ("title",
P_("Title"), P_("Title"),
P_("Title"), P_("Title"),
NULL, "",
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
@ -243,7 +243,7 @@ gtk_shortcuts_gesture_class_init (GtkShortcutsGestureClass *klass)
g_param_spec_string ("subtitle", g_param_spec_string ("subtitle",
P_("Subtitle"), P_("Subtitle"),
P_("Subtitle"), P_("Subtitle"),
NULL, "",
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**

View File

@ -225,7 +225,7 @@ gtk_shortcuts_group_class_init (GtkShortcutsGroupClass *klass)
*/ */
properties[PROP_TITLE] = properties[PROP_TITLE] =
g_param_spec_string ("title", P_("Title"), P_("Title"), g_param_spec_string ("title", P_("Title"), P_("Title"),
NULL, "",
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
@ -279,7 +279,7 @@ gtk_shortcuts_group_class_init (GtkShortcutsGroupClass *klass)
*/ */
properties[PROP_HEIGHT] = properties[PROP_HEIGHT] =
g_param_spec_uint ("height", P_("Height"), P_("Height"), g_param_spec_uint ("height", P_("Height"), P_("Height"),
0, G_MAXUINT, 0, 0, G_MAXUINT, 1,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, LAST_PROP, properties); g_object_class_install_properties (object_class, LAST_PROP, properties);

View File

@ -101,6 +101,8 @@ static guint signals[LAST_SIGNAL];
static void gtk_shortcuts_section_set_view_name (GtkShortcutsSection *self, static void gtk_shortcuts_section_set_view_name (GtkShortcutsSection *self,
const gchar *view_name); const gchar *view_name);
static void gtk_shortcuts_section_set_max_height (GtkShortcutsSection *self,
guint max_height);
static void gtk_shortcuts_section_add_group (GtkShortcutsSection *self, static void gtk_shortcuts_section_add_group (GtkShortcutsSection *self,
GtkShortcutsGroup *group); GtkShortcutsGroup *group);
@ -210,7 +212,7 @@ gtk_shortcuts_section_set_property (GObject *object,
break; break;
case PROP_MAX_HEIGHT: case PROP_MAX_HEIGHT:
self->max_height = g_value_get_uint (value); gtk_shortcuts_section_set_max_height (self, g_value_get_uint (value));
break; break;
default: default:
@ -268,7 +270,7 @@ gtk_shortcuts_section_class_init (GtkShortcutsSectionClass *klass)
properties[PROP_VIEW_NAME] = properties[PROP_VIEW_NAME] =
g_param_spec_string ("view-name", P_("View Name"), P_("View Name"), g_param_spec_string ("view-name", P_("View Name"), P_("View Name"),
NULL, NULL,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/** /**
* GtkShortcutsSection:title: * GtkShortcutsSection:title:
@ -293,7 +295,7 @@ gtk_shortcuts_section_class_init (GtkShortcutsSectionClass *klass)
properties[PROP_MAX_HEIGHT] = properties[PROP_MAX_HEIGHT] =
g_param_spec_uint ("max-height", P_("Maximum Height"), P_("Maximum Height"), g_param_spec_uint ("max-height", P_("Maximum Height"), P_("Maximum Height"),
0, G_MAXUINT, 15, 0, G_MAXUINT, 15,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
g_object_class_install_properties (object_class, LAST_PROP, properties); g_object_class_install_properties (object_class, LAST_PROP, properties);
@ -376,8 +378,6 @@ static void
gtk_shortcuts_section_set_view_name (GtkShortcutsSection *self, gtk_shortcuts_section_set_view_name (GtkShortcutsSection *self,
const gchar *view_name) const gchar *view_name)
{ {
g_return_if_fail (GTK_IS_SHORTCUTS_SECTION (self));
if (g_strcmp0 (self->view_name, view_name) == 0) if (g_strcmp0 (self->view_name, view_name) == 0)
return; return;
@ -390,6 +390,20 @@ gtk_shortcuts_section_set_view_name (GtkShortcutsSection *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VIEW_NAME]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VIEW_NAME]);
} }
static void
gtk_shortcuts_section_set_max_height (GtkShortcutsSection *self,
guint max_height)
{
if (self->max_height == max_height)
return;
self->max_height = max_height;
gtk_shortcuts_section_maybe_reflow (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MAX_HEIGHT]);
}
static void static void
gtk_shortcuts_section_add_group (GtkShortcutsSection *self, gtk_shortcuts_section_add_group (GtkShortcutsSection *self,
GtkShortcutsGroup *group) GtkShortcutsGroup *group)
@ -397,9 +411,6 @@ gtk_shortcuts_section_add_group (GtkShortcutsSection *self,
GList *children; GList *children;
GtkWidget *page, *column; GtkWidget *page, *column;
g_return_if_fail (GTK_IS_SHORTCUTS_SECTION (self));
g_return_if_fail (GTK_IS_SHORTCUTS_GROUP (group));
children = gtk_container_get_children (GTK_CONTAINER (self->stack)); children = gtk_container_get_children (GTK_CONTAINER (self->stack));
if (children) if (children)
page = children->data; page = children->data;

View File

@ -215,7 +215,7 @@ gtk_shortcuts_shortcut_class_init (GtkShortcutsShortcutClass *klass)
g_param_spec_string ("title", g_param_spec_string ("title",
P_("Title"), P_("Title"),
P_("Title"), P_("Title"),
NULL, "",
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**

View File

@ -598,7 +598,7 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
*/ */
properties[PROP_SECTION_NAME] = properties[PROP_SECTION_NAME] =
g_param_spec_string ("section-name", P_("Section Name"), P_("Section Name"), g_param_spec_string ("section-name", P_("Section Name"), P_("Section Name"),
NULL, "internal-search",
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**