[Pkg-wmaker-commits] [wmstickynotes] 01/81: Initial import.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 25 02:33:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmstickynotes.

commit 1e96865ca9f3855b2844f4c885386325e0758a80
Author: hnc <hnc at 7fc852e4-12a7-4f5b-bad7-374d67da4d19>
Date:   Sat Feb 14 01:25:39 2009 +0000

    Initial import.
---
 ChangeLog         |   0
 INSTALL           | 291 ++++++++++++++++++++++++++++++++++++++++++
 Makefile.am       |  13 ++
 NEWS              |   0
 README            |   0
 configure.ac      |  38 ++++++
 delete_button.xpm |  15 +++
 resize_button.xpm |  15 +++
 wmstickynotes.c   | 372 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 wmstickynotes.h   |  47 +++++++
 10 files changed, 791 insertions(+)

diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..8b82ade
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,291 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008 Free Software Foundation, Inc.
+
+   This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+   Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+   By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+   Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *Note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..8e17c04
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,13 @@
+#
+# $Id: $
+#
+# Heath Caldwell <hncaldwell at gmail.com>
+#
+
+AM_CFLAGS = @GTK_CFLAGS@
+
+AUTOMAKE_OPTIONS = gnu
+bin_PROGRAMS = wmstickynotes
+wmstickynotes_SOURCES = wmstickynotes.c wmstickynotes.h delete_button.xpm resize_button.xpm
+
+wmstickynotes_LDADD = @GTK_LIBS@
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..4edd29f
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,38 @@
+#
+# $Id: $
+#
+# Heath Caldwell <hncaldwell at gmail.com>
+#
+
+AC_INIT([wmstickynotes], [0.1], [Heath Caldwell <hncaldwell at gmail.com>])
+AM_INIT_AUTOMAKE
+AC_CONFIG_HEADER([config.h])
+
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+AC_LANG_C
+AC_PATH_XTRA
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+
+AM_PATH_GTK_2_0([2.4.0])
+PKG_CHECK_MODULES(GTK, gdk-2.0 gtk+-2.0,,exit)
+AC_SUBST(GTK_LIBS)
+AC_SUBST(GTK_CFLAGS)
+
+AC_C_CONST
+AC_TYPE_PID_T
+AC_HEADER_TIME
+
+AC_FUNC_MALLOC
+AC_FUNC_MEMCMP
+AC_TYPE_SIGNAL
+AC_FUNC_STRFTIME
+AC_CHECK_FUNCS([atexit mkdir])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+
diff --git a/delete_button.xpm b/delete_button.xpm
new file mode 100644
index 0000000..4253b33
--- /dev/null
+++ b/delete_button.xpm
@@ -0,0 +1,15 @@
+/* XPM */
+static char * delete_button_xpm[] = {
+"8 8 4 1",
+" 	c #000000",
+".	c #939393",
+"+	c #FFFFFF",
+"@	c #494848",
+"        ",
+" .++++. ",
+" + ++ + ",
+" ++@@++ ",
+" ++@@++ ",
+" + ++ + ",
+" .++++. ",
+"        "};
diff --git a/resize_button.xpm b/resize_button.xpm
new file mode 100644
index 0000000..cf646d2
--- /dev/null
+++ b/resize_button.xpm
@@ -0,0 +1,15 @@
+/* XPM */
+static char * resize_button_xpm[] = {
+"10 10 2 1",
+" 	c #FFFFFF",
+".	c #000000",
+"         .",
+"        . ",
+"       .  ",
+"      .  .",
+"     .  . ",
+"    .  .  ",
+"   .  .  .",
+"  .  .  . ",
+" .  .  .  ",
+".  .  .  ."};
diff --git a/wmstickynotes.c b/wmstickynotes.c
new file mode 100644
index 0000000..377015f
--- /dev/null
+++ b/wmstickynotes.c
@@ -0,0 +1,372 @@
+/*
+ * $Id: $
+ *
+ * Heath Caldwell <hncaldwell at gmail.com>
+ *
+ */
+
+/* http://mail.gnome.org/archives/gtk-list/2000-January/msg00072.html */
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <dirent.h>
+
+#include "wmstickynotes.h"
+#include "delete_button.xpm"
+#include "resize_button.xpm"
+#include "config.h"
+
+#include <X11/Xlib.h>
+#include <X11/extensions/shape.h>
+
+/* The place under HOME to store notes */
+char *wmstickynotes_dir = ".wmstickynotes";
+
+GdkColormap *colormap;
+
+/* The highest note id used so far (this is used when making a new note so
+ * that no ids are clobbered */
+long int highest_note_id = 0;
+
+
+
+void delete_note(GtkWidget *widget, Note *note)
+{
+	char *filename;
+	asprintf(&filename, "%d", note->id);
+	unlink(filename);
+	free(note);
+}
+
+void save_note(GtkWidget *widget, Note *note)
+{
+	FILE *file;
+	char *filename;
+	GtkTextIter start;
+	GtkTextIter end;
+
+	gchar *text;
+
+	gtk_text_buffer_get_start_iter(note->text_buffer, &start);
+	gtk_text_buffer_get_end_iter(note->text_buffer, &end);
+
+	text = gtk_text_buffer_get_text(note->text_buffer, &start, &end, FALSE);
+
+	asprintf(&filename, "%d", note->id);
+	file = fopen(filename, "w");
+	free(filename);
+
+	fprintf(file, "%d,%d,%d,%d,%d\n%s", note->x, note->y, note->width, note->height, note->color, text);
+	fclose(file);
+
+	g_free(text);
+}
+
+gboolean note_configure_event(GtkWidget *window, GdkEventConfigure *event, Note *note)
+{
+	note->x = event->x;
+	note->y = event->y;
+	note->width = event->width;
+	note->height = event->height;
+	save_note(window, note);
+	return FALSE;
+}
+
+void bar_pressed(GtkWidget *widget, GdkEventButton *event, Note *note)
+{
+	gtk_window_begin_move_drag(GTK_WINDOW(note->window), event->button, event->x_root, event->y_root, event->time);
+}
+
+void resize_button_pressed(GtkWidget *widget, GdkEventButton *event, Note *note)
+{
+	gtk_window_begin_resize_drag(GTK_WINDOW(note->window), GDK_WINDOW_EDGE_SOUTH_EAST, event->button, event->x_root, event->y_root, event->time);
+}
+
+void delete_button_pressed(GtkWidget *widget, GdkEventButton *event, GtkWidget *window)
+{
+	if(event->button != 1) return;
+
+	gtk_widget_destroy(window);
+}
+
+void create_note(Note *old_note, int color)
+{
+	GtkWidget *window;
+	GtkWidget *text_widget;
+	GtkWidget *vbox;
+	GtkWidget *top_hbox;
+	GtkWidget *mid_hbox;
+	GtkWidget *bottom_bar;
+	GtkWidget *bottom_hbox;
+	GtkWidget *top_bar;
+	GtkWidget *top_bar_box;
+	GtkWidget *delete_button;
+	GtkWidget *delete_button_box;
+	GdkPixmap *delete_button_pixmap;
+	GdkBitmap *delete_button_mask;
+	GtkWidget *resize_button;
+	GtkWidget *resize_button_box;
+	GdkPixmap *resize_button_pixmap;
+	GdkBitmap *resize_button_mask;
+	GdkColor gcolor;
+
+	Note *note;
+	
+	note = old_note ? old_note : malloc(sizeof(Note));
+
+	if(!old_note) {
+		highest_note_id++;
+		note->id = highest_note_id;
+		note->color = color;
+	}
+
+	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
+	gtk_window_set_default_size(GTK_WINDOW(window), 150, 150);
+
+	text_widget = gtk_text_view_new_with_buffer(old_note ? old_note->text_buffer : NULL);
+	note->text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget));
+
+	note->window = window;
+
+	vbox = gtk_vbox_new(FALSE, 0);
+	top_hbox = gtk_hbox_new(FALSE, 0);
+	mid_hbox = gtk_hbox_new(FALSE, 0);
+	bottom_hbox = gtk_hbox_new(FALSE, 0);
+	top_bar = gtk_label_new("");
+	top_bar_box = gtk_event_box_new();
+	gtk_widget_set_size_request(top_bar, -1, 10);
+	bottom_bar = gtk_label_new("");
+	gtk_widget_set_size_request(bottom_bar, -1, 10);
+
+	delete_button_pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap, &delete_button_mask, NULL, delete_button_xpm);
+	delete_button = gtk_image_new_from_pixmap(delete_button_pixmap, delete_button_mask);
+	delete_button_box = gtk_event_box_new();
+	gtk_widget_set_size_request(delete_button_box, 10, 10);
+
+	resize_button_pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap, &resize_button_mask, NULL, resize_button_xpm);
+	resize_button = gtk_image_new_from_pixmap(resize_button_pixmap, resize_button_mask);
+	resize_button_box = gtk_event_box_new();
+
+	gdk_color_parse(color_schemes[note->color].top, &gcolor);
+	gtk_widget_modify_bg(top_bar_box, GTK_STATE_NORMAL, &gcolor);
+	gtk_widget_modify_bg(delete_button_box, GTK_STATE_NORMAL, &gcolor);
+	gdk_color_parse(color_schemes[note->color].background, &gcolor);
+	gtk_widget_modify_base(text_widget, GTK_STATE_NORMAL, &gcolor);
+	gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &gcolor);
+
+	gtk_container_add(GTK_CONTAINER(window), vbox);
+	gtk_container_add(GTK_CONTAINER(top_bar_box), top_bar);
+	gtk_container_add(GTK_CONTAINER(delete_button_box), delete_button);
+	gtk_container_add(GTK_CONTAINER(resize_button_box), resize_button);
+	gtk_box_pack_start(GTK_BOX(top_hbox), top_bar_box, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(top_hbox), delete_button_box, FALSE, FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(mid_hbox), text_widget, TRUE, TRUE, 2);
+	gtk_box_pack_start(GTK_BOX(bottom_hbox), bottom_bar, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(bottom_hbox), resize_button_box, FALSE, FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), top_hbox, FALSE, FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), mid_hbox, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), bottom_hbox, FALSE, FALSE, 0);
+
+	gtk_widget_show_all(window);
+
+	if(old_note) {
+		gtk_window_resize(GTK_WINDOW(window), old_note->width, old_note->height);
+		gtk_window_move(GTK_WINDOW(window), old_note->x, old_note->y);
+	} else {
+		gtk_window_get_position(GTK_WINDOW(window), &(note->x), &(note->y));
+		gtk_window_get_size(GTK_WINDOW(window), &(note->width), &(note->height));
+	}
+
+	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(delete_note), note);
+	g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(note_configure_event), note);
+	g_signal_connect(G_OBJECT(delete_button_box), "button-press-event", G_CALLBACK(delete_button_pressed), window);
+	g_signal_connect(G_OBJECT(resize_button_box), "button-press-event", G_CALLBACK(resize_button_pressed), note);
+	g_signal_connect(G_OBJECT(note->text_buffer), "changed", G_CALLBACK(save_note), note);
+	g_signal_connect(G_OBJECT(top_bar_box), "button-press-event", G_CALLBACK(bar_pressed), note);
+}
+
+void new_note_button_clicked(GtkButton *button, char *color)
+{
+	int c;
+
+	for(c=0; c<=5; c++) {
+		if(!strcmp(color_schemes[c].name, color)) break;
+	}
+	if(strcmp(color_schemes[c].name, color)) c = 0;
+
+	create_note(NULL, c);
+}
+
+void read_old_notes()
+{
+	Note *note;
+	GtkTextIter iter;
+	DIR *dir = opendir(".");
+	FILE *file;
+	struct dirent *entry;
+	int i;
+	char buffer[256];
+
+	rewinddir(dir);
+	while((entry = readdir(dir)) != NULL) {
+		/* Check if it is a valid note name */
+		for(i=0; entry->d_name[i]; i++) {
+			if(entry->d_name[i] < '0' || entry->d_name[i] > '9') break;
+		}
+		if(i < strlen(entry->d_name)) continue;
+
+		file = fopen(entry->d_name, "r");
+		note = malloc(sizeof(Note));
+
+		note->id = atoi(entry->d_name);
+		if(note->id > highest_note_id) highest_note_id = note->id;
+
+		fscanf(file, "%d,%d,%d,%d,%d\n", &(note->x), &(note->y), &(note->width), &(note->height), &(note->color));
+		if(note->color > 5) note->color = 0;
+
+		note->text_buffer = gtk_text_buffer_new(NULL);
+		while(fgets(buffer, 256, file)) {
+			gtk_text_buffer_get_end_iter(note->text_buffer, &iter);
+			gtk_text_buffer_insert(note->text_buffer, &iter, buffer, -1);
+		}
+
+		create_note(note, 0);
+
+		fclose(file);
+	}
+
+	closedir(dir);
+}
+
+int main(int argc, char *argv[])
+{
+	GtkWidget *window;
+	GtkWidget *box;
+	GtkWidget *vbox;
+	GtkWidget *hbox;
+	GtkWidget *table;
+	GtkWidget *yellow_button;
+	GtkWidget *green_button;
+	GtkWidget *orange_button;
+	GtkWidget *red_button;
+	GtkWidget *blue_button;
+	GtkWidget *white_button;
+	GdkColor color;
+	XWMHints mywmhints;
+	char *dir;
+
+	gtk_init(&argc, &argv);
+
+	colormap = gdk_colormap_new(gdk_visual_get_system(), TRUE);
+
+	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	gtk_window_set_default_size(GTK_WINDOW(window), 64, 64);
+
+	box = gtk_event_box_new();
+	gtk_container_add(GTK_CONTAINER (window), box);
+
+	vbox = gtk_vbox_new(FALSE, 0);
+	hbox = gtk_hbox_new(FALSE, 0);
+
+	table = gtk_table_new(2, 3, TRUE);
+	gtk_table_set_row_spacings(GTK_TABLE(table), 1);
+	gtk_table_set_col_spacings(GTK_TABLE(table), 1);
+
+	yellow_button = gtk_button_new();
+	green_button = gtk_button_new();
+	orange_button = gtk_button_new();
+	red_button = gtk_button_new();
+	blue_button = gtk_button_new();
+	white_button = gtk_button_new();
+
+	gdk_color_parse (color_schemes[0].top, &color);
+	gtk_widget_modify_bg(yellow_button, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg(yellow_button, GTK_STATE_PRELIGHT, &color);
+	gdk_color_parse (color_schemes[1].top, &color);
+	gtk_widget_modify_bg(green_button, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg(green_button, GTK_STATE_PRELIGHT, &color);
+	gdk_color_parse (color_schemes[2].top, &color);
+	gtk_widget_modify_bg(orange_button, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg(orange_button, GTK_STATE_PRELIGHT, &color);
+	gdk_color_parse (color_schemes[3].top, &color);
+	gtk_widget_modify_bg(red_button, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg(red_button, GTK_STATE_PRELIGHT, &color);
+	gdk_color_parse (color_schemes[4].top, &color);
+	gtk_widget_modify_bg(blue_button, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg(blue_button, GTK_STATE_PRELIGHT, &color);
+	gdk_color_parse (color_schemes[5].background, &color);
+	gtk_widget_modify_bg(white_button, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg(white_button, GTK_STATE_PRELIGHT, &color);
+
+	gtk_table_attach_defaults(GTK_TABLE(table), yellow_button, 0, 1, 0, 1);
+	gtk_table_attach_defaults(GTK_TABLE(table), green_button, 1, 2, 0, 1);
+	gtk_table_attach_defaults(GTK_TABLE(table), orange_button, 2, 3, 0, 1);
+	gtk_table_attach_defaults(GTK_TABLE(table), red_button, 0, 1, 1, 2);
+	gtk_table_attach_defaults(GTK_TABLE(table), blue_button, 1, 2, 1, 2);
+	gtk_table_attach_defaults(GTK_TABLE(table), white_button, 2, 3, 1, 2);
+
+	gdk_color_parse ("#fafafa", &color);
+	gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &color);
+
+	gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 4);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
+	gtk_container_add(GTK_CONTAINER(box), vbox);
+
+	gtk_widget_show_all(window);
+
+	mywmhints.initial_state = WithdrawnState;
+	mywmhints.icon_window = GDK_WINDOW_XWINDOW(box->window);
+	mywmhints.icon_x = 0; 
+	mywmhints.icon_y = 0; 
+	mywmhints.window_group = GDK_WINDOW_XWINDOW(window->window);
+	mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
+
+	XSetWMHints(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window->window), &mywmhints);
+
+	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
+	g_signal_connect(G_OBJECT(yellow_button), "clicked", G_CALLBACK(new_note_button_clicked), "yellow");
+	g_signal_connect(G_OBJECT(green_button), "clicked", G_CALLBACK(new_note_button_clicked), "green");
+	g_signal_connect(G_OBJECT(orange_button), "clicked", G_CALLBACK(new_note_button_clicked), "orange");
+	g_signal_connect(G_OBJECT(red_button), "clicked", G_CALLBACK(new_note_button_clicked), "red");
+	g_signal_connect(G_OBJECT(blue_button), "clicked", G_CALLBACK(new_note_button_clicked), "blue");
+	g_signal_connect(G_OBJECT(white_button), "clicked", G_CALLBACK(new_note_button_clicked), "white");
+
+	umask(077);
+
+	dir = calloc(strlen(wmstickynotes_dir) + strlen(getenv("HOME")) + 2, sizeof(char));
+	strcpy(dir, getenv("HOME"));
+	strcat(dir, "/");
+	strcat(dir, wmstickynotes_dir);
+
+	if(chdir(dir)) {
+		if(errno == ENOENT) {
+			if(mkdir(dir, 0777)) {
+				fprintf(stderr, "Couldn't make directory: %s\n", dir);
+				exit(1);
+			}
+			if(chdir(dir)) {
+				fprintf(stderr, "Couldn't change to directory: %s\n", dir);
+				exit(1);
+			}
+		} else {
+			fprintf(stderr, "Couldn't change to directory: %s\n", dir);
+			exit(1);
+		}
+	}
+
+	free(dir);
+
+	read_old_notes();
+	gtk_main();
+
+	return 0;
+}
+
diff --git a/wmstickynotes.h b/wmstickynotes.h
new file mode 100644
index 0000000..197f80c
--- /dev/null
+++ b/wmstickynotes.h
@@ -0,0 +1,47 @@
+/*
+ * $Id: $
+ *
+ * Heath Caldwell <hncaldwell at gmail.com>
+ *
+ */
+
+#ifndef WMSTICKYNOTES_H
+#define WMSTICKYNOTES_H
+
+typedef struct {
+	char *name;
+	char *top;
+	char *background;
+} ColorScheme;
+
+typedef struct {
+	long int id;
+	int x;
+	int y;
+	int width;
+	int height;
+	int color;
+	GtkWidget *window;
+	GtkTextBuffer *text_buffer;
+} Note;
+
+ColorScheme color_schemes[] = {
+	{"yellow",	"#ffff00",	"#ffff88"},
+	{"green",	"#66ff00",	"#d0f0c0"},
+	{"orange",	"#ff7f00",	"#ffe5b4"},
+	{"red",		"#ff007f",	"#ffc0cb"},
+	{"blue",	"#0000ff",	"#ccccff"},
+	{"white",	"#aaaaaa",	"#ffffff"}};
+
+
+void delete_note(GtkWidget *widget, Note *note);
+void save_note(GtkWidget *widget, Note *note);
+gboolean note_configure_event(GtkWidget *window, GdkEventConfigure *event, Note *note);
+void bar_pressed(GtkWidget *widget, GdkEventButton *event, Note *note);
+void resize_button_pressed(GtkWidget *widget, GdkEventButton *event, Note *note);
+void delete_button_pressed(GtkWidget *widget, GdkEventButton *event, GtkWidget *window);
+void create_note(Note *old_note, int color);
+void new_note_button_clicked(GtkButton *button, char *color);
+void read_old_notes();
+
+#endif /* WMSTICKYNOTES_H */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmstickynotes.git



More information about the Pkg-wmaker-commits mailing list