Re: How does one set background color for entire line in textview? - not possible

2007-01-16 Thread Tony Freeman
I've searched all over and I figure that this type of functionality is
not possible at the current time.

I'll just have to do without :-)

-- Tony


On Mon, 2007-01-15 at 15:06 -0500, Tony Freeman wrote:
 Hello,
 
 I have a function that takes the output of a spawned process and
 displays that in a text buffer (part of a notebook widget).  When the
 spawned process is finished, I'd like to put some colorized text at the
 bottom of the text buffer/view that alerts the user that the process is
 done.
 
 What I want is the entire line to have a background color of blue.  The
 code that I have so far just displays the blue background under the
 text.
 
 How do I make the entire line blue?
 
 
 switch (status) {
   case G_IO_STATUS_NORMAL:
   return TRUE;
   default:
   /* Use a tag to make the DONE notification noticeable */
   tag = gtk_text_buffer_create_tag (
   buffer, done_notification, 
   foreground, white, 
   background, blue, 
   justification, GTK_JUSTIFY_CENTER,
   background-full-height, TRUE,
   NULL);
   start_byte = gtk_text_buffer_get_char_count(buffer);
   gtk_text_buffer_insert(buffer, iter, 
   \n--\nDONE\n--\n, -1);
   end_byte = gtk_text_buffer_get_char_count(buffer);
   gtk_text_buffer_get_iter_at_offset (buffer, 
   start, start_byte);
   gtk_text_buffer_get_iter_at_offset (buffer, 
   end, end_byte);
   gtk_text_buffer_apply_tag (buffer, tag, start, end);
   end_mark = gtk_text_buffer_create_mark(
   buffer, end_mark, end, FALSE);
   gtk_text_view_scroll_to_mark(textview, end_mark, 
   0.0, FALSE, 0.0, 0.0);
   return FALSE;
 }
 
 -- 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


How does one set background color for entire line in textview?

2007-01-15 Thread Tony Freeman
Hello,

I have a function that takes the output of a spawned process and
displays that in a text buffer (part of a notebook widget).  When the
spawned process is finished, I'd like to put some colorized text at the
bottom of the text buffer/view that alerts the user that the process is
done.

What I want is the entire line to have a background color of blue.  The
code that I have so far just displays the blue background under the
text.

How do I make the entire line blue?


switch (status) {
case G_IO_STATUS_NORMAL:
return TRUE;
default:
/* Use a tag to make the DONE notification noticeable */
tag = gtk_text_buffer_create_tag (
buffer, done_notification, 
foreground, white, 
background, blue, 
justification, GTK_JUSTIFY_CENTER,
background-full-height, TRUE,
NULL);
start_byte = gtk_text_buffer_get_char_count(buffer);
gtk_text_buffer_insert(buffer, iter, 
\n--\nDONE\n--\n, -1);
end_byte = gtk_text_buffer_get_char_count(buffer);
gtk_text_buffer_get_iter_at_offset (buffer, 
start, start_byte);
gtk_text_buffer_get_iter_at_offset (buffer, 
end, end_byte);
gtk_text_buffer_apply_tag (buffer, tag, start, end);
end_mark = gtk_text_buffer_create_mark(
buffer, end_mark, end, FALSE);
gtk_text_view_scroll_to_mark(textview, end_mark, 
0.0, FALSE, 0.0, 0.0);
return FALSE;
}

-- Tony

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How does one pipe output from process to text buffer? -- FIXED

2006-12-31 Thread Tony Freeman
On Sun, 2006-12-31 at 05:43 +, [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On Sat, Dec 30, 2006 at 12:15:33AM -0500, Tony Freeman wrote:
  Thanks everyone, I have this working now :-)  Special thanks to Tomas!
 
 happy it helped :-)
 
 Still strange that it blocks, though. Perhaps
 g_spawn_async_with_pipes(...) gives you channels in blocking mode (I'd
 doubt that, but I don't know for sure).
 
 You might try this out e.g. with
 
   g_io_channel_set_flags(gioout,
  G_IO_FLAG_NONBLOCK | g_io_channel_get_flags(gioout)),
  err); /* or NULL, if you live on the edge */
 
 right after the gioout = g_io_channel_unix_new(...)
 
 Regards
 - -- tomás

Thank you again!  That was exactly the answer :-)  The application does
not freeze at all now.

Excellent!


GPid pid;
gint stdout;
GIOChannel *gioout;
g_spawn_async_with_pipes( NULL, 
ssh_command, 
NULL, 
G_SPAWN_SEARCH_PATH,
NULL,
NULL,
pid,
NULL, stdout, NULL,
NULL );
gioout = g_io_channel_unix_new(stdout);
g_io_channel_set_flags(gioout, G_IO_FLAG_NONBLOCK, NULL);
g_io_channel_get_flags(gioout);


-- Tony


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How does one pipe output from process to text buffer? -- FIXED

2006-12-29 Thread Tony Freeman
Thanks everyone, I have this working now :-)  Special thanks to Tomas!

The program still freezes for a very brief moment, but then it comes
quickly back to life with wonderful data spilling onto the notebook
pages. 


Here's the target function:


void on_confirm_okbutton_clicked (GtkWidget *widget, gpointer data)
{
gchar *tmp_ssh_command;
gchar **ssh_command;
gint i = 0;
gint count = g_strv_length(serverlist);

/* remove any existing notebook pages */
remove_notebook_pages(GTK_NOTEBOOK(notebook1));

/* start a process for each server */
for (i=0; icount; i++ ) {
tmp_ssh_command=g_strjoin( , SSH_PROGRAM, serverlist[i], 
  MAINSCRIPT_PROGRAM, command, 
  serverlist[i], NULL);
ssh_command = g_strsplit(tmp_ssh_command,  , -1);

/* create notebook page with textview for this process */
GtkWidget *textview;
GtkWidget *scroller;
GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);
GtkWidget *label = gtk_label_new(serverlist[i]);
textview = gtk_text_view_new_with_buffer(buffer);

scroller = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller),
 GTK_POLICY_AUTOMATIC,
 GTK_POLICY_AUTOMATIC);

gtk_container_add(GTK_CONTAINER(scroller), textview);

gtk_notebook_insert_page(GTK_NOTEBOOK(notebook1), 
 scroller, label, i);

gtk_widget_show_all(notebook1);

/* spawn off the process */
GPid pid;
gint stdout;
GIOChannel *gioout;
g_spawn_async_with_pipes( NULL, 
ssh_command, 
NULL, 
G_SPAWN_SEARCH_PATH,
NULL,
NULL,
pid,
NULL, stdout, NULL,
NULL );
gioout = g_io_channel_unix_new(stdout);
g_io_add_watch_full(gioout, 
G_PRIORITY_DEFAULT,

(GIOCondition)(G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL), 
(GIOFunc)watch_out_callback, 
textview,
NULL);
g_io_channel_unref(gioout);
g_free(tmp_ssh_command);
}

gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook1), 0);

gtk_widget_show(progressdialog);
gtk_widget_hide(confirmdialog);
}


And here is the callback function.  The new item I added that I think
helped stop the program from freezing is the addtion of an iter and 
a call to 'gtk_text_buffer_get_end_iter'.  


gboolean watch_out_callback (GIOChannel *channel, 
GIOCondition condition, 
gpointer data)
{
GIOStatus status = G_IO_STATUS_NORMAL;
GtkTextView *textview;
GtkTextBuffer *buffer;
GtkTextIter iter;
GtkTextMark *mark;
gchar buf[512];
gsize bytes_read;

/* set up pointers to our textbuffer */
textview = GTK_TEXT_VIEW((GtkWidget *)data);
buffer = gtk_text_view_get_buffer(textview);
gtk_text_buffer_get_end_iter(buffer, iter);

/* send ssh output to our gui */
status = g_io_channel_read_chars(channel, buf, sizeof(buf), 
bytes_read, NULL);
if (bytes_read) {
gtk_text_buffer_insert(buffer, iter, buf, bytes_read);
}

/* decide if we should close the channel */
switch (status) {
case G_IO_STATUS_NORMAL:
return TRUE;
default:
return FALSE;
}
}


Thanks for helping me get through this.  It sure was the most difficult part of 
this 
program.  I still have a lot to do, but mainly cosmetic compared to this.

Thanks!


-- Tony


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How does one pipe output from process to text buffer?

2006-12-28 Thread Tony Freeman
On Wed, 2006-12-27 at 06:17 +, [EMAIL PROTECTED] wrote: 
 On Tue, Dec 26, 2006 at 10:41:33PM -0500, Tony Freeman wrote:
  Hello,
  
  I need some example code or a tutorial for how to pipe output from a
  process to a GtkTextBuffer.
  
  The idea of this program is to spawn off 6 or more ssh commands and have
  the output go to it's own textbuffer in it's assigned notebook page.
  
  This is what I have so far.  Now I need the output from the process to
  go to it's respective text buffer.
  
  
  void on_confirm_okbutton_clicked (GtkWidget *widget, gpointer data)
  {
  /* 
   * Globals used:
   *  serverlist : string array of server names
   *  command: the options to send to mainscript program
   *  notebook1  : notebook widget
   */
 [...]
  /* now fire off the process and redirect output
   * to our textbuffer */
  GPid pid;
  g_spawn_async_with_pipes( NULL,
ssh_command, 
NULL, 
G_SPAWN_CHILD_INHERITS_STDIN,
NULL,
NULL,
pid,
NULL, NULL, NULL,
NULL );
  }
 
 This looks like the interesting part. First of all, I doubt
 G_SPAWN_CHILD_INHERITS_STDIN is what you are after. I guess you'll have
 to give each child its own file descriptors (possibly all three, to let
 the user see possible errors), like so:
 
 | GPid pid;
 | gint stdin, stdout, stderr;
 | g_spawn_async_with_pipes( NULL,/* workdir */
 |   ssh_command, /* argv */
 |   NULL,/* envp */
 |   NULL,/* flags */
 |   NULL,/* child setup func */
 |   NULL,/* --- udata */
 |   pid,
 |   stdin, stdout, stderr,
 |   NULL );  /* error */
 
 Now you'll have to catch whatever comes from stdout and stderr and
 append it to the text buffer of the text widget (possibly making sure
 that the in and err part don't get too messed up, and possibly making
 nifty things like painting the errors in red :-). Likewise, you'll have
 to (somehow) collect user input, sending it via stdin to the process
 (when it is ready to take input).
 
 To this purpose, you may wrap the descriptors in GIOChannels and watch
 the channels with g_io_add_watch(), which is just a fancy way to use the
 select() system call. I'll sketch this with stdin (the others work
 analogously). In a full-fledged version you'll typically want to collect
 all this stuff in a struct which you may attach to the corresponding
 notebook widget, so you may easily find all those thingies in callbacks,
 etc -- like so:
 
 |  typedef struct {
 |GIOChannel *stdin;
 |GIOChannel *stdout;
 |GIOChannel *stderr;
 |/* other useful things like the text widget go here */
 |  } ssh_slave;
 
 Now comes the fun part. After the spawn_async() (and after checking for
 errors ;-) you do:
 
 |  ssh_slave *slave = g_new(ssh_slave, 1);
 |  slave-stdin = g_io_channel_unix_new(stdin);
 |  GIOFunc watch_slave;
 |  g_io_channel_add_watch_full(ch_stdin, G_IO_IN, watch_slave, slave);
 
 
 Then you define your watch function (I'd use the same function for all
 three channels, but I'm a really, really lazy person ;-)
 
 | gboolean watch_slave(GIOChannel *src, GIOCondition *cond, gpointer udata)
 | {
 |   ssh_slave *slave = (ssh_slave *) udata; /* hopefully ;-) */
 |   gchar buf[1024]; /* or another meaningful size */
 |   GIOstatus st;
 |   GIOError *err;
 | 
 |   /* this is for stdin, stderr: */
 |   st = g_io_channel_read_chars(src, buf, sizeof(buf), got, err);
 |   /* handle errors */
 |   ...
 |   /* append whatever you got to the text widget, which you can hopefully
 |  pull from slave */
 |   ...
 |   /* Do likewise for stdout. You might have a buffer of pending chars
 |  hidden in slave-xxx and add/remove the write watch depending
 |  on whether there is write pending (otherwise the program will hog
 |  CPU spinning here). */
 |   ...
 |   return TRUE; /* typically. Return FALSE if you want the watch removed */
 | }
 
 That's at least how I go about this. Hope it gives you some ideas.
 
 Regards
 - -- tomás

Thanks!

I'm getting really close now!  Thanks for your help.

Currently, I have the program doing what I want but for one thing ... it
freezes until all my ssh commands have returned.  Once control is
returned, all the notebook pages have all the proper ssh output
associated

How does one pipe output from process to text buffer?

2006-12-26 Thread Tony Freeman
Hello,

I need some example code or a tutorial for how to pipe output from a
process to a GtkTextBuffer.

The idea of this program is to spawn off 6 or more ssh commands and have
the output go to it's own textbuffer in it's assigned notebook page.

This is what I have so far.  Now I need the output from the process to
go to it's respective text buffer.


void on_confirm_okbutton_clicked (GtkWidget *widget, gpointer data)
{
/* 
 * Globals used:
 *  serverlist : string array of server names
 *  command: the options to send to mainscript program
 *  notebook1  : notebook widget
 */

gchar *tmp_ssh_command;
gchar **ssh_command;
gint i = 0;
gint count = g_strv_length(serverlist);

/* remove any existing notebook pages */
remove_notebook_pages(GTK_NOTEBOOK(notebook1));

/* start a process for each server */
for (i=0; icount; i++ ) {
tmp_ssh_command=g_strjoin( , SSH_PROGRAM, serverlist[i],
MAINSCRIPT_PROGRAM, command, NULL);
ssh_command = g_strsplit(tmp_ssh_command,  , -1);

/* CREATE NOTEBOOK PAGE FOR THIS PROCESS */

/* create textview */
GtkWidget *textview;
GtkWidget *scroller;
GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);
GtkWidget *label = gtk_label_new(serverlist[i]);
gchar *introtext = g_strdup_printf(WORKING ON: %s\n%s\n,
serverlist[i], tmp_ssh_command);
textview = gtk_text_view_new_with_buffer(buffer);
gtk_text_buffer_set_text(buffer, introtext, -1);
g_free(introtext);
g_free(tmp_ssh_command);
gtk_widget_show(textview);

/* create scrolled window for textview */
scroller = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(
GTK_SCROLLED_WINDOW(scroller),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER);
gtk_widget_show(scroller);
gtk_container_add(GTK_CONTAINER(scroller), textview);

/* finally create the notebook page */
gtk_notebook_insert_page(
GTK_NOTEBOOK(notebook1), 
scroller, label, i);

/* now fire off the process and redirect output
 * to our textbuffer */
GPid pid;
g_spawn_async_with_pipes( NULL,
  ssh_command, 
  NULL, 
  G_SPAWN_CHILD_INHERITS_STDIN,
  NULL,
  NULL,
  pid,
  NULL, NULL, NULL,
  NULL );
}

gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook1), 0);

gtk_widget_show(progressdialog);
gtk_widget_hide(confirmdialog);
}

Any help, pointers, tips would be appreciated :-)

-- Tony


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_array_new problem with initializer element

2006-12-25 Thread Tony Freeman
On Mon, 2006-12-25 at 09:19 +0100, David Nečas (Yeti) wrote:
 On Mon, Dec 25, 2006 at 12:22:50AM -0500, Tony Freeman wrote:
  What am I doing wrong?  I would like an array of gchar values.  The
  gchar values would be lx1 lx2 dx1 that a user would select from a
  GtkTreeView.
 
 Why you ceate some GArray instead of a GtkListStore -- you
 will have to create a tree model anyway, so why not use it
 directly as the storage?
 
  However, the following line gives an error:
  
  GArray *serverlist = g_array_new(TRUE, FALSE, sizeof(gchar));
 
 lx1 and lx2 do not look like single characters, so this
 is probably wrong.  You created an array of *characters*,
 not an array of strings.
 
  The error is:
  
  main.c:58: error: initializer element is not constant
 
 serverlist is a global variable, right?  Global variables
 have to be initialized with constants in C.  You can move
 the initializer to main() or some initialization function,
 but global variables are Evil and in most cases the best
 approach is to avoid them anyway.
 
 Yeti

Thanks Yeti,

Your hint about creating an array of characters as opposed to an array
of strings pointed me in the right direction.  I've changed the code to
create a null terminated string array with this command:

serverlist = g_strsplit(tmp_server_list,  , -1);


Here's the edited down version of the code:

void on_executebutton_clicked (GtkWidget *widget, gpointer data)
{
/* **
NOTE: THE FOLLOWING ARE GLOBALS:
treeview_servers : treeview widget
list_of_servers  : a string to use for a label
serverlist   : string array of server names
 * **/

GtkTreeSelection *servers_selection;
GtkTreeModel *servers_model;
GList *list = NULL;
gchar *tmp_server_list = ;

/* POPULATE GLOBAL 'serverlist' and 'list_of_servers' */

/* get the list of selected servers */
servers_selection =
gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview_servers));
servers_model =
gtk_tree_view_get_model(GTK_TREE_VIEW(treeview_servers));
machines = gtk_tree_selection_get_selected_rows(servers_selection,
servers_model);

for (list = machines; list != NULL; list = g_list_next(list)) {
GtkTreeIter iter;
GtkTreePath *path = list-data;
if (gtk_tree_model_get_iter(servers_model, iter, path)) {
gchar *text;
gtk_tree_model_get(servers_model, iter, 1, text, -1);
tmp_server_list = g_strjoin( , tmp_server_list, text, 
NULL);
}
gtk_tree_path_free(path);
}
g_list_free(list);

g_strstrip(tmp_server_list);
list_of_servers = tmp_server_list;
serverlist = g_strsplit(tmp_server_list,  , -1);

gtk_widget_show(confirmdialog);

}


I can now walk through the string array to build my command:


void on_confirm_okbutton_clicked (GtkWidget *widget, gpointer data)
{
/* 
   NOTE: THE FOLLOWING ARE GLOBALS:
serverlist : string array of server names
 * /

gchar *ssh_command = ;
gint i = 0;
gint count = g_strv_length(serverlist);

/* TODO: build the ssh command and start a process for each server */
for (i=0; icount; i++) {
ssh_command=g_strjoin( , ssh, serverlist[i], 
MAINSCRIPT_PROGRAM,
command, NULL);
g_print(SSH Command: %s\n, ssh_command);
}

/* TODO: run command on each server sending output to temporary text
buffers */

gtk_widget_show(progressdialog);
gtk_widget_hide(confirmdialog);
}


Thanks for the insight!

-- Tony

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

g_array_new problem with initializer element

2006-12-24 Thread Tony Freeman
Hello,

What am I doing wrong?  I would like an array of gchar values.  The
gchar values would be lx1 lx2 dx1 that a user would select from a
GtkTreeView.  However, the following line gives an error:

GArray *serverlist = g_array_new(TRUE, FALSE, sizeof(gchar));

The error is:

main.c:58: error: initializer element is not constant

I went to 'codebase' (http://www.codase.com/) and found all sorts of
examples of how to create an array in glib ... why does this not work
for me?


-- Tony


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Trimming GtkEntry Text

2006-12-22 Thread Tony Freeman
Thanks!  

That fixed my 'custom_command' problem.  Here's the working code:

void on_executebutton_clicked (GtkWidget *widget, gpointer data)
{
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 || g_utf8_strlen(custom_command, -1) = 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);
g_free(custom_command);
}

-- Tony


On Thu, 2006-12-21 at 19:54 -0800, Micah Carrick wrote:
 (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


Trimming GtkEntry Text

2006-12-21 Thread Tony Freeman
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


Re: GtkComboBox question

2006-12-20 Thread Tony Freeman
On Tue, 2006-12-19 at 16:21 -0800, Russell Markus wrote:
 I am trying to work on an application which has a combo box.  I want to
 restrict the user to values that are included in the drop down list only.
 My thought was to prevent the user from editing the value in the entry box,
 but I can't seem to find a way to do this.
 
 I am running Fedora Core 6, and developed the application using glade-2.  I
 am not using the lib, but working with the generated C code.
 
 Thanks for any assistance.


Hello Russell,

I had to do something similar recently.  I used glade to build the
interface, but then had to go back and remove the GtkComboBoxEntry
widgest and replace them with GtkCombobox widgets.

Here's the code with a note:

Note #1:  localization_sites is a global.  The value is populated by the
user via a configuration file. (gchar **localization_sites;)


void build_wfo_list (GtkWidget *combobox)
{
gint i=0;
gint count=0;

/* FILL IN THE DROP DOWN LIST */
count = g_strv_length(localization_sites);
for (i=0; icount; i++) {
gtk_combo_box_append_text(GTK_COMBO_BOX(combobox),
  localization_sites[i]);
}

/* SET A DEFAULT SELECTION */
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
}

-- Tony

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Proper way to show unique icon in treeview -- FIXED :-)

2006-12-18 Thread Tony Freeman
  Hello,
  
  I need help understanding how one would create a treeview so that the
  first column is an icon and the second column is text.  The icon and
  text represent the type of machine the user can choose (linux
  workstation, linux server, hp).  I want to have a different icon for
  each machine; however, I notice that whatever icon is called last in the
  code that I have written, is the icon that is shown for ALL the rows.  
  
  Please help!  What am I doing wrong?
 
 I forgot to attach the code!
 
 Here it is:
 
 
 void build_server_list (GtkWidget *treeview)
 {
   GtkListStore *liststore;
   GtkTreeIter iter;
   GtkCellRenderer *text_renderer;
   GtkCellRenderer *icon_renderer;
   gint i = 0;
   gint count = 0;
   
 
   icon_renderer = gtk_cell_renderer_pixbuf_new();
   gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(treeview),
0,  
 ,  
icon_renderer,
NULL);
   
   text_renderer = gtk_cell_renderer_text_new();
   gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(treeview),
1,  
 ,  
text_renderer,
NULL);
   
   liststore = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
   
   /* workstations */
   count = g_strv_length(workstations);
   g_object_set(icon_renderer, stock-id, gtk-close, NULL);
   for (i=0; icount; i++) {
   gtk_list_store_append(liststore, iter);
   gtk_list_store_set(liststore, iter,
   0, icon_renderer,
   1, workstations[i], -1);
   }
   
   /* linux servers */
   count = g_strv_length(servers_linux);
   g_object_set(icon_renderer, stock-id, gtk-save, NULL);
   for (i=0; icount; i++) {
   gtk_list_store_append(liststore, iter);
   gtk_list_store_set(liststore, iter,
   0, icon_renderer,
   1, servers_linux[i], -1);
   }
   
   
   /* hp servers */
   count = g_strv_length(servers_hp);
   g_object_set(icon_renderer, stock-id, gtk-open, NULL);
   for (i=0; icount; i++) {
   gtk_list_store_append(liststore, iter);
   gtk_list_store_set(liststore, iter,
   0, icon_renderer,
   1, servers_hp[i], -1);
   }
   
   gtk_tree_view_set_model(GTK_TREE_VIEW(treeview),
 GTK_TREE_MODEL(liststore));
 }
 

Thanks to all who replied with comments.  

Here is the working function:

void build_server_list (GtkWidget *treeview)
{
GtkListStore *liststore;
GtkTreeIter iter;
GtkCellRenderer *text_renderer = gtk_cell_renderer_text_new();
GtkCellRenderer *pixbuf_renderer = gtk_cell_renderer_pixbuf_new();
GdkPixbuf *ws_pixbuf, *sv_pixbuf, *hp_pixbuf;
GtkTreeViewColumn *pixbuf_column, *text_column;
gint i = 0;
gint count = 0;


/* CREATE THE LISTSTORE MODEL */

liststore = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);


/* ATTACHED THE LISTSTORE MODEL TO THE TREEVIEW */

gtk_tree_view_set_model(GTK_TREE_VIEW(treeview),
GTK_TREE_MODEL(liststore));


/* DESCRIBE EACH COLUMN */

pixbuf_column = gtk_tree_view_column_new_with_attributes (
Icon, 
pixbuf_renderer,
pixbuf, 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), pixbuf_column);

text_column = gtk_tree_view_column_new_with_attributes (
Machine, 
text_renderer,
text, 1,
NULL);

gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), text_column);


/* GET SOME STOCK ICONS */
/* getting a 'pixbuf' icon is the key here */

ws_pixbuf = gtk_widget_render_icon(treeview, GTK_STOCK_ABOUT,
GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
sv_pixbuf = gtk_widget_render_icon(treeview, GTK_STOCK_HARDDISK,
GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
hp_pixbuf = gtk_widget_render_icon(treeview, GTK_STOCK_NETWORK,
GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);


/* FILL LISTSTORE MODEL WITH DATA */

/* workstations */
count = 

RE: Problem with gtk

2006-12-17 Thread Tony Freeman
Hello,

  int main ()
{
  int i;
  while (i  25000)
  printf (%d\n, i);
} 

Create a file called test.c and add these lines:

#include stdio.h

int main (int argc, char *argv[])
{
int i = 0;

while (i  25000) {
printf(%d\n, i++);
}

return 0;
}


Now compile the program with this command:

gcc -Wall -o test test.c


If compilation was successful, run he program:

./test


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Proper way to show unique icon in treeview

2006-12-17 Thread Tony Freeman
Hello,

I need help understanding how one would create a treeview so that the
first column is an icon and the second column is text.  The icon and
text represent the type of machine the user can choose (linux
workstation, linux server, hp).  I want to have a different icon for
each machine; however, I notice that whatever icon is called last in the
code that I have written, is the icon that is shown for ALL the rows.  

Please help!  What am I doing wrong?

-- Tony


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Makefile.am Help for GnomeProgram make errors

2006-12-16 Thread Tony Freeman
Hello,

I am using Anjuta.  I need help with a particular piece of configuration
in order to make GnomeProgram work properly.

I get this series of errors when trying to make the program:

main.c: In function ‘main’:
main.c:121: error: ‘PREFIX’ undeclared (first use in this function)
main.c:121: error: (Each undeclared identifier is reported only once
main.c:121: error: for each function it appears in.)
main.c:121: error: ‘SYSCONFDIR’ undeclared (first use in this function)
main.c:121: error: ‘DATADIR’ undeclared (first use in this function)
main.c:121: error: ‘LIBDIR’ undeclared (first use in this function)

I know I need to put PREFIX, SYSCONFDIR, etc in the Makefiles as a
CFLAGS -DPREFIX= thing, but I'm not sure how do do this properly.  

I *think* I need to add something to Makefile.am ... but I'm not sure of
the magic entry to put there.

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

Question: Gnome-CRITICAL **: gnome_program_get_app_id

2006-08-13 Thread Tony Freeman
Hello,

I've created a pygtk program with the ui created by glade-2 and imported
into python via pygtk ... however there is a harmless message I'm
getting when I run the program from the command line.  

Evidently I'm not doing something correctly ... could you tell me what
bit of code I need to place in my program in order to remove this error
message:

(rwt.py:11811): Gnome-CRITICAL **: gnome_program_get_app_id: assertion
`program != NULL' failed


-- Tony


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


AMD64 Installation/Usage-Experience Checklist?

2006-03-12 Thread Tony Freeman
I was just on the Ubuntu site 

http://www.ubuntu.com/testing/flight5

... and noted that they have a checklist of sorts for people to report
back on their installation and experience using the software.  

( scoll down the page to the 'testing' section or click here for the
long vesion of the test checklist:
https://wiki.ubuntu.com/Testing/Long )

I was just wondering if AMD64 should have the same sort of thing?  Such
a check list could be posted on this site:

http://www.debian.org/ports/amd64/

... with a request that people join the mailing list to submit the
results of their experience.



-- Tony



___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Help Fill In Blank (glade-2 project)

2006-03-06 Thread Tony Freeman
Hello,

I'm still pretty new to C programming and especially glib / gtk ... so
I'm wondering if you could help me fill in the blank.  Attached is a
glade project with a blank area at the upper left hand side that needs a
sound recorder/player put in it.  it would be great if I could just drop
some sort of pre-built thing like gnome-sound-recorder into that
spot ;-)  And it would be nice to be able to drop GEdit into the 'notes'
spot :-)

The project is a classroom note taking type application with the
addition of the ability to record the teacher/speaker.It's ment to
be used full screen.  You write your notes in the 'notes' section on the
right hand side and you record the lecture on the upper left hand side.
The rest of the left hand side is meta data type stuff about the
class/subject.

I'd appreciate any glade-2 samples or suggestions ... especially for the
recorder/player area.  If there is actually a way to put use GEdit as a
drop in replacement for the 'notes' section, I'd like to know how to do
that ;-)

-- Tony


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Fingerprint Scanner for GDM Login

2005-03-30 Thread Tony Freeman
I'd like to be able to use my fingerprint to log into my linux
machine.  

Because GDM is the login manager for our favorite desktop, I was
wondering if you have heard of a project that is trying to interface the
new fingerprint scanners with GDM (or similar login managers).

I'd really be interested in contributing in some capacity to such a
project.  


-- Tony




___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Compile Line for GnomeVFS Programs. -- thanks

2005-02-09 Thread Tony Freeman
Thank you, Antonio:

Thanks for pointing that resource out to me!  I did a search for gnome.h
on the unstable version and up popped:

usr/include/gnome-1.0/gnome.h
usr/include/libgnomeui-2.0/gnome.h

So I did the compile line like this:

 gcc `pkg-config --cflags --libs libgnomeui-2.0 gnome-vfs-2.0`
gnome_vfs.c -o test

... and it compiled just fine:-)

I just wish that these example programs and tutorials would have compile
line examples to go with the code.

Thanks for helping!

--Tony



On Wed, 2005-02-09 at 16:26 -0400, Antonio Gomes wrote:
 Hi ...
 
 Go to the site http://www.debian.org/distrib/packages , section
 Search the contents of packages, mark the packages that contain
 files or directories whose names contain the keyword option, and then
 type in the entry 'gnome.h' (or the others file mentioned above -
 gfileutils.h - gnome-util.h). It will show you what debian package
 (.deb) to download and install using synaptic or apt-get ...
 
 Best Regards 
 
 
 On Tue, 08 Feb 2005 19:34:04 -0500, Tony Freeman
 [EMAIL PROTECTED] wrote:
  Trying to compile the program located at:
  http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-first-steps.html
  
  Here's the compile line I'm using now and the output:
  
  gcc `pkg-config --cflags --libs gnome gnome-vfs-2.0` gnome_vfs.c -o test
  
  In file included from /usr/include/gnome-1.0/libgnome/libgnome.h:39,
   from /usr/include/gnome-1.0/gnome.h:16,
   from gnome_vfs.c:2:
  /usr/include/gnome-1.0/libgnome/gnome-util.h:29: error: conflicting
  types for `G_FILE_TEST_EXISTS'
  /usr/include/glib-2.0/glib/gfileutils.h:70: error: previous declaration
  of `G_FILE_TEST_EXISTS'
  /usr/include/gnome-1.0/libgnome/gnome-util.h:35: error: conflicting
  types for `g_file_test'
  /usr/include/glib-2.0/glib/gfileutils.h:84: error: previous declaration
  of `g_file_test'
  
  Here's another guess at the compile line with results:
  gcc `pkg-config --cflags --libs libgnome-2.0 gnome-vfs-2.0` gnome_vfs.c
  -o test
  gnome_vfs.c:2:19: gnome.h: No such file or directory
  
  It seems to me that I need to have the gnome-2.0 include files ... but
  I don't know where to get them.  I have Debian.  Any idea what the
  package name would be that I need to install?  I've searched all over
  using Synaptic for gnome development packages and I've installed a
  bunch ... but nothing seems to help.
  
  --Tony
  
  
  On Mon, 2005-02-07 at 22:06 -0500, Allin Cottrell wrote:
   On Mon, 7 Feb 2005, Tony Freeman wrote:
  
Every time I try to compile a program that has a #include gnome.h I
run into problems.  For example:  I have just finished typing in the
sample program located at:
   
http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-first-steps.html
   
Now I want to compile.  I finally got the program to compile with this
line:
   
gcc `pkg-config --cflags --libs gnome libgnomevfs` gnome-vfs.c -o test
  
   Try
  
   pkg-config --cflags --libs gnome gnome-vfs-2.0
  
   If this doesn't work, then you don't have the right files installed.
  
   Allin Cottrell
  
  
  
  ___
  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