This is just a code snippet, not a complete app:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#define GLADE_FILE "glade/connmgr.glade"
typedef struct
{
GtkWidget *tabbed_notebook;
GtkWidget *host_entry;
} MyWidgets;
int create_home_appdir(char *appdir)
{
mode_t mode = (S_IRWXU);
int isdir = chdir(appdir);
if(isdir != 0)
{
mkdir(appdir, mode);
}
isdir = chdir(appdir);
if(isdir != 0)
{
printf("***ERROR*** Cannot see directory: %s\n", appdir);
return 1;
}
return 0;
}
int main (int argc, char *argv[])
{
GtkWidget *main_dialog;
GladeXML *gxml;
MyWidgets *widgets;
// create the application directory within the homespace
char *user = getenv("HOME");
char dotappname[10] = "/.connmgr";
char appdir[1024];
strcpy(appdir, user);
strcat(appdir, dotappname);
create_home_appdir(appdir);
widgets = g_slice_new (MyWidgets);
// initialize the GTK+ library
gtk_init (&argc, &argv);
// build GladeXML object from the glade XML file
gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
// get widgets from GladeXML object
main_dialog = glade_xml_get_widget (gxml, "main_dialog");
widgets->host_entry = glade_xml_get_widget (gxml, "host_entry");
}
The above code snippet does not compile correctly. Oddly enough, if I remove the line:
create_home_appdir(appdir);...the snippet compiles correctly.
However, with it un-commented, it dies with the following error message:
Quote:
(connmgr:22246): libglade-WARNING **: could not find glade file 'glade/connmgr.glade'
...any ideas why?
I'm compiling the above snippet with the following line:
gcc -o connmgr src/connmgr.c `pkg-config --cflags --libs libglade-2.0`-export-dynamic
Please keep in mind, I'm just starting out with C, so feel free to give as much constructive criticism as possible.
Thanks,
-Lup