r3357 rjek - in /trunk/netsurf/gtk: gtk_gui.c gtk_gui.h gtk_scaffolding.c res/netsurf.glade

netsurf at semichrome.net netsurf at semichrome.net
Fri Jun 22 16:16:49 BST 2007


Author: rjek
Date: Fri Jun 22 16:16:48 2007
New Revision: 3357

URL: http://svn.semichrome.net?rev=3D3357&view=3Drev
Log:
Implement Open File... in nsgtk

Modified:
    trunk/netsurf/gtk/gtk_gui.c
    trunk/netsurf/gtk/gtk_gui.h
    trunk/netsurf/gtk/gtk_scaffolding.c
    trunk/netsurf/gtk/res/netsurf.glade

Modified: trunk/netsurf/gtk/gtk_gui.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_gui.c?rev=3D3357&r1=3D=
3356&r2=3D3357&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/gtk/gtk_gui.c (original)
+++ trunk/netsurf/gtk/gtk_gui.c Fri Jun 22 16:16:48 2007
@@ -63,6 +63,7 @@
 GladeXML *gladeWindows;
 GtkWindow *wndTooltip;
 GtkLabel *labelTooltip;
+GtkDialog *wndOpenFile;
 =

 /**
  * Locate a shared resource file by searching known places in order.
@@ -241,6 +242,7 @@
 		glade_xml_get_widget(gladeWindows, "textviewGPL")), fontdesc);
 	=

 	wndWarning =3D GTK_WINDOW(glade_xml_get_widget(gladeWindows, "wndWarning"=
));
+	wndOpenFile =3D GTK_DIALOG(glade_xml_get_widget(gladeWindows, "wndOpenFil=
e"));
 =

 	nsgtk_history_init();
 }

Modified: trunk/netsurf/gtk/gtk_gui.h
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_gui.h?rev=3D3357&r1=3D=
3356&r2=3D3357&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/gtk/gtk_gui.h (original)
+++ trunk/netsurf/gtk/gtk_gui.h Fri Jun 22 16:16:48 2007
@@ -18,3 +18,5 @@
 =

 extern GtkWindow *wndTooltip;
 extern GtkLabel *labelTooltip;
+
+extern GtkDialog *wndOpenFile;

Modified: trunk/netsurf/gtk/gtk_scaffolding.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_scaffolding.c?rev=3D33=
57&r1=3D3356&r2=3D3357&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/gtk/gtk_scaffolding.c (original)
+++ trunk/netsurf/gtk/gtk_scaffolding.c Fri Jun 22 16:16:48 2007
@@ -79,7 +79,7 @@
 };
 =

 static int open_windows =3D 0;		/**< current number of open browsers */
-
+static struct gtk_scaffolding *current_model; /**< current window for mode=
l dialogue use */
 static void nsgtk_window_destroy_event(GtkWidget *, gpointer);
 =

 static void nsgtk_window_update_back_forward(struct gtk_scaffolding *);
@@ -99,6 +99,8 @@
 =

 static void nsgtk_attach_menu_handlers(GladeXML *, gpointer);
 =

+gboolean nsgtk_openfile_open(GtkWidget *widget, gpointer data);
+
 #define MENUEVENT(x) { #x, G_CALLBACK(nsgtk_on_##x##_activate) }
 #define MENUPROTO(x) static gboolean nsgtk_on_##x##_activate( \
 					GtkMenuItem *widget, gpointer g)
@@ -106,6 +108,7 @@
 /* file menu */
 MENUPROTO(new_window);
 MENUPROTO(open_location);
+MENUPROTO(open_file);
 MENUPROTO(close_window);
 MENUPROTO(quit);
 =

@@ -138,6 +141,7 @@
 	/* file menu */
 	MENUEVENT(new_window),
 	MENUEVENT(open_location),
+	MENUEVENT(open_file),
 	MENUEVENT(close_window),
 	MENUEVENT(quit),
 =

@@ -337,6 +341,24 @@
 }
 =

 =

+gboolean nsgtk_openfile_open(GtkWidget *widget, gpointer data)
+{
+        struct browser_window *bw =3D nsgtk_get_browser_for_gui(
+						current_model->top_level);
+	char *filename =3D gtk_file_chooser_get_filename(
+						GTK_FILE_CHOOSER(wndOpenFile));
+	char *url =3D malloc(strlen(filename) + strlen("file://"));
+
+	sprintf(url, "file://%s", filename);
+	=

+        browser_window_go(bw, url, 0, true);
+
+	g_free(filename);
+	free(url);
+
+        return TRUE;
+}
+
 /* signal handlers for menu entries */
 #define MENUHANDLER(x) gboolean nsgtk_on_##x##_activate(GtkMenuItem *widge=
t, \
  gpointer g)
@@ -357,6 +379,14 @@
 	struct gtk_scaffolding *gw =3D (struct gtk_scaffolding *)g;
 =

 	gtk_widget_grab_focus(GTK_WIDGET(gw->url_bar));
+
+	return TRUE;
+}
+
+MENUHANDLER(open_file)
+{
+	current_model =3D (struct gtk_scaffolding *)g;
+	gtk_dialog_run(wndOpenFile);
 =

 	return TRUE;
 }

Modified: trunk/netsurf/gtk/res/netsurf.glade
URL: http://svn.semichrome.net/trunk/netsurf/gtk/res/netsurf.glade?rev=3D33=
57&r1=3D3356&r2=3D3357&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/gtk/res/netsurf.glade (original)
+++ trunk/netsurf/gtk/res/netsurf.glade Fri Jun 22 16:16:48 2007
@@ -74,7 +74,6 @@
 		  <child>
 		    <widget class=3D"GtkImageMenuItem" id=3D"open_file">
 		      <property name=3D"visible">True</property>
-		      <property name=3D"sensitive">False</property>
 		      <property name=3D"tooltip" translatable=3D"yes">Open a file on you=
r computer into this browser window.</property>
 		      <property name=3D"label" translatable=3D"yes">Open _file...</prope=
rty>
 		      <property name=3D"use_underline">True</property>
@@ -5447,4 +5446,76 @@
   </child>
 </widget>
 =

+<widget class=3D"GtkFileChooserDialog" id=3D"wndOpenFile">
+  <property name=3D"action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
+  <property name=3D"local_only">True</property>
+  <property name=3D"select_multiple">False</property>
+  <property name=3D"show_hidden">False</property>
+  <property name=3D"do_overwrite_confirmation">False</property>
+  <property name=3D"title" translatable=3D"yes">Open file</property>
+  <property name=3D"type">GTK_WINDOW_TOPLEVEL</property>
+  <property name=3D"window_position">GTK_WIN_POS_NONE</property>
+  <property name=3D"modal">True</property>
+  <property name=3D"resizable">True</property>
+  <property name=3D"destroy_with_parent">False</property>
+  <property name=3D"decorated">True</property>
+  <property name=3D"skip_taskbar_hint">False</property>
+  <property name=3D"skip_pager_hint">False</property>
+  <property name=3D"type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name=3D"gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name=3D"focus_on_map">True</property>
+  <property name=3D"urgency_hint">False</property>
+
+  <child internal-child=3D"vbox">
+    <widget class=3D"GtkVBox" id=3D"dialog-vbox4">
+      <property name=3D"visible">True</property>
+      <property name=3D"homogeneous">False</property>
+      <property name=3D"spacing">24</property>
+
+      <child internal-child=3D"action_area">
+	<widget class=3D"GtkHButtonBox" id=3D"dialog-action_area4">
+	  <property name=3D"visible">True</property>
+	  <property name=3D"layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class=3D"GtkButton" id=3D"button15">
+	      <property name=3D"visible">True</property>
+	      <property name=3D"can_default">True</property>
+	      <property name=3D"can_focus">True</property>
+	      <property name=3D"label">gtk-cancel</property>
+	      <property name=3D"use_stock">True</property>
+	      <property name=3D"relief">GTK_RELIEF_NORMAL</property>
+	      <property name=3D"focus_on_click">True</property>
+	      <property name=3D"response_id">-6</property>
+	      <signal name=3D"clicked" handler=3D"gtk_widget_hide" object=3D"wndO=
penFile" last_modification_time=3D"Fri, 22 Jun 2007 14:50:25 GMT"/>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class=3D"GtkButton" id=3D"button16">
+	      <property name=3D"visible">True</property>
+	      <property name=3D"can_default">True</property>
+	      <property name=3D"has_default">True</property>
+	      <property name=3D"can_focus">True</property>
+	      <property name=3D"label">gtk-open</property>
+	      <property name=3D"use_stock">True</property>
+	      <property name=3D"relief">GTK_RELIEF_NORMAL</property>
+	      <property name=3D"focus_on_click">True</property>
+	      <property name=3D"response_id">-5</property>
+	      <signal name=3D"clicked" handler=3D"nsgtk_openfile_open" last_modif=
ication_time=3D"Fri, 22 Jun 2007 14:52:48 GMT"/>
+	      <signal name=3D"clicked" handler=3D"gtk_widget_hide" object=3D"wndO=
penFile" last_modification_time=3D"Fri, 22 Jun 2007 14:53:02 GMT"/>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name=3D"padding">0</property>
+	  <property name=3D"expand">False</property>
+	  <property name=3D"fill">True</property>
+	  <property name=3D"pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>





More information about the netsurf-commits mailing list