Exemplo n.º 1
0
/**
 * glade_cursor_init:
 *
 * Initializes cursors for use with glade_cursor_set().
 */
void
glade_cursor_init (void)
{
	gchar *path;
	GError *error = NULL;

	cursor = g_new0 (GladeCursor, 1);

	cursor->selector            = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
	cursor->add_widget          = gdk_cursor_new (GDK_PLUS);
	cursor->resize_top_left     = gdk_cursor_new (GDK_TOP_LEFT_CORNER);
	cursor->resize_top_right    = gdk_cursor_new (GDK_TOP_RIGHT_CORNER);
	cursor->resize_bottom_left  = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER);
	cursor->resize_bottom_right = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
	cursor->resize_left         = gdk_cursor_new (GDK_LEFT_SIDE);
	cursor->resize_right        = gdk_cursor_new (GDK_RIGHT_SIDE);
	cursor->resize_top          = gdk_cursor_new (GDK_TOP_SIDE);
	cursor->resize_bottom       = gdk_cursor_new (GDK_BOTTOM_SIDE);
	cursor->drag                = gdk_cursor_new (GDK_FLEUR);
	cursor->add_widget_pixbuf   = NULL;

	/* load "add" cursor pixbuf */
	path = g_build_filename (glade_app_get_pixmaps_dir (), ADD_PIXBUF_FILENAME, NULL);

	cursor->add_widget_pixbuf = gdk_pixbuf_new_from_file (path, &error);

	if (cursor->add_widget_pixbuf == NULL)
	{
		g_critical (_("Unable to load image (%s)"), error->message);

		g_error_free (error);
		error = NULL;
	}
	g_free (path);
}
Exemplo n.º 2
0
static void
register_icon (const gchar    *new_icon_name,
               gint            size,
               const gchar    *icon_name,
               const gchar    *file_name)
{
  GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
  GdkPixbuf *pixbuf;
  GtkIconInfo *info;

  if ((info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size, 0)))
    {
      pixbuf = gtk_icon_info_load_icon (info, NULL);
    }
  else
    {
      gchar *path = g_build_filename (glade_app_get_pixmaps_dir (), file_name, NULL);
      pixbuf = gdk_pixbuf_new_from_file (path, NULL);
      g_free (path);
    }

  if (pixbuf)
    {
      gtk_icon_theme_add_builtin_icon (new_icon_name, size, pixbuf);
      g_object_unref (pixbuf);
    }
}
Exemplo n.º 3
0
/**
 * glade_cursor_init:
 *
 * Initializes cursors for use with glade_cursor_set().
 */
void
glade_cursor_init (void)
{
  gchar *path;
  GError *error = NULL;
  GdkDisplay *display;

  cursor = g_new0 (GladeCursor, 1);
  display = gdk_display_get_default ();

  cursor->selector = NULL;
  cursor->add_widget = gdk_cursor_new_from_name (display, "crosshair");
  cursor->resize_top_left = gdk_cursor_new_from_name (display, "nw-resize");
  cursor->resize_top_right = gdk_cursor_new_from_name (display, "ne-resize");
  cursor->resize_bottom_left = gdk_cursor_new_from_name (display, "sw-resize");
  cursor->resize_bottom_right = gdk_cursor_new_from_name (display, "se-resize");
  cursor->resize_left = gdk_cursor_new_from_name (display, "w-resize");
  cursor->resize_right = gdk_cursor_new_from_name (display, "e-resize");
  cursor->resize_top = gdk_cursor_new_from_name (display, "n-resize");
  cursor->resize_bottom = gdk_cursor_new_from_name (display, "s-resize");
  cursor->drag = gdk_cursor_new_from_name (display, "move");
  cursor->add_widget_pixbuf = NULL;

  /* load "add" cursor pixbuf */
  path =
      g_build_filename (glade_app_get_pixmaps_dir (), ADD_PIXBUF_FILENAME,
                        NULL);

  cursor->add_widget_pixbuf = gdk_pixbuf_new_from_file (path, &error);

  if (cursor->add_widget_pixbuf == NULL)
    {
      g_critical (_("Unable to load image (%s)"), error->message);

      g_error_free (error);
      error = NULL;
    }
  g_free (path);
}
Exemplo n.º 4
0
static cairo_pattern_t *
get_fixed_layout_pattern (void)
{
  static cairo_pattern_t *static_pattern = NULL;

  if (!static_pattern)
    {
      gchar *path = g_build_filename (glade_app_get_pixmaps_dir (), "fixed-bg.png", NULL);
      cairo_surface_t *surface = 
        cairo_image_surface_create_from_png (path);

      if (surface)
        {
          static_pattern = cairo_pattern_create_for_surface (surface);
          cairo_pattern_set_extend (static_pattern, CAIRO_EXTEND_REPEAT);
        }
      else 
        g_warning ("Failed to create surface for %s\n", path);

      g_free (path);
    }
  return static_pattern;
}