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 / gtk_editable_get_position.c
Created December 22, 2009 20:51
GTK editable get position example
/*!
* \file gtk_editable_get_position.c
* \brief
*/
#include <gtk/gtk.h>
static void
@bert
bert / pango_layout_word_wrap.c
Created December 23, 2009 05:28
Pango layout word wrap example
/*!
* \file pango_layout_word_wrap.c
* \brief pango layout word wrap
*
* \author Ben Pfaff http://benpfaff.org
*
* In working with Pango I found an oddity that I do not understand.
* It may be a bug, or it might just be my misunderstanding.
*
* As part of a table layout procedure for printing, my code wishes to find out
@bert
bert / change_window_title.c
Created December 25, 2009 09:37
Change window title example
/*!
* \file change_window_title.c
* \brief
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@bert
bert / reparent.cpp
Created December 25, 2009 10:33
Reparent example
/*!
* \file reparent.cpp
* \brief
*/
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/label.h>
#include <gtkmm/button.h>
@bert
bert / factorial.c
Created December 25, 2009 11:41
Factorial overflow
/*!
* \file factorial.c
* \brief Factorials overflow int at 13! use the code below instead.
*
* Calculating factorials is one of the most classic examples used in teaching recursion.
* The code to do so is quite simple:
*
<pre>
int factorial(int i)
{
@bert
bert / seconds_to_human.c
Created December 25, 2009 12:41
Seconds to humans
char *
seconds_to_human (int secs, char *buf)
{
char buf[10];
int secs;
if (secs < 60)
{
sprintf (buf, "%ds", secs);
}
@bert
bert / timer.c
Created December 25, 2009 13:09
Timer
/*!
* \file timer.c
* \brief
*
* This set of macros is probably most useful when you're playing around with algorithms and need a quick
* and easy way to figure out how long something will take to run.
* You could do this to find bottlenecks, or do benchmarks of one algorithm versus another.
* An advantage of these macros is that they only measure CPU time given to this program,
* so if the program is run on a busy machine, the other programs running won't affect the time measured.
* Instead of having PRINTTIME only having a printf in it, change it so it's an fprintf and you can tell it
@bert
bert / native_windows_font.c
Created December 28, 2009 16:57
Native widows font
/*!
* \file native_windows_font.c
* \brief
*
* Requires gtk >= 2.2.0
*/
#ifdef G_OS_WIN32
static char appfontname[128] = "tahoma 8"; /* fallback value */
@bert
bert / sacred_data.md
Last active November 19, 2017 11:28
Your data is sacred

Your data is sacred.

It's that simple, really. When one ensures that a machine can't lose a user's work, interfaces become a lot simpler; no more dialog boxes asking questions like, "Are you sure you want to delete that entry?"; no more remembering to click a "Save" button like it's a nervous twitch. You never need to regret any action you take, because any action you take can instantly be undone. Not to mention your complete lack of terror when you're in the middle of

@bert
bert / gist:265608
Created December 29, 2009 21:16
Get window state snippet
gint f = gdk_window_get_state (gdk_window);
gboolean max = f & GDK_WINDOW_STATE_MAXIMIZED;