Search
lxdream.org :: lxdream/src/gui/support.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/support.c
changeset 1:eea311cfd33e
author nkeynes
date Tue Dec 19 09:51:35 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change First cut of port 576890 (sysreset) and ide enable/disable
file annotate diff log raw
nkeynes@1
     1
/*
nkeynes@1
     2
 * DO NOT EDIT THIS FILE - it is generated by Glade.
nkeynes@1
     3
 */
nkeynes@1
     4
nkeynes@1
     5
#ifdef HAVE_CONFIG_H
nkeynes@1
     6
#  include <config.h>
nkeynes@1
     7
#endif
nkeynes@1
     8
nkeynes@1
     9
#include <sys/types.h>
nkeynes@1
    10
#include <sys/stat.h>
nkeynes@1
    11
#include <unistd.h>
nkeynes@1
    12
#include <string.h>
nkeynes@1
    13
#include <stdio.h>
nkeynes@1
    14
nkeynes@1
    15
#include <gnome.h>
nkeynes@1
    16
nkeynes@1
    17
#include "support.h"
nkeynes@1
    18
nkeynes@1
    19
GtkWidget*
nkeynes@1
    20
lookup_widget                          (GtkWidget       *widget,
nkeynes@1
    21
                                        const gchar     *widget_name)
nkeynes@1
    22
{
nkeynes@1
    23
  GtkWidget *parent, *found_widget;
nkeynes@1
    24
nkeynes@1
    25
  for (;;)
nkeynes@1
    26
    {
nkeynes@1
    27
      if (GTK_IS_MENU (widget))
nkeynes@1
    28
        parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
nkeynes@1
    29
      else
nkeynes@1
    30
        parent = widget->parent;
nkeynes@1
    31
      if (!parent)
nkeynes@1
    32
        parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
nkeynes@1
    33
      if (parent == NULL)
nkeynes@1
    34
        break;
nkeynes@1
    35
      widget = parent;
nkeynes@1
    36
    }
nkeynes@1
    37
nkeynes@1
    38
  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
nkeynes@1
    39
                                                 widget_name);
nkeynes@1
    40
  if (!found_widget)
nkeynes@1
    41
    g_warning ("Widget not found: %s", widget_name);
nkeynes@1
    42
  return found_widget;
nkeynes@1
    43
}
nkeynes@1
    44
nkeynes@1
    45
/* This is an internally used function to create pixmaps. */
nkeynes@1
    46
GtkWidget*
nkeynes@1
    47
create_pixmap                          (GtkWidget       *widget,
nkeynes@1
    48
                                        const gchar     *filename)
nkeynes@1
    49
{
nkeynes@1
    50
  GtkWidget *pixmap;
nkeynes@1
    51
  gchar *pathname;
nkeynes@1
    52
nkeynes@1
    53
  if (!filename || !filename[0])
nkeynes@1
    54
      return gtk_image_new ();
nkeynes@1
    55
nkeynes@1
    56
  pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
nkeynes@1
    57
                                        filename, TRUE, NULL);
nkeynes@1
    58
  if (!pathname)
nkeynes@1
    59
    {
nkeynes@1
    60
      g_warning (_("Couldn't find pixmap file: %s"), filename);
nkeynes@1
    61
      return gtk_image_new ();
nkeynes@1
    62
    }
nkeynes@1
    63
nkeynes@1
    64
  pixmap = gtk_image_new_from_file (pathname);
nkeynes@1
    65
  g_free (pathname);
nkeynes@1
    66
  return pixmap;
nkeynes@1
    67
}
nkeynes@1
    68
nkeynes@1
    69
/* This is an internally used function to create pixmaps. */
nkeynes@1
    70
GdkPixbuf*
nkeynes@1
    71
create_pixbuf                          (const gchar     *filename)
nkeynes@1
    72
{
nkeynes@1
    73
  gchar *pathname = NULL;
nkeynes@1
    74
  GdkPixbuf *pixbuf;
nkeynes@1
    75
  GError *error = NULL;
nkeynes@1
    76
nkeynes@1
    77
  if (!filename || !filename[0])
nkeynes@1
    78
      return NULL;
nkeynes@1
    79
nkeynes@1
    80
  pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
nkeynes@1
    81
                                        filename, TRUE, NULL);
nkeynes@1
    82
nkeynes@1
    83
  if (!pathname)
nkeynes@1
    84
    {
nkeynes@1
    85
      g_warning (_("Couldn't find pixmap file: %s"), filename);
nkeynes@1
    86
      return NULL;
nkeynes@1
    87
    }
nkeynes@1
    88
nkeynes@1
    89
  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
nkeynes@1
    90
  if (!pixbuf)
nkeynes@1
    91
    {
nkeynes@1
    92
      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
nkeynes@1
    93
               pathname, error->message);
nkeynes@1
    94
      g_error_free (error);
nkeynes@1
    95
    }
nkeynes@1
    96
  g_free (pathname);
nkeynes@1
    97
  return pixbuf;
nkeynes@1
    98
}
nkeynes@1
    99
nkeynes@1
   100
/* This is used to set ATK action descriptions. */
nkeynes@1
   101
void
nkeynes@1
   102
glade_set_atk_action_description       (AtkAction       *action,
nkeynes@1
   103
                                        const gchar     *action_name,
nkeynes@1
   104
                                        const gchar     *description)
nkeynes@1
   105
{
nkeynes@1
   106
  gint n_actions, i;
nkeynes@1
   107
nkeynes@1
   108
  n_actions = atk_action_get_n_actions (action);
nkeynes@1
   109
  for (i = 0; i < n_actions; i++)
nkeynes@1
   110
    {
nkeynes@1
   111
      if (!strcmp (atk_action_get_name (action, i), action_name))
nkeynes@1
   112
        atk_action_set_description (action, i, description);
nkeynes@1
   113
    }
nkeynes@1
   114
}
nkeynes@1
   115
.