/home/fernape/Projects/lkmonitor/src/support.c

Go to the documentation of this file.
00001 /*
00002         lkmonitor (Linux Kernel Monitor)
00003 
00004         Application for monitoring and tuning a Linux kernel.
00005 
00006         Copyright (C) 2005-2008  Fernando ApesteguĂ­a
00007 
00008         This program is free software; you can redistribute it and/or
00009         modify it under the terms of the GNU General Public License
00010         as published by the Free Software Foundation; either version 2
00011         of the License, or (at your option) any later version.
00012 
00013         This program is distributed in the hope that it will be useful,
00014         but WITHOUT ANY WARRANTY; without even the implied warranty of
00015         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016         GNU General Public License for more details.
00017 
00018         You should have received a copy of the GNU General Public License
00019         along with this program; if not, write to the Free Software
00020         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021 */
00022 
00023 /*
00024  * DO NOT EDIT THIS FILE - it is generated by Glade.
00025  */
00026 
00027 #ifdef HAVE_CONFIG_H
00028 #  include <config.h>
00029 #endif
00030 
00031 #include <sys/types.h>
00032 #include <sys/stat.h>
00033 #include <unistd.h>
00034 #include <string.h>
00035 #include <stdio.h>
00036 
00037 #include <gnome.h>
00038 
00039 #include "support.h"
00040 
00041 GtkWidget*
00042 lookup_widget                          (GtkWidget       *widget,
00043                                         const gchar     *widget_name)
00044 {
00045   GtkWidget *parent, *found_widget;
00046 
00047   for (;;)
00048     {
00049       if (GTK_IS_MENU (widget))
00050         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
00051       else
00052         parent = widget->parent;
00053       if (!parent)
00054         parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
00055       if (parent == NULL)
00056         break;
00057       widget = parent;
00058     }
00059 
00060   found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
00061                                                  widget_name);
00062   if (!found_widget)
00063     g_warning ("Widget not found: %s", widget_name);
00064   return found_widget;
00065 }
00066 
00067 /* This is an internally used function to create pixmaps. */
00068 GtkWidget*
00069 create_pixmap                          (GtkWidget       *widget,
00070                                         const gchar     *filename)
00071 {
00072   GtkWidget *pixmap;
00073   gchar *pathname;
00074 
00075   if (!filename || !filename[0])
00076       return gtk_image_new ();
00077 
00078   pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00079                                         filename, TRUE, NULL);
00080   if (!pathname)
00081     {
00082       g_warning (_("Couldn't find pixmap file: %s"), filename);
00083       return gtk_image_new ();
00084     }
00085 
00086   pixmap = gtk_image_new_from_file (pathname);
00087   g_free (pathname);
00088   return pixmap;
00089 }
00090 
00091 /* This is an internally used function to create pixmaps. */
00092 GdkPixbuf*
00093 create_pixbuf                          (const gchar     *filename)
00094 {
00095   gchar *pathname = NULL;
00096   GdkPixbuf *pixbuf;
00097   GError *error = NULL;
00098 
00099   if (!filename || !filename[0])
00100       return NULL;
00101 
00102   pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00103                                         filename, TRUE, NULL);
00104 
00105   if (!pathname)
00106     {
00107       g_warning (_("Couldn't find pixmap file: %s"), filename);
00108       return NULL;
00109     }
00110 
00111   pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
00112   if (!pixbuf)
00113     {
00114       fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
00115                pathname, error->message);
00116       g_error_free (error);
00117     }
00118   g_free (pathname);
00119   return pixbuf;
00120 }
00121 
00122 /* This is used to set ATK action descriptions. */
00123 void
00124 glade_set_atk_action_description       (AtkAction       *action,
00125                                         const gchar     *action_name,
00126                                         const gchar     *description)
00127 {
00128   gint n_actions, i;
00129 
00130   n_actions = atk_action_get_n_actions (action);
00131   for (i = 0; i < n_actions; i++)
00132     {
00133       if (!strcmp (atk_action_get_name (action, i), action_name))
00134         atk_action_set_description (action, i, description);
00135     }
00136 }
00137 

Generated on Tue Apr 1 22:52:52 2008 for lkmonitor by  doxygen 1.5.1