diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2013-11-18 13:51:37 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2013-11-20 20:30:59 +0100 |
commit | 368b34f2db3098df62bd81f5f538da25e33f7ce0 (patch) | |
tree | e21d93b0f8a2680d8b18941b5dcbb0ff625aa4e5 | |
parent | b7fa014af970d0dfd836c2798cab52da5c9d61ea (diff) | |
download | gnome-settings-daemon-368b34f2db3098df62bd81f5f538da25e33f7ce0.tar.gz |
common: Add helper function to GsdShell
Currently only one helper function is provided to interface with ShowOSD, it
takes care of creating the GVariant with all provided arguments.
-rw-r--r-- | plugins/common/Makefile.am | 5 | ||||
-rw-r--r-- | plugins/common/gsd-shell-helper.c | 53 | ||||
-rw-r--r-- | plugins/common/gsd-shell-helper.h | 36 |
3 files changed, 93 insertions, 1 deletions
diff --git a/plugins/common/Makefile.am b/plugins/common/Makefile.am index b0e907cb..59e458da 100644 --- a/plugins/common/Makefile.am +++ b/plugins/common/Makefile.am @@ -6,9 +6,12 @@ libcommon_la_SOURCES = \ gsd-keygrab.c \ gsd-keygrab.h \ gsd-input-helper.c \ - gsd-input-helper.h + gsd-input-helper.h \ + gsd-shell-helper.c \ + gsd-shell-helper.h libcommon_la_CPPFLAGS = \ + -I$(top_srcdir)/gnome-settings-daemon \ $(AM_CPPFLAGS) libcommon_la_CFLAGS = \ diff --git a/plugins/common/gsd-shell-helper.c b/plugins/common/gsd-shell-helper.c new file mode 100644 index 00000000..21ff2078 --- /dev/null +++ b/plugins/common/gsd-shell-helper.c @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2013 Carlos Garnacho <carlosg@gnome.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include "config.h" +#include "gsd-shell-helper.h" + +void +shell_show_osd (GsdShell *shell, + const gchar *icon_name, + const gchar *label, + gint level, + gint monitor) +{ + GVariantBuilder builder; + + g_return_if_fail (GSD_IS_SHELL (shell)); + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + + if (icon_name) + g_variant_builder_add (&builder, "{sv}", + "icon", g_variant_new_string (icon_name)); + if (label) + g_variant_builder_add (&builder, "{sv}", + "label", g_variant_new_string (label)); + if (level >= 0) + g_variant_builder_add (&builder, "{sv}", + "level", g_variant_new_int32 (level)); + if (monitor >= 0) + g_variant_builder_add (&builder, "{sv}", + "monitor", g_variant_new_int32 (monitor)); + + gsd_shell_call_show_osd (shell, + g_variant_builder_end (&builder), + NULL, NULL, NULL); +} diff --git a/plugins/common/gsd-shell-helper.h b/plugins/common/gsd-shell-helper.h new file mode 100644 index 00000000..b478164f --- /dev/null +++ b/plugins/common/gsd-shell-helper.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2013 Carlos Garnacho <carlosg@gnome.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef __GSD_SHELL_HELPER_H__ +#define __GSD_SHELL_HELPER_H__ + +#include "gsd-shell-glue.h" + +G_BEGIN_DECLS + +void shell_show_osd (GsdShell *shell, + const gchar *icon_name, + const gchar *label, + gint level, + gint monitor); + +G_END_DECLS + +#endif /* __GSD_SHELL_HELPER_H__ */ |