Пример #1
0
/**
 * gtk_icon_entry_set_icon_sensitive
 * @entry: A #GtkIconEntry.
 * @position: Icon position.
 * @sensitive: Specifies whether the icon should appear sensitive or insensitive.
 *
 * Sets the sensitivity for the specified icon.
 */
void
gtk_icon_entry_set_icon_sensitive (const GtkIconEntry *icon_entry,
				   GtkIconEntryPosition icon_pos,
				   gboolean sensitive)
{
  EntryIconInfo *icon_info;
  GtkIconEntryPrivate *priv;

  g_return_if_fail (icon_entry != NULL);
  g_return_if_fail (GTK_IS_ICON_ENTRY (icon_entry));
  g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos));

  priv = GTK_ICON_ENTRY_GET_PRIVATE (icon_entry);

  icon_info = &priv->icons[icon_pos];

  icon_info->insensitive = !sensitive;

  if (icon_info->custom_cursor == TRUE && GTK_WIDGET_REALIZED (GTK_WIDGET (icon_entry)))
    {
      GdkCursor *cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (icon_entry)),
						      sensitive ? icon_info->cursor_type : GDK_ARROW);
      gdk_window_set_cursor (icon_info->window, cursor);
      gdk_cursor_unref (cursor);
    }
}
Пример #2
0
/**
 * sexy_icon_entry_get_icon_highlight
 * @entry: A #SexyIconEntry.
 * @position: Icon position.
 *
 * Retrieves whether entry will highlight the icon on mouseover.
 *
 * Returns: TRUE if icon highlights.
 */
gboolean
sexy_icon_entry_get_icon_highlight(const SexyIconEntry *entry,
								   SexyIconEntryPosition icon_pos)
{
	g_return_val_if_fail(entry != NULL, FALSE);
	g_return_val_if_fail(SEXY_IS_ICON_ENTRY(entry), FALSE);
	g_return_val_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos), FALSE);

	return entry->priv->icons[icon_pos].highlight;
}
Пример #3
0
/**
 * sexy_icon_entry_get_icon
 * @entry: A #SexyIconEntry.
 * @position: Icon position.
 *
 * Retrieves the image used for the icon
 *
 * Returns: A #GtkImage.
 */
GtkImage *
sexy_icon_entry_get_icon(const SexyIconEntry *entry,
						 SexyIconEntryPosition icon_pos)
{
	g_return_val_if_fail(entry != NULL, NULL);
	g_return_val_if_fail(SEXY_IS_ICON_ENTRY(entry), NULL);
	g_return_val_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos), NULL);

	return entry->priv->icons[icon_pos].icon;
}
Пример #4
0
/**
 * sexy_icon_entry_set_icon
 * @entry: A #SexyIconEntry.
 * @position: Icon position.
 * @icon: A #GtkImage to set as the icon.
 *
 * Sets the icon shown in the entry
 */
void
sexy_icon_entry_set_icon(SexyIconEntry *entry, SexyIconEntryPosition icon_pos,
						 GtkImage *icon)
{
	SexyIconInfo *icon_info;

	g_return_if_fail(entry != NULL);
	g_return_if_fail(SEXY_IS_ICON_ENTRY(entry));
	g_return_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos));
	g_return_if_fail(icon == NULL || GTK_IS_IMAGE(icon));

	icon_info = &entry->priv->icons[icon_pos];

	if (icon == icon_info->icon)
		return;

	if (icon_pos == SEXY_ICON_ENTRY_SECONDARY &&
		entry->priv->icon_released_id != 0)
	{
		g_signal_handler_disconnect(entry, entry->priv->icon_released_id);
		entry->priv->icon_released_id = 0;
	}

	if (icon == NULL)
	{
		if (icon_info->icon != NULL)
		{
			gtk_widget_destroy(GTK_WIDGET(icon_info->icon));
			icon_info->icon = NULL;

			/*
			 * Explicitly check, as the pointer may become invalidated
			 * during destruction.
			 */
			if (icon_info->window != NULL && GDK_IS_WINDOW(icon_info->window))
				gdk_window_hide(icon_info->window);
		}
	}
	else
	{
		if (icon_info->window != NULL && icon_info->icon == NULL)
			gdk_window_show(icon_info->window);

		g_signal_connect(G_OBJECT(icon), "notify",
						 G_CALLBACK(update_icon), entry);

		icon_info->icon = icon;
		g_object_ref(icon);
	}

	update_icon(NULL, NULL, entry);
}
Пример #5
0
/**
 * gtk_icon_entry_get_icon_highlight
 * @entry: A #GtkIconEntry.
 * @position: Icon position.
 *
 * Retrieves whether entry will highlight the icon on mouseover.
 *
 * Returns: TRUE if icon highlights.
 */
gboolean
gtk_icon_entry_get_icon_highlight (const GtkIconEntry *entry,
				   GtkIconEntryPosition icon_pos)
{
  GtkIconEntryPrivate *priv;

  g_return_val_if_fail (entry != NULL, FALSE);
  g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), FALSE);
  g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), FALSE);

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);

  return priv->icons[icon_pos].highlight;
}
Пример #6
0
/**
 * gtk_icon_entry_get_pixbuf
 * @entry: A #GtkIconEntry.
 * @position: Icon position.
 *
 * Retrieves the image used for the icon.  Unlike the other methods of setting
 * and getting icon data, this method will work regardless of whether the icon
 * was set using a #GdkPixbuf, a #GIcon, a stock item, or an icon name.
 *
 * Returns: A #GdkPixbuf, or NULL if no icon is set for this position.
 */
GdkPixbuf *
gtk_icon_entry_get_pixbuf (const GtkIconEntry *entry,
			   GtkIconEntryPosition icon_pos)
{
  GtkIconEntryPrivate *priv;

  g_return_val_if_fail (entry != NULL, NULL);
  g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), NULL);
  g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), NULL);

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);

  return priv->icons[icon_pos].pixbuf;
}
Пример #7
0
/**
 * gtk_icon_entry_set_icon_from_pixbuf
 * @entry: A #GtkIconEntry.
 * @position: Icon position.
 * @pixbuf: A #GdkPixbuf.
 *
 * Sets the icon shown in the specified position using a pixbuf.
 */
void
gtk_icon_entry_set_icon_from_pixbuf (GtkIconEntry *entry,
				     GtkIconEntryPosition icon_pos,
				     GdkPixbuf *pixbuf)
{
  EntryIconInfo *icon_info;
  GtkIconEntryPrivate *priv;

  g_return_if_fail (entry != NULL);
  g_return_if_fail (GTK_IS_ICON_ENTRY (entry));
  g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos));

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);
  icon_info = &priv->icons[icon_pos];

  if (pixbuf == icon_info->pixbuf)
    return;

  if (icon_pos == GTK_ICON_ENTRY_SECONDARY &&
      priv->icon_released_id != 0)
    {
      g_signal_handler_disconnect (entry, priv->icon_released_id);
      priv->icon_released_id = 0;
    }

  if (pixbuf == NULL)
    {
      if (icon_info->pixbuf != NULL)
	{
	  g_object_unref (icon_info->pixbuf);
	  icon_info->pixbuf = NULL;

	  /* Explicitly check, as the pointer may become invalidated
	   * during destruction.
	   */
	  if (icon_info->window != NULL && GDK_IS_WINDOW (icon_info->window))
	    gdk_window_hide (icon_info->window);
	}
    }
  else
    {
      if (icon_info->window != NULL && icon_info->pixbuf == NULL)
	gdk_window_show (icon_info->window);

      icon_info->pixbuf = pixbuf;
      g_object_ref (pixbuf);
    }

  gtk_widget_queue_draw (GTK_WIDGET (entry));
}
Пример #8
0
/**
 * gtk_icon_entry_set_icon_from_icon_name
 * @entry: A #GtkIconEntry;
 * @icon_pos: The position at which to set the icon
 * @icon_name: An icon name
 *
 * Sets the icon shown in the entry at the specified position from the current
 * icon theme.  If the icon name isn't known, a "broken image" icon will be
 * displayed instead.  If the current icon theme is changed, the icon will be
 * updated appropriately.
 */
void
gtk_icon_entry_set_icon_from_icon_name (GtkIconEntry *entry,
					GtkIconEntryPosition icon_pos,
					const gchar *icon_name)
{
  GdkPixbuf *pixbuf = NULL;
  EntryIconInfo *icon_info;
  GtkIconEntryPrivate *priv;
  GdkScreen *screen;
  GtkIconTheme *icon_theme;
  GtkSettings *settings;
  gint width, height;
  GError *error = NULL;

  g_return_if_fail (entry != NULL);
  g_return_if_fail (GTK_IS_ICON_ENTRY (entry));
  g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos));

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);
  icon_info = &priv->icons[icon_pos];

  screen = gtk_widget_get_screen (GTK_WIDGET (entry));
  icon_theme = gtk_icon_theme_get_for_screen (screen);
  settings = gtk_settings_get_for_screen (screen);

  if (icon_name != NULL)
    {
      gtk_icon_size_lookup_for_settings (settings,
					 GTK_ICON_SIZE_MENU,
					 &width, &height);

      pixbuf = gtk_icon_theme_load_icon (icon_theme,
					 icon_name,
					 MIN (width, height), 0, &error);

      if (pixbuf == NULL)
	{
	  g_error_free (error);
	  pixbuf = gtk_widget_render_icon (GTK_WIDGET (entry),
					   GTK_STOCK_MISSING_IMAGE,
					   GTK_ICON_SIZE_MENU,
					   NULL);
	}
    }

  gtk_icon_entry_set_icon_internal (entry,
				    icon_pos,
				    pixbuf);
}
Пример #9
0
GIcon *
gtk_icon_entry_get_gicon (const GtkIconEntry *entry,
			  GtkIconEntryPosition icon_pos)
{
  GtkIconEntryPrivate *priv;
  EntryIconInfo *icon_info;

  g_return_val_if_fail (entry != NULL, NULL);
  g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), NULL);
  g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), NULL);

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);
  icon_info = &priv->icons[icon_pos];

  return icon_info->storage_type == GTK_IMAGE_GICON ? icon_info->gicon : NULL;
}
Пример #10
0
/**
 * sexy_icon_entry_set_icon_highlight
 * @entry: A #SexyIconEntry;
 * @position: Icon position.
 * @highlight: TRUE if the icon should highlight on mouse-over
 *
 * Determines whether the icon will highlight on mouse-over.
 */
void
sexy_icon_entry_set_icon_highlight(SexyIconEntry *entry,
								   SexyIconEntryPosition icon_pos,
								   gboolean highlight)
{
	SexyIconInfo *icon_info;

	g_return_if_fail(entry != NULL);
	g_return_if_fail(SEXY_IS_ICON_ENTRY(entry));
	g_return_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos));

	icon_info = &entry->priv->icons[icon_pos];

	if (icon_info->highlight == highlight)
		return;

	icon_info->highlight = highlight;
}
Пример #11
0
/**
 * gtk_icon_entry_set_icon_highlight
 * @entry: A #GtkIconEntry;
 * @position: Icon position.
 * @highlight: TRUE if the icon should highlight on mouse-over
 *
 * Determines whether the icon will highlight on mouse-over.
 */
void
gtk_icon_entry_set_icon_highlight (const GtkIconEntry *entry,
				   GtkIconEntryPosition icon_pos,
				   gboolean highlight)
{
  EntryIconInfo *icon_info;
  GtkIconEntryPrivate *priv;

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);

  g_return_if_fail (entry != NULL);
  g_return_if_fail (GTK_IS_ICON_ENTRY (entry));
  g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos));

  icon_info = &priv->icons[icon_pos];

  if (icon_info->highlight == highlight)
    return;

  icon_info->highlight = highlight;
}
Пример #12
0
/**
 * gtk_icon_entry_set_tooltip
 * @entry: A #GtkIconEntry.
 * @position: Icon position.
 * @text: The text to be used for the tooltip.
 *
 * Sets the tooltip text used for the specified icon.
 */
void
gtk_icon_entry_set_tooltip (const GtkIconEntry *entry,
			    GtkIconEntryPosition icon_pos,
			    const gchar *text)
{
  EntryIconInfo *icon_info;
  GtkIconEntryPrivate *priv;
  gchar *new_tooltip;

  g_return_if_fail (entry != NULL);
  g_return_if_fail (GTK_IS_ICON_ENTRY (entry));
  g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos));

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);

  icon_info = &priv->icons[icon_pos];

  new_tooltip = g_strdup (text);
  if (icon_info->tooltip_text != NULL)
    g_free (icon_info->tooltip_text);
  icon_info->tooltip_text = new_tooltip;
}