- switch to gtk+2

This commit is contained in:
jasper 2010-03-23 22:12:39 +00:00
parent 2fc67f3b3e
commit 6538bfb273
8 changed files with 307 additions and 8 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.3 2007/09/15 20:04:25 merdely Exp $
# $OpenBSD: Makefile,v 1.4 2010/03/23 22:12:39 jasper Exp $
COMMENT= Window Maker dock.app clock
DISTNAME= wmclockmon-0.8.0
PKGNAME= ${DISTNAME}p0
CATEGORIES= x11 x11/windowmaker
HOMEPAGE= http://tnemeth.free.fr/projets/dockapps.html
@ -11,14 +12,21 @@ MAINTAINER= Niall O Higgins <niallo@openbsd.org>
MASTER_SITES= http://tnemeth.free.fr/projets/programmes/
# GPL
# GPLv2
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
WANTLIB= X11 Xext Xi Xpm c gmodule iconv intl m glib
LIB_DEPENDS= gtk.>=1.2,gdk.>=1.2::x11/gtk+
MODULES= devel/gettext
WANTLIB += X11 Xau Xcomposite Xcursor Xdamage Xdmcp Xext Xfixes
WANTLIB += Xi Xinerama Xpm Xrandr Xrender atk-1.0 c cairo expat
WANTLIB += fontconfig freetype gio-2.0 glib-2.0 glitz gmodule-2.0
WANTLIB += gobject-2.0 m pango-1.0 pangocairo-1.0 pangoft2-1.0
WANTLIB += pixman-1 png pthread-stubs xcb z
LIB_DEPENDS= gdk_pixbuf-2.0,gdk-x11-2.0,gtk-x11-2.0::x11/gtk+2
USE_X11= Yes
NO_REGRESS= Yes

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-wmclockmon-cal_Makefile_in,v 1.1 2010/03/23 22:12:39 jasper Exp $
- Switch to gtk+2.
--- wmclockmon-cal/Makefile.in.orig Tue Mar 23 23:03:29 2010
+++ wmclockmon-cal/Makefile.in Tue Mar 23 23:03:53 2010
@@ -96,14 +96,14 @@ PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
-LDFLAGS = @LDFLAGS@ `gtk-config --libs`
+LDFLAGS = @LDFLAGS@ `pkg-config --libs gtk+-2.0`
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
wmclockmon_OBJECTS = main.o mainwindow.o tools.o
wmclockmon_DEPENDENCIES =
wmclockmon_LDFLAGS =
-CFLAGS = @CFLAGS@ `gtk-config --cflags`
+CFLAGS = @CFLAGS@ `pkg-config --cflags gtk+-2.0`
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@

View File

@ -0,0 +1,155 @@
$OpenBSD: patch-wmclockmon-cal_mainwindow_c,v 1.1 2010/03/23 22:12:39 jasper Exp $
Switch to gtk+2:
- Remove call to deprecated function.
--- wmclockmon-cal/mainwindow.c.orig Mon May 31 10:15:18 2004
+++ wmclockmon-cal/mainwindow.c Tue Mar 23 23:11:30 2010
@@ -51,7 +51,6 @@ static void show_editor() {
gtk_widget_hide(calendar);
gtk_widget_hide(closewindow);
gtk_widget_grab_default(GTK_WIDGET(cancel));
- gtk_widget_draw_default(GTK_WIDGET(cancel));
gtk_widget_grab_focus(GTK_WIDGET(edit));
gtk_widget_show(text_buttons);
gtk_widget_show(edit);
@@ -69,7 +68,6 @@ static void hide_editor() {
gtk_widget_hide(cancel);
gtk_widget_show(calendar);
gtk_widget_grab_default(GTK_WIDGET(closewindow));
- gtk_widget_draw_default(GTK_WIDGET(closewindow));
gtk_widget_grab_focus(GTK_WIDGET(closewindow));
gtk_widget_show(closewindow);
}
@@ -93,13 +91,20 @@ static void load_file(const char *datestr) {
FILE *file;
char *filename = get_file(datestr);
+ GtkTextIter iter;
+ GtkTextBuffer *buf;
+
+ buf = GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit)));
+ gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))), &iter);
+ gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))), &iter);
+
if ((file = fopen(filename, "r")) != NULL) {
while (! feof(file)) {
char line[MAXSTRLEN + 1];
bzero(line, MAXSTRLEN + 1);
fgets(line, MAXSTRLEN, file);
if (line[0] != 0)
- gtk_text_insert(GTK_TEXT(edit), NULL, NULL, NULL, line, -1);
+ gtk_text_buffer_insert(buf, &iter, line, -1);
}
fclose(file);
}
@@ -152,23 +157,14 @@ static void set_buttons_text() {
gtk_label_set_text(GTK_LABEL(label_m), datestr);
}
-
static void editor_flush() {
- int cont = TRUE;
-
- while (cont) {
- cont = gtk_text_backward_delete(GTK_TEXT(edit), 1);
- }
- cont = TRUE;
- while (cont) {
- cont = gtk_text_forward_delete(GTK_TEXT(edit), 1);
- }
+ gtk_text_buffer_set_text(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))), "", 0);
}
-
static void editor_fill(int which) {
char *filename, *dstr;
- GtkWidget *label;
+ GtkWidget *label = NULL;
+ GtkTextIter iter;
switch (which) {
case UNIQUE: label = label_u; break;
@@ -179,11 +175,10 @@ static void editor_fill(int which) {
gtk_label_get(GTK_LABEL(label), &dstr);
strcpy(daystr, dstr);
to_button(which);
- gtk_text_freeze(GTK_TEXT(edit));
editor_flush();
load_file(daystr);
- gtk_text_set_point(GTK_TEXT(edit), gtk_text_get_length(GTK_TEXT(edit)));
- gtk_text_thaw(GTK_TEXT(edit));
+ gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))), &iter);
+ gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))), &iter);
}
@@ -225,8 +220,15 @@ static void save_datas() {
char *dirname = xmalloc(len + 2);
struct stat stat_buf;
+ GtkTextIter ts, te;
+ gchar *tbuf;
+ int tlen;
+
+ tlen = gtk_text_buffer_get_char_count(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))));
+ gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))), &ts, &te);
+
sprintf(dirname, "%s/%s", robust_home(), DEFAULT_CONFIGDIR);
- if (gtk_text_get_length(GTK_TEXT(edit)) > 0) {
+ if (tlen > 0) {
if (! ((stat(dirname, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)))
mkdir(dirname, 0755);
@@ -235,13 +237,11 @@ static void save_datas() {
int year, month, day;
if (file) {
- int i;
- for (i = 0 ; i < gtk_text_get_length(GTK_TEXT(edit)) ; i++) {
- char t = GTK_TEXT_INDEX(GTK_TEXT(edit), i);
- fprintf(file, "%c", t);
- }
- fflush(file);
- fclose(file);
+ tbuf = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit))), &ts, &te, TRUE);
+ fprintf(file, "%s", tbuf);
+ g_free(tbuf);
+ fflush(file);
+ fclose(file);
}
gtk_calendar_get_date(GTK_CALENDAR(calendar), &year, &month, &day);
gtk_calendar_mark_day(GTK_CALENDAR(calendar), day);
@@ -259,9 +259,7 @@ static void delete_file() {
gtk_calendar_get_date(GTK_CALENDAR(calendar), &year, &month, &day);
gtk_calendar_unmark_day(GTK_CALENDAR(calendar), day);
FREE(filename);
- gtk_text_freeze(GTK_TEXT(edit));
editor_flush();
- gtk_text_thaw(GTK_TEXT(edit));
}
@@ -357,10 +355,10 @@ void create_mainwindow() {
GTK_SIGNAL_FUNC(mark_days), NULL);
gtk_widget_show(calendar);
- edit = gtk_text_new(NULL, NULL);
- gtk_text_set_editable(GTK_TEXT(edit), TRUE);
- gtk_text_set_word_wrap(GTK_TEXT(edit), TRUE);
- gtk_text_set_line_wrap(GTK_TEXT(edit), TRUE);
+ edit = gtk_text_view_new();
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(edit), TRUE);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(edit), GTK_WRAP_WORD_CHAR);
+
gtk_box_pack_start(GTK_BOX(main_vbox), edit, TRUE, TRUE, 1);
@@ -413,7 +411,6 @@ void create_mainwindow() {
gtk_box_pack_start(GTK_BOX(buttons_hbox), closewindow, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(closewindow), GTK_CAN_DEFAULT);
gtk_widget_grab_default(GTK_WIDGET(closewindow));
- gtk_widget_draw_default(GTK_WIDGET(closewindow));
gtk_widget_show(closewindow);

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-wmclockmon-config_Makefile_in,v 1.1 2010/03/23 22:12:39 jasper Exp $
Switch to gtk+2.
--- wmclockmon-config/Makefile.in.orig Tue Mar 23 22:55:19 2010
+++ wmclockmon-config/Makefile.in Tue Mar 23 22:55:42 2010
@@ -96,14 +96,14 @@ PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
-LDFLAGS = @LDFLAGS@ `gtk-config --libs`
+LDFLAGS = @LDFLAGS@ `pkg-config --libs gtk+-2.0`
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
wmclockmon_OBJECTS = actions.o dialogs.o edit.o main.o mainwindow.o tools.o
wmclockmon_DEPENDENCIES =
wmclockmon_LDFLAGS =
-CFLAGS = @CFLAGS@ `gtk-config --cflags`
+CFLAGS = @CFLAGS@ `pkg-config --cflags gtk+-2.0`
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-wmclockmon-config_dialogs_c,v 1.1 2010/03/23 22:12:39 jasper Exp $
Switch to gtk+2:
- Remove call to deprecated function.
--- wmclockmon-config/dialogs.c.orig Tue Mar 23 23:04:11 2010
+++ wmclockmon-config/dialogs.c Tue Mar 23 23:04:24 2010
@@ -38,7 +38,6 @@ void ync_dialog(const char *title, const char *text, v
bouton, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
gtk_widget_grab_default(GTK_WIDGET(bouton));
- gtk_widget_draw_default(GTK_WIDGET(bouton));
gtk_widget_show(bouton);
bouton = gtk_button_new_with_label("No");
@@ -96,7 +95,6 @@ void ok_dialog(const char *title, const char *text) {
bouton, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
gtk_widget_grab_default(GTK_WIDGET(bouton));
- gtk_widget_draw_default(GTK_WIDGET(bouton));
gtk_widget_show(bouton);
gtk_container_set_border_width(GTK_CONTAINER

View File

@ -0,0 +1,15 @@
$OpenBSD: patch-wmclockmon-config_edit_c,v 1.1 2010/03/23 22:12:39 jasper Exp $
Switch to gtk+2:
- Remove call to deprecated function.
--- wmclockmon-config/edit.c.orig Tue Mar 23 23:04:31 2010
+++ wmclockmon-config/edit.c Tue Mar 23 23:04:39 2010
@@ -76,7 +76,6 @@ void edit_dialog(const char *title,
bouton, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
gtk_widget_grab_default(GTK_WIDGET(bouton));
- gtk_widget_draw_default(GTK_WIDGET(bouton));
gtk_widget_show(bouton);
bouton = gtk_button_new_with_label("Cancel");

View File

@ -0,0 +1,52 @@
$OpenBSD: patch-wmclockmon-config_mainwindow_c,v 1.1 2010/03/23 22:12:39 jasper Exp $
Switch to gtk+2:
- Prevent symbol clash of remove.
- Remove call to deprecated function.
--- wmclockmon-config/mainwindow.c.orig Tue Mar 23 22:59:40 2010
+++ wmclockmon-config/mainwindow.c Tue Mar 23 23:04:55 2010
@@ -12,7 +12,7 @@
static GtkWidget *edit;
static GtkWidget *set;
-static GtkWidget *remove;
+static GtkWidget *gtk_remove;
static gint list_sel_cb (GtkCList *clist,
gint row,
@@ -22,7 +22,7 @@ static gint list_sel_cb (GtkCList *clist,
selected_row = row;
gtk_widget_set_sensitive(edit, TRUE);
gtk_widget_set_sensitive(set, TRUE);
- gtk_widget_set_sensitive(remove, TRUE);
+ gtk_widget_set_sensitive(gtk_remove, TRUE);
return TRUE;
}
@@ -35,7 +35,7 @@ gint list_unsel_cb (GtkCList *clist,
selected_row = -1;
gtk_widget_set_sensitive(edit, FALSE);
gtk_widget_set_sensitive(set, FALSE);
- gtk_widget_set_sensitive(remove, FALSE);
+ gtk_widget_set_sensitive(gtk_remove, FALSE);
return TRUE;
}
@@ -283,7 +283,7 @@ void create_mainwindow() {
gtk_table_attach_defaults(GTK_TABLE(table), bouton, 1, 2, 0, 1);
gtk_widget_set_sensitive(bouton, FALSE);
gtk_widget_show(bouton);
- remove = bouton;
+ gtk_remove = bouton;
label = gtk_label_new(" Alarms ");
@@ -312,7 +312,6 @@ void create_mainwindow() {
gtk_box_pack_start(GTK_BOX(buttons_hbox), bouton, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
gtk_widget_grab_default(GTK_WIDGET(bouton));
- gtk_widget_draw_default(GTK_WIDGET(bouton));
gtk_widget_show(bouton);
bouton = gtk_button_new_with_label(" Cancel ");

View File

@ -1,7 +1,7 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2005/03/07 21:45:00 niallo Exp $
bin/wmclockmon
bin/wmclockmon-cal
bin/wmclockmon-config
@comment $OpenBSD: PLIST,v 1.2 2010/03/23 22:12:39 jasper Exp $
@bin bin/wmclockmon
@bin bin/wmclockmon-cal
@bin bin/wmclockmon-config
@man man/man1/wmclockmon-cal.1
@man man/man1/wmclockmon-config.1
@man man/man1/wmclockmon.1