gtk

Passing additional arguments to gtk function

坚强是说给别人听的谎言 提交于 2020-01-02 08:43:21
问题 I'm trying to learn how to make GUIs using gtk+ 3.0. I want to pass a simple argument, an integer, to a callback function, so that when I press the button the value of the argument changes. Here's my code: #include <gtk/gtk.h> void buttonFunction(GtkWidget * widget, gpointer data, int & n){ n = 1; } int main(int argc, char ** argv){ int n = 0; GtkWidget * window; GtkWidget * button; gtk_init(&argc,&argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); button = gtk_button_new_with_label("Osss")

Passing additional arguments to gtk function

情到浓时终转凉″ 提交于 2020-01-02 08:43:07
问题 I'm trying to learn how to make GUIs using gtk+ 3.0. I want to pass a simple argument, an integer, to a callback function, so that when I press the button the value of the argument changes. Here's my code: #include <gtk/gtk.h> void buttonFunction(GtkWidget * widget, gpointer data, int & n){ n = 1; } int main(int argc, char ** argv){ int n = 0; GtkWidget * window; GtkWidget * button; gtk_init(&argc,&argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); button = gtk_button_new_with_label("Osss")

webkit: is it possible to store cookies to file and reuse it again?

北战南征 提交于 2020-01-02 08:29:42
问题 is it possible to store cookies to file when you use webkit and reuse it again next time when I run my application? 回答1: I know its old question and have been looking for the answer all over the place. Finally came up on my own after some trial and error. Hope this helps others. from gi.repository import Soup cookiejar = Soup.CookieJarText.new("<Your cookie path>", False) cookiejar.set_accept_policy(Soup.CookieJarAcceptPolicy.ALWAYS) session = WebKit.get_default_session() session.add_feature

Custom signal from widget to widget

北城余情 提交于 2020-01-02 07:26:33
问题 try to send signal from one gtk.EventBox child to another. on init HeadMode (line 75) got error: TypeError : unknown signal name: message-send why? #!/usr/bin/env python # -*- coding: utf8 -*- import pygtk pygtk.require('2.0') import gtk import gobject def Destroy(widget): gtk.main_quit() class CustomEventBox(gtk.EventBox): def __init__(self): super(CustomEventBox, self).__init__() self.press_hid = self.connect("button_press_event", self.on_press) self.release_hid = self.connect("button

g_signal_connect for right mouse click?

霸气de小男生 提交于 2020-01-02 06:52:19
问题 I got this code that works for the left mouse click on a button but how would I use to get the right mouse click signal: g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button-action), NULL); 回答1: A simple way to listen for any mouse clicks, be it left or right would be this: g_signal_connect( G_OBJECT(button) "button-press-event", G_CALLBACK(btn_press_callback), NULL ); Then, for the callback function: gboolean btn_press_callback(GtkWidget *btn, GdkEventButton *event, gpointer

is GTK 3.x a real cross-platform solution?

青春壹個敷衍的年華 提交于 2020-01-02 06:50:46
问题 I have tasted both Qt 4.x/5.x and GTKmm 3.x and I really like GTKmm over Qt. Now I have just discovered that GTKmm 3.x doesn't offer a Windows porting, they also do not offer a Mac porting, basically I can't find nothing but libraries/sources/binaries for Linux. Apparently the Windows support ( I'm not sure about the situation for the Mac OS stuff ) was dropped in the 2.x era and it's still not-existing today. I have planned to use GTK 3.x for specific reasons, especially for some new

How to get a current font for GtkTextView?

丶灬走出姿态 提交于 2020-01-02 05:40:28
问题 It's pretty easy to set the default font for a GtkTextView via gtk_widget_modify_font() , but how to get which one is current? (I'm not using any tags in the widget.) 回答1: You can use gtk_widget_get_style() to get the current GtkStyle, and then use gtk_style_get_font() . 来源: https://stackoverflow.com/questions/1908645/how-to-get-a-current-font-for-gtktextview

Unable to connect signal and signal handler in Glade GTK+3

拈花ヽ惹草 提交于 2020-01-02 05:40:08
问题 Hi i'm working on a project in GTK+ 3 on Ubuntu 14.04 LTS. I'm trying to use Glade,but when i tried to connect a "toggled" signal of toggle button to a function called kaczka ,after compiling i got this in my console: (Gra_w_Statki:11072): Gtk-Warning**:Could not find signal handler 'kaczka. Did you compile with -rdynamic? The window and the button render itself and work normally except of that toggling button doesn't change anything. What am i doing wrong ? This is how i tried to connect

How To Save Content of GTKTextBuffer to a File

南笙酒味 提交于 2020-01-02 04:54:11
问题 I'm writing on Ubuntu 12.04 in Anjuta with C and GTK a program. It's a graphical interface for the nbc (Lego NXT Compiler). I have a GTKTextView. Now I want to save the content of the textview to a file, which could be chosen by a GTKFileChooser. Now I don't know how to get the text from the TextView and write it to the file. How do i do this? 回答1: First, get the GtkTextBuffer from the GtkTextView using gtk_text_view_get_buffer() . Then get the start and end GtkTextIters from the buffer to

How does one add an item to GTK's “recently used” file list from Python?

非 Y 不嫁゛ 提交于 2020-01-02 00:27:05
问题 I'm trying to add to the "recently used" files list from Python 3 on Ubuntu. I am able to successfully read the recently used file list like this: from gi.repository import Gtk recent_mgr = Gtk.RecentManager.get_default() for item in recent_mgr.get_items(): print(item.get_uri()) This prints out the same list of files I see when I look at "Recent" in Nautilus, or look at the "Recently Used" place in the file dialog of apps like GIMP. However, when I tried adding an item like this (where /home