[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (79159d64bff6b84bd7a6565eb517fc656a35156a)



The branch, master has been updated
       via  79159d64bff6b84bd7a6565eb517fc656a35156a (commit)
       via  93c24529851a68ac00ac6b6157aa8696bf1321d6 (commit)
      from  33d88cae984a02b036dcabd6fac10a8c33a651c4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 configure.ac                 |    4 +-
 src/hid/gtk/gui-top-window.c |  131 ++++++++++++++++++++++++++++++++++++++++--
 src/hid/gtk/gui.h            |    4 +
 3 files changed, 131 insertions(+), 8 deletions(-)


=================
 Commit Messages
=================

commit 79159d64bff6b84bd7a6565eb517fc656a35156a
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Add file change notification for the currently open PCB
    
    If the file is modified on disk, a bar appears at the top of the PCB
    area offering the user a choice as to whether they wish to reload the
    board or cancel (do nothing).
    
    If the user has changes, and hits reload - they are prompted as to
    whether they wish to throw away their changes.
    
    Requires GTK 2.18 or higher due to use of the GtkInfoBar widget.

:100644 100644 fae0655... 1352be0... M	src/hid/gtk/gui-top-window.c
:100644 100644 8abfd12... 883e803... M	src/hid/gtk/gui.h

commit 93c24529851a68ac00ac6b6157aa8696bf1321d6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Require GTK 2.18 or later for the GTK HID.
    
    This is for some new widgets, like the GtkInfoBar.

:100644 100644 422347a... 20b5cd3... M	configure.ac

=========
 Changes
=========

commit 79159d64bff6b84bd7a6565eb517fc656a35156a
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Add file change notification for the currently open PCB
    
    If the file is modified on disk, a bar appears at the top of the PCB
    area offering the user a choice as to whether they wish to reload the
    board or cancel (do nothing).
    
    If the user has changes, and hits reload - they are prompted as to
    whether they wish to throw away their changes.
    
    Requires GTK 2.18 or higher due to use of the GtkInfoBar widget.

diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index fae0655..1352be0 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -607,6 +607,118 @@ make_actions (GHidPort * port)
                                 (GHID_LAYER_SELECTOR (ghidgui->layer_selector)));
 }
 
+static void
+info_bar_response_cb (GtkInfoBar *info_bar,
+                      gint        response_id,
+                      gpointer    user_data)
+{
+  GhidGui *_gui = (GhidGui *)user_data;
+
+  if (response_id == GTK_RESPONSE_ACCEPT)
+    hid_actionl ("LoadFrom", "revert", "none", NULL);
+
+  gtk_widget_destroy (_gui->info_bar);
+  _gui->info_bar = NULL;
+}
+
+static void
+file_changed_cb (GFileMonitor     *monitor,
+                 GFile            *file,
+                 GFile            *other_file,
+                 GFileMonitorEvent event_type,
+                 gpointer          user_data)
+{
+  GhidGui *_gui = (GhidGui *)user_data;
+  GtkWidget *icon;
+  GtkWidget *label;
+  GtkWidget *content_area;
+  char *file_path;
+  char *file_path_utf8;
+  char *markup;
+
+  if (event_type != G_FILE_MONITOR_EVENT_CHANGED)
+    return;
+
+  /* File has changed on disk */
+
+  if (_gui->info_bar)
+    gtk_widget_destroy (_gui->info_bar);
+
+  _gui->info_bar = gtk_info_bar_new_with_buttons (_("Reload"),
+                                                  GTK_RESPONSE_ACCEPT,
+                                                  GTK_STOCK_CANCEL,
+                                                  GTK_RESPONSE_CANCEL,
+                                                  NULL);
+  gtk_box_pack_start (GTK_BOX (_gui->vbox_middle),
+                      _gui->info_bar, FALSE, FALSE, 0);
+  gtk_box_reorder_child (GTK_BOX (_gui->vbox_middle), _gui->info_bar, 0);
+
+  gtk_info_bar_set_message_type (GTK_INFO_BAR (_gui->info_bar),
+                                 GTK_MESSAGE_WARNING);
+
+  g_signal_connect (_gui->info_bar, "response",
+                    G_CALLBACK (info_bar_response_cb), _gui);
+
+  file_path = g_file_get_path (file);
+  file_path_utf8 = g_filename_to_utf8 (file_path, -1, NULL, NULL, NULL);
+  g_free (file_path);
+  markup =
+    g_markup_printf_escaped (_("<b>The file %s has changed on disk</b>\n"
+                               "\n"
+                               "Do you want to reload the file?"),
+                             file_path_utf8);
+  g_free (file_path_utf8);
+
+  content_area =
+    gtk_info_bar_get_content_area (GTK_INFO_BAR (_gui->info_bar));
+
+  icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+                                   GTK_ICON_SIZE_DIALOG);
+  gtk_box_pack_start (GTK_BOX (content_area),
+                      icon, FALSE, FALSE, 0);
+
+  label = gtk_label_new ("");
+  gtk_box_pack_start (GTK_BOX (content_area),
+                      label, TRUE, TRUE, 6);
+
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  gtk_label_set_markup (GTK_LABEL (label), markup);
+  g_free (markup);
+
+  gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+
+  gtk_widget_show_all (_gui->info_bar);
+}
+
+static void
+connect_file_change_monitor (GhidGui *_gui, char *filename)
+{
+  GFile *file;
+
+  if (_gui->file_monitor != NULL)
+    g_object_unref (_gui->file_monitor);
+  _gui->file_monitor = NULL;
+
+  if (_gui->info_bar != NULL)
+    gtk_widget_destroy (_gui->info_bar);
+  _gui->info_bar = NULL;
+
+  if (filename == NULL)
+    return;
+
+  file = g_file_new_for_path (filename);
+
+  /* XXX: Could hook up more error handling for g_file_monitor_file */
+  _gui->file_monitor = g_file_monitor_file (file,
+                                            G_FILE_MONITOR_NONE,
+                                            NULL,
+                                            NULL);
+  g_object_unref (file);
+
+  g_signal_connect (_gui->file_monitor, "changed",
+                    G_CALLBACK (file_changed_cb), _gui);
+}
+
 
 /* Refreshes the window title bar and sets the PCB name to the
  * window title bar or to a seperate label
@@ -636,6 +748,11 @@ ghid_window_set_name_label (gchar * name)
   gtk_window_set_title (GTK_WINDOW (gport->top_window), str);
   g_free (str);
   g_free (filename);
+
+  if (PCB->Filename && *PCB->Filename)
+    connect_file_change_monitor (ghidgui, PCB->Filename);
+  else
+    connect_file_change_monitor (ghidgui, NULL);
 }
 
 static void
@@ -1403,11 +1520,12 @@ ghid_build_pcb_top_window (void)
   gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 4);
   make_route_style_buttons(vbox, port);
 
-  vbox = gtk_vbox_new (FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (hbox_middle), vbox, TRUE, TRUE, 0);
+  ghidgui->vbox_middle = gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox_middle),
+                      ghidgui->vbox_middle, TRUE, TRUE, 0);
 
   hbox = gtk_hbox_new (FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (ghidgui->vbox_middle), hbox, TRUE, TRUE, 0);
 
   /* -- The PCB layout output drawing area */
 
@@ -1448,15 +1566,16 @@ ghid_build_pcb_top_window (void)
     gtk_hscrollbar_new (GTK_ADJUSTMENT (ghidgui->h_adjustment));
   gtk_range_set_update_policy (GTK_RANGE (ghidgui->h_range),
 			       GTK_UPDATE_CONTINUOUS);
-  gtk_box_pack_start (GTK_BOX (vbox), ghidgui->h_range, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (ghidgui->vbox_middle),
+                      ghidgui->h_range, FALSE, FALSE, 0);
 
   g_signal_connect (G_OBJECT (ghidgui->h_adjustment), "value_changed",
 		    G_CALLBACK (h_adjustment_changed_cb), ghidgui);
 
   /* -- The bottom status line label */
   ghidgui->status_line_hbox = gtk_hbox_new (FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), ghidgui->status_line_hbox,
-		      FALSE, FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (ghidgui->vbox_middle),
+                      ghidgui->status_line_hbox, FALSE, FALSE, 2);
 
   label = gtk_label_new ("");
   gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 8abfd12..883e803 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -112,6 +112,10 @@ typedef struct
   GtkWidget *grid_units_button;
   GtkWidget *menu_bar, *layer_selector;
   GtkWidget *mode_toolbar;
+  GtkWidget *vbox_middle;
+
+  GtkWidget *info_bar;
+  GFileMonitor *file_monitor;
 
   GtkWidget *h_range, *v_range;
   GtkObject *h_adjustment, *v_adjustment;

commit 93c24529851a68ac00ac6b6157aa8696bf1321d6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Require GTK 2.18 or later for the GTK HID.
    
    This is for some new widgets, like the GtkInfoBar.

diff --git a/configure.ac b/configure.ac
index 422347a..20b5cd3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -752,8 +752,8 @@ for e in $HIDLIST; do
 		AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
 	fi
 
-	PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.12.0, ,
-		[AC_MSG_ERROR([Cannot find gtk+ >= 2.12.0, install it and rerun ./configure
+	PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.18.0, ,
+		[AC_MSG_ERROR([Cannot find gtk+ >= 2.18.0, install it and rerun ./configure
 Please review the following errors:
 $GTK_PKG_ERRORS])]
 	)




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs