Main Page | Data Structures | File List | Data Fields | Globals

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,2006  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 #ifdef HAVE_CONFIG_H
00024 #  include <config.h>
00025 #endif
00026 
00027 #include <sys/types.h>
00028 #include <sys/stat.h>
00029 #include <unistd.h>
00030 #include <string.h>
00031 #include <stdio.h>
00032 
00033 #include <gnome.h>
00034 
00035 #include "support.h"
00036 
00037 GtkWidget*
00038 lookup_widget                          (GtkWidget       *widget,
00039                                         const gchar     *widget_name)
00040 {
00041   GtkWidget *parent, *found_widget;
00042 
00043   for (;;)
00044     {
00045       if (GTK_IS_MENU (widget))
00046         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
00047       else
00048         parent = widget->parent;
00049       if (!parent)
00050         parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
00051       if (parent == NULL)
00052         break;
00053       widget = parent;
00054     }
00055 
00056   found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
00057                                                  widget_name);
00058   if (!found_widget)
00059     g_warning ("Widget not found: %s", widget_name);
00060   return found_widget;
00061 }
00062 
00063 /* This is an internally used function to create pixmaps. */
00064 GtkWidget*
00065 create_pixmap                          (GtkWidget       *widget,
00066                                         const gchar     *filename)
00067 {
00068   GtkWidget *pixmap;
00069   gchar *pathname;
00070 
00071   if (!filename || !filename[0])
00072       return gtk_image_new ();
00073 
00074   pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00075                                         filename, TRUE, NULL);
00076   if (!pathname)
00077     {
00078       g_warning (_("Couldn't find pixmap file: %s"), filename);
00079       return gtk_image_new ();
00080     }
00081 
00082   pixmap = gtk_image_new_from_file (pathname);
00083   g_free (pathname);
00084   return pixmap;
00085 }
00086 
00087 /* This is an internally used function to create pixmaps. */
00088 GdkPixbuf*
00089 create_pixbuf                          (const gchar     *filename)
00090 {
00091   gchar *pathname = NULL;
00092   GdkPixbuf *pixbuf;
00093   GError *error = NULL;
00094 
00095   if (!filename || !filename[0])
00096       return NULL;
00097 
00098   pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00099                                         filename, TRUE, NULL);
00100 
00101   if (!pathname)
00102     {
00103       g_warning (_("Couldn't find pixmap file: %s"), filename);
00104       return NULL;
00105     }
00106 
00107   pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
00108   if (!pixbuf)
00109     {
00110       fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
00111                pathname, error->message);
00112       g_error_free (error);
00113     }
00114   g_free (pathname);
00115   return pixbuf;
00116 }
00117 
00118 /* This is used to set ATK action descriptions. */
00119 void
00120 glade_set_atk_action_description       (AtkAction       *action,
00121                                         const gchar     *action_name,
00122                                         const gchar     *description)
00123 {
00124   gint n_actions, i;
00125 
00126   n_actions = atk_action_get_n_actions (action);
00127   for (i = 0; i < n_actions; i++)
00128     {
00129       if (!strcmp (atk_action_get_name (action, i), action_name))
00130         atk_action_set_description (action, i, description);
00131     }
00132 }

Generated on Wed Feb 15 11:24:01 2006 for lkmonitor by  doxygen 1.3.9.1