Barra laterale

programmazione:gtk:usare_il_widget_gtkheaderbar

Dotare le applicazioni gtk3 di una diversa decorazione per la finestra

Autore: Fabio Di Matteo
Ultima revisione: 03/03/2017 - 10:16

Le Gtk3 permettono di dotare le nostre applicazioni di una diversa decorazione per la finestra , ottenuta grazie al widget GtkHeaderBar. Vedi screenshot sopra. Per ottenere l'effetto desiderato basta selezionare la finestra creata in Glade e tra le proprietà flaggare Decorazioni della finestra lato client. A questo punto dovrebbe vedersi proprio sotto l'intestazione della finestra (sotto _ [ ] X ) un'area vuota dove poter inserire il widget GtkHeaderBar

File di Glade

gui.ui

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkWindow" id="mainWindow">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="resizable">False</property>
    <signal name="delete-event" handler="on_mainWindow_delete_event()" swapped="no"/>
    <child>
      <object class="GtkBox">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <child>
          <object class="GtkAlignment">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <placeholder/>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="padding">7</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="label">
            <property name="name">myLabel</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">Pronto.</property>
            <attributes>
              <attribute name="font-desc" value="Nimbus Sans Narrow Bold Oblique Semi-Condensed 40"/>
            </attributes>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="btBigButton">
            <property name="label" translatable="yes">Non fa niente</property>
            <property name="name">btBigButton</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
      </object>
    </child>
    <child type="titlebar">
      <object class="GtkHeaderBar">
        <property name="name">HeaderBar</property>
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="title">Titolo Applicazione</property>
        <property name="subtitle">Applicazione d'esempio</property>
        <property name="show_close_button">True</property>
        <child>
          <object class="GtkBox">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <object class="GtkButton" id="btPlus">
                <property name="label">gtk-add</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="btClean">
                <property name="label">gtk-clear</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">2</property>
              </packing>
            </child>
          </object>
        </child>
      </object>
    </child>
  </object>
</interface>

programmazione/gtk/usare_il_widget_gtkheaderbar.txt · Ultima modifica: 18/04/2018 - 15:48 (modifica esterna)