Add template for a preferences dialog
This commit is contained in:
		@@ -21,6 +21,7 @@ gg-resources.c: $(res_src) $(resource_files)
 | 
				
			|||||||
VALA_SOURCES = \
 | 
					VALA_SOURCES = \
 | 
				
			||||||
	gg-application.vala \
 | 
						gg-application.vala \
 | 
				
			||||||
	gg-window.vala \
 | 
						gg-window.vala \
 | 
				
			||||||
 | 
						gg-preferences.vala \
 | 
				
			||||||
	gg-main.vala
 | 
						gg-main.vala
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gnome_gitlab_SOURCES = \
 | 
					gnome_gitlab_SOURCES = \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@ namespace GnomeGitlab
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const GLib.ActionEntry[] action_entries = {
 | 
					        const GLib.ActionEntry[] action_entries = {
 | 
				
			||||||
 | 
					            { "preferences", on_preferences_activate },
 | 
				
			||||||
            { "quit", on_quit_activate }
 | 
					            { "quit", on_quit_activate }
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -59,5 +60,12 @@ namespace GnomeGitlab
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            quit ();
 | 
					            quit ();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void on_preferences_activate ()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Preferences.show ((Window)get_active_window ());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										28
									
								
								src/gg-preferences.vala
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/gg-preferences.vala
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					namespace GnomeGitlab
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [GtkTemplate (ui = "/eu/polonkai/gergely/gnome-gitlab/ui/gg-preferences.ui")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class Preferences : Gtk.Dialog
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private static GLib.Once<Preferences> instance;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private Preferences () {
 | 
				
			||||||
 | 
					            response.connect (() => {
 | 
				
			||||||
 | 
					                hide ();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void show (Window parent)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Preferences inst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inst = instance.once (() => { return new Preferences (); });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (parent != inst.get_transient_for ()) {
 | 
				
			||||||
 | 
					                inst.set_transient_for (parent);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inst.present ();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -2,5 +2,6 @@
 | 
				
			|||||||
<gresources>
 | 
					<gresources>
 | 
				
			||||||
  <gresource prefix="/eu/polonkai/gergely/gnome-gitlab">
 | 
					  <gresource prefix="/eu/polonkai/gergely/gnome-gitlab">
 | 
				
			||||||
    <file>ui/gg-window.ui</file>
 | 
					    <file>ui/gg-window.ui</file>
 | 
				
			||||||
 | 
					    <file>ui/gg-preferences.ui</file>
 | 
				
			||||||
  </gresource>
 | 
					  </gresource>
 | 
				
			||||||
</gresources>
 | 
					</gresources>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								src/resources/ui/gg-preferences.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/resources/ui/gg-preferences.ui
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<interface>
 | 
				
			||||||
 | 
					  <requires lib="gtk+" version="3.12"/>
 | 
				
			||||||
 | 
					  <template class="GnomeGitlabPreferences" parent="GtkDialog">
 | 
				
			||||||
 | 
					    <property name="title" translatable="yes">Preferences</property>
 | 
				
			||||||
 | 
					    <property name="type_hint">normal</property>
 | 
				
			||||||
 | 
					    <property name="can_focus">False</property>
 | 
				
			||||||
 | 
					    <child internal-child="vbox">
 | 
				
			||||||
 | 
					      <object class="GtkBox">
 | 
				
			||||||
 | 
					        <child>
 | 
				
			||||||
 | 
					          <object class="GtkLabel">
 | 
				
			||||||
 | 
					            <property name="visible">True</property>
 | 
				
			||||||
 | 
					            <property name="label">Preferences dialog</property>
 | 
				
			||||||
 | 
					          </object>
 | 
				
			||||||
 | 
					        </child>
 | 
				
			||||||
 | 
					      </object>
 | 
				
			||||||
 | 
					    </child>
 | 
				
			||||||
 | 
					  </template>
 | 
				
			||||||
 | 
					</interface>
 | 
				
			||||||
@@ -38,6 +38,16 @@
 | 
				
			|||||||
                    <property name="fill">True</property>
 | 
					                    <property name="fill">True</property>
 | 
				
			||||||
                  </packing>
 | 
					                  </packing>
 | 
				
			||||||
                </child>
 | 
					                </child>
 | 
				
			||||||
 | 
					                <child>
 | 
				
			||||||
 | 
					                  <object class="GtkButton">
 | 
				
			||||||
 | 
					                    <property name="label" translatable="yes">Manage GitLab instances</property>
 | 
				
			||||||
 | 
					                    <property name="action_name">app.preferences</property>
 | 
				
			||||||
 | 
					                  </object>
 | 
				
			||||||
 | 
					                  <packing>
 | 
				
			||||||
 | 
					                    <property name="expand">False</property>
 | 
				
			||||||
 | 
					                    <property name="fill">False</property>
 | 
				
			||||||
 | 
					                  </packing>
 | 
				
			||||||
 | 
					                </child>
 | 
				
			||||||
              </object>
 | 
					              </object>
 | 
				
			||||||
              <packing>
 | 
					              <packing>
 | 
				
			||||||
                <property name="name">no-instances</property>
 | 
					                <property name="name">no-instances</property>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user