Re: is there a signal for typing at bottom of window?

2018-09-26 Thread Doug McCasland
Thanks Joël,

I don't see how your code reacts to scrolling ? But I used your idea to
check the buffer length.  That helped filter out a lot of the signals.  But
other non-keyboard actions can change the buffer length, of course, so it's
not dependable.  :-/


On Tue, Sep 25, 2018 at 10:17 PM Joël Krähemann 
wrote:

> Hi again,
>
> For sure you should probably use:
>
> g_signal_connect_after(your_text_buffer, "changed",
>   G_CALLBACK(your_text_buffer_changed_callback), your_data);
>
> and YOUR_DATA(your_data) just casts to your pointer to a struct or
> object containing some information:
>
> struct _YourData{
>   gint last_newline_position;
> };
>
> Well this is it.
>
> Bests,
> Joël
>
>
>
> On Wed, Sep 26, 2018 at 7:12 AM Joël Krähemann 
> wrote:
> >
> > Hi,
> >
> > g_object_get(your_text_view,
> >   "buffer", _text_buffer,
> >   NULL);
> > g_signal_connect(your_text_buffer, "changed",
> >   G_CALLBACK(your_text_buffer_changed_callback), your_data);
> >
> > void your_text_buffer_changed_callback(GtkTextBuffer
> > *your_text_buffer, gpointer your_data)
> > {
> >   gint line_count;
> >
> >   line_count = gtk_text_buffer_get_line_count(your_text_buffer);
> >
> >   if(line_count > YOUR_DATA(your_data)->line_count){
> > gchar *your_text;
> >
> > g_object_get(your_text_buffer,
> >   "text", _text,
> >   NULL);
> >
> > if(your_text[strlen(your_text) - 1] == '\n' &&
> > YOUR_DATA(your_data)->last_newline_position <
> > &(your_text[strlen(your_text) - 1]) - your_text){
> >   //TODO:DMC: implement me
> > }
> >   }
> > }
> >
> > by,
> > Joël
> >
> > On Wed, Sep 26, 2018 at 6:49 AM Doug McCasland 
> wrote:
> > >
> > > Eric, thanks for the ideas!
> > >
> > > I tried a bunch of things to distinguish the callbacks, but it got too
> > > complicated.  Checking for a different line number is a clever idea,
> but
> > > PgUp and PgDown also move the cursor which changes the line number.
> > >  Similar problems for tracking the char offset in the line (for simply
> > > typing at the end of the last visible line, not creating a new
> line/para).
> > >
> > > So, it would be nice if there was a simple signal for this case, where
> the
> > > window scrolls because of keyboard input in the last visible line.
> > >
> > > The reason I want this is, is so my app can scroll the window
> > > automatically, so that the cursor insert point becomes centered
> > > vertically.  In other words, when I'm typing a long paragraph, and
> it's the
> > > last visible line, I want it to scroll up, so I'm now typing in the
> middle
> > > of the window (vs. continuing to type on the last visible line).
> > >
> > > I suppose this is a bit esoteric.
> > >
> > > I did create a kbd shortcut to do that scroll manually:
> > >
> > > gtk_text_view_scroll_to_iter(..., 0.0, TRUE, 1.0, 0.5)
> > >
> > > so I have that to use.
> > >
> > >
> > > On Tue, Sep 25, 2018 at 2:34 PM  wrote:
> > >
> > > >
> > > > Not sure how to go about this myself. I see the extra callbacks and
> it
> > > > would be a good thing to limit them. For filtering maybe check if the
> > > > cursor has changed lines along with the adjustment value change.
> Suspect
> > > > there is a better solution for this.
> > > >
> > > > static void value_changed(GtkAdjustment *v_adjust, gpointer textview)
> > > >   {
> > > > static gint s_line=0;
> > > > GtkTextIter iter;
> > > > GtkTextBuffer
> > > > *buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
> > > > GtkTextMark *mark=gtk_text_buffer_get_mark(buffer, "insert");
> > > > gtk_text_buffer_get_iter_at_mark(buffer, , mark);
> > > > gint line=gtk_text_iter_get_line();
> > > > if(s_line!=line)
> > > >   {
> > > > g_print("Scroll Line\n");
> > > > s_line=line;
> > > >   }
> > > >   }
> > > >
> > > > Eric
> > > >
> > > >
> > > > -Original Message-
> > > > From: Doug McCasland 
> > > > To: cecashon 
> > > > Sent: Tue, Sep 25, 2018 2:10 pm
> > > > Subject: Re: is there a signal for typing at bottom of window?
> > > >
> > > > Actually I get 11 signals with a different setting of:
> > > > gtk_text_view_set_pixels_inside_wrap()
> > > >
> > > > So it's one signal per vertical pixel perhaps?   I can code for that.
> > > >
> > > > But I also I get those signals during any scrolling (scrollbar or
> > > > mousewheel).  How can I distinguish between automatic scrolling at
> bottom
> > > > and user-commanded scrolling?
> > > >
> > > > thanks
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Tue, Sep 25, 2018 at 1:47 PM Doug McCasland 
> > > > wrote:
> > > >
> > > > Woo-hoo, that works!
> > > >
> > > > BUT, I get 12 signals for each line that is auto-scrolled.  I can
> code for
> > > > this, but why 12?  Will it always be 12?
> > > >
> > > >
> > > > On Tue, Sep 25, 2018 at 11:46 AM  wrote:
> > > >
> > > >
> > > > Hi Doug,
> > > >
> > > > Try getting the vertical adjustment of the scrolled window and
> connect to
> > > > "value-changed". See if that will work. Something 

That reminds me -- is there a signal that can be used when mouse over mainwin titlebar?

2018-09-26 Thread David C. Rankin
All,

  Thanks to the other "is there a signal?" question, that reminded me I have
been looking for a signal (or way) to detect when the user has the mouse over
the titlebar of the main window in an editor where I would like to activate a
tooltip showing the absolute path for the file in the currently focused
textview. I just cannot find a signal or event window scheme to do it --
probably because the main window titlebar is owned by the window manager and
not the application. But still, I see other editors that are capable of this.

  Is there any such signal, or something that can be used in conjunction with
the set_window_title call that would also provide a tooltip on mouseover I
could respond to?

-- 
David C. Rankin, J.D.,P.E.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_log_set_fatal_mask () does not appear to be present

2018-09-26 Thread Richard Shann

> Date: Sun, 09 Sep 2018 20:21:54 +0100
> From: Richard Shann 
> To: gtk-app-devel-list@gnome.org
> Subject: g_log_set_fatal_mask () does not appear to be present
> Message-ID: <1536520914.1394.1.ca...@rshann.plus.com>
> Content-Type: text/plain; charset="UTF-8"
> 
> I used to call 
> g_log_set_fatal_mask ()
> 
> via gdb to catch the place where critical errors happen. But now I
> get
> 
> (gdb) call g_log_set_fatal_mask ("Gtk", 0x)
> No symbol "g_log_set_fatal_mask" in current context.

I've been trying to dig deeper into this (guessing that
g_log_set_fatal_mask may have become a macro or something) and find
that I can call it after gtk_init_check() from within the program
without a compile time error, but the program still does not stop on
errors.

Indeed

g_print ("Error level was %x\n", g_log_set_fatal_mask (NULL, -1));
g_print ("Error level now %x\n", g_log_set_fatal_mask (NULL, -1));

prints out 0x5 as the initial setting of the mask and 0xfffd
 as the setting after setting to -1

but I then can trigger a slew of 

(denemo:1717): Gtk-CRITICAL **: gtk_box_gadget_distribute: assertion
'size >= 0' failed in GtkScrollbar

errors without the program stopping.

Is there something involving threads here?

Richard Shann

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