Re: How do I disable automatic drag and drop between GtkEntry widgets?

2008-05-16 Thread Brian J. Tarricone
On Fri, 16 May 2008 16:12:50 -0400 [EMAIL PROTECTED] wrote:

> I'm using mwm and libglade if that makes a difference.  Is this
> automatic drag and drop something that libglade sets up for me by
> chance?

Why would you want to do this?  People accustomed to how entry widgets
behave will likely be confused that yours behave differently, and will
assume your application is broken.

If you really want to do this, I believe you can unset the widget's drag
source and drag destination.  See the API reference for how to do this.

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


Re: Question aboutusing message dialog to ask confirmation

2008-05-16 Thread Brian J. Tarricone
On Fri, 16 May 2008 19:19:55 +0100 John M Collins wrote:

> I want to have a "do you really want to do this" type question and I'm
> trying to use a message dialog thus:
> 
> GtkWidget  *dlg = gtk_message_dialog_new(GTK_WINDOW(previous),
> GTK_DIALOG_DESTROY_WITH_PARENT,
>  GTK_MESSAGE_QUESTION,
>  GTK_BUTTONS_YES_NO, "Are you sure?");
> g_signal_connect_swapped(dlg,
>   "response", G_CALLBACK(gtk_widget_destroy), dlg);
>
> Then I put
> 
> if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_YES)  {
> 
>   /* Do the thing we asked about */
> }
> else  {
>   /* Get out of here */
> }
> 
> 
> the return value from gtk_dialog_run is never GTK_RESPONSE_YES, it's
> always zero whether the Yes or No button is clicked.

gtk_dialog_run() also connects to the 'response' signal.  You cannot
rely on signal callbacks being called in any particular order.  In your
case, likely your handler (gtk_widget_destroy()) is getting called
before gtk_dialog_run()'s response handler, so you destroy the widget
before the gtk_dialog_run() response handler can run.

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


Re: Recalculation of timeouts with g_timeout_add

2008-05-16 Thread Luis Menina

Mitko Haralanov a écrit :
> On Fri, 16 May 2008 09:54:22 +0200
> G Hasse <[EMAIL PROTECTED]> wrote:
> 
>> Let your callback return FALSE and reregister before the return
> 
> Hi, I thought of that but I was sure that there is a better way to do
> this without playing games with unregistering and re-registering the
> timeout.
> 
> I am not sure why the GTK devs decided that re-calculating the timeout
> based on the time right after the timeout thread is started is the
> right thing to do but it seems very wrong to me. 

I think this is really the best solution. And by the way, this timeout 
comportment (counting elapsed time since last time the callback was 
called) is the right thing to do, as it's the most common case. Just 
because your current problem has different needs doesn't mean it was the 
wrong choice. How could you trigger an event, say, 10 times per second 
otherwise (for an animation for example) ?

> What if the timeout function takes longer then the timeout itself? You
> end up with multiple threads running the timeout function at the same
> time.

As already specified, there's only the main thread. GTK doesn't create 
other threads alone.

Oh, and you should use g_timeout_add_seconds for timeouts > 1s.

For your example, just set the timeout at the end of the callback, and 
return always FALSE. To set it the first time, just call the callback 
alone. That way the callback is called 20 seconds after the last 
callback call ended (I didn't tested the code, but it should work).

#include 
#include 
#include 
#include 

gboolean callback (gpointer data) {
  int timeout = GPOINTER_TO_INT (data);
  printf ("callback called at: %lu\n", time (NULL));
  sleep (timeout);
  printf ("callback returns at: %lu\n", time (NULL));
  g_timeout_add_seconds (20, callback, GINT_TO_POINTER (timeout));
  return FALSE;
}

int main (int argc, char **argv) {
  int timeout = 10;
  gtk_init (&argc, &argv);
  callback (GINT_TO_POINTER (timeout);
  gtk_main ();
}



Also, you should give a look to GTimer, with is nice to use when you 
want to measure timings.


Cheers,

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


Can I turn off scrolling on combobox lists?

2008-05-16 Thread kmbruhnk
I'm trying to simulate an application that does not feature scrolling 
combobox lists (this only happens when near the top or bottom of the 
screen).  I need to disable this feature.  Can it be done without 
modifying Gtk itself?

Kurt M. Bruhnke
Rockwell-Collins Simulation & Training Solutions
Phone: 703-234-2163
Email: [EMAIL PROTECTED]

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


How do I disable automatic drag and drop between GtkEntry widgets?

2008-05-16 Thread kmbruhnk
I'm using mwm and libglade if that makes a difference.  Is this automatic 
drag and drop something that libglade sets up for me by chance?

Kurt M. Bruhnke
Rockwell-Collins Simulation & Training Solutions
Phone: 703-234-2163
Email: [EMAIL PROTECTED]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Recalculation of timeouts with g_timeout_add

2008-05-16 Thread jcupitt
2008/5/16 Mitko Haralanov <[EMAIL PROTECTED]>:
>  I am not sure why the GTK devs decided that re-calculating the timeout
>  based on the time right after the timeout thread is started is the
>  right thing to do but it seems very wrong to me.

I think the idea is that the timeout might represent a counter. If you
set a 1s timeout, you can expect that after 5 calls (for example)
about 5s will have passed.

>  What if the timeout function takes longer then the timeout itself? You
>  end up with multiple threads running the timeout function at the same
>  time.

No, glib never runs more than one callback at once. They will just
queue up and run when the mainloop becomes idle again.

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


Re: Recalculation of timeouts with g_timeout_add

2008-05-16 Thread Daniel Atallah
On Fri, May 16, 2008 at 1:20 PM, Mitko Haralanov <[EMAIL PROTECTED]> wrote:
> On Fri, 16 May 2008 09:54:22 +0200
> G Hasse <[EMAIL PROTECTED]> wrote:
>
>> Let your callback return FALSE and reregister before the return
>
> Hi, I thought of that but I was sure that there is a better way to do
> this without playing games with unregistering and re-registering the
> timeout.
>
> I am not sure why the GTK devs decided that re-calculating the timeout
> based on the time right after the timeout thread is started is the
> right thing to do but it seems very wrong to me.

It isn't a "timeout thread", it just a function that is run in the main loop.
It really isn't a matter of right or wrong, it comes down to the fact
that it had to work one way and it so happens that it works like this.
Depending on your intended usage, the way that subsequent timeouts are
called may or may be what you want.

> What if the timeout function takes longer then the timeout itself? You
> end up with multiple threads running the timeout function at the same
> time.

No, the timeout function will block the main loop until it completes;
there will not be multiple threads running your timeout function.

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


Re: Recalculation of timeouts with g_timeout_add

2008-05-16 Thread G Hasse
Let your callback return FALSE and reregister before the return

#include 
#include 
#include 
#include 
#include 

gboolean callback (gpointer data) {

  int seconds = 0;
  struct tm *mytm;
  time_t mytime;

  mytime = time( NULL );
  mytm = gmtime( &mytime );
  
  printf("Called :");   
  printf( "%d-%2.2d-%2.2d ", mytm->tm_year+1900, 
mytm->tm_mon+1,mytm->tm_mday); 
  printf( "%2.2d:%2.2d:%2.2d\n", mytm->tm_hour, 
mytm->tm_min,mytm->tm_sec); 

  // Sleeping som random time
  seconds = random()%5+1;
  sleep(seconds);
  
  g_timeout_add (10*1000, callback, NULL );

  mytime = time( NULL );
  mytm = gmtime( &mytime );

  printf("Return :");   
  printf( "%d-%2.2d-%2.2d ", mytm->tm_year+1900, 
mytm->tm_mon+1,mytm->tm_mday); 
  printf( "%2.2d:%2.2d:%2.2d\n", mytm->tm_hour, 
mytm->tm_min,mytm->tm_sec); 
  
  //printf ("callback returns at: %lu\n", time (NULL));
  return FALSE;
  
}


int main( int argc, char ** argv )
{

  GMainLoop *loop;
  loop = g_main_new( TRUE );
  g_timeout_add (10*1000, callback, NULL )
  g_main_run( loop );
  return(0);
}



-- 
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


Re: problem finding the position of a button in the gtk dialog ( sample code inside )

2008-05-16 Thread Federico Mena Quintero
On Wed, 2008-05-07 at 11:33 +0530, chirag juneja wrote:

> approach i am using is :
> i will find the distance of the button from its parent, and then its
> parent's distance form its parent .. and so on, till i get toplevel
> window.
> then i am adding the decoration's height, border's width and distance
> of top level window from origin of root window(0,0).

That's a lot of overkill :)  You can simply do

void 
get_absolute_position (GtkWidget *widget, int *ret_x, int *ret_y)
{
  GdkWindow *parent;
  int parent_x, parent_y;

  parent = gtk_widget_get_parent_window (widget);
  gdk_window_get_origin (parent, &parent_x, &parent_y);

  *ret_x = parent_x + widget->allocation.x;
  *ret_y = parent_y + widget->allocation.y;
}

  Federico


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


Re: Question aboutusing message dialog to ask confirmation

2008-05-16 Thread Eduardo M KALINOWSKI
On Fri, May 16, 2008 at 3:19 PM, John M Collins <[EMAIL PROTECTED]> wrote:
> I want to have a "do you really want to do this" type question and I'm
> trying to use a message dialog thus:
>
> GtkWidget  *dlg = gtk_message_dialog_new(GTK_WINDOW(previous),
> GTK_DIALOG_DESTROY_WITH_PARENT,
>  GTK_MESSAGE_QUESTION,
>  GTK_BUTTONS_YES_NO, "Are you sure?");
> g_signal_connect_swapped(dlg,
>  "response", G_CALLBACK(gtk_widget_destroy), dlg);
>
> Then I put
>
> if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_YES)  {
>
>/* Do the thing we asked about */
> }
> else  {
>/* Get out of here */
> }
>
>
> the return value from gtk_dialog_run is never GTK_RESPONSE_YES, it's
> always zero whether the Yes or No button is clicked.
>
> However if I get rid of the "response" signal and put
>
> retval = gtk_dialog_run(GTK_DIALOG(dlg));
> gtk_widget_destroy(dlg);
>
> if (retval ==  GTK_RESPONSE_YES)  {
>
>/* Do stuff */
> }
> else  {
>/* Get out of here */
> }
>
> It works OK.
>
> "Is this a bug or a feature"?

It is a feature, and of the kind that bears to similarity to a bug.

You do not need to use gtk_signal_connect to connect to the "response"
signal if you are using the standard interface: it is already
connected. By connecting, you are probably destroying the dialog
before the value can be read, and it is surprinsing that you do not
get some random garbage.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Question aboutusing message dialog to ask confirmation

2008-05-16 Thread John M Collins
I want to have a "do you really want to do this" type question and I'm
trying to use a message dialog thus:

GtkWidget  *dlg = gtk_message_dialog_new(GTK_WINDOW(previous),
GTK_DIALOG_DESTROY_WITH_PARENT,
 GTK_MESSAGE_QUESTION,
 GTK_BUTTONS_YES_NO, "Are you sure?");
g_signal_connect_swapped(dlg,
  "response", G_CALLBACK(gtk_widget_destroy), dlg);

Then I put

if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_YES)  {

/* Do the thing we asked about */
}
else  {
/* Get out of here */
}


the return value from gtk_dialog_run is never GTK_RESPONSE_YES, it's
always zero whether the Yes or No button is clicked.

However if I get rid of the "response" signal and put

retval = gtk_dialog_run(GTK_DIALOG(dlg));
gtk_widget_destroy(dlg);

if (retval ==  GTK_RESPONSE_YES)  {

/* Do stuff */
}
else  {
/* Get out of here */
}

It works OK.

"Is this a bug or a feature"?


John Collins Xi Software Ltd www.xisl.com

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


Re: Recalculation of timeouts with g_timeout_add

2008-05-16 Thread Mitko Haralanov
On Fri, 16 May 2008 09:54:22 +0200
G Hasse <[EMAIL PROTECTED]> wrote:

> Let your callback return FALSE and reregister before the return

Hi, I thought of that but I was sure that there is a better way to do
this without playing games with unregistering and re-registering the
timeout.

I am not sure why the GTK devs decided that re-calculating the timeout
based on the time right after the timeout thread is started is the
right thing to do but it seems very wrong to me. 

What if the timeout function takes longer then the timeout itself? You
end up with multiple threads running the timeout function at the same
time.

-- 
Mitko Haralanov
==
System going down at 1:45 this afternoon for disk crashing.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Broken Input Shaping

2008-05-16 Thread natan yellin
I've experimented around with this, and I've found that it doesn't work when
the input shape was set from another application using a foreign GdkWindow.
I've encountered some strangeness when using it within the same application,
it doesn't fail totally.

Natan

On Thu, May 15, 2008 at 12:39 PM, natan yellin <[EMAIL PROTECTED]> wrote:

> Hello,
> I've been trying to get gdk_window_set_child_input_shapes() to work without
> success.
>
> Interestingly, if I don't use an input shape and I just call
> gdk_window_set_child_shapes then it works fine.
>
> As far as I can tell, the function is totally broken. If someone can
> confirm that it doesn't work for them either then I'll file a bug on
> bugzilla.
>
> Natan
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Recalculation of timeouts with g_timeout_add

2008-05-16 Thread Pascal Bonfils
I haven't tried to pass the timeout value but what do is with a global 
variable.


Imagine that you have the reference of the timeout, as a global variable :
   guint TimeOut_Ref;

then you have a first call to your callback function
   TimeOut_Ref = g_timeout_add (20*1000, callback, (gpointer)&timeout);

you stop the timeout just when you enter the function :
   gboolean callback (gpointer data) {
   if (TimeOut_Ref > 0) {
   g_source_remove(TimeOut_Ref);
   TimeOut_Ref = 0;
   }
   
Then, at the end of you called function, just before the return, you 
reactivate the timeout :

   .
   TimeOut_Ref = g_timeout_add (20*1000, callback, (gpointer)&timeout);
return TRUE;
   }


Regards

Pascal


Mitko Haralanov a écrit :

I have a question about g_timeout_add's timeout recalculation.

Currently, the next call time is calculated based on  + . This means that if I
call g_timeout_add with a timeout of 20*1000 msecs (20 seconds) and my
callback takes 10 seconds to complete, my callback will be called 10
seconds after it completes. Here is an example:

#include 
#include 
#include 
#include 

gboolean callback (gpointer data) {
 int timeout = *((int *)data);
 printf ("callback called at: %lu\n", time (NULL));
 sleep (timeout);
 printf ("callback returns at: %lu\n", time (NULL));
 return TRUE;
}

int main (int argc, char **argv) {
 int timeout = 10;
 gtk_init (&argc, &argv);
 g_timeout_add (20*1000, callback, (gpointer)&timeout);
 gtk_main ();
}


will produce this:
callback called at: 1210893003
callback returns at: 1210893013
callback called at: 1210893023
callback returns at: 1210893033
callback called at: 1210893043

What I would to happen is that my callback is called 20 seconds after
it returns, not 20 seconds after it is started.

How can I accomplish this?

  


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