Dynamic color setting of GtkListStore/TreeStore selection cursor

2008-07-07 Thread R. Dresens

Hello,

I have a question regarding the color of the cursor/selection of the
selected item(s) in a GtkListStore or GtkTreeStore.

I'm currently able to set the colors of individual cells by associating
the 'foreground'-property of a TreeViewColumn/CellRendererText to a
certain column in a liststore.

That works nice, but the selected item(s) remain in a certain default
theme-determined color. It would be nice if there were some 'foreground
selected' and 'background-selected' properties.

For instance, if I have cells with a black background and colored text,
then it would be nice if the selected items are not in the default
theme color. Instead, they should have black text and the associated
color as the background (i.e inverted).

Is this possible? Anyone a useful hint for me? :)

Thanks for your time in advance,

Greetings,

Raymond Dresens.


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


How to align buttons in GtkHButtonBox?

2008-07-07 Thread Mitko Haralanov
Hi,

Is it possible to get the buttons of a gtk_toolbar to align to the left
side of the widget (the same behaviour as
gtk_button_box_set_layout(button_box, GTK_BUTTONBOX_END))?

I could not find anything in the widget's hierarchy that would do it
and packing it into a GtkAlignment does help either.

Thanks

-- 
Mitko Haralanov
==
The 11 is for people with the pride of a 10 and the pocketbook of an 8.
-- R.B. Greenberg [referring to PDPs?]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: [Usability] UI design question

2008-07-07 Thread Dave Foster
On Sun, Jun 29, 2008 at 9:35 AM, natan yellin [EMAIL PROTECTED] wrote:

 I'm curious by nature, so does your application already have a website?
 This is something that I've always felt would be useful.


Not yet, I want to finish most of it before revealing it.  I know,
developing in the dark is bad, but I'd rather do it this way and finish it
rather than announce a half broken project.


 Regarding your question, I agree with Mathew that the noun--verb
 relationship is a bit simpler. If you decide to use the verb--noun design,
 I'd recommend hiding the Theme Name field until the user actually clicks
 on Create a new theme or Modify an existing theme. I would try to reduce
 the amount of unnecessary fields and boxes whenever possible.


Ok, thanks.

For all in the thread, I have for the time being abandoned the all in one
dialog - just too many concepts at once.  I currently have a separate New
and Open dialog, but I may revisit it in the future.  Wanted to get
something in place to work and see how it felt rather than endlessly
planning it!

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


Wrting to a text file in N800 /media/mmc1

2008-07-07 Thread nisha jain
Hi All,

Does any Hildon or gtk API supports writing into text files my following
code written in C is not
working for N800 which works perfectly fine under MAEMO ARMEL
mode.Please if some
one has some information let me know...

Regards,
Nisha

-- Forwarded message --
From: nisha jain [EMAIL PROTECTED]
Date: Jul 5, 2008 4:09 PM
Subject: Re: Wrting to a text file in N800 /media/mmc1
To: [EMAIL PROTECTED]
Cc: gary liquid [EMAIL PROTECTED]

Hi All,

I just checked in N800 the following program for writing into a file which

doesn't work Any clues what is going wrong? I neither get any error not
it is

creating a file and writing into it.

#includestdio.h

void main()
{
FILE *Gfile;
if ((Gfile = fopen(/media/mmc1/test.txt, w+)) == NULL)
{
printf(Error in file creation);
}

if(Gfile)
fprintf(Gfile,%02x,0x10);
fclose(Gfile);
}

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


Forking from Gtk

2008-07-07 Thread G Hasse
Hello,

I have a small demo app. This works on FreeBSD but I can't
get to work on Linux. I know that in Linux setsid will fail
if the child has the same session_id as the parent. So on
Linux you must fork twice. But it also seems that the parent
must do an exit. And I don't want that. The code is not very
long - so I include it here.

---snipp---
//--
//
//  $Id: GtkFork.c,v 1.2 2008/07/07 20:29:17 gorhas Exp $
//
//  Experiment to run a thing in background
//  This works on FreeBSD but not on Linux...
//
//  Build with
//
//  CFLAGS := `pkg-config glib-2.0 --cflags` `pkg-config gtk+-2.0 
--cflags`
//  LDFLAGS := `pkg-config glib-2.0 --libs` `pkg-config gtk+-2.0 --libs`
//
//  cc $(CFLAGS) -o GtkFork GtkFork.c $(LDFLAGS)
//
//--

#include gtk/gtk.h
#include stdlib.h
#include stdio.h
#include time.h
#include string.h

//--
// run_btn_callback
//
// Try to run something in the background
//
//--
static void run_btn_callback (GtkWidget *button, gpointer data)
{

   int loops_to_run = 0;
   int i = 0;
   int pid = -1;
   int ret = -1;

   // Skriv ut innehållet på skärmen 
   printf(Clicked..\n);
   printf(Data was: %s\n, gtk_entry_get_text( data ));

   loops_to_run = atoi( gtk_entry_get_text(data));

   // We dont want to wait very long...
   if( loops_to_run  60 )
   {
  loops_to_run = 60;
  printf(Adjusting to 60 loops...\n);
   }
   printf(Loops to run: %d\n, loops_to_run );



   printf(We make a daemon\n);
   if ( ( pid = fork() )  0 )
   {
  // Something went wrong
  printf(We could not fork just exit);
  exit(-1);
   }
   else if ( pid != 0 )
   {
  
  // This is the parent process
  printf(The background process have pid:  %d\n, pid);
  return;
   }

   // Quit gtk
   gtk_main_quit();

   // Become session leader
   ret = setsid();
   if( ret == -1 )
   {
  perror(We could not be session leader\n);
  exit(-1);
   }

   // Set umask for safety
   umask(0);
   
   // Set root dir
   chdir(/);
  
 
   for( i = 0; i  loops_to_run; i++ )
   {
  printf(We are running: %d\n, i );
  sleep(1);
   } 

   exit(0);

}

//--
// When we quit
//--
static void quit_callback()
{
   gtk_main_quit ();
}


//--
//  main
//
//  Creates a gtk windows to specify how many loops
//  the daemon should run.
//
//--
int 
main (int argc, char **argv)
{

  GtkWidget *mainwin = 0L;
  GtkWidget *number_entry = 0L;
  GtkWidget *run_btn = 0L;
  GtkWidget *vbox = 0L;

  /* Initialize i18n support */
  printf(Locale is: %s\n, gtk_set_locale () );

  /* Initialize the widget set */
  gtk_init (argc, argv);

  /* Create the main window */
  mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  /* Set up our GUI elements */
  vbox = gtk_vbox_new (FALSE, 0);

  number_entry = gtk_entry_new();

  run_btn = gtk_button_new_with_label(Just run);

  gtk_container_add (GTK_CONTAINER (mainwin), vbox);
  gtk_box_pack_start (GTK_BOX (vbox), number_entry, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), run_btn, TRUE, TRUE, 0);

  
  // Function to call when main window is destroyed
  g_signal_connect (G_OBJECT (mainwin),
destroy,
GTK_SIGNAL_FUNC (quit_callback),
NULL);

  // Function to call when we click the button
  g_signal_connect(GTK_OBJECT(run_btn), clicked,
 G_CALLBACK(run_btn_callback),
 number_entry);

  /* Show the application window */
  gtk_widget_show_all (mainwin);

  /* Enter the main event loop, and wait for user interaction */
  gtk_main ();

  /* The user lost interest */
  return 0;

}

//--
// END
//--

---snipp---

-- 
Göran Hasse


Göran Hasse   email: [EMAIL PROTECTED]  Tel: 019-450105
Raditex AB http://www.raditex.se
Planiavägen 15, 1tr Mob: 070-5530148
131 34  NACKA, SWEDEN OrgNr: 556240-0589
VAT: SE556240058901
--

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


gtk_text_view_get_iter_at_location

2008-07-07 Thread Steve Salazar

Hi, I'm having some problems and confusion.  I am trying to truncate all text 
not visible in a GtkTextView but am getting very different results depending on 
if the text has any \n characters or not even if they all appear after where 
I would truncate. 

Here is the test case: 

http://pastebin.com/m27906ec3

The text I provide will full up 5 lines in the GtkTextView which is only 3 
lines high.  I try to truncate so that after loading, you will only have the 
first three lines and scrolling down ends after the third line.  With the 
string that has a newline between the 4th and 5th wrapped lines it doesn't 
work.  With the text that has no newlines, it works fine.

I'm compiling like this:

   gcc test2.c -o test2 `pkg-config --cflags --libs gtk+-2.0` 

And run like this:

   ./test2 0 # For bad case where down arrow three times show text not truncated

Or

   ./test2 1 # For good case where buffer is truncated to only what fits in 
viewable area

Thanks in advance for any help.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Forking from Gtk

2008-07-07 Thread James Scott Jr
G,

The basic design decision to use fork() as a way to do work in the
background flawed.  fork()ing is not practical for gtk program.  While
fork() has been a valid option for many non-gui programs in the absence
of threads, either g_thread_create() or pthread_create().  Today it is
not very useful -- as in stop doing it now!

Consider instead using a valid multi-threaded implementation like
g_threads_xxx() for GTK based programs.  Or if full multi-threading is
not required, look at g_timeout_add() which is a background timer
routine that can serve as one or more background execution units; neatly
inside an gtk context.

$ devhelp
$ gtk-demo

The above two program you be pre-installed on your Linux machine:
devhelp has the gtk and glib api documentation, and gtk-demo shows you
many of the gtk/glib features in action.

Having said the multi-thread phrase, here is another word of caution.
In GTK only the main or ONE thread can safely interface with GTK api
calls that change the display.  Using more than one thread to call gtk
apis at the same time will fail or cause a sigfault.  The context of GTK
being your front-end to X11 is the source of this
none-thread-safe-caution; it is in how gtk MUST interact with X that
placing the multi-thread restriction.  There are elegant work-arounds
this issue.

Here is a link to the classic FAQ answer on Multi-threaded GTK programs:
http://library.gnome.org/devel/gtk-faq/stable/x482.html

Regards,
James,


On Mon, 2008-07-07 at 23:03 +0200, G Hasse wrote:
 Hello,
 
 I have a small demo app. This works on FreeBSD but I can't
 get to work on Linux. I know that in Linux setsid will fail
 if the child has the same session_id as the parent. So on
 Linux you must fork twice. But it also seems that the parent
 must do an exit. And I don't want that. The code is not very
 long - so I include it here.
 
 ---snipp---
 //--
 //
 //  $Id: GtkFork.c,v 1.2 2008/07/07 20:29:17 gorhas Exp $
 //
 //  Experiment to run a thing in background
 //  This works on FreeBSD but not on Linux...
 //
 //  Build with
 //
 //  CFLAGS := `pkg-config glib-2.0 --cflags` `pkg-config gtk+-2.0 
 --cflags`
 //  LDFLAGS := `pkg-config glib-2.0 --libs` `pkg-config gtk+-2.0 --libs`
 //
 //  cc $(CFLAGS) -o GtkFork GtkFork.c $(LDFLAGS)
 //
 //--
 
 #include gtk/gtk.h
 #include stdlib.h
 #include stdio.h
 #include time.h
 #include string.h
 
 //--
 // run_btn_callback
 //
 // Try to run something in the background
 //
 //--
 static void run_btn_callback (GtkWidget *button, gpointer data)
 {
 
int loops_to_run = 0;
int i = 0;
int pid = -1;
int ret = -1;
 
// Skriv ut innehållet på skärmen 
printf(Clicked..\n);
printf(Data was: %s\n, gtk_entry_get_text( data ));
 
loops_to_run = atoi( gtk_entry_get_text(data));
 
// We dont want to wait very long...
if( loops_to_run  60 )
{
   loops_to_run = 60;
   printf(Adjusting to 60 loops...\n);
}
printf(Loops to run: %d\n, loops_to_run );
 
 
 
printf(We make a daemon\n);
if ( ( pid = fork() )  0 )
{
   // Something went wrong
   printf(We could not fork just exit);
   exit(-1);
}
else if ( pid != 0 )
{
   
   // This is the parent process
   printf(The background process have pid:  %d\n, pid);
   return;
}
 
// Quit gtk
gtk_main_quit();
 
// Become session leader
ret = setsid();
if( ret == -1 )
{
   perror(We could not be session leader\n);
   exit(-1);
}
 
// Set umask for safety
umask(0);

// Set root dir
chdir(/);
   
  
for( i = 0; i  loops_to_run; i++ )
{
   printf(We are running: %d\n, i );
   sleep(1);
} 
 
exit(0);
 
 }
 
 //--
 // When we quit
 //--
 static void quit_callback()
 {
gtk_main_quit ();
 }
 
 
 //--
 //  main
 //
 //  Creates a gtk windows to specify how many loops
 //  the daemon should run.
 //
 //--
 int 
 main (int argc, char **argv)
 {
 
   GtkWidget *mainwin = 0L;
   GtkWidget *number_entry = 0L;
   GtkWidget *run_btn = 0L;
   GtkWidget *vbox = 0L;
 
   /* Initialize i18n support */
   printf(Locale is: %s\n, gtk_set_locale () );
 
   /* Initialize the widget set */
   gtk_init (argc, argv);
 
   /* Create the main window */
   mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
   /* Set up our GUI elements */
   vbox = gtk_vbox_new (FALSE, 0);
 
   number_entry = gtk_entry_new();
 
   run_btn =