[Pkg-wmaker-commits] [wmstickynotes] 18/81: Add README and THANKS. Added color boxes to color menus.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 25 02:33:43 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 3177cde8fd54defd252de208891ad66aad3b52d9
Author: hnc <hnc at 7fc852e4-12a7-4f5b-bad7-374d67da4d19>
Date:   Fri Feb 20 23:13:19 2009 +0000

    Add README and THANKS.  Added color boxes to color menus.
    
    git-svn-id: svn://svn.code.sf.net/p/wmstickynotes/code@9 7fc852e4-12a7-4f5b-bad7-374d67da4d19
---
 Makefile.am     |   1 +
 README          |  19 ++++++++
 THANKS          |   3 ++
 wmstickynotes.c | 133 +++++++++++++++++++++++++++++++++++++++-----------------
 wmstickynotes.h |   8 +++-
 5 files changed, 121 insertions(+), 43 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a8fbeaa..14712a7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,3 +11,4 @@ bin_PROGRAMS = wmstickynotes
 wmstickynotes_SOURCES = wmstickynotes.c wmstickynotes.h wmstickynotes.xpm delete_button.xpm resize_button.xpm
 
 wmstickynotes_LDADD = @GTK_LIBS@
+EXTRA_DIST = THANKS
diff --git a/README b/README
index e69de29..5ca861e 100644
--- a/README
+++ b/README
@@ -0,0 +1,19 @@
+wmstickynotes
+-------------
+Heath Caldwell <hncaldwell at gmail.com>
+
+This program is a Window Maker style dockapp which allows you to create note
+windows.  The notes, along with their position, size, and color, are stored on
+disk and will be restored when wmstickynotes is run again.
+
+Left click the note icon to create a new note with the default color (yellow).
+
+Right click the note icon to get a menu of colors, selecting one of which will
+create a new note of that color.
+
+Click the x in the top right of a note to delete it.
+
+Drag the bottom right corner of a note to resize it.
+
+Right click a note to get a popup menu where you can change its color,
+cut/paste, etc.
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..39cdeda
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,3 @@
+Thanks to David Raufeisen for this post:
+http://mail.gnome.org/archives/gtk-list/2000-January/msg00072.html
+which helped me learn how to make a gtk+ dockapp.
diff --git a/wmstickynotes.c b/wmstickynotes.c
index 43f0899..468e3c8 100644
--- a/wmstickynotes.c
+++ b/wmstickynotes.c
@@ -1,12 +1,10 @@
 /*
  * $Id$
  *
- * Heath Caldwell <hncaldwell at gmail.com>
+ * Copyright (C) 2009 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>
@@ -28,9 +26,6 @@
 #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
@@ -42,6 +37,16 @@ Note *current_note;
 
 
 
+void usage()
+{
+	printf("Usage: wmstickynotes [options]\n");
+	printf("\toptions:\n");
+	printf("\t-d [dir], --directory=[dir]\tSet directory in which to store notes\n");
+	printf("\t\t\t\t\tDefaults to $HOME/%s\n", default_wmstickynotes_dir);
+	printf("\t-v, --version\tPrint version information\n");
+	printf("\t-h, --help\tPrint usage\n");
+}
+
 int main(int argc, char *argv[])
 {
 	GtkWidget *window;
@@ -54,32 +59,73 @@ int main(int argc, char *argv[])
 	GtkWidget *main_button_box;
 	GtkWidget *color_menu;
 	GtkWidget *item;
-	char *dir;
+	GtkWidget *label;
+	GtkWidget *color_box;
+	GtkWidget *hbox;
+	GdkColor gcolor;
+	char *wmstickynotes_dir = NULL;
+	gboolean use_default_dir = TRUE;
 	int option_index = 0;
 	int i = 0;
 
-	static struct option long_options[] = {
-		{"dir", required_argument, 0, 'd'},
+	struct option long_options[] = {
+		{"directory", required_argument, 0, 'd'},
+		{"version", no_argument, 0, 'v'},
 		{"help", no_argument, 0, 'h'},
 		{0, 0, 0, 0}};
 
 	for(
-		i = getopt_long(argc, argv, "d:h", long_options, &option_index);
+		i = getopt_long(argc, argv, "d:vh", long_options, &option_index);
 		i >= 0;
-		i = getopt_long(argc, argv, "d:h", long_options, &option_index)
+		i = getopt_long(argc, argv, "d:vh", long_options, &option_index)
 	) {
 		switch(i) {
 			case 'd':
 				wmstickynotes_dir = optarg;
+				use_default_dir = FALSE;
 				break;
+			case 'v':
+				printf("%s\n", PACKAGE_STRING);
+				printf("Copyright (C) 2009  %s\n", PACKAGE_BUGREPORT);
+				return 0;
 			case 'h':
-				printf("Help\n");
-				break;
+				usage();
+				return 0;
 			default:
-				abort();
+				usage();
+				return 1;
+		}
+	}
+
+	umask(077);
+
+	if(use_default_dir) {
+		wmstickynotes_dir = calloc(
+			strlen(default_wmstickynotes_dir) +
+			strlen(getenv("HOME")) + 2, sizeof(char));
+		strcpy(wmstickynotes_dir, getenv("HOME"));
+		strcat(wmstickynotes_dir, "/");
+		strcat(wmstickynotes_dir, default_wmstickynotes_dir);
+	}
+
+	if(chdir(wmstickynotes_dir)) {
+		if(errno == ENOENT) {
+			if(mkdir(wmstickynotes_dir, 0777)) {
+				fprintf(stderr, "Couldn't make directory: %s\n", wmstickynotes_dir);
+				exit(1);
+			}
+			if(chdir(wmstickynotes_dir)) {
+				fprintf(stderr, "Couldn't change to directory: %s\n", wmstickynotes_dir);
+				exit(1);
+			}
+		} else {
+			fprintf(stderr, "Couldn't change to directory: %s\n", wmstickynotes_dir);
+			exit(1);
 		}
 	}
 
+	if(use_default_dir) free(wmstickynotes_dir);
+
 	gtk_init(&argc, &argv);
 
 	colormap = gdk_colormap_new(gdk_visual_get_system(), TRUE);
@@ -102,7 +148,20 @@ int main(int argc, char *argv[])
 	color_menu = gtk_menu_new();
 
 	for(i=0; i < num_color_schemes; i++) {
-		item = gtk_menu_item_new_with_label(color_schemes[i].name);
+		item = gtk_menu_item_new();
+		label = gtk_label_new(color_schemes[i].name);
+		color_box = gtk_event_box_new();
+		gtk_widget_set_size_request(color_box, 15, -1);
+		hbox = gtk_hbox_new(FALSE, 4);
+
+		gdk_color_parse(color_schemes[i].top, &gcolor);
+		gtk_widget_modify_bg(color_box, GTK_STATE_NORMAL, &gcolor);
+		gtk_widget_modify_bg(color_box, GTK_STATE_PRELIGHT, &gcolor);
+
+		gtk_container_add(GTK_CONTAINER(item), hbox);
+		gtk_box_pack_start(GTK_BOX(hbox), color_box, FALSE, FALSE, 0);
+		gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+
 		gtk_menu_shell_append(GTK_MENU_SHELL(color_menu), item);
 		g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(new_note_from_menu), (gpointer)i);
 	}
@@ -122,31 +181,6 @@ int main(int argc, char *argv[])
 	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 	g_signal_connect(G_OBJECT(main_button_box), "button-press-event", G_CALLBACK(main_button_pressed), color_menu);
 
-	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();
 
@@ -362,6 +396,10 @@ void populate_note_popup(GtkTextView *entry, GtkMenu *menu, Note *note)
 	GtkWidget *color_menu;
 	GtkWidget *color_item;
 	GtkWidget *item;
+	GtkWidget *label;
+	GtkWidget *color_box;
+	GtkWidget *hbox;
+	GdkColor gcolor;
 	int i;
 
 	color_menu = gtk_menu_new();
@@ -372,7 +410,20 @@ void populate_note_popup(GtkTextView *entry, GtkMenu *menu, Note *note)
 
 	current_note = note;
 	for(i=0; i < num_color_schemes; i++) {
-		item = gtk_menu_item_new_with_label(color_schemes[i].name);
+		item = gtk_menu_item_new();
+		label = gtk_label_new(color_schemes[i].name);
+		color_box = gtk_event_box_new();
+		gtk_widget_set_size_request(color_box, 15, -1);
+		hbox = gtk_hbox_new(FALSE, 4);
+
+		gdk_color_parse(color_schemes[i].top, &gcolor);
+		gtk_widget_modify_bg(color_box, GTK_STATE_NORMAL, &gcolor);
+		gtk_widget_modify_bg(color_box, GTK_STATE_PRELIGHT, &gcolor);
+
+		gtk_container_add(GTK_CONTAINER(item), hbox);
+		gtk_box_pack_start(GTK_BOX(hbox), color_box, FALSE, FALSE, 0);
+		gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+
 		gtk_menu_shell_append(GTK_MENU_SHELL(color_menu), item);
 		g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_current_note_color), (gpointer)i);
 	}
diff --git a/wmstickynotes.h b/wmstickynotes.h
index 0e6df03..3985179 100644
--- a/wmstickynotes.h
+++ b/wmstickynotes.h
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Heath Caldwell <hncaldwell at gmail.com>
+ * Copyright (C) 2009 Heath Caldwell <hncaldwell at gmail.com>
  *
  */
 
@@ -9,7 +9,7 @@
 #define WMSTICKYNOTES_H
 
 typedef struct {
-	char *name;
+char *name;
 	char *top;
 	char *background;
 } ColorScheme;
@@ -28,6 +28,9 @@ typedef struct {
 	GtkWidget *resize_button_box;
 } Note;
 
+/* The default directory under $HOME in which to store notes */
+const char *default_wmstickynotes_dir = ".wmstickynotes";
+
 const num_color_schemes = 8;
 ColorScheme color_schemes[] = {
 	{"Yellow",	"#ffff00",	"#ffff88"},
@@ -52,5 +55,6 @@ void populate_note_popup(GtkTextView *entry, GtkMenu *menu, Note *note);
 void set_current_note_color(GtkMenuItem *menuitem, gpointer color);
 void set_note_color(Note *note, int color);
 void main_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
+void usage();
 
 #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