(custom_command == NULL || sizeof(custom_command) <= 0) custom_command is a gchar pointer, so, using sizeof simply gives you the size of the pointer, not the length of the string. "sizeof(custom_command) <= 0" will always be the size of a gchar pointer (4 bytes on my system).
If you're looking for the length of characters in the string, try using g_utf8_strlen() instead. - Micah Carrick www.micahcarrick.com www.gtkforums.com Tony Freeman wrote: > Hello, > > I have two problems I'm trying to work through that maybe someone here > can help me with. > > I have a GtkEntry called a 'custom_command_entry'. I would like to trim > white space from the beginning and end of what a user may enter in this > field. custom_command_entry is a global. > > This is what I have so far: > > void on_executebutton_clicked (GtkWidget *widget, gpointer data) > { > const gchar *custom_command; > gchar *entry_wfo1, *entry_wfo2; > > /* GET THE BACKUP WFO SELECTION */ > entry_wfo1 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combobox1)); > > /* GET THE LOCALIZED WFO SELECTION */ > entry_wfo2 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combobox2)); > > /* GET THE CUSTOM COMMAND */ > custom_command = > g_strdup(gtk_entry_get_text(GTK_ENTRY(custom_command_entry))); > g_strstrip(custom_command); > > if (custom_command == NULL || sizeof(custom_command) <= 0) { > g_print("entry1 = %s :: entry2 = %s \n", entry_wfo1, > entry_wfo2); > } else { > g_print("Custom Command: %s\n", custom_command); > } > > gtk_widget_show(confirmdialog); > } > > The 'if' statement above ALWAYS returns false, so that the custom > command is always printed to output even if there is nothing to print. > > The idea is that the user can override the default command to run by > typing in a command in the 'custom_command_entry' GtkEntry field. If > there is no command there, just whitespace, then the program needs to > run the default command. > > Please help! > > -- Tony > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list