glib

How do you set an enum property on a GLib object?

自闭症网瘾萝莉.ら 提交于 2020-02-16 05:49:28
问题 I am trying to set the "ellipsize" enum property on a GtkCellRendererText object. I am trying to use g_object_set_property as follows: GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); GValue val = G_VALUE_INIT; g_value_init (&val, G_TYPE_ENUM); g_value_set_enum (&val, PANGO_ELLIPSIZE_END); g_object_set_property (G_OBJECT(renderer), "ellipsize", &val); However, I get an error message at run time: (infog:27114): GLib-GObject-WARNING **: 12:24:29.848: ../../../../gobject/gvalue.c:188:

How does GObject style construction work?

你离开我真会死。 提交于 2020-02-05 03:22:26
问题 I'm new to Vala and trying to understand how the language works. I usually use script languages like Python or JavaScript. So, my question is why are there three ways of class constructor definition and how does the GObject style constructor work? For the best understanding lets make an analogy with python: Python class definition class Car(object): speed: int def __init__(self, speed): # default constructor self.speed = speed # property And Vala class Car : GLib.Object { public int speed {

fatal error: glib.h: No such file or directory

折月煮酒 提交于 2020-01-26 07:55:42
在学习BLE bluez的时候,做了一个测试程序,看到gatttool.c下面有一个glib解析命令行的功能,想移植到自己的程序接口中,但是添加了#include <glib.h>后,出现了fatal error: glib.h: No such file or directory错误。经过网上查找答案,询问同事,找到了解决方法:在Makefile中添加glib库和头文件。 方法如下 1.安装glib库: apt-get install libglib2.0-dev 2.(Makefile中): LINKFLAGS += -lglib-2.0 INCL_PATH += -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include/ .SUFFIXES:.c.o.h $(BIN):$(OBJECTS)   $(CC) $(CMPOPT) $(BIN) $(OBJECTS) $(LINKFLAGS) %.o:%.c    $(CC) -c $(INCL_PATH) $(CFLAGS) $< $(CMPOPT) $@ 来源: https://www.cnblogs.com/hjj801006/p/9482306.html

Is it possible to define GTK+ type using gtkmm?

风格不统一 提交于 2020-01-14 04:05:13
问题 I would like to define a new subclass of some gtkmm type, implementing interface of underlying GTK+ object. Then, i want to compile it into some kind of dll and use in pure C code (GTK+, no gtkmm) through this interface. Is it possible? 回答1: The followings are required to use gtkmm widget in GTK+ : implement the desired custom widget in gtkmm create a library from the widget for Glade design the user interface containing the custom widget with Glade declare the C interface for the application

Initialize a GObject with parameters which are not GObject properties?

孤人 提交于 2020-01-13 13:11:30
问题 I have a GObject "A" which creates an instance of another GObject "B" in its constructor. The "B" object needs to be passed several construction-only properties. Now when creating an instance of object "A" I want to allow passing values for these properties through the constructor of object "A" on to the constructor of object "B". The only way I have found to do that was to create identical properties for object "A" and pass their values on to the constructor of "B". These properties would

Data written in file using glib

走远了吗. 提交于 2020-01-06 21:20:43
问题 I have a code that writes a number of characters of length <length> in a file, using g_file_set_contents. When I open the file, I see some weird characters that seem to be ASCII like @&@@. I assumed that the data might be written in ASCII format, converting from binary, so I used a function to convert from ASCII to binary. I still did not get any resolution after execution. Here is the code #include <glib.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char**

How to open/spawn a file with glib/gtkmm in Windows

£可爱£侵袭症+ 提交于 2020-01-05 05:27:15
问题 I've already tried: GError *pError = NULL; string uri = g_filename_to_uri(file.c_str(), NULL, &pError); if (!g_app_info_launch_default_for_uri(uri.c_str(), NULL, &pError)) { cout << "Failed to open uri: " << pError->message; } Here I get the error "URIs not supported". Is the uri I create here wrong? My second approach was to spawn the file with an asynchronous command line: file = quoteStr(file); try { Glib::spawn_command_line_async(file); } catch (Glib::SpawnError error) { cout << error

GLib Hash Table Loop Problem

旧时模样 提交于 2020-01-04 05:15:28
问题 I am going to use GLib's Hash table implementation in a C program and just for now I am just experimenting with it. I wrote the following piece of code for testing: #include <glib.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <string.h> int main(){ // Some codes and declerations here GHashTable *g_hash_table; uint32_t *a; a=(uint32_t *)malloc(sizeof(uint32_t)); if(a==NULL){ printf("Not Enough Mem For a\n"); return 1; } *a=1123231; uint32_t* key; key=(uint32_t *)malloc

add callback for separate g_main_loop

一个人想着一个人 提交于 2020-01-03 17:19:34
问题 I have some misunderstanding about how GMainLoop work. Main thing - API which add some callbacks into g_main_loop (like g_timeout_add_seconds() ) don't take pointer to which loop you want to add that callback. It looks like you add callback's for all g_main_loop instances. Even if you have not yet created. Simple example for this: #include <glib.h> gboolean callback(gpointer data) { static guint16 i=0; g_print("Iter=%"G_GUINT16_FORMAT"\n",i++); if(i%5==0){ g_print("try to stop loop1\n"); g

Glib-GIO-ERROR when opening an file chooser dialog

感情迁移 提交于 2020-01-02 10:11:26
问题 I use GTK3 , codeblcks IDE, glade3 in windows 7... In my application i have a button which when clicked should open a gtk_file_chooser_dialog... But gives the fillowing error.. Glib-GIO-ERROR** : No GSettings schemas are installed on the system static void on_save_clicked(GtkWidget *widget,gpointer data) { GtkWidget *dialog; //dialog=gtk_file_chooser_dialog_new("Save it",GTK_WINDOW(gtk_builder_get_object(builder,"mainwindow")),GTK_FILE_CHOOSER_ACTION_SAVE,GTK_STOCK_OK,GTK_RESPONSE_OK,GTK