Skip to content

Instantly share code, notes, and snippets.

View bert's full-sized avatar
🎯
Focusing

Bert Timmerman bert

🎯
Focusing
View GitHub Profile
@bert
bert / number.c
Created December 19, 2009 09:57
Add number snippet
NUMBER add (NUMBER a, NUMBER b)
{
int i;
int carry;
int aux;
int vec[MAX];
NUMBER result;
if (a.length <= b.length)
aux = b.length;
@bert
bert / Makefile
Created December 19, 2009 10:04
How to use and process GTK enter or leave signals
CFLAGS = -Wall -g `pkg-config --cflags gtk+-2.0`
LDFLAGS = `pkg-config --libs gtk+-2.0`
enter_and_leave_signals_demo: enter_and_leave_signals_demo.c
$(CC) -o enter_and_leave_signals_demo enter_and_leave_signals_demo.c $(CFLAGS) $(LDFLAGS)
clean:
rm -f *~
rm -f *.o
rm -f enter_and_leave_signals_demo
@bert
bert / Makefile
Created December 19, 2009 14:11
GTK grid widget example
CFLAGS = -Wall -g `pkg-config --cflags gtk+-2.0`
LDFLAGS = `pkg-config --libs gtk+-2.0`
grid_test: grid_test.c
$(CC) -o grid_test grid_test.c $(CFLAGS) $(LDFLAGS)
clean:
rm -f *~
rm -f *.o
rm -f grid
@bert
bert / .gitignore
Created December 19, 2009 14:19
GIOChannel based command system example
*.o
*~
command
@bert
bert / gtk_entry_insert_text_comment.c
Created December 19, 2009 14:48
GTK entry insert text comment snippet
/*!
* \file gtk_entry_insert_text_comment.c
* \brief
*
* The algorithms here will work as long as the text size (a
* multiple of 2), fits into a guint16. We specify a shorter
* maximum length so that if the user pastes a very long text, there
* is not a long hang from the slow X_LOCALE functions.
*/
@bert
bert / README
Created December 19, 2009 15:27
GTK statusbar push and pop example
Use at your own risk.
Requires:
gtk+-2.0
@bert
bert / mysql_text_entry.c
Created December 19, 2009 16:57
MySQL text entry example
/*!
* \file mysql_text_entry.c
* \brief
*/
#include <gtk/gtk.h>
#include <glib.h>
#include <stdio.h>
#include <mysql/mysql.h>
@bert
bert / grey drawing area.c
Created December 19, 2009 17:02
Grey drawing area snippet
width = DrawingArea->allocation.width;
height = DrawingArea->allocation.height;
rgbbuf = malloc (width * height * 3);
memset (rgbbuf, 240, width * height * 3); // set the background to GREY = (240, 240, 240)
//DrawBufferImage (rgbbuf, width, height, data);
gdk_draw_rgb_image (pixmap,
DrawingArea->style->fg_gc[GTK_STATE_NORMAL],
0, 0, width, height, GDK_RGB_DITHER_NONE, rgbbuf, width*3);
free (rgbbuf);
@bert
bert / gtk_and_glade_test.c
Created December 19, 2009 17:11
Glade_new in gtk-win32 example
/*!
* \file gtk_and_glade_test.c
* \brief
*
* How to use glade_new in gtk-win32
* You have to link with the libraries you use, particularly -lglade-2.0 here.
* But since you use gcc, I suppose pkg-config would work for you,
* and therefore stop guessing what to put on the gcc command line and use
* pkg-config.
*/
@bert
bert / get_startup_time.c
Created December 19, 2009 18:24
Get startup time example
/*!
* \file get_startup_time.c
* \brief
*/
#include <glib.h>
int