Added a tray icon (partially implements Keyboard/#59)

This commit is contained in:
Pierre Pronchery 2012-05-21 23:35:12 +00:00
parent ddcec88a53
commit 12b63cf046
4 changed files with 45 additions and 9 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Keyboard 0.2.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-22 01:04+0200\n"
"POT-Creation-Date: 2012-05-22 01:30+0200\n"
"PO-Revision-Date: 2012-05-20 14:32+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n"
@ -16,35 +16,39 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: ../src/keyboard.c:97
#: ../src/keyboard.c:100
msgid "_Close"
msgstr "_Fermer"
#: ../src/keyboard.c:104
#: ../src/keyboard.c:107
msgid "_Hide"
msgstr "Masquer"
#: ../src/keyboard.c:112 ../src/keyboard.c:114
#: ../src/keyboard.c:115 ../src/keyboard.c:117
msgid "_About"
msgstr "À propos"
#: ../src/keyboard.c:121
#: ../src/keyboard.c:124
msgid "_File"
msgstr "_Fichier"
#: ../src/keyboard.c:122
#: ../src/keyboard.c:125
msgid "_View"
msgstr "_Vue"
#: ../src/keyboard.c:123
#: ../src/keyboard.c:126
msgid "_Help"
msgstr "_Aide"
#: ../src/keyboard.c:502
#: ../src/keyboard.c:415
msgid "Virtual keyboard"
msgstr "Clavier virtuel"
#: ../src/keyboard.c:521
msgid "Keyboard"
msgstr "Clavier"
#: ../src/keyboard.c:606
#: ../src/keyboard.c:625
msgid "Virtual keyboard for the DeforaOS desktop"
msgstr "Clavier virtuel pour l'environnement DeforaOS"

View File

@ -116,3 +116,13 @@ void on_view_hide(gpointer data)
keyboard_show(keyboard, FALSE);
}
/* systray */
/* on_systray_activate */
void on_systray_activate(gpointer data)
{
Keyboard * keyboard = data;
keyboard_show(keyboard, TRUE);
}

View File

@ -38,4 +38,7 @@ void on_file_close(gpointer data);
void on_help_about(gpointer data);
void on_view_hide(gpointer data);
/* systray */
void on_systray_activate(gpointer data);
#endif /* !KEYBOARD_CALLBACKS_H */

View File

@ -52,6 +52,9 @@ struct _Keyboard
PangoFontDescription * font;
GtkWidget * window;
#if GTK_CHECK_VERSION(2, 10, 0)
GtkStatusIcon * icon;
#endif
GtkWidget * ab_window;
GdkRectangle geometry;
int width;
@ -358,6 +361,7 @@ Keyboard * keyboard_new(KeyboardPrefs * prefs)
/* windows */
_new_mode(keyboard, prefs->mode);
gtk_widget_modify_bg(keyboard->window, GTK_STATE_NORMAL, &gray);
keyboard->icon = NULL;
keyboard->ab_window = NULL;
/* fonts */
if(prefs->font != NULL)
@ -401,9 +405,24 @@ Keyboard * keyboard_new(KeyboardPrefs * prefs)
gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0);
gtk_widget_show(vbox);
if(prefs->mode != KEYBOARD_MODE_EMBEDDED)
{
#if GTK_CHECK_VERSION(2, 10, 0)
/* create the systray icon */
keyboard->icon = gtk_status_icon_new_from_icon_name(
"input-keyboard");
# if GTK_CHECK_VERSION(2, 16, 0)
gtk_status_icon_set_tooltip_text(keyboard->icon,
_("Virtual keyboard"));
# endif
g_signal_connect_swapped(keyboard->icon, "activate", G_CALLBACK(
on_systray_activate), keyboard);
#endif
/* show the window */
gtk_widget_show(keyboard->window);
}
else
{
/* print the window ID and force a flush */
printf("%u\n", gtk_plug_get_id(GTK_PLUG(keyboard->window)));
fclose(stdout);
}