Skip to content

Commit

Permalink
fix/wire: cancel wire on leave event
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Nov 27, 2019
1 parent 83d4715 commit 0e16c70
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/oregano.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2006 Ricardo Markiewicz
* Copyright (C) 2009-2012 Marc Lorber
* Copyright (C) 2013 Bernhard Schuster
* Copyright (C) 2013,2019 Bernhard Schuster
* Copyright (C) 2017 Guido Trentalancia
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -217,6 +217,7 @@ static void oregano_application (GApplication *app, GFile *file)
g_signal_add_emission_hook (g_signal_lookup ("last_schematic_destroyed", TYPE_SCHEMATIC), 0,
quit_hook, NULL, NULL);

if (oregano.show_splash && splash)
if (oregano.show_splash && splash) {
oregano_splash_done (splash, _ ("Welcome to Oregano"));
}
}
3 changes: 3 additions & 0 deletions src/sheet/create-wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ gboolean create_wire_event (Sheet *sheet, GdkEvent *event, gpointer data)
break;
}
break;
case GDK_LEAVE_NOTIFY:
return create_wire_discard (sheet, event);

case GDK_MOTION_NOTIFY:
if (create_wire_info->state == WIRE_ACTIVE)
return create_wire_update (sheet, event);
Expand Down
32 changes: 21 additions & 11 deletions src/sheet/sheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2006 Ricardo Markiewicz
* Copyright (C) 2009-2012 Marc Lorber
* Copyright (C) 2013-2014 Bernhard Schuster
* Copyright (C) 2013-2019 Bernhard Schuster
* Copyright (C) 2017 Guido Trentalancia
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -137,6 +137,9 @@ static void sheet_init (Sheet *sheet)
sheet->priv->voltmeter_nodes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

sheet->state = SHEET_STATE_NONE;

// track these to cancel wires if the cursor leaves the window
gtk_widget_add_events(GTK_WIDGET(sheet), GDK_LEAVE_NOTIFY | GDK_ENTER_NOTIFY);
}

static void sheet_finalize (GObject *object)
Expand Down Expand Up @@ -719,9 +722,11 @@ void sheet_show_node_labels (Sheet *sheet, gboolean show)
GList *item = NULL;

for (item = sheet->priv->items; item; item = item->next) {
if (IS_PART_ITEM (item->data))
if (part_get_num_pins (PART (sheet_item_get_data (SHEET_ITEM (item->data)))) == 1)
if (IS_PART_ITEM (item->data)) {
if (part_get_num_pins (PART (sheet_item_get_data (SHEET_ITEM (item->data)))) == 1) {
part_item_show_node_labels (PART_ITEM (item->data), show);
}
}
}
}

Expand Down Expand Up @@ -785,17 +790,19 @@ int sheet_event_callback (GtkWidget *widget, GdkEvent *event, Sheet *sheet)
}

if (event->button.button == 1) {
if (!(event->button.state & GDK_SHIFT_MASK))
if (!(event->button.state & GDK_SHIFT_MASK)) {
sheet_select_all (sheet, FALSE);
}

rubberband_start (sheet, event);
return TRUE;
}
break;

case GDK_BUTTON_RELEASE:
if (event->button.button == 4 || event->button.button == 5)
if (event->button.button == 4 || event->button.button == 5) {
return TRUE;
}

if (event->button.button == 1 && sheet->priv->rubberband_info->state == RUBBERBAND_ACTIVE) {
rubberband_finish (sheet, event);
Expand All @@ -810,17 +817,21 @@ int sheet_event_callback (GtkWidget *widget, GdkEvent *event, Sheet *sheet)
GdkEventScroll *scr_event = (GdkEventScroll *)event;
if (scr_event->state & GDK_SHIFT_MASK) {
// Scroll horizontally
if (scr_event->direction == GDK_SCROLL_UP)
if (scr_event->direction == GDK_SCROLL_UP) {
sheet_scroll_pixel (sheet, -30, 0);
else if (scr_event->direction == GDK_SCROLL_DOWN)
}
else if (scr_event->direction == GDK_SCROLL_DOWN) {
sheet_scroll_pixel (sheet, 30, 0);
}

} else if (scr_event->state & GDK_CONTROL_MASK) {
// Scroll vertically
if (scr_event->direction == GDK_SCROLL_UP)
if (scr_event->direction == GDK_SCROLL_UP) {
sheet_scroll_pixel (sheet, 0, -30);
else if (scr_event->direction == GDK_SCROLL_DOWN)
}
else if (scr_event->direction == GDK_SCROLL_DOWN) {
sheet_scroll_pixel (sheet, 0, 30);
}

} else {
// Zoom
Expand Down Expand Up @@ -852,8 +863,7 @@ int sheet_event_callback (GtkWidget *widget, GdkEvent *event, Sheet *sheet)
return wklass->enter_notify_event (widget, (GdkEventCrossing *)event);

case GDK_LEAVE_NOTIFY:
g_signal_emit_by_name (G_OBJECT (sheet), "cancel");
return TRUE;
return wklass->leave_notify_event (widget, (GdkEventCrossing *)event);

case GDK_KEY_PRESS:
switch (event->key.keyval) {
Expand Down
2 changes: 1 addition & 1 deletion wscript
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python3
# encoding: utf-8

VERSION = '0.84.42'
VERSION = '0.84.43'
APPNAME = 'oregano'

top = '.'
Expand Down

0 comments on commit 0e16c70

Please sign in to comment.