static void
cc_mouse_panel_dispose (GObject *object)
{
    CcMousePanelPrivate *priv = CC_MOUSE_PANEL (object)->priv;

    g_clear_object (&priv->shell_header);

    if (priv->prefs_widget)
    {
        gnome_mouse_properties_dispose (priv->prefs_widget);
        priv->prefs_widget = NULL;
    }

    if (priv->test_widget)
    {
        gnome_mouse_test_dispose (priv->test_widget);
        priv->test_widget = NULL;
    }

    if (priv->builder)
    {
        g_object_unref (priv->builder);
        priv->builder = NULL;
    }

    G_OBJECT_CLASS (cc_mouse_panel_parent_class)->dispose (object);
}
static void
cc_mouse_panel_dispose (GObject *object)
{
  CcMousePanelPrivate *priv = CC_MOUSE_PANEL (object)->priv;

  if (priv->test_dialog)
    {
      gtk_widget_destroy (priv->test_dialog);
      priv->test_dialog = NULL;
    }

  G_OBJECT_CLASS (cc_mouse_panel_parent_class)->dispose (object);
}
static void
cc_mouse_panel_constructed (GObject *object)
{
  CcMousePanel *self = CC_MOUSE_PANEL (object);
  CcMousePanelPrivate *priv = self->priv;
  GtkWidget *button, *container, *toplevel, *label;
  CcShell *shell;

  G_OBJECT_CLASS (cc_mouse_panel_parent_class)->constructed (object);

  /* Add test area button to shell header. */
  shell = cc_panel_get_shell (CC_PANEL (self));

  label = gtk_label_new_with_mnemonic (_("Test Your _Settings"));
  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
  gtk_widget_show (label);

  button = gtk_button_new ();
  gtk_container_add (GTK_CONTAINER (button), label);
  gtk_style_context_add_class (gtk_widget_get_style_context (button),
                               "text-button");
  gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
  gtk_widget_set_visible (button, TRUE);

  cc_shell_embed_widget_in_header (shell, button);

  g_signal_connect (GTK_BUTTON (button), "clicked",
                    G_CALLBACK (shell_test_button_clicked),
                    self);

  toplevel = cc_shell_get_toplevel (shell);
  priv->test_dialog = g_object_new (GTK_TYPE_DIALOG, "title", _("Test Your Settings"),
                                                     "transient-for", GTK_WINDOW (toplevel),
                                                     "modal", TRUE,
                                                     "use_header-bar", TRUE,
                                                     "resizable", FALSE,
                                                     NULL);

  container = gtk_dialog_get_content_area (GTK_DIALOG (priv->test_dialog));
  gtk_container_add (GTK_CONTAINER (container), priv->test_widget);
}
/* Add test area toggle to shell header. */
static gboolean
add_shell_test_button_cb (gpointer user_data)
{
    CcMousePanel *panel = CC_MOUSE_PANEL (user_data);
    GtkWidget *box, *button;

    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

    button = gtk_toggle_button_new_with_mnemonic (_("_Test Your Settings"));
    gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
    gtk_widget_set_visible (button, TRUE);

    cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (panel)), box);
    gtk_widget_set_visible (box, TRUE);

    panel->priv->shell_header = g_object_ref (box);

    g_signal_connect (GTK_BUTTON (button), "toggled",
                      G_CALLBACK (shell_test_button_toggle_event),
                      panel);

    return FALSE;
}