cropper

diff support.c @ 0:ca9155129253

initial commit code base: gthumb_crop.glade and generated code from it with glade
author meillo@marmaro.de
date Tue, 04 Dec 2007 16:48:51 +0100
parents
children 80535e4deaa4
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/support.c	Tue Dec 04 16:48:51 2007 +0100
     1.3 @@ -0,0 +1,144 @@
     1.4 +/*
     1.5 + * DO NOT EDIT THIS FILE - it is generated by Glade.
     1.6 + */
     1.7 +
     1.8 +#ifdef HAVE_CONFIG_H
     1.9 +#  include <config.h>
    1.10 +#endif
    1.11 +
    1.12 +#include <sys/types.h>
    1.13 +#include <sys/stat.h>
    1.14 +#include <unistd.h>
    1.15 +#include <string.h>
    1.16 +#include <stdio.h>
    1.17 +
    1.18 +#include <gtk/gtk.h>
    1.19 +
    1.20 +#include "support.h"
    1.21 +
    1.22 +GtkWidget*
    1.23 +lookup_widget                          (GtkWidget       *widget,
    1.24 +                                        const gchar     *widget_name)
    1.25 +{
    1.26 +  GtkWidget *parent, *found_widget;
    1.27 +
    1.28 +  for (;;)
    1.29 +    {
    1.30 +      if (GTK_IS_MENU (widget))
    1.31 +        parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
    1.32 +      else
    1.33 +        parent = widget->parent;
    1.34 +      if (!parent)
    1.35 +        parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
    1.36 +      if (parent == NULL)
    1.37 +        break;
    1.38 +      widget = parent;
    1.39 +    }
    1.40 +
    1.41 +  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
    1.42 +                                                 widget_name);
    1.43 +  if (!found_widget)
    1.44 +    g_warning ("Widget not found: %s", widget_name);
    1.45 +  return found_widget;
    1.46 +}
    1.47 +
    1.48 +static GList *pixmaps_directories = NULL;
    1.49 +
    1.50 +/* Use this function to set the directory containing installed pixmaps. */
    1.51 +void
    1.52 +add_pixmap_directory                   (const gchar     *directory)
    1.53 +{
    1.54 +  pixmaps_directories = g_list_prepend (pixmaps_directories,
    1.55 +                                        g_strdup (directory));
    1.56 +}
    1.57 +
    1.58 +/* This is an internally used function to find pixmap files. */
    1.59 +static gchar*
    1.60 +find_pixmap_file                       (const gchar     *filename)
    1.61 +{
    1.62 +  GList *elem;
    1.63 +
    1.64 +  /* We step through each of the pixmaps directory to find it. */
    1.65 +  elem = pixmaps_directories;
    1.66 +  while (elem)
    1.67 +    {
    1.68 +      gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
    1.69 +                                         G_DIR_SEPARATOR_S, filename);
    1.70 +      if (g_file_test (pathname, G_FILE_TEST_EXISTS))
    1.71 +        return pathname;
    1.72 +      g_free (pathname);
    1.73 +      elem = elem->next;
    1.74 +    }
    1.75 +  return NULL;
    1.76 +}
    1.77 +
    1.78 +/* This is an internally used function to create pixmaps. */
    1.79 +GtkWidget*
    1.80 +create_pixmap                          (GtkWidget       *widget,
    1.81 +                                        const gchar     *filename)
    1.82 +{
    1.83 +  gchar *pathname = NULL;
    1.84 +  GtkWidget *pixmap;
    1.85 +
    1.86 +  if (!filename || !filename[0])
    1.87 +      return gtk_image_new ();
    1.88 +
    1.89 +  pathname = find_pixmap_file (filename);
    1.90 +
    1.91 +  if (!pathname)
    1.92 +    {
    1.93 +      g_warning ("Couldn't find pixmap file: %s", filename);
    1.94 +      return gtk_image_new ();
    1.95 +    }
    1.96 +
    1.97 +  pixmap = gtk_image_new_from_file (pathname);
    1.98 +  g_free (pathname);
    1.99 +  return pixmap;
   1.100 +}
   1.101 +
   1.102 +/* This is an internally used function to create pixmaps. */
   1.103 +GdkPixbuf*
   1.104 +create_pixbuf                          (const gchar     *filename)
   1.105 +{
   1.106 +  gchar *pathname = NULL;
   1.107 +  GdkPixbuf *pixbuf;
   1.108 +  GError *error = NULL;
   1.109 +
   1.110 +  if (!filename || !filename[0])
   1.111 +      return NULL;
   1.112 +
   1.113 +  pathname = find_pixmap_file (filename);
   1.114 +
   1.115 +  if (!pathname)
   1.116 +    {
   1.117 +      g_warning ("Couldn't find pixmap file: %s", filename);
   1.118 +      return NULL;
   1.119 +    }
   1.120 +
   1.121 +  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
   1.122 +  if (!pixbuf)
   1.123 +    {
   1.124 +      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
   1.125 +               pathname, error->message);
   1.126 +      g_error_free (error);
   1.127 +    }
   1.128 +  g_free (pathname);
   1.129 +  return pixbuf;
   1.130 +}
   1.131 +
   1.132 +/* This is used to set ATK action descriptions. */
   1.133 +void
   1.134 +glade_set_atk_action_description       (AtkAction       *action,
   1.135 +                                        const gchar     *action_name,
   1.136 +                                        const gchar     *description)
   1.137 +{
   1.138 +  gint n_actions, i;
   1.139 +
   1.140 +  n_actions = atk_action_get_n_actions (action);
   1.141 +  for (i = 0; i < n_actions; i++)
   1.142 +    {
   1.143 +      if (!strcmp (atk_action_get_name (action, i), action_name))
   1.144 +        atk_action_set_description (action, i, description);
   1.145 +    }
   1.146 +}
   1.147 +