Re: turn on italics in TextView

2017-06-13 Thread Eric Cashon via gtk-app-devel-list

 
Hi Doug,

You can try using the "insert-text" callback to set your italics on the 
inserted text. This is what I came up with to test. The signal is connected 
after so that the update occurs first. Careful about not changing the location 
iter also since there is a warning in the documentation about doing so. Might 
not need to worry about it here but something to be aware of.

https://developer.gnome.org/gtk3/stable/GtkTextBuffer.html#GtkTextBuffer-insert-text

Eric


/*
  gcc -Wall textview2.c -o textview2 `pkg-config --cflags --libs gtk+-3.0`
  Tested on GTK3.18 and Ubuntu16.04
*/

#include

static gboolean italic=FALSE;

static void toggle_italic(GtkToggleButton *toggle1, gpointer data)
  {
GtkWidget *label=gtk_bin_get_child(GTK_BIN(toggle1));
if(gtk_toggle_button_get_active(toggle1))
  {
gtk_label_set_markup(GTK_LABEL(label), "Italics");
italic=TRUE;
  }
else
  {
gtk_label_set_text(GTK_LABEL(label), "Italics");
italic=FALSE;
  }
gtk_widget_grab_focus(GTK_WIDGET(data));
  }
static void new_text(GtkTextBuffer *textbuffer, GtkTextIter *location, gchar 
*text, gint len, gpointer user_data)
  {
if(italic)
  {
GtkTextIter *start=gtk_text_iter_copy(location);
GtkTextIter *end=gtk_text_iter_copy(location);
gtk_text_iter_backward_chars(start, len);
gtk_text_buffer_apply_tag_by_name(textbuffer, "tag1", start, end);
gtk_text_iter_free(start);
gtk_text_iter_free(end);
  }
  }
int main (int argc, char *argv[])
  {
gtk_init(, );

GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Textview");
gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

GtkWidget *text_view1=gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view1), GTK_WRAP_CHAR);
gtk_widget_set_vexpand(text_view1, TRUE);
gtk_widget_set_hexpand(text_view1, TRUE);

GtkTextBuffer *buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view1));
gtk_text_buffer_create_tag(buffer, "tag1", "style", PANGO_STYLE_ITALIC, 
NULL);
g_signal_connect_after(buffer, "insert-text", G_CALLBACK(new_text), NULL);

GtkWidget *toggle1=gtk_toggle_button_new_with_label("Italics");
g_signal_connect(toggle1, "toggled", G_CALLBACK(toggle_italic), text_view1);

GtkWidget *grid=gtk_grid_new();
gtk_container_set_border_width(GTK_CONTAINER(grid), 8);
gtk_grid_set_row_spacing(GTK_GRID(grid), 12);
gtk_grid_attach(GTK_GRID(grid), text_view1, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), toggle1, 0, 1, 1, 1);

gtk_container_add(GTK_CONTAINER(window), grid);

gtk_widget_show_all(window);

gtk_main();

return 0;
  }


 


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


Re: GtkLabel max-width-chars with ellipsize broken?

2017-06-13 Thread Eric Cashon via gtk-app-devel-list

 
What version of GTK are you using?

It does work on my computer. The label expands and shrinks as the window 
expands and shrinks and the label stops expanding at 012345678901234567... I 
take that to be 20 chars if you start at 0 and include the three dots. The 
tooltip shows the full string.

Eric

 



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


Re: GtkLabel max-width-chars with ellipsize broken?

2017-06-13 Thread infirit
On 10/06/17 19:39, cecas...@aol.com wrote:
> Hi infirit,

Hi

> Give the hexpand a try and see if that works. It works for me on Python3.5 
> and GTK3.18

Define works :) Does it limit to what was set as maximum width chars?
When resizing does it use the available space to show more or less
characters? Nope :(

It indeed does expand the label but it expands to the complete width of
the notebook (ugly). While this appears to have the effect to fix the
problem is really doesn't as max-width-chars is still not properly used.
Its behaviour is very inconsistent imo and appears very broken.

Thanks for the response though.

~infirit

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


Re: Integrate IP Camera stream in GTK app

2017-06-13 Thread Eric Cashon via gtk-app-devel-list

 
Hi Ruben,

I am sure you can do that with GTK and GStreamer. That way the code would be 
portable across platforms.

I don't have any examples of using GStreamer to get video from an ip camera. I 
have some test code that will show the video from the local webcam.

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/Sound/webcam3.c

There are a couple of other programs in the Sound folder that uses GStreamer 
with GTK if that is of any help. Also, I have an updated GStreamer 
basic-tutorial5 that will play local video or video from over the web if that 
would be of any help to you.

Eric

 


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


Integrate IP Camera stream in GTK app

2017-06-13 Thread Rúben Rodrigues
Hi guys,

Someone knows how to integrate IP Camera stream in GTK+ app? I tested 
with libvlc an gstreamer in my raspberrry pi, but don't works.. Any 
other library to make this?

Thanks

Rúben


---
Este e-mail foi verificado em termos de vírus pelo software antivírus Avast.
https://www.avast.com/antivirus

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