Difference between revisions of "GTK+ (Italiano)"

From ArchWiki
Jump to: navigation, search
Line 26: Line 26:
 
* {{Pkg|gtk2_prefs}}
 
* {{Pkg|gtk2_prefs}}
  
Example install command:
+
Un comando d'installazione d'esempio:
 
  # pacman -S gtk-theme-switch2
 
  # pacman -S gtk-theme-switch2
  
See also [[Uniform Look for QT and GTK Applications#How do I set styles for each toolkit?]]
+
Può essere utile guardare anche [[Uniform_Look_for_QT_and_GTK_Applications_(Italiano)#Come_posso_configurare_lo_stile_per_ogni_toolkit.3F|Uniformare il look di applicazioni QT e GTK - Come posso configurare lo stile per ogni toolkit]]
  
== Themes ==
+
== Temi ==
  
 
=== GTK+ 1.x ===
 
=== GTK+ 1.x ===
Old GTK+ 1 apps (like xmms) often do not look very nice at first. This is because they use ugly themes by default.
+
Le vecchia applicazioni GTK+ 1 (come xmms) quasi sempre non hanno un bel look all'inizio. La causa è data dal fatto che usano di default dei temi poco gradevoli.
To change this, you need to:
+
Per cambiare la sitazione, è necessario:
# download and install some nice themes
+
# scaricare ed installare dei bei temi
# change the theme
+
# cambiare il tema di default
  
Some nice themes are in the [[Arch User Repository|AUR]]. To install them, see {{AUR|gtk-smooth-engine}}.
+
Molti temi gradevoli si trovano in [[Arch User Repository (Italiano)|AUR]]. Per installarli, si veda {{AUR|gtk-smooth-engine}}.
  
To change the theme you can use ''gtk-theme-switch2''. Run it with the 'switch' command.
+
Per cambiare il tema è possibile usare ''gtk-theme-switch2''. Per avviarlo basta usare il comando 'switch'.
  
 
=== GTK+ 2.x ===
 
=== GTK+ 2.x ===
  
Major [[Desktop Environment|desktop environments]] provide tools to configure the GTK+ theme, icons, font and font size. Alternatively, tools such as those mentioned above may be used.
+
I maggiori [[Desktop_Environment_(Italiano)|ambienti desktop]] muniscono l'utente di strumenti per configurare il tema GTK+, le icone, il font e la sua dimensione. In alternativa, si possono usare programmi come quelli appena menzionati.
  
It is recommended to [[pacman|install]] some GTK+ 2 themes as well. The popular ''Clearlooks'' theme is included within the {{Pkg|gtk-engines}} package.
+
È raccomandato anche [[Pacman_(Italiano)|installare]] alcuni temi GTK+ 2. Il famoso tema ''Clearlooks'' è incluso al pacchetto {{Pkg|gtk-engines}}.
  
Further themes can be found in the [[Arch User Repository|AUR]]:
+
Altri temi si possono trovare in [[Arch User Repository (Italiano)|AUR]]:
 
*https://aur.archlinux.org/packages.php?O=0&K=gtk2-theme&do_Search=Go
 
*https://aur.archlinux.org/packages.php?O=0&K=gtk2-theme&do_Search=Go
 
*https://aur.archlinux.org/packages.php?O=0&K=gtk-theme&do_Search=Go
 
*https://aur.archlinux.org/packages.php?O=0&K=gtk-theme&do_Search=Go
  
Alternatively, GTK+ settings can be configured manually by editing {{ic|~/.gtkrc-2.0}}. A list of GTK+ settings can be found in the [http://library.gnome.org/devel/gtk/stable/GtkSettings.html GNOME library]. To manually change the GTK+ theme, icons, font and font size, add the following to {{ic|~/.gtkrc-2.0}}:
+
In alternativa, le impostazioni di GTK+ possono essere configurate manualmente modificando {{ic|~/.gtkrc-2.0}}. Una lista di impostazioni GTK+ possono essere trovate in [http://library.gnome.org/devel/gtk/stable/GtkSettings.html GNOME library]. Per cambiare manualmente il tema GTK+, le icone, i font e la loro grandezza, basta aggiungere le righe seguenti a {{ic|~/.gtkrc-2.0}}:
  
 
{{hc|~/.gtkrc-2.0|2=
 
{{hc|~/.gtkrc-2.0|2=
gtk-icon-theme-name = "[name-of-icon-theme]"
+
gtk-icon-theme-name = "[nome-del-tema-icone]"
gtk-theme-name = "[name-of-theme]"
+
gtk-theme-name = "[nome-del-tema]"
gtk-font-name = "[font-name] [size]"
+
gtk-font-name = "[nome-del-font] [grandezza]"
 
}}
 
}}
  
For example:
+
Ad esempio:
 
{{hc|~/.gtkrc-2.0|2=
 
{{hc|~/.gtkrc-2.0|2=
 
gtk-icon-theme-name = "Tango"
 
gtk-icon-theme-name = "Tango"
Line 68: Line 68:
 
}}
 
}}
  
{{Note| The above example requires the packages {{Pkg|ttf-dejavu}}, {{Pkg|tango-icon-theme}}, {{Pkg|gtk-engine-murrine}} from the [[Official Repositories|official repositories]], and {{AUR|murrine-themes-collection}} from the AUR.}}
+
{{Note| L'esempio appena riportato richiede i pacchetti {{Pkg|ttf-dejavu}}, {{Pkg|tango-icon-theme}}, {{Pkg|gtk-engine-murrine}} da [[Official Repositories (Italiano)|repository ufficiali]], e {{AUR|murrine-themes-collection}} da [[Arch User Repository (Italiano)|AUR]].}}
  
 
=== GTK+ 3.x ===
 
=== GTK+ 3.x ===

Revision as of 12:50, 17 January 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Attenzione: Questo articolo è in fase di traduzione. Seguite per ora le istruzioni della versione inglese.
Sommario help replacing me
Questi articoli trattano la configurazione di applicazioni GTK+. GTK+ (GIMP Toolkit) è uno strumento multi-piattaforma per la creazione di interfacce utente grafiche (GUI). Qui si esploreranno le utilità usate per configurare un tema GTK+, lo stile, le icone, il font, oltre a spiegare dettagliatamente la configurazione manuale.
Risorse collegate
Uniform Look for QT and GTK Applications (Italiano)
Qt
GNU Project

Dal Sito di GTK+:

GTK+, o The GIMP Toolkit, è un toolkit multi-piattaforma per creare interfacce utente (UI) grafiche. In quanto offre un set completo di strumenti, GTK+ è adatto per ogni progetto, da piccoli strumenti unici a interfacce complete di applicazioni.

GTK+, The GIMP Toolkit, fu creato inizialmente dal Progetto GNU per il GIMP, ma ora è un toolkit molto famoso con supporto per molte lingue.

Programmi di configurazione

Questi programmi GUI (Graphic User Interface) permettono la selezione del tema oltre alla personalizzazione del font e del cursore. Generalmente sovrascrivono il file ~/.gtkrc-2.0.

Un comando d'installazione d'esempio:

# pacman -S gtk-theme-switch2

Può essere utile guardare anche Uniformare il look di applicazioni QT e GTK - Come posso configurare lo stile per ogni toolkit

Temi

GTK+ 1.x

Le vecchia applicazioni GTK+ 1 (come xmms) quasi sempre non hanno un bel look all'inizio. La causa è data dal fatto che usano di default dei temi poco gradevoli. Per cambiare la sitazione, è necessario:

  1. scaricare ed installare dei bei temi
  2. cambiare il tema di default

Molti temi gradevoli si trovano in AUR. Per installarli, si veda gtk-smooth-engineAUR.

Per cambiare il tema è possibile usare gtk-theme-switch2. Per avviarlo basta usare il comando 'switch'.

GTK+ 2.x

I maggiori ambienti desktop muniscono l'utente di strumenti per configurare il tema GTK+, le icone, il font e la sua dimensione. In alternativa, si possono usare programmi come quelli appena menzionati.

È raccomandato anche installare alcuni temi GTK+ 2. Il famoso tema Clearlooks è incluso al pacchetto gtk-engines.

Altri temi si possono trovare in AUR:

In alternativa, le impostazioni di GTK+ possono essere configurate manualmente modificando ~/.gtkrc-2.0. Una lista di impostazioni GTK+ possono essere trovate in GNOME library. Per cambiare manualmente il tema GTK+, le icone, i font e la loro grandezza, basta aggiungere le righe seguenti a ~/.gtkrc-2.0:

~/.gtkrc-2.0
gtk-icon-theme-name = "[nome-del-tema-icone]"
gtk-theme-name = "[nome-del-tema]"
gtk-font-name = "[nome-del-font] [grandezza]"

Ad esempio:

~/.gtkrc-2.0
gtk-icon-theme-name = "Tango"
gtk-theme-name = "Murrine-Gray"
gtk-font-name = "DejaVu Sans 8"
Note: L'esempio appena riportato richiede i pacchetti ttf-dejavu, tango-icon-theme, gtk-engine-murrine da repository ufficiali, e murrine-themes-collectionAUR da AUR.

GTK+ 3.x

If you use GNOME 3, the theme can be changed with the gnome-tweak-tool.

If you use a GTK+ 2.x based DE, like Xfce, LXDE, gnome-tweak-tool won't work; see FS#23644. You need to install librsvg, and set your theme manually in {XDG_CONFIG_HOME}/gtk-3.0/settings.ini (this is usually ~/.config/gtk-3.0/settings.ini. An example settings.ini file:

{XDG_CONFIG_HOME}/gtk-3.0/settings.ini
[Settings]
gtk-application-prefer-dark-theme = false
gtk-theme-name = Zukitwo
gtk-fallback-icon-theme = gnome
gtk-icon-theme-name = [icon theme name]
gtk-font-name = [font name] [font size]

If it still does not change, delete old gtk-3.0 folder in {XDG_CONFIG_HOME} and copy gtk-3.0 folder from /path-to-the-theme to {XDG_CONFIG_HOME}. example:

rm -r ~/.config/gtk-3.0/
cp -r /usr/share/themes/Zukitwo/gtk-3.0/ ~/.config/  

After this, you need to set the same theme in your DE's appearance configuration tool. There are only a few themes which provide a uniform look for GTK+ 3.x and GTK+ 2.x apps. A few examples:

  1. Adwaita for GTK+ 3 and Advaicium for GTK+ 2
  2. Newlooks for GKT+ 3 and Clearlooks for GTK+ 2
  3. Zukitwo
  4. Elegant Brit
  5. Atolm
  6. Hope

You could find what themes installed on your system have both an Gtk2 and Gtk3 version by using this command (don't work with names containing spaces) :

find $(find /home/twix/.themes /usr/share/themes/ -wholename "*/gtk-3.0" | sed -e "s/^\(.*\)\/gtk-3.0$/\1/")\
-wholename "*/gtk-2.0" | sed -e "s/.*\/\(.*\)\/gtk-2.0/\1"/


Note: There probably are other themes. Some of these themes are available in the AUR. Also, some of them are not usable as is for displaying a GTK+ 2.x panel (light text over light background), so you need to use the provided panel background.

GTK+ and QT

If you have GTK+ and QT (KDE) applications on your desktop then you know that their looks do not blend well. If you wish to make your GTK+ styles match your QT styles please read Uniform Look for QT and GTK Applications.

Configuration file

Note: See the GtkSettings properties in the GTK+ programming reference manual for the full list of GTK configuration options.

The purpose of this section is to collect GTK configuration settings which can e.g. be used within ~/.gtkrc-2.0.

Enabling Customizable Keyboard Shortcuts

You can customize your GTK applications' keyboard shortcuts (those are called accelerators in GTK terminology) by hovering your mouse over a menu item and pressing your desired key combination. However, this feature is disabled by default. To enable it, set

gtk-can-change-accels = 1

Speed up your GNOME menu

This setting controls the delay between you pointing the mouse at a menu and that menu opening in GNOME. Change this to a setting you prefer. I guess the number is in milliseconds, e.g. 250 being a quarter of a second.

gtk-menu-popup-delay = 0

Reduce widget sizes

If you have a small screen or you just do not like big icons and widgets, you can resize things easily. To have icons without text in toolbars, use

gtk-toolbar-style = GTK_TOOLBAR_ICONS

To use smaller icons, use a line like this:

gtk-icon-sizes = "panel-menu=16,16:panel=16,16:gtk-menu=16,16:gtk-large-toolbar=16,16\
:gtk-small-toolbar=16,16:gtk-button=16,16"

Or to remove icons from buttons completely:

gtk-button-images = 0

You can also remove icons from menus:

gtk-menu-images = 0

There is some more tweaking to do in your themes gtkrc like explained here and there's another theme that does it all.

Development

When writing a start-from-scratch GTK+ 3 program with C, it's necessary to add CFLAGS for gcc:

gcc -g -Wall `pkg-config --cflags --libs gtk+-3.0` -o base base.c

-g and -Wall parameters are not necessary since they are only for verbose debugging outputs. You may try out the official Hello World example.

Write a simple message dialog app

You can write your own GTK+ 3 message dialog easily in many programming languages through GObject-Introspection or bindings, or you can simply use bash.

The following examples display a simple "Hello world" in a message dialog.

Bash

hello_world.sh
#!/bin/bash
zenity --info --title='Hello world!' --text='This is an example dialog.'

C

  • Dependency: gtk3
  • Build with: gcc -o hello_world `pkg-config --cflags --libs gtk+-3.0` hello_world.c
hello_world.c
#include <gtk/gtk.h>
void main (int argc, char *argv[]) {
	gtk_init (&argc, &argv);
        GtkWidget *hello = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Hello world!");
	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (hello), "This is an example dialog.");
        gtk_dialog_run(GTK_DIALOG (hello));
}

C++

  • Dependency: gtkmm3
  • Build with: g++ -o hello_world `pkg-config --cflags --libs gtkmm-3.0` hello_world.cc
hello_world.cc
#include <gtkmm.h>
#include <gtkmm/messagedialog.h>
int main(int argc, char *argv[]) {
	Gtk::Main kit(argc, argv);
	Gtk::MessageDialog Hello("Hello world!", false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK);
	Hello.set_secondary_text("This is an example dialog.");
	Hello.run();
}

Genie

  • Dependency: gtk3
  • Makedependency: vala
  • Build with: valac --pkg gtk+-3.0 hello_world.gs
hello_world.gs
uses 
	Gtk
init
	Gtk.init (ref args)
	var Hello=new MessageDialog (null, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Hello world!")
	Hello.format_secondary_text ("This is an example dialog.")
	Hello.run ()

JavaScript

hello_world.js
#!/usr/bin/gjs
Gtk = imports.gi.Gtk
Gtk.init(null, null)
Hello = new Gtk.MessageDialog({type: Gtk.MessageType.INFO,
                               buttons: Gtk.ButtonsType.OK,
                               text: "Hello world!",
                               "secondary-text": "This is an example dialog."})
Hello.run()

Python

hello_world.py
#!/usr/bin/python
from gi.repository import Gtk
Gtk.init(None)
Hello=Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, "Hello world!")
Hello.format_secondary_text("This is an example dialog.")
Hello.run()

Vala

  • Dependency: gtk3
  • Makedependency: vala
  • Build with: valac --pkg gtk+-3.0 hello_world.vala
hello_world.vala
using Gtk;
public class HelloWorld {
	static void main (string[] args) {
		Gtk.init (ref args);
		var Hello=new MessageDialog (null, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Hello world!");
		Hello.format_secondary_text ("This is an example dialog.");
		Hello.run ();
	}
}

Resources