예제 #1
0
void
egg_empty_state_set_icon_name (EggEmptyState *self,
                               const gchar   *icon_name)
{
  EggEmptyStatePrivate *priv = egg_empty_state_get_instance_private (self);

  g_return_if_fail (EGG_IS_EMPTY_STATE (self));

  if (g_strcmp0 (icon_name, egg_empty_state_get_icon_name (self)) != 0)
    {
      GtkStyleContext *context;

      g_object_set (priv->image,
                    "icon-name", icon_name,
                    NULL);

      context = gtk_widget_get_style_context (GTK_WIDGET (priv->image));

      if (icon_name != NULL && g_str_has_suffix (icon_name, "-symbolic"))
        gtk_style_context_add_class (context, "dim-label");
      else
        gtk_style_context_remove_class (context, "dim-label");

      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ICON_NAME]);
    }
}
예제 #2
0
const gchar *
egg_empty_state_get_title (EggEmptyState *self)
{
  EggEmptyStatePrivate *priv = egg_empty_state_get_instance_private (self);

  g_return_val_if_fail (EGG_IS_EMPTY_STATE (self), NULL);

  return gtk_label_get_label (priv->title);
}
예제 #3
0
const gchar *
egg_empty_state_get_icon_name (EggEmptyState *self)
{
  EggEmptyStatePrivate *priv = egg_empty_state_get_instance_private (self);
  const gchar *icon_name = NULL;

  g_return_val_if_fail (EGG_IS_EMPTY_STATE (self), NULL);

  gtk_image_get_icon_name (priv->image, &icon_name, NULL);

  return icon_name;
}
예제 #4
0
void
egg_empty_state_set_title (EggEmptyState *self,
                           const gchar   *title)
{
  EggEmptyStatePrivate *priv = egg_empty_state_get_instance_private (self);

  g_return_if_fail (EGG_IS_EMPTY_STATE (self));

  if (g_strcmp0 (title, egg_empty_state_get_title (self)) != 0)
    {
      gtk_label_set_label (priv->title, title);
      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
    }
}
예제 #5
0
void
egg_empty_state_set_icon_name (EggEmptyState *self,
                               const gchar   *icon_name)
{
  EggEmptyStatePrivate *priv = egg_empty_state_get_instance_private (self);

  g_return_if_fail (EGG_IS_EMPTY_STATE (self));

  if (g_strcmp0 (icon_name, egg_empty_state_get_icon_name (self)) != 0)
    {
      g_object_set (priv->image, "icon-name", icon_name, NULL);
      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ICON_NAME]);
    }
}
예제 #6
0
static gboolean
egg_empty_state_activate_link (EggEmptyState *self,
                               const gchar   *uri,
                               GtkLabel      *label)
{
  g_assert (EGG_IS_EMPTY_STATE (self));
  g_assert (uri != NULL);
  g_assert (GTK_IS_LABEL (label));

  if (g_str_has_prefix (uri, "action://"))
    {
      g_autofree gchar *full_name = NULL;
      g_autofree gchar *action_name = NULL;
      g_autofree gchar *group_name = NULL;
      g_autoptr(GVariant) param = NULL;
      g_autoptr(GError) error = NULL;

      uri += strlen ("action://");

      if (g_action_parse_detailed_name (uri, &full_name, &param, &error))
        {
          const gchar *dot = strchr (full_name, '.');

          if (param != NULL && g_variant_is_floating (param))
            param = g_variant_ref_sink (param);

          if (dot == NULL)
            return FALSE;

          group_name = g_strndup (full_name, dot - full_name);
          action_name = g_strdup (++dot);

          egg_empty_state_action (GTK_WIDGET (self),
                                  group_name,
                                  action_name,
                                  param);

          return TRUE;
        }
      else
        g_warning ("%s", error->message);
    }

  return FALSE;
}
예제 #7
0
void
egg_empty_state_set_resource (EggEmptyState *self,
                              const gchar   *resource)
{
  EggEmptyStatePrivate *priv = egg_empty_state_get_instance_private (self);

  g_return_if_fail (EGG_IS_EMPTY_STATE (self));

  if (resource != NULL)
    {
      GdkPixbuf *pixbuf;
      GError *error = NULL;
      gint scale_factor;

      scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));

      pixbuf = gdk_pixbuf_new_from_resource_at_scale (resource,
                                                      128 * scale_factor,
                                                      128 * scale_factor,
                                                      TRUE,
                                                      &error);

      if (pixbuf == NULL)
        {
          g_warning ("%s", error->message);
          g_clear_error (&error);
          return;
        }

      g_object_set (priv->image,
                    "pixbuf", pixbuf,
                    NULL);

      g_clear_object (&pixbuf);
    }
}