Replaced Gnome.AppBar with a dialog (stored in .glade file)
authorMiloš Klouček <m.kloucek.m@atlas.cz>
Fri, 24 Oct 2008 17:01:13 +0000 (17:01 +0000)
committerMiloš Klouček <m.kloucek.m@atlas.cz>
Fri, 24 Oct 2008 17:01:13 +0000 (17:01 +0000)
SVN-Revision: 5802

tools/tilemanager/Application.cs
tools/tilemanager/Makefile
tools/tilemanager/tiler.glade

index a72031c..a8fe0a9 100644 (file)
@@ -3,7 +3,6 @@ using System.IO;
 using System.Collections;
 using Gtk;
 using Gdk;
-using Gnome;
 using Glade;
 
 public class Application {
@@ -32,16 +31,17 @@ public class Application {
     [Glade.Widget]
     private Gtk.Entry IDEntry;
     [Glade.Widget]
-    private Gnome.AppBar AppBar;
-    [Glade.Widget]
-    private Gtk.VBox MainLayout;
-    [Glade.Widget]
     private Gtk.TreeView TileList;
     [Glade.Widget]
     private Gtk.Combo TileGroupComboBox;
     [Glade.Widget]
     private Gtk.MenuItem AddTileGroupMenu;
 
+    [Glade.Widget]
+    private Gtk.Dialog RemapDialog;
+    [Glade.Widget]
+    private Gtk.SpinButton RD_spinButton;
+
     private string tilesetdir;
     private string tilesetfile;
     private TileSet tileset;
@@ -75,20 +75,13 @@ public class Application {
         Glade.XML gxml = new Glade.XML(null, "tiler.glade", null, null);
         gxml.Autoconnect(this);
 
-        if(MainWindow == null || DrawingArea == null || AppBar == null)
+        if(MainWindow == null || DrawingArea == null || RemapDialog == null)
             throw new Exception("some widgets not found");
 
         DrawingArea.AddEvents((int) Gdk.EventMask.ButtonPressMask);
         DrawingArea.AddEvents((int) Gdk.EventMask.ButtonReleaseMask);
         DrawingArea.AddEvents((int) Gdk.EventMask.ButtonMotionMask);
 
-        // libglade missed interactivity property :-/
-        MainLayout.Remove(AppBar);
-        AppBar = new AppBar(true, true, PreferencesType.Always);
-        AppBar.UserResponse += new EventHandler(OnAppBarUserResponse);
-        MainLayout.PackStart(AppBar, false, false, 0);
-        AppBar.Show();
-
         MainWindow.Show();
     }
 
@@ -291,35 +284,39 @@ public class Application {
     }
 
     protected void OnRemapTiles(object o, EventArgs e) {
-        AppBar.SetPrompt("Start-ID:", true);
-    }
-
-    protected void OnCreateTileGroup(object o, EventArgs e) {
+       if(Tiles == null)
+               return;
+       RemapDialog.Show();
     }
 
-    protected void OnRenameTileGroup(object o, EventArgs e) {
+    protected void OnRemapDialogCancel(object o, EventArgs e) {
+       RemapDialog.Hide();
     }
 
-    protected void OnAppBarUserResponse(object o, EventArgs e) {
+    protected void OnRemapDialogApply(object o, EventArgs e) {
+       RemapDialog.Hide();
         try {
-            if(AppBar.Response == null || AppBar.Response == ""
-                    || Tiles == null)
-                return;
 
             // remap tiles
             int id;
             try {
-                id = Int32.Parse(AppBar.Response);
+                id = RD_spinButton.ValueAsInt;
             } catch(Exception exception) {
                 ShowException(exception);
                 return;
             }
             RemapTiles(id);
         } finally {
-            AppBar.ClearPrompt();
+            RD_spinButton.Value = 1;
         }
     }
 
+    protected void OnCreateTileGroup(object o, EventArgs e) {
+    }
+
+    protected void OnRenameTileGroup(object o, EventArgs e) {
+    }
+
     protected void RemapTiles(int startID) {
        if(Tiles == null)
                return;
index 642e9c8..e483bd2 100644 (file)
@@ -1,6 +1,6 @@
 GOAL=tilemanager.exe
 SOURCES=$(wildcard *.cs)
-CSFLAGS=-debug -pkg:gtk-sharp-2.0 -pkg:glade-sharp-2.0 -pkg:gnome-sharp-2.0 -r:System.Drawing
+CSFLAGS=-debug -pkg:gtk-sharp-2.0 -pkg:glade-sharp-2.0 -r:System.Drawing
 RESOURCES=tiler.glade
 CSFLAGS+=$(foreach file,$(RESOURCES),-resource:$(file) )
 
index 359b5ac..8a0b330 100644 (file)
@@ -2,7 +2,6 @@
 <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
 
 <glade-interface>
-<requires lib="gnome"/>
 
 <widget class="GtkWindow" id="MainWindow">
   <property name="visible">True</property>
@@ -19,6 +18,8 @@
   <property name="skip_pager_hint">False</property>
   <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
   <signal name="delete_event" handler="OnDeleteQuit" last_modification_time="Sun, 21 Nov 2004 12:26:12 GMT"/>
 
   <child>
@@ -30,6 +31,8 @@
       <child>
        <widget class="GtkMenuBar" id="menubar1">
          <property name="visible">True</property>
+         <property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>
+         <property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>
 
          <child>
            <widget class="GtkMenuItem" id="menuitem1">
          <child>
            <widget class="GtkMenuItem" id="menuitem4">
              <property name="visible">True</property>
-             <property name="label">gtk-help</property>
-             <property name="use_stock">True</property>
+             <property name="label" translatable="yes">Help</property>
+             <property name="use_underline">True</property>
 
              <child>
                <widget class="GtkMenu" id="menuitem4_menu">
                      <property name="rules_hint">False</property>
                      <property name="reorderable">False</property>
                      <property name="enable_search">True</property>
+                     <property name="fixed_height_mode">False</property>
+                     <property name="hover_selection">False</property>
+                     <property name="hover_expand">False</property>
                      <signal name="cursor-changed" handler="OnTileListCursorChanged"/>
                    </widget>
                  </child>
                      <property name="max_length">0</property>
                      <property name="text" translatable="yes"></property>
                      <property name="has_frame">True</property>
-                     <property name="invisible_char" translatable="yes">*</property>
+                     <property name="invisible_char">*</property>
                      <property name="activates_default">False</property>
                      <signal name="activated" handler="OnTileGroupComboBoxEntryActivated"/>
                      <signal name="changed" handler="OnTileGroupComboBoxEntryActivated"/>
                  <property name="yalign">0.5</property>
                  <property name="xpad">0</property>
                  <property name="ypad">0</property>
+                 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                 <property name="width_chars">-1</property>
+                 <property name="single_line_mode">False</property>
+                 <property name="angle">0</property>
                </widget>
                <packing>
                  <property name="padding">6</property>
                  <property name="border_width">6</property>
                  <property name="visible">True</property>
                  <property name="n_rows">6</property>
-                 <property name="n_columns">2</property>
+                 <property name="n_columns">3</property>
                  <property name="homogeneous">False</property>
                  <property name="row_spacing">6</property>
                  <property name="column_spacing">6</property>
                      <property name="yalign">0.5</property>
                      <property name="xpad">0</property>
                      <property name="ypad">0</property>
+                     <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                     <property name="width_chars">-1</property>
+                     <property name="single_line_mode">False</property>
+                     <property name="angle">0</property>
                    </widget>
                    <packing>
                      <property name="left_attach">0</property>
                      <property name="max_length">0</property>
                      <property name="text" translatable="yes"></property>
                      <property name="has_frame">True</property>
-                     <property name="invisible_char" translatable="yes">*</property>
+                     <property name="invisible_char">*</property>
                      <property name="activates_default">False</property>
                      <signal name="changed" handler="OnEntryChanged" last_modification_time="Sun, 21 Nov 2004 13:42:39 GMT"/>
                    </widget>
                      <property name="yalign">0.5</property>
                      <property name="xpad">0</property>
                      <property name="ypad">0</property>
+                     <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                     <property name="width_chars">-1</property>
+                     <property name="single_line_mode">False</property>
+                     <property name="angle">0</property>
                    </widget>
                    <packing>
                      <property name="left_attach">0</property>
                      <property name="max_length">0</property>
                      <property name="text" translatable="yes"></property>
                      <property name="has_frame">True</property>
-                     <property name="invisible_char" translatable="yes">*</property>
+                     <property name="invisible_char">*</property>
                      <property name="activates_default">False</property>
                      <signal name="changed" handler="OnEntryChanged" last_modification_time="Sun, 21 Nov 2004 13:42:48 GMT"/>
                    </widget>
                      <property name="yalign">0.5</property>
                      <property name="xpad">0</property>
                      <property name="ypad">0</property>
+                     <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                     <property name="width_chars">-1</property>
+                     <property name="single_line_mode">False</property>
+                     <property name="angle">0</property>
                    </widget>
                    <packing>
                      <property name="left_attach">0</property>
                      <property name="max_length">0</property>
                      <property name="text" translatable="yes"></property>
                      <property name="has_frame">True</property>
-                     <property name="invisible_char" translatable="yes">*</property>
+                     <property name="invisible_char">*</property>
                      <property name="activates_default">False</property>
                      <signal name="changed" handler="OnEntryChanged" last_modification_time="Sun, 21 Nov 2004 13:42:57 GMT"/>
                    </widget>
                      <property name="y_options"></property>
                    </packing>
                  </child>
-              <child>
-          <widget class="GtkCheckButton" id="HiddenCheckButton">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="label" translatable="yes">Hidden</property>
-            <property name="use_underline">True</property>
-            <property name="relief">GTK_RELIEF_NORMAL</property>
-            <property name="focus_on_click">True</property>
-            <property name="active">False</property>
-            <property name="inconsistent">False</property>
-            <property name="draw_indicator">True</property>
-            <signal name="toggled" handler="OnCheckButtonToggled" last_modification_time="Sun, 21 Nov 2004 13:42:00 GMT"/>
-          </widget>
-          <packing>
-            <property name="left_attach">2</property>
-            <property name="right_attach">3</property>
-            <property name="top_attach">0</property>
-            <property name="bottom_attach">1</property>
-            <property name="x_options">fill</property>
-            <property name="y_options"></property>
-          </packing>
-        </child>
+
+                 <child>
+                   <widget class="GtkCheckButton" id="HiddenCheckButton">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="label" translatable="yes">Hidden</property>
+                     <property name="use_underline">True</property>
+                     <property name="relief">GTK_RELIEF_NORMAL</property>
+                     <property name="focus_on_click">True</property>
+                     <property name="active">False</property>
+                     <property name="inconsistent">False</property>
+                     <property name="draw_indicator">True</property>
+                     <signal name="toggled" handler="OnCheckButtonToggled" last_modification_time="Sun, 21 Nov 2004 13:42:00 GMT"/>
+                   </widget>
+                   <packing>
+                     <property name="left_attach">2</property>
+                     <property name="right_attach">3</property>
+                     <property name="top_attach">0</property>
+                     <property name="bottom_attach">1</property>
+                     <property name="x_options">fill</property>
+                     <property name="y_options"></property>
+                   </packing>
+                 </child>
                </widget>
                <packing>
                  <property name="padding">0</property>
          <property name="fill">True</property>
        </packing>
       </child>
+    </widget>
+  </child>
+</widget>
 
-      <child>
-       <widget class="GnomeAppBar" id="AppBar">
+<widget class="GtkDialog" id="RemapDialog">
+  <property name="border_width">5</property>
+  <property name="title" translatable="yes">Tile Manager - Question</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">True</property>
+  <property name="resizable">False</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <property name="has_separator">False</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="vbox4">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="hbuttonbox1">
          <property name="visible">True</property>
-         <property name="has_progress">True</property>
-         <property name="has_status">True</property>
-         <signal name="user_response" handler="OnAppBarUserResponse" last_modification_time="Sun, 21 Nov 2004 15:23:58 GMT"/>
+         <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+         <child>
+           <widget class="GtkButton" id="RD_buttonApply">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-apply</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">-10</property>
+             <signal name="pressed" handler="OnRemapDialogApply" last_modification_time="Fri, 24 Oct 2008 16:47:51 GMT"/>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="RD_buttonCancel">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-cancel</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">-6</property>
+             <signal name="pressed" handler="OnRemapDialogCancel" last_modification_time="Fri, 24 Oct 2008 16:46:46 GMT"/>
+           </widget>
+         </child>
        </widget>
        <packing>
          <property name="padding">0</property>
          <property name="expand">False</property>
-         <property name="fill">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkHBox" id="hbox2">
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <widget class="GtkHBox" id="hbox3">
+             <property name="visible">True</property>
+             <property name="homogeneous">False</property>
+             <property name="spacing">0</property>
+
+             <child>
+               <widget class="GtkLabel" id="RD_label">
+                 <property name="visible">True</property>
+                 <property name="label" translatable="yes">Start-ID: </property>
+                 <property name="use_underline">False</property>
+                 <property name="use_markup">False</property>
+                 <property name="justify">GTK_JUSTIFY_LEFT</property>
+                 <property name="wrap">False</property>
+                 <property name="selectable">False</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xpad">0</property>
+                 <property name="ypad">0</property>
+                 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                 <property name="width_chars">-1</property>
+                 <property name="single_line_mode">False</property>
+                 <property name="angle">0</property>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkSpinButton" id="RD_spinButton">
+                 <property name="width_request">120</property>
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="climb_rate">1</property>
+                 <property name="digits">0</property>
+                 <property name="numeric">False</property>
+                 <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+                 <property name="snap_to_ticks">False</property>
+                 <property name="wrap">False</property>
+                 <property name="adjustment">1 0 100 1 10 10</property>
+               </widget>
+               <packing>
+                 <property name="padding">5</property>
+                 <property name="expand">True</property>
+                 <property name="fill">True</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
        </packing>
       </child>
     </widget>