Sophie

Sophie

distrib > Mageia > 5 > x86_64 > by-pkgid > e9ad1ccac3195cf8239c1979d672e9fe > files > 5

gamine-1.2-0.git20110427.5.mga5.src.rpm

diff -ur gamine-1.2-git20110427.orig/ChangeLog gamine-1.2-git20110427/ChangeLog
--- gamine-1.2-git20110427.orig/ChangeLog	2011-04-27 23:52:45.000000000 +0400
+++ gamine-1.2-git20110427/ChangeLog	2014-09-05 18:43:45.000000000 +0400
@@ -1,3 +1,10 @@
+1.2 - 02/09/14
+Gtk3 without unstable X11
+Using /etc/gamine.conf instead of gconf
+Add and fix locales
+Fix cursor
+Translations for desktop file
+
 1.1a - "Happy new year" - 02/01/11
 
 Add DESTDIR in Makefile
diff -ur gamine-1.2-git20110427.orig/gamine.c gamine-1.2-git20110427/gamine.c
--- gamine-1.2-git20110427.orig/gamine.c	2011-04-27 23:52:45.000000000 +0400
+++ gamine-1.2-git20110427/gamine.c	2014-09-05 19:17:33.000000000 +0400
@@ -7,18 +7,19 @@
 
 #include <gtk/gtk.h>
 #include <cairo.h>
-#include <cairo-xlib.h>
-#include <gdk/gdkx.h>
-#include <math.h>
-#include <time.h>
 #include <gst/gst.h>
 #include <gdk/gdkkeysyms.h>
-#include <gconf/gconf-client.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
 
-//gettext
-#include <libintl.h>
 #include <locale.h>
 #include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <math.h>
+#include <time.h>
 
 
 typedef struct {
@@ -62,40 +63,81 @@
 gdouble timer_color_change;
 gchar *background_music;
 clock_t last_color_change;
+guint lastkeyval;
 
 static void
 load_conf ()
 {
-    GConfClient* gc;
-    gc = gconf_client_get_default();
-    if(!gc) {
-        printf(gettext("** error: failed to initialize GConf\n"));
-        linewidth = 0;
-        objectweight = 0;
-        fontweight = 0;
-        timer_color_change = 0;
-        background_music = NULL;
-    } else {
-        linewidth = gconf_client_get_int(gc, "/apps/gamine/line_width", NULL);
-        objectweight = gconf_client_get_int(gc, "/apps/gamine/object_weight", 
-                NULL);
-        fontweight = gconf_client_get_int(gc, "/apps/gamine/font_weight", NULL);
-        timer_color_change = gconf_client_get_float(gc,
-                "/apps/gamine/timer_color_change", NULL);
-        background_music = gconf_client_get_string(gc,
-                "/apps/gamine/background_music", NULL);
-        g_object_unref(gc);
-    }
-    if ( linewidth == 0 )
-        linewidth = 10;
-    if ( objectweight == 0 )
-        objectweight = 15;
-    if ( fontweight == 0 )
-        fontweight = 50;
-    if ( timer_color_change == 0 )
-        timer_color_change = 100,0;
-    if ( background_music == NULL )
-        background_music = "BachJSBrandenburgConcertNo2inFMajorBWV1047mvmt1.ogg";
+	gchar *filename;
+	GKeyFile *conffile;
+	GError *error;
+	
+	error = NULL;
+	conffile = g_key_file_new();
+	filename = g_build_filename(SYSCONFDIR, "gamine.conf", NULL);
+	
+	if (g_key_file_load_from_file(conffile, filename, G_KEY_FILE_NONE, &error)) {
+		/*Line width*/
+		if (g_key_file_has_key(conffile, "gamine", "line_width", NULL)) {
+			linewidth = g_key_file_get_integer(conffile, "gamine", "line_width", NULL);
+			if (linewidth == 0) {
+				linewidth = 10;
+			}
+		} else {
+			linewidth = 10;
+		}
+		/*Object weight*/
+		if (g_key_file_has_key(conffile, "gamine", "object_weight", NULL)) {
+			objectweight = g_key_file_get_integer(conffile, "gamine", "object_weight", NULL);
+			if (objectweight == 0) {
+				objectweight = 15;
+			}
+		} else {
+			objectweight = 15;
+		}
+		/*Font weight*/
+		if (g_key_file_has_key(conffile, "gamine", "font_weight", NULL)) {
+			fontweight = g_key_file_get_integer(conffile, "gamine", "font_weight", NULL);
+			if (fontweight == 0) {
+				fontweight = 50;
+			}
+		} else {
+			fontweight = 50;
+		}
+		/*Timer color change*/
+		if (g_key_file_has_key(conffile, "gamine", "timer_color_change", NULL)) {
+			timer_color_change = g_key_file_get_double(conffile, "gamine", "timer_color_change", NULL);
+			if (timer_color_change == 0.0) {
+				timer_color_change = 100.0;
+			}
+		} else {
+			timer_color_change = 100.0;
+		}
+		/*Background music*/
+		if (g_key_file_has_key(conffile, "gamine", "background_music", NULL)) {
+			background_music = g_key_file_get_string(conffile, "gamine", "background_music", NULL);
+			if (background_music == NULL) {
+				background_music = g_strdup("BachJSBrandenburgConcertNo2inFMajorBWV1047mvmt1.ogg");
+			}
+			g_key_file_free(conffile);
+		} else {
+			background_music = g_strdup("BachJSBrandenburgConcertNo2inFMajorBWV1047mvmt1.ogg");
+		}
+	} else {
+		/*Set default settings*/
+		linewidth = 10;
+		objectweight = 15;
+		fontweight = 50;
+		timer_color_change = 100.0;
+		background_music = "BachJSBrandenburgConcertNo2inFMajorBWV1047mvmt1.ogg";
+		/*Show waring message*/
+		if (error != NULL) {
+			g_warning("%s - %s", filename, error->message);
+			g_error_free(error);
+		}
+	}
+	
+	g_free(filename);
 }
 
 static void
@@ -130,7 +172,7 @@
         gst_object_unref (bus);
         filename = g_build_filename(DATADIR, "sounds", filesnd, NULL);
         if (!g_file_test (filename, G_FILE_TEST_EXISTS))
-            printf(gettext("** error: %s does not exists\n"), filename);
+            g_printf(_("** error: %s does not exists\n"), filename);
         else {
             filename = g_strdup_printf("file://%s", filename);
             g_object_set (G_OBJECT(pipeline), "uri", filename, NULL);
@@ -190,13 +232,14 @@
         gboolean new_color, 
         gboolean is_line)
 {
-    if (cairo_status (cb->context) != CAIRO_STATUS_SUCCESS) {
-        cb->context = gdk_cairo_create((cb->drawing_area)->window);
-        cairo_select_font_face (cb->context, "Sans", CAIRO_FONT_SLANT_NORMAL,
-            CAIRO_FONT_WEIGHT_BOLD);
-        cairo_set_font_size (cb->context, fontweight);
-    }
-    if (is_line && (&cb->star)->is_set == TRUE) {
+	if (((cb->context != NULL) && (cairo_status (cb->context) != CAIRO_STATUS_SUCCESS)) || (cb->context == NULL)) {
+		cb->context = gdk_cairo_create(gtk_widget_get_window(cb->drawing_area));
+		cairo_select_font_face (cb->context, "Sans", CAIRO_FONT_SLANT_NORMAL,
+			CAIRO_FONT_WEIGHT_BOLD);
+		cairo_set_font_size (cb->context, fontweight);
+	}
+	
+	if (is_line && (&cb->star)->is_set == TRUE) {
         gint width = objectweight + linewidth;
         if ( cb->star.mx - width > cb->xold ||
                 cb->star.mx + width < cb->xold ||
@@ -206,11 +249,12 @@
         }
         cairo_set_source_rgb (cb->context, cb->star.color.red,
                 cb->star.color.green, cb->star.color.blue);
-        printf("%s\n", cb->star.str);
-        if (strcmp(cb->star.str, "none") == 0)
-            build_star(cb->context, cb->star);
-        else
-            build_string(cb->context, cb->star);
+        g_debug("%s\n", cb->star.str);
+        if (strcmp(cb->star.str, "none") == 0) {
+			build_star(cb->context, cb->star);
+		} else {
+			build_string(cb->context, cb->star);
+		}
         cairo_set_source_rgb (cb->context, cb->color.red, cb->color.green,
                 cb->color.blue);
     }
@@ -225,8 +269,7 @@
         } else {
             color = cb->linecolor;
         }
-    }
-    if ( ! is_line ) {
+    } else {
         color.red = random() % 10 * 0.1;
         color.green = random() % 10 * 0.1;
         color.blue = random() % 10 * 0.1;
@@ -257,37 +300,54 @@
     } else {
         context = get_cairo_context(cb, FALSE, TRUE);
     }
-    cairo_new_path (context);
-    cairo_set_line_width (context, linewidth);
-    //Use rounded lines to avoid cuts in the path
-    cairo_set_line_cap(context, CAIRO_LINE_CAP_ROUND);
-    //move the cursor
-    cairo_move_to (context, cb->xold, cb->yold);
-    //line for old cursor to new one's
-    cb->xold = mx;
-    cb->yold = my;
-    cairo_line_to (context, cb->xold, cb->yold);
-    //draw
-    cairo_stroke (context);
+    if ((cb->xold != -1) && (cb->yold != -1)) {
+		cairo_new_path (context);
+		cairo_set_line_width (context, linewidth);
+		//Use rounded lines to avoid cuts in the path
+		cairo_set_line_cap(context, CAIRO_LINE_CAP_ROUND);
+		//move the cursor
+		cairo_move_to (context, cb->xold, cb->yold);
+		//line for old cursor to new one's
+		cb->xold = mx;
+		cb->yold = my;
+		cairo_line_to (context, cb->xold, cb->yold);
+		//draw
+		cairo_stroke (context);
+	} else {
+		cb->xold = mx;
+		cb->yold = my;
+	}
 }
 
 static void
 draw_string (gamine_t *cb,
         gchar *str)
 {
+    GdkDisplay *display;
+    GdkDeviceManager *devmanager;
+    GdkDevice *device;
     star_t star;
     gint mx;
     gint my;
     cairo_t *context;
-    gdk_window_get_pointer((cb->drawing_area)->window, &mx, &my, NULL);
-    star.mx = mx;
-    star.my = my;
-    star.str = str;
-    star.is_set = TRUE;
-    cb->star = star;
-    play_random_sound(cb->bus);
-    context = get_cairo_context(cb, TRUE, FALSE);
-    build_string(context, star);
+    
+    display = gdk_window_get_display(gtk_widget_get_window(cb->drawing_area));
+    devmanager = gdk_display_get_device_manager(display);
+    if (devmanager != NULL) {
+		device = gdk_device_manager_get_client_pointer(devmanager);
+		gdk_window_get_device_position(gtk_widget_get_window(cb->drawing_area), device, &mx, &my, NULL);
+		star.mx = mx;
+		star.my = my;
+		star.str = str;
+		star.is_set = TRUE;
+		star.inner_radius = objectweight;
+		star.outer_radius = 20;
+		cb->star = star;
+		cb->star.color = cb->color;
+		play_random_sound(cb->bus);
+		context = get_cairo_context(cb, TRUE, FALSE);
+		build_string(context, star);
+	}
 }
 
 static void
@@ -330,93 +390,123 @@
     //if dirname not exists
     if(stat(dirname,&st) != 0)
         if (mkdir(dirname, 0750) < 0)
-            printf(gettext("*** error: failed to create directory %s***\n"),
+            g_printf(_("*** error: failed to create directory %s***\n"),
                     dirname);
     sprintf(buf, "%d-%d-%d_%d-%d-%d.png", 1900 + t->tm_year,
             t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
     filename = g_build_filename(dirname, buf, NULL);
     surface = cairo_get_target (cb->context);
     if (cairo_surface_write_to_png(surface, filename) < 0)
-        printf(gettext("*** error: failed to create file %s***\n"), filename);
+        g_printf(_("*** error: failed to create file %s***\n"), filename);
     g_free(filename);
     g_free(dirname);
 }
 
-static void
+static gboolean
 key_press (GtkWidget *pWidget,
     GdkEventKey* pKey,
     gamine_t *cb)
 {
-    if (pKey->type == GDK_KEY_PRESS)
-    {
+	guint32 unichar;
+	static gchar utf8string[10];
+	gsize utf8stringlen;
+		
+    if ((pKey->type == GDK_KEY_PRESS) && (pKey->keyval != lastkeyval)) {
         switch (pKey->keyval)
         {
-            case GDK_Escape :
+            case GDK_KEY_Escape :
                 gtk_main_quit ();
             break;
-            case GDK_space :
+            case GDK_KEY_space :
                 gtk_widget_queue_draw(pWidget);
             break;
-            case GDK_Print:
+            case GDK_KEY_Print:
                 save_picture(cb);
             break;
             default:
-                draw_string(cb, pKey->string);
+		/*Get unicode string*/
+		unichar = gdk_keyval_to_unicode(pKey->keyval);
+		utf8stringlen = g_unichar_to_utf8(unichar, utf8string);
+		utf8string[utf8stringlen] = '\0';
+		/*Disable repeats*/
+		lastkeyval = pKey->keyval;
+		/*Draw it*/
+		draw_string(cb, utf8string);
             break;
         }
-    };
+    }
+    
+    return TRUE;
 }
 
-static void
-display_help (GtkWidget      *widget,
-       GdkEventExpose *eev,
-       gpointer        data)
+static gboolean
+key_release (GtkWidget *pWidget,
+    GdkEventKey* pKey,
+    gamine_t *cb)
 {
-    gint height;
-    cairo_t *context;
+	if (pKey->type == GDK_KEY_RELEASE) {
+		lastkeyval = 0;
+	}
+	
+	return TRUE;
+}
 
-    height = widget->allocation.height - 5;
-    //Note that due to double-buffering, Cairo contexts created in a GTK+
-    //expose event handler cannot be cached and reused between different
-    //expose events
-    //http://library.gnome.org/devel/gdk/stable/gdk-Cairo-Interaction.html
-    context = gdk_cairo_create (widget->window);
-    
-    cairo_select_font_face (context, "Sans", CAIRO_FONT_SLANT_NORMAL,
-        CAIRO_FONT_WEIGHT_BOLD);
-    cairo_set_font_size (context, 15);
-    cairo_move_to (context, 0, height);
-    cairo_set_source_rgb (context, 0,0,0);
-    //cairo_show_text (context,
-	//	    gettext("Quit: esc | Clear: space | Save: printscr"));
-    cairo_stroke (context);
-    cairo_destroy (context);
+static void
+display_help (GtkWidget *widget, 
+			cairo_t *cr,
+			gpointer data)
+{
+	PangoLayout *layout;
+	PangoFontDescription *desc;
+	GtkAllocation allocation;
+    gint width, height;
+    
+    layout = pango_cairo_create_layout(cr);
+	pango_layout_set_text(layout, _("Quit: esc | Clear: space | Save: printscr"), -1);
+	
+	desc = pango_font_description_from_string("Sans Bold 15");
+	pango_layout_set_font_description(layout, desc);
+	pango_font_description_free(desc);
+	
+	pango_layout_get_pixel_size(layout, &width, &height);
+	gtk_widget_get_allocation(widget, &allocation);
+	cairo_translate(cr, 0, allocation.height - height); 
+	
+	pango_cairo_update_layout(cr, layout);
+	pango_cairo_show_layout(cr, layout);
+	g_object_unref(layout);
 }
 
 gint
 main (gint argc, gchar *argv[])
 {
-    Window root;
-    //gettext
-    bindtextdomain( "gamine", LOCALDIR );
-    textdomain( "gamine" );
     gamine_t cb;
     GtkWidget *window;
     GdkWindow *gdkwindow;
     GtkWindow *gtkwindow;
-    GdkScreen *screen;
-    GdkPixbuf *cursor_pixbuf;
+    GdkPixbuf *cursor_pixbuf, *scaled_cursor_pixbuf;
     GdkPixbuf *icon_pixbuf;
     GdkCursor *cursor;
-    GdkColor bg_color;
+    GdkRGBA color;
     gchar *cursorfile;
     gchar *iconfile;
+    gint imageheight, imagewidth;
+    guint cursorheight, cursorwidth;
     star_t star;
+    GdkScreen *screen;
+    GdkDisplay *display;
+    GdkDeviceManager *devicemanager;
+    GdkDevice *mouse, *keyboard;
+     
+    //gettext
+    bindtextdomain("gamine", LOCALDIR);
+    bind_textdomain_codeset("gamine", "UTF8");
+    textdomain("gamine");
+    setlocale(LC_ALL, "");
 
     last_color_change = clock();
     gtk_init (&argc, &argv);
     gst_init (&argc, &argv);
-    gconf_init(argc, argv, NULL);
     load_conf();
 
     star.is_set = FALSE;
@@ -427,22 +517,22 @@
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 /* Create the drawing area and configuration */
     cb.drawing_area = gtk_drawing_area_new ();
-    bg_color.red   = 65535;
-    bg_color.green = 65535;
-    bg_color.blue  = 65535;
-    gtk_widget_modify_bg (cb.drawing_area, GTK_STATE_NORMAL, &bg_color);
+    color.red = 1.0;
+    color.green = 1.0;
+    color.blue = 1.0;
+    color.alpha = 1.0;
+    gtk_widget_override_background_color(cb.drawing_area, GTK_STATE_FLAG_NORMAL, (const GdkRGBA *)&color);
     gtk_container_add (GTK_CONTAINER (window), cb.drawing_area);
 
     gtkwindow = GTK_WINDOW(window);
     gtk_window_set_title (gtkwindow, "Gamine");
     gtk_window_set_wmclass(gtkwindow, "gamine", "Gamine");
     gtk_container_set_border_width (GTK_CONTAINER (gtkwindow), 0);
-
-
-/* Event signals */
+    
+    /* Event signals */
     g_signal_connect (gtkwindow, "destroy",
          G_CALLBACK (gtk_main_quit), &gtkwindow);
-    g_signal_connect (G_OBJECT (cb.drawing_area), "expose-event",
+    g_signal_connect (G_OBJECT (cb.drawing_area), "draw",
         G_CALLBACK (display_help), NULL);
     g_signal_connect (cb.drawing_area, "motion_notify_event",
         G_CALLBACK (draw_line), &cb);
@@ -450,6 +540,9 @@
         G_CALLBACK (draw_star), &cb);
     g_signal_connect (gtkwindow, "key-press-event",
         G_CALLBACK (key_press), &cb);
+    g_signal_connect (gtkwindow, "key-release-event",
+        G_CALLBACK (key_release), &cb);
+ 
     gtk_widget_set_events (cb.drawing_area,
             gtk_widget_get_events (cb.drawing_area)
         | GDK_LEAVE_NOTIFY_MASK
@@ -457,58 +550,105 @@
         | GDK_BUTTON_RELEASE_MASK
         | GDK_POINTER_MOTION_MASK
         | GDK_POINTER_MOTION_HINT_MASK);
-/* Set fullscreen, grab mouse/keyboard, ...*/
+
     gtk_window_present (gtkwindow);
-    gtk_window_stick(gtkwindow);
     gtk_window_fullscreen (gtkwindow);
     gtk_widget_show_all (window);
-    gdkwindow = GDK_WINDOW(window->window);
-    //gdkwindow = gtk_widget_get_parent_window(window);
-    screen = gtk_widget_get_screen (cb.drawing_area);
-
-    //set fullscreen
-    gdk_window_fullscreen (gdkwindow);
-    gdk_window_raise (gdkwindow);
-    //set full screen without window manager
-    XMoveResizeWindow(GDK_WINDOW_XDISPLAY(gdkwindow), GDK_WINDOW_XID(gdkwindow),
-        0, 0, gdk_screen_get_width (screen), gdk_screen_get_height (screen));
-    root = DefaultRootWindow(GDK_WINDOW_XDISPLAY (gdkwindow));
-    XGrabPointer(GDK_WINDOW_XDISPLAY (gdkwindow), root, True, PointerMotionMask,
-        GrabModeAsync, GrabModeAsync, root, None, CurrentTime); 
-    XGrabKeyboard(GDK_WINDOW_XDISPLAY (gdkwindow), root, True,
-                    GrabModeAsync, GrabModeAsync, CurrentTime);
-    //remove keyboard repeat
-    XAutoRepeatOff(GDK_WINDOW_XDISPLAY (gdkwindow));
-    gtk_window_has_toplevel_focus (gtkwindow);
-/*cursor*/
-    cursorfile = g_build_filename(DATADIR, "pencil.png", NULL);
-    if (!g_file_test (cursorfile, G_FILE_TEST_EXISTS)) {
-        printf(gettext("*** error: %s does not exists***\n"), cursorfile);
-    } else {
-        cursor_pixbuf = gdk_pixbuf_new_from_file(cursorfile, NULL);
-        cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
-            cursor_pixbuf, 0, 38);
-        gdk_window_set_cursor(gdkwindow, cursor);
-        gdk_cursor_unref(cursor);
-        gdk_pixbuf_unref(cursor_pixbuf);
+    gdkwindow = gtk_widget_get_window(window);
+    gdk_window_fullscreen(gdkwindow);
+    gdk_window_raise(gdkwindow);
+
+/* Set fullscreen, grab mouse/keyboard, ...*/
+	screen = gtk_widget_get_screen(window);
+    gdk_window_move_resize(gdkwindow, 0, 0, gdk_screen_get_width(screen), gdk_screen_get_height(screen));
+    
+    display = gdk_display_get_default();
+    devicemanager = gdk_display_get_device_manager(display);
+    mouse = gdk_device_manager_get_client_pointer(devicemanager);
+    keyboard = gdk_device_get_associated_device(mouse);
+    
+    if (mouse != NULL) {
+		gdk_device_grab(mouse,
+                    gdk_get_default_root_window(),
+                    GDK_OWNERSHIP_WINDOW,
+                    TRUE,
+                    GDK_POINTER_MOTION_MASK |
+					GDK_BUTTON_PRESS_MASK |
+					GDK_BUTTON_RELEASE_MASK,
+                    NULL,
+                    GDK_CURRENT_TIME);
+    }
+    
+    if (keyboard != NULL) {    
+		gdk_device_grab(keyboard,
+                    gdk_get_default_root_window(),
+                    GDK_OWNERSHIP_WINDOW,
+                    TRUE,
+                    GDK_KEY_PRESS_MASK |
+                    GDK_KEY_RELEASE_MASK,
+                    NULL,
+                    GDK_CURRENT_TIME);
     }
-    g_free(cursorfile);
+/*cursor*/
+    if ((gdk_display_supports_cursor_color(display)) && (gdk_display_supports_cursor_alpha(display))) {
+		cursorfile = g_build_filename(DATADIR, "pencil.png", NULL);
+		if (!g_file_test (cursorfile, G_FILE_TEST_EXISTS)) {
+			g_printf(_("*** error: %s does not exists***\n"), cursorfile);
+		} else {
+			cursor_pixbuf = gdk_pixbuf_new_from_file(cursorfile, NULL);
+			if (cursor_pixbuf != NULL) {
+				/*Determine image size*/
+				imageheight = gdk_pixbuf_get_height((const GdkPixbuf *)cursor_pixbuf);
+				imagewidth = gdk_pixbuf_get_width((const GdkPixbuf *)cursor_pixbuf);
+				gdk_display_get_maximal_cursor_size(display, &cursorwidth, &cursorheight);
+				/*Correct image size if needed*/
+				if ((imageheight > cursorheight) || (imagewidth > cursorwidth)) {
+					scaled_cursor_pixbuf = gdk_pixbuf_scale_simple(cursor_pixbuf, cursorwidth, cursorheight, GDK_INTERP_BILINEAR);
+					if (scaled_cursor_pixbuf != NULL) {
+						g_object_unref(cursor_pixbuf);
+						cursor_pixbuf = scaled_cursor_pixbuf;
+						imageheight = cursorheight;
+						imagewidth = cursorwidth;
+					}
+				}
+				/*Set cursor*/
+				cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), cursor_pixbuf, 0, imageheight-1);
+				gdk_window_set_cursor(gdkwindow, cursor);
+				g_object_unref(cursor);
+				g_object_unref(cursor_pixbuf);
+			}
+		}
+		g_free(cursorfile);
+	} else {
+		g_printf(_("*** error: coloured cursors with alpha channel aren't supported, using default cursor***\n"));
+	}
 /*Set icon*/
     iconfile = g_build_filename(DATADIR, "gamine.png", NULL);
     if (!g_file_test (iconfile, G_FILE_TEST_EXISTS))
-        printf(gettext("*** error: %s does not exists***\n"), iconfile);
+        g_printf(_("*** error: %s does not exists***\n"), iconfile);
     else {
         icon_pixbuf = gdk_pixbuf_new_from_file(iconfile, NULL);
         gtk_window_set_icon (gtkwindow, icon_pixbuf);
-        gdk_pixbuf_unref (icon_pixbuf);
+        g_object_unref (icon_pixbuf);
     }
     g_free(iconfile);
+    
+    cb.xold = -1;
+    cb.yold = -1;
+    cb.context = NULL;
+    lastkeyval = 0;
+
 
-    gdk_window_get_pointer(window->window, &cb.xold, &cb.yold, NULL);
     gtk_main ();
-    //set keyboard repeat
-    XAutoRepeatOn(GDK_WINDOW_XDISPLAY (gdkwindow));
-    XCloseDisplay(GDK_WINDOW_XDISPLAY (gdkwindow));
+    
+    if (keyboard != NULL) {
+		gdk_device_ungrab(keyboard, GDK_CURRENT_TIME);
+	}
+	
+	if (mouse != NULL) {
+		gdk_device_ungrab(mouse, GDK_CURRENT_TIME);
+	}
+    
     return 0;
 }
 
diff -ur gamine-1.2-git20110427.orig/Makefile gamine-1.2-git20110427/Makefile
--- gamine-1.2-git20110427.orig/Makefile	2011-04-27 23:52:45.000000000 +0400
+++ gamine-1.2-git20110427/Makefile	2014-09-05 18:43:45.000000000 +0400
@@ -9,14 +9,10 @@
 ICONDIR = $(DATADIR)/icons/hicolor/scalable/apps
 LOCALEDIR = $(DATADIR)/locale
 
-GCONFTOOL = /usr/bin/gconftool-2
-GCONF_SCHEMA_CONFIG_SOURCE = xml:merged:/etc/gconf/gconf.xml.defaults
-GCONF_SCHEMA_FILE_DIR = $(SYSCONFDIR)/gconf/schemas
-GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL = 0
 CFLAGS = -Wall
 #CFLAGS = -Wall -g 
-CPPFLAGS = $(shell pkg-config --cflags gtk+-2.0 cairo glib-2.0 gstreamer-0.10 gconf-2.0)  -DDATADIR=\""$(PKGDATADIR)"\"  -DLOCALDIR=\""$(LOCALEDIR)"\"
-LDLIBS = $(shell pkg-config --libs gtk+-2.0 cairo glib-2.0 gstreamer-0.10 gconf-2.0)  -DDATADIR=\""$(PKGDATADIR)"\"  -DLOCALDIR=\""$(LOCALEDIR)"\" -lX11
+CPPFLAGS = $(shell pkg-config --cflags gtk+-3.0 cairo glib-2.0 gstreamer-0.10)  -DDATADIR=\""$(PKGDATADIR)"\"  -DLOCALDIR=\""$(LOCALEDIR)"\" -DSYSCONFDIR=\""$(SYSCONFDIR)"\"
+LDLIBS = $(shell pkg-config --libs gtk+-3.0 cairo glib-2.0 gstreamer-0.10)  -DDATADIR=\""$(PKGDATADIR)"\"  -DLOCALDIR=\""$(LOCALEDIR)"\" -DSYSCONFDIR=\""$(SYSCONFDIR)"\" -lm
 LDFLAGS = -g 
 CC = gcc
 target = gamine
@@ -41,7 +37,7 @@
 	mkdir -p $(DESTDIR)$(DOCDIR)
 	mkdir -p $(DESTDIR)$(ICONDIR)
 	mkdir -p $(DESTDIR)$(DESKTOPDIR)
-	mkdir -p $(DESTDIR)$(GCONF_SCHEMA_FILE_DIR)
+	mkdir -p $(DESTDIR)$(SYSCONFDIR)
 	mkdir -p $(DESTDIR)$(LOCALEDIR)/fr/LC_MESSAGES
 	mkdir -p $(DESTDIR)$(LOCALEDIR)/ru/LC_MESSAGES
 	mkdir -p $(DESTDIR)$(LOCALEDIR)/nl/LC_MESSAGES
@@ -51,21 +47,18 @@
 	install -m 644 gamine.png $(DESTDIR)$(PKGDATADIR)/
 	install -m 644 sounds/* $(DESTDIR)$(PKGDATADIR)/sounds/
 	install -m 644 README.pencil README.sounds README ChangeLog COPYING $(DESTDIR)$(DOCDIR)/
-	install -m 644 gamine.schemas $(DESTDIR)$(GCONF_SCHEMA_FILE_DIR)/
+	install -m 644 gamine.conf $(DESTDIR)$(SYSCONFDIR)/
 	install -m 644 locale/fr.mo $(DESTDIR)$(LOCALEDIR)/fr/LC_MESSAGES/gamine.mo
 	install -m 644 locale/ru.mo $(DESTDIR)$(LOCALEDIR)/ru/LC_MESSAGES/gamine.mo
 	install -m 644 locale/nl.mo $(DESTDIR)$(LOCALEDIR)/nl/LC_MESSAGES/gamine.mo
 	install -m 644 locale/zh_CN.mo $(DESTDIR)$(LOCALEDIR)/zh_CN/LC_MESSAGES/gamine.mo
 	install -m 644 gamine.desktop $(DESTDIR)$(DESKTOPDIR)/
 	install -m 644 gamine.svg $(DESTDIR)$(ICONDIR)/
-ifeq ($(DESTDIR), "")
-	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(GCONF_SCHEMA_FILE_DIR)/gamine.schemas
-endif
 
 uninstall:
 	rm -rf $(DESTDIR)$(BINDIR)/gamine
 	rm -rf $(DESTDIR)$(PKGDATADIR)
 	rm -rf $(DESTDIR)$(DOCDIR)
-	rm -rf $(DESTDIR)$(GCONF_SCHEMA_FILE_DIR)/gamine.schemas
 	rm -rf $(DESTDIR)$(DESKTOPDIR)/gamine.desktop
 	rm -rf $(DESTDIR)$(ICONDIR)/gamine.svg
+	rm -rf $(DESTDIR)$(SYSCONFDIR)/gamine.conf
diff -ur gamine-1.2-git20110427.orig/README gamine-1.2-git20110427/README
--- gamine-1.2-git20110427.orig/README	2011-04-27 23:52:45.000000000 +0400
+++ gamine-1.2-git20110427/README	2014-09-05 18:43:45.000000000 +0400
@@ -8,24 +8,26 @@
 The child uses the mouse to draw coloured dots and lines on the screen and keyboard
 to display letter.
 
-Require:
-You need gstreamer-0.10, cairo and gconf (with devel package).
+Requires:
+You need gstreamer-0.10, gtk3 (with devel package).
 
 Build without install gamine:
 % make pkgdatadir=`pwd`
 
 Build and install gamine:
-% make PREFIX=/usr/ sysconfdir=/etc/
-% make install PREFIX=/usr  sysconfdir=/etc/
+% make PREFIX=/usr SYSCONFDIR=/etc
+% make install PREFIX=/usr SYSCONFDIR=/etc
 
 Uninstall gamine:
 % make uninstall
 
 Configure gamine:
-There is 3 gconf keys:
-- width of the line draw bug cursor: /apps/gamine/line_width
-- font weight of text: /apps/gamine/font_weight
-- object (square, ...) weight: /apps/gamine/object_weight
+There is 5 keys in /etc/gamine.conf:
+- width of the line draw bug cursor: line_width
+- font weight of text: font_weight
+- object (square, ...) weight: object_weight
+- background music: background_music
+- timer color change: timer_color_change
 
 Use gamine:
 % gamine