From d87d54b16f4c1fd0ee595be273a56c424eaee694 Mon Sep 17 00:00:00 2001 From: monsta Date: Fri, 15 Dec 2017 18:24:04 +0300 Subject: drop polkitgtkmate library and its docs it contains only PolkitLockButton widget which nobody uses by now and GTK+3 already has GtkLockButton same as done upstream long ago: https://git.gnome.org/browse/PolicyKit-gnome/commit/?id=1340926a935b60b2b605a8d0d9b256e3a83c3d7d https://git.gnome.org/browse/PolicyKit-gnome/commit/?id=b8d700121941bb1f032b95c428d2e52a11c5d330 --- Makefile.am | 4 +- configure.ac | 35 - docs/Makefile.am | 86 -- docs/polkit-gtk-mate-1-docs.xml | 71 -- docs/polkit-lock-button-lock-down.png | Bin 2100 -> 0 bytes docs/polkit-lock-button-locked.png | Bin 2504 -> 0 bytes docs/polkit-lock-button-not-authorized.png | Bin 2505 -> 0 bytes docs/polkit-lock-button-unlocked.png | Bin 2575 -> 0 bytes docs/version.xml.in | 1 - po/POTFILES.in | 1 - po/POTFILES.skip | 1 - polkitgtkmate/Makefile.am | 111 --- polkitgtkmate/example.c | 193 ----- polkitgtkmate/polkit-gtk-mate-1.pc.in | 11 - polkitgtkmate/polkitgtkmate.h | 32 - polkitgtkmate/polkitgtkmatetypes.h | 35 - polkitgtkmate/polkitlockbutton.c | 1200 ---------------------------- polkitgtkmate/polkitlockbutton.h | 118 --- 18 files changed, 1 insertion(+), 1898 deletions(-) delete mode 100644 docs/Makefile.am delete mode 100644 docs/polkit-gtk-mate-1-docs.xml delete mode 100644 docs/polkit-lock-button-lock-down.png delete mode 100644 docs/polkit-lock-button-locked.png delete mode 100644 docs/polkit-lock-button-not-authorized.png delete mode 100644 docs/polkit-lock-button-unlocked.png delete mode 100644 docs/version.xml.in delete mode 100644 polkitgtkmate/Makefile.am delete mode 100644 polkitgtkmate/example.c delete mode 100644 polkitgtkmate/polkit-gtk-mate-1.pc.in delete mode 100644 polkitgtkmate/polkitgtkmate.h delete mode 100644 polkitgtkmate/polkitgtkmatetypes.h delete mode 100644 polkitgtkmate/polkitlockbutton.c delete mode 100644 polkitgtkmate/polkitlockbutton.h diff --git a/Makefile.am b/Makefile.am index d4074e4..81b0523 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = polkitgtkmate src po docs +SUBDIRS = src po EXTRA_DIST = \ autogen.sh \ @@ -6,8 +6,6 @@ EXTRA_DIST = \ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc - clean-local : rm -f *~ po/*~ diff --git a/configure.ac b/configure.ac index f8a4d20..cd84953 100644 --- a/configure.ac +++ b/configure.ac @@ -28,8 +28,6 @@ AC_HEADER_STDC LT_PREREQ([2.2.6]) LT_INIT -GTK_DOC_CHECK([1.3]) - #### gcc warning flags if test "x$GCC" = "xyes"; then @@ -172,32 +170,6 @@ AM_CONDITIONAL(HAVE_APPINDICATOR, test "x$enable_appindicator" = "xyes") AC_SUBST(APPINDICATOR_CFLAGS) AC_SUBST(APPINDICATOR_LIBS) -AC_ARG_ENABLE([examples], - AC_HELP_STRING([--enable-examples], [Build the example programs]),, - [enable_examples=yes]) - -AM_CONDITIONAL(BUILD_EXAMPLES, test "x$enable_examples" = "xyes") - -# GObject introspection -# -AC_ARG_ENABLE([introspection], - AS_HELP_STRING([--enable-introspection], [enable GObject introspection]), - [], [enable_introspection=yes]) -if test "x$enable_introspection" = xyes; then - PKG_CHECK_MODULES([INTROSPECTION], [gobject-introspection-1.0 >= 0.6.2]) - AC_DEFINE([ENABLE_INTROSPECTION], [1], [enable GObject introspection support]) - AC_SUBST([G_IR_SCANNER], [$($PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0)]) - AC_SUBST([G_IR_COMPILER], [$($PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0)]) - AC_SUBST([G_IR_GENERATE], [$($PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0)]) - #AC_SUBST([GIRDIR], [$($PKG_CONFIG --variable=girdir gobject-introspection-1.0)]) - #AC_SUBST([GIRTYPELIBDIR], [$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)]) - GIRDIR=${datadir}/gir-1.0 - GIRTYPELIBDIR=${libdir}/girepository-1.0 - AC_SUBST(GIRDIR) - AC_SUBST(GIRTYPELIBDIR) -fi -AM_CONDITIONAL([ENABLE_INTROSPECTION], [test "x$enable_introspection" = xyes]) - # ******************** # Internationalisation # ******************** @@ -214,17 +186,12 @@ AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[gettext domain]) AC_SUBST([AM_CPPFLAGS]) AC_SUBST([AM_CFLAGS]) -AC_SUBST([AM_CXXFLAGS]) AC_SUBST([AM_LDFLAGS]) AC_CONFIG_FILES([ Makefile po/Makefile.in -polkitgtkmate/Makefile -polkitgtkmate/polkit-gtk-mate-1.pc src/Makefile -docs/version.xml -docs/Makefile ]) AC_OUTPUT @@ -249,6 +216,4 @@ echo " Accountsservice: ${enable_accountsservice} Application indicator: ${enable_appindicator} Maintainer mode: ${USE_MAINTAINER_MODE} - Building api docs: ${enable_gtk_doc} - GObject Introspection: ${enable_introspection} " diff --git a/docs/Makefile.am b/docs/Makefile.am deleted file mode 100644 index 45dd77f..0000000 --- a/docs/Makefile.am +++ /dev/null @@ -1,86 +0,0 @@ - -NULL = - -AUTOMAKE_OPTIONS = 1.7 - -# The name of the module. -DOC_MODULE=polkit-gtk-mate-1 - -# The top-level SGML file. -DOC_MAIN_SGML_FILE=polkit-gtk-mate-1-docs.xml - -# Extra options to supply to gtkdoc-scan -SCAN_OPTIONS=--ignore-headers=config.h - -# The directory containing the source code. Relative to $(srcdir) -DOC_SOURCE_DIR=../polkitgtkmate - -# Used for dependencies -HFILE_GLOB=$(top_srcdir)/polkitgtkmate/*.h -CFILE_GLOB=$(top_srcdir)/polkitgtkmate/*.c - -# Headers to ignore -IGNORE_HFILES= \ - $(NULL) - -# CFLAGS and LDFLAGS for compiling scan program. Only needed -# if $(DOC_MODULE).types is non-empty. -AM_CPPFLAGS = \ - $(POLKIT_GOBJECT_CFLAGS) \ - $(GTK_CFLAGS) \ - -I$(top_srcdir)/polkitgtkmate \ - $(NULL) - -GTKDOC_LIBS = \ - $(POLKIT_GOBJECT_LIBS) \ - $(GTK_LIBS) \ - $(top_builddir)/polkitgtkmate/libpolkit-gtk-mate-1.la \ - $(NULL) - -# Extra options to supply to gtkdoc-mkdb -MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=polkit - -# Extra options to supply to gtkdoc-mktmpl -MKTMPL_OPTIONS= - -# Non-autogenerated SGML files to be included in $(DOC_MAIN_SGML_FILE) -content_files = \ - version.xml \ - $(NULL) - -# Images to copy into HTML directory -HTML_IMAGES = \ - polkit-lock-button-locked.png \ - polkit-lock-button-not-authorized.png \ - polkit-lock-button-unlocked.png \ - polkit-lock-button-lock-down.png \ - $(NULL) - -# Extra options to supply to gtkdoc-fixref -FIXXREF_OPTIONS= - -if ENABLE_GTK_DOC -include $(top_srcdir)/gtk-doc.make -else -CLEANFILES = -EXTRA_DIST = $(HTML_IMAGES) -endif - -CLEANFILES += *~ \ - polkit-gtk-mate-1-scan.* \ - polkit-gtk-mate-1.args \ - polkit-gtk-mate-1.hierarchy \ - polkit-gtk-mate-1.interfaces \ - polkit-gtk-mate-1.prerequisites \ - polkit-gtk-mate-1.signals \ - *.bak \ - polkit-gtk-mate-1-decl-list.txt \ - polkit-gtk-mate-1-decl.txt \ - polkit-gtk-mate-1-overrides.txt \ - polkit-gtk-mate-1-undeclared.txt \ - polkit-gtk-mate-1-undocumented.txt \ - *.stamp \ - version.xml \ - -rf html xml \ - $(NULL) - diff --git a/docs/polkit-gtk-mate-1-docs.xml b/docs/polkit-gtk-mate-1-docs.xml deleted file mode 100644 index 5a3257e..0000000 --- a/docs/polkit-gtk-mate-1-docs.xml +++ /dev/null @@ -1,71 +0,0 @@ - - -]> - - - PolicyKit-GTK+ Reference Manual - Version &version; - - - David - Zeuthen - -
- davidz@redhat.com -
-
-
-
- - - 2008-2009 - The PolicyKit Authors - - - - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - - - Many of the names used by companies to distinguish their - products and services are claimed as trademarks. Where those - names appear in any GNOME documentation, and those - trademarks are made aware to the members of the - GNOME Documentation Project, the names have been - printed in caps or initial caps. - - -
- - - API Reference - - - - - - Object Hierarchy - - - - - Index - - -
diff --git a/docs/polkit-lock-button-lock-down.png b/docs/polkit-lock-button-lock-down.png deleted file mode 100644 index 4e383f7..0000000 Binary files a/docs/polkit-lock-button-lock-down.png and /dev/null differ diff --git a/docs/polkit-lock-button-locked.png b/docs/polkit-lock-button-locked.png deleted file mode 100644 index 26d8f83..0000000 Binary files a/docs/polkit-lock-button-locked.png and /dev/null differ diff --git a/docs/polkit-lock-button-not-authorized.png b/docs/polkit-lock-button-not-authorized.png deleted file mode 100644 index 9c33f89..0000000 Binary files a/docs/polkit-lock-button-not-authorized.png and /dev/null differ diff --git a/docs/polkit-lock-button-unlocked.png b/docs/polkit-lock-button-unlocked.png deleted file mode 100644 index 3c5f548..0000000 Binary files a/docs/polkit-lock-button-unlocked.png and /dev/null differ diff --git a/docs/version.xml.in b/docs/version.xml.in deleted file mode 100644 index d78bda9..0000000 --- a/docs/version.xml.in +++ /dev/null @@ -1 +0,0 @@ -@VERSION@ diff --git a/po/POTFILES.in b/po/POTFILES.in index feedb7d..f2b06d0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,7 +1,6 @@ # List of source files containing translatable strings. # Please keep this file sorted alphabetically. [encoding: UTF-8] -polkitgtkmate/polkitlockbutton.c src/main.c src/polkitmateauthenticationdialog.c src/polkitmateauthenticator.c diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 0cec32c..8d0c2fb 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1,2 +1 @@ -polkitgtkmate/example.c src/polkit-mate-authentication-agent-1.desktop.in diff --git a/polkitgtkmate/Makefile.am b/polkitgtkmate/Makefile.am deleted file mode 100644 index 6e6e751..0000000 --- a/polkitgtkmate/Makefile.am +++ /dev/null @@ -1,111 +0,0 @@ - -NULL = - -lib_LTLIBRARIES=libpolkit-gtk-mate-1.la - -libpolkit_gtk_mate_1includedir=$(includedir)/polkit-gtk-mate-1/polkitgtkmate - -libpolkit_gtk_mate_1include_HEADERS = \ - polkitgtkmate.h \ - polkitgtkmatetypes.h \ - polkitlockbutton.h \ - $(NULL) - -libpolkit_gtk_mate_1_la_SOURCES = \ - polkitgtkmate.h \ - polkitgtkmatetypes.h \ - polkitlockbutton.h \ - polkitlockbutton.c \ - $(NULL) - -libpolkit_gtk_mate_1_la_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/polkitgtkmate \ - -I$(top_builddir)/polkitgtkmate \ - -DG_LOG_DOMAIN=\"polkitgtkmate\" \ - -DMATELOCALEDIR=\""$(datadir)/locale"\" \ - $(DISABLE_DEPRECATED) \ - $(AM_CPPFLAGS) \ - -DPOLKIT_GTK_MATE_COMPILATION \ - $(NULL) - -libpolkit_gtk_mate_1_la_CFLAGS = \ - $(POLKIT_GOBJECT_CFLAGS) \ - $(GTK_CFLAGS) \ - $(WARN_CFLAGS) \ - $(AM_CFLAGS) \ - $(NULL) - -libpolkit_gtk_mate_1_la_LIBADD = \ - $(POLKIT_GOBJECT_LIBS) \ - $(GTK_LIBS) \ - $(INTLLIBS) \ - $(NULL) - - -libpolkit_gtk_mate_1_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ - -export-dynamic -no-undefined -export-symbols-regex '(^polkit_.*)' - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = polkit-gtk-mate-1.pc - -if BUILD_EXAMPLES -noinst_PROGRAMS = example - -example_SOURCES = example.c -example_CFLAGS = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(POLKIT_GOBJECT_CFLAGS) \ - $(GTK_CFLAGS) \ - $(WARN_CFLAGS) \ - $(AM_CFLAGS) \ - $(NULL) - -example_LDADD = \ - $(POLKIT_GOBJECT_LIBS) \ - $(GTK_LIBS) \ - $(INTLLIBS) \ - libpolkit-gtk-mate-1.la \ - $(NULL) -endif - -if ENABLE_INTROSPECTION -girdir = $(GIRDIR) -gir_DATA = PolkitGtkMate-1.0.gir - -typelibsdir = $(GIRTYPELIBDIR) -typelibs_DATA = PolkitGtkMate-1.0.typelib - -PolkitGtkMate-1.0.gir: libpolkit-gtk-mate-1.la $(G_IR_SCANNER) Makefile.am - $(G_IR_SCANNER) -v \ - --namespace PolkitGtkMate \ - --strip-prefix=Polkit \ - --nsversion=1.0 \ - --include=Gtk-3.0 \ - --include=Polkit-1.0 \ - --library=polkit-gtk-mate-1 \ - --output $@ \ - --pkg=polkit-gobject-1 \ - --pkg=gtk+-3.0 \ - --pkg-export=polkit-mate-gtk-1 \ - --c-include='polkitgtkmate/polkitgtkmate.h' \ - --libtool=$(top_builddir)/libtool \ - -I$(top_srcdir) \ - -DPOLKIT_GTK_MATE_COMPILATION \ - $(srcdir)/polkitgtkmate.h \ - $(srcdir)/polkitgtkmatetypes.h \ - $(srcdir)/polkitlockbutton.h \ - $(NULL) - -PolkitGtkMate-1.0.typelib: PolkitGtkMate-1.0.gir $(G_IR_COMPILER) - $(G_IR_COMPILER) $< -o $@ - -endif # ENABLE_INTROSPECTION - -CLEANFILES = $(BUILT_SOURCES) $(pkgconfig_DATA) $(gir_DATA) $(typelibs_DATA) - -clean-local : - rm -f *~ $(BUILT_SOURCES) - diff --git a/polkitgtkmate/example.c b/polkitgtkmate/example.c deleted file mode 100644 index 6fc09da..0000000 --- a/polkitgtkmate/example.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: David Zeuthen - */ - -#include - -static PolkitAuthority* authority = NULL; -const gchar* action_id = NULL; -static PolkitSubject* system_bus_name_subject = NULL; -static PolkitSubject* unix_process_subject = NULL; -static GtkWidget* system_bus_name_authorized_label = NULL; -static GtkWidget* unix_process_authorized_label = NULL; - -static void update_one(PolkitSubject* subject, GtkWidget* label) -{ - PolkitAuthorizationResult* result; - GError* error; - GString* s; - gchar* subject_str; - - s = g_string_new(NULL); - subject_str = polkit_subject_to_string(subject); - g_string_append_printf(s, "Result for subject `%s': ", subject_str); - g_free(subject_str); - - error = NULL; - result = polkit_authority_check_authorization_sync(authority, subject, action_id, NULL, POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE, NULL, &error); - - if (result == NULL) - { - g_string_append_printf(s, "failed: %s", error->message); - g_error_free(error); - } - else - { - g_string_append_printf(s, "authorized=%d challenge=%d retains=%d temporary=%d", polkit_authorization_result_get_is_authorized(result), polkit_authorization_result_get_is_challenge(result), polkit_authorization_result_get_retains_authorization(result), polkit_authorization_result_get_temporary_authorization_id(result) != NULL); - g_object_unref(result); - } - - gtk_label_set_text(GTK_LABEL(label), s->str); - g_string_free(s, TRUE); -} - -static void update_labels(void) -{ - update_one(system_bus_name_subject, system_bus_name_authorized_label); - update_one(unix_process_subject, unix_process_authorized_label); -} - -static void on_authority_changed(PolkitAuthority* authority, gpointer user_data) -{ - update_labels(); -} - -static void on_close(PolkitLockButton* button, gpointer user_data) -{ - gtk_main_quit(); -} - -static void on_button_changed(PolkitLockButton* button, gpointer user_data) -{ - GtkWidget* entry = GTK_WIDGET(user_data); - - gtk_widget_set_sensitive(entry, polkit_lock_button_get_is_authorized(button)); -} - -int main(int argc, char* argv[]) -{ - GDBusConnection* bus; - GtkWidget* window; - GtkWidget* label; - GtkWidget* button; - GtkWidget* entry; - GtkWidget* vbox; - GError* error; - gchar* s; - - gtk_init(&argc, &argv); - - if (argc != 2) - { - g_printerr("usage: %s \n", argv[0]); - goto out; - } - - action_id = argv[1]; - - error = NULL; - bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL /* GCancellable* */, &error); - - if (bus == NULL) - { - g_printerr("Failed connecting to system bus: %s\n", error->message); - g_error_free(error); - goto out; - } - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_resizable(GTK_WINDOW(window), TRUE); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); - gtk_container_set_border_width(GTK_CONTAINER(window), 12); - gtk_container_add(GTK_CONTAINER(window), vbox); - - s = g_strdup_printf("Showing PolkitLockButton for action id: %s", action_id); - label = gtk_label_new(s); -#if GTK_CHECK_VERSION (3, 16, 0) - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_yalign (GTK_LABEL (label), 0.5); -#else - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -#endif - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - g_free(s); - - label = gtk_label_new(NULL); -#if GTK_CHECK_VERSION (3, 16, 0) - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_yalign (GTK_LABEL (label), 0.5); -#else - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -#endif - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - system_bus_name_authorized_label = label; - - label = gtk_label_new(NULL); -#if GTK_CHECK_VERSION (3, 16, 0) - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_yalign (GTK_LABEL (label), 0.5); -#else - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -#endif - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - unix_process_authorized_label = label; - - entry = gtk_entry_new(); - gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); - - button = polkit_lock_button_new(action_id); - g_signal_connect(button, "changed", G_CALLBACK(on_button_changed), entry); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - - - system_bus_name_subject = polkit_system_bus_name_new(g_dbus_connection_get_unique_name(bus)); - unix_process_subject = polkit_unix_process_new_for_owner(getpid(), 0, -1); - - error = NULL; - authority = polkit_authority_get_sync(NULL /* GCancellable* */, &error); - - if (authority == NULL) - { - g_printerr("Failed getting the authority: %s\n", error->message); - g_error_free(error); - goto out; - } - - g_debug("backend: name=`%s' version=`%s' features=%d", polkit_authority_get_backend_name(authority), polkit_authority_get_backend_version(authority), polkit_authority_get_backend_features(authority)); - g_signal_connect(authority, "changed", G_CALLBACK(on_authority_changed), NULL); - - update_labels(); - - gtk_widget_set_sensitive(entry, polkit_lock_button_get_is_authorized(POLKIT_LOCK_BUTTON(button))); - - gtk_widget_show_all(window); - gtk_window_present(GTK_WINDOW(window)); - - g_signal_connect(button, "destroy", G_CALLBACK(on_close), NULL); - - gtk_main(); - - out: - return 0; -} diff --git a/polkitgtkmate/polkit-gtk-mate-1.pc.in b/polkitgtkmate/polkit-gtk-mate-1.pc.in deleted file mode 100644 index 152054e..0000000 --- a/polkitgtkmate/polkit-gtk-mate-1.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: polkit-gtk-mate-1 -Description: PolicyKit GTK+ widgets -Version: @VERSION@ -Libs: -L${libdir} -lpolkit-gtk-mate-1 -Cflags: -I${includedir}/polkit-gtk-mate-1 -Requires: polkit-gobject-1 diff --git a/polkitgtkmate/polkitgtkmate.h b/polkitgtkmate/polkitgtkmate.h deleted file mode 100644 index 1fa2dee..0000000 --- a/polkitgtkmate/polkitgtkmate.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: David Zeuthen - */ - -#ifndef __POLKIT_GTK_MATE_H -#define __POLKIT_GTK_MATE_H - -#define _POLKIT_GTK_MATE_INSIDE_POLKIT_GTK_MATE_H 1 - -#include -#include - -#undef _POLKIT_GTK_MATE_INSIDE_POLKIT_GTK_MATE_H - -#endif /* __POLKIT_GTK_MATE_H */ diff --git a/polkitgtkmate/polkitgtkmatetypes.h b/polkitgtkmate/polkitgtkmatetypes.h deleted file mode 100644 index 4bd672d..0000000 --- a/polkitgtkmate/polkitgtkmatetypes.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: David Zeuthen - */ - -#if !defined (_POLKIT_GTK_MATE_INSIDE_POLKIT_GTK_MATE_H) && !defined (POLKIT_GTK_MATE_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents." -#endif - -#ifndef __POLKIT_GTK_MATE_TYPES_H -#define __POLKIT_GTK_MATE_TYPES_H - -#include -#include - -struct _PolkitLockButton; -typedef struct _PolkitLockButton PolkitLockButton; - -#endif /* __POLKIT_GTK_MATE_TYPES_H */ diff --git a/polkitgtkmate/polkitlockbutton.c b/polkitgtkmate/polkitlockbutton.c deleted file mode 100644 index 1b15cbe..0000000 --- a/polkitgtkmate/polkitlockbutton.c +++ /dev/null @@ -1,1200 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: David Zeuthen - */ - -#include "config.h" - -#include -#include -#include - -#include "polkitlockbutton.h" - -/** - * SECTION:polkitlockbutton - * @title: PolkitLockButton - * @short_description: Widget for obtaining/revoking authorizations - * @stability: Stable - * - * #PolkitLockButton is a widget that can be used in control panels to - * allow users to obtain and revoke authorizations needed for the - * control panel UI to function. - * - * If the user lacks the authorization but authorization can be - * obtained through authentication, the widget looks like this - * - * - * - * - * - * and the user can click the button to obtain the authorization. This - * will pop up an authentication dialog. - * Once authorization is obtained, the widget changes to this - * - * - * - * - * - * and the authorization can be dropped by clicking the button. - * If the user is not able to obtain authorization at all, the widget - * looks like this - * - * - * - * - * - * If the user is authorized (either implicitly via the .policy file - * defaults or through e.g. Local Authority configuration) and no - * authentication is necessary and the Authority Implementation - * supports lock-down, the widget looks like this - * - * - * - * - * - * allowing the user to lock down the action. The lockdown can be - * removed by right clicking the button - the user can discover this - * through the tooltip. If the Authority implementation does not - * support lockdown, the widget will be hidden. - * - * Finally, if the user is not authorized but authorization can be - * obtained and the obtained authorization will be a one-shot - * authorization, the widget will be hidden. This means that any - * attempt to use the Mechanism that requires authorization for the - * specified action will always prompt for authentication. This - * condition happens exactly when - * (!polkit_lock_button_get_is_authorized() && - * polkit_lock_button_get_can_obtain() && - * !polkit_lock_button_get_is_visible()) is %TRUE. - * - * Typically #PolkitLockButton is only useful for actions where - * authorization is obtained through authentication (and retained) or - * where users are implictly authorized (cf. the defaults specified in - * the .policy file for the action) but note that - * this behavior can be overridden by the Authority implementation. - * - * The typical usage of this widget is like this: - * - * static void - * update_sensitivity_according_to_lock_button (FooBar *bar) - * { - * gboolean make_sensitive; - * - * make_sensitive = FALSE; - * if (polkit_lock_button_get_is_authorized (POLKIT_LOCK_BUTTON (bar->priv->lock_button))) - * { - * make_sensitive = TRUE; - * } - * else - * { - * /* Catch the case where authorization is one-shot - this means - * * an authentication dialog will be shown every time a widget the user - * * manipulates calls into the Mechanism. - * */ - * if (polkit_lock_button_get_can_obtain (POLKIT_LOCK_BUTTON (bar->priv->lock_button)) && - * !polkit_lock_button_get_is_visible (POLKIT_LOCK_BUTTON (bar->priv->lock_button))) - * make_sensitive = TRUE; - * } - * - * - * /* Make all widgets relying on authorization sensitive according to - * * the value of make_sensitive. - * */ - * } - * - * static void - * on_lock_button_changed (PolkitLockButton *button, - * gpointer user_data) - * { - * FooBar *bar = FOO_BAR (user_data); - * - * update_sensitivity_according_to_lock_button (bar); - * } - * - * static void - * foo_bar_init (FooBar *bar) - * { - * /* Construct other widgets */ - * - * bar->priv->lock_button = polkit_lock_button_new ("org.project.mechanism.action-name"); - * g_signal_connect (bar->priv->lock_button, - * "changed", - * G_CALLBACK (on_lock_button_changed), - * bar); - * update_sensitity_according_to_lock_button (bar); - * - * /* Pack bar->priv->lock_button into widget hierarchy */ - * } - * - */ - -struct _PolkitLockButtonPrivate { - PolkitAuthority* authority; - PolkitSubject* subject; - gchar* action_id; - - gchar* text_unlock; - gchar* text_lock; - gchar* text_lock_down; - gchar* text_not_authorized; - - gchar* tooltip_unlock; - gchar* tooltip_lock; - gchar* tooltip_lock_down; - gchar* tooltip_not_authorized; - - GtkWidget* button; - GtkWidget* label; - - gboolean can_obtain; - gboolean retains_after_challenge; - gboolean authorized; - gboolean hidden; - - /* is non-NULL exactly when we are authorized and have a temporary authorization */ - gchar* tmp_authz_id; - - /* This is non-NULL exactly when we have a non-interactive check outstanding */ - GCancellable* check_cancellable; - - /* This is non-NULL exactly when we have an interactive check outstanding */ - GCancellable* interactive_check_cancellable; -}; - -enum{ - PROP_0, - PROP_ACTION_ID, - PROP_IS_AUTHORIZED, - PROP_IS_VISIBLE, - PROP_CAN_OBTAIN, - PROP_TEXT_UNLOCK, - PROP_TEXT_LOCK, - PROP_TEXT_LOCK_DOWN, - PROP_TEXT_NOT_AUTHORIZED, - PROP_TOOLTIP_UNLOCK, - PROP_TOOLTIP_LOCK, - PROP_TOOLTIP_LOCK_DOWN, - PROP_TOOLTIP_NOT_AUTHORIZED, -}; - -enum { - CHANGED_SIGNAL, - LAST_SIGNAL, -}; - -static guint signals[LAST_SIGNAL] = {0, }; - -static void initiate_check(PolkitLockButton* button); -static void do_sync_check(PolkitLockButton* button); -static void update_state(PolkitLockButton* button); - -static void on_authority_changed(PolkitAuthority* authority, gpointer user_data); - -static void on_clicked(GtkButton* button, gpointer user_data); - -G_DEFINE_TYPE(PolkitLockButton, polkit_lock_button, GTK_TYPE_BOX); - -static void polkit_lock_button_finalize(GObject* object) -{ - PolkitLockButton *button = POLKIT_LOCK_BUTTON(object); - - g_free(button->priv->action_id); - g_free(button->priv->tmp_authz_id); - g_object_unref(button->priv->subject); - - if (button->priv->check_cancellable != NULL) - { - g_cancellable_cancel(button->priv->check_cancellable); - g_object_unref(button->priv->check_cancellable); - } - - if (button->priv->interactive_check_cancellable != NULL) - { - g_cancellable_cancel(button->priv->interactive_check_cancellable); - g_object_unref(button->priv->interactive_check_cancellable); - } - - g_signal_handlers_disconnect_by_func(button->priv->authority, on_authority_changed, button); - g_object_unref(button->priv->authority); - - if (G_OBJECT_CLASS(polkit_lock_button_parent_class)->finalize != NULL) - { - G_OBJECT_CLASS(polkit_lock_button_parent_class)->finalize(object); - } -} - -static void -polkit_lock_button_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - PolkitLockButton *button = POLKIT_LOCK_BUTTON (object); - - switch (property_id) - { - case PROP_ACTION_ID: - g_value_set_string (value, button->priv->action_id); - break; - - case PROP_IS_AUTHORIZED: - g_value_set_boolean (value, button->priv->authorized); - break; - - case PROP_IS_VISIBLE: - g_value_set_boolean (value, !button->priv->hidden); - break; - - case PROP_CAN_OBTAIN: - g_value_set_boolean (value, button->priv->can_obtain); - break; - - case PROP_TEXT_UNLOCK: - g_value_set_string (value, button->priv->text_unlock); - break; - - case PROP_TEXT_LOCK: - g_value_set_string (value, button->priv->text_lock); - break; - - case PROP_TEXT_LOCK_DOWN: - g_value_set_string (value, button->priv->text_lock_down); - break; - - case PROP_TEXT_NOT_AUTHORIZED: - g_value_set_string (value, button->priv->text_not_authorized); - break; - - case PROP_TOOLTIP_UNLOCK: - g_value_set_string (value, button->priv->tooltip_unlock); - break; - - case PROP_TOOLTIP_LOCK: - g_value_set_string (value, button->priv->tooltip_lock); - break; - - case PROP_TOOLTIP_LOCK_DOWN: - g_value_set_string (value, button->priv->tooltip_lock_down); - break; - - case PROP_TOOLTIP_NOT_AUTHORIZED: - g_value_set_string (value, button->priv->tooltip_not_authorized); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -polkit_lock_button_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - PolkitLockButton *button = POLKIT_LOCK_BUTTON (object); - - switch (property_id) - { - case PROP_ACTION_ID: - button->priv->action_id = g_value_dup_string (value); - break; - - case PROP_TEXT_UNLOCK: - polkit_lock_button_set_unlock_text (button, g_value_get_string (value)); - break; - - case PROP_TEXT_LOCK: - polkit_lock_button_set_lock_text (button, g_value_get_string (value)); - break; - - case PROP_TEXT_LOCK_DOWN: - polkit_lock_button_set_lock_down_text (button, g_value_get_string (value)); - break; - - case PROP_TEXT_NOT_AUTHORIZED: - polkit_lock_button_set_not_authorized_text (button, g_value_get_string (value)); - break; - - case PROP_TOOLTIP_UNLOCK: - polkit_lock_button_set_unlock_tooltip (button, g_value_get_string (value)); - break; - - case PROP_TOOLTIP_LOCK: - polkit_lock_button_set_lock_tooltip (button, g_value_get_string (value)); - break; - - case PROP_TOOLTIP_LOCK_DOWN: - polkit_lock_button_set_lock_down_tooltip (button, g_value_get_string (value)); - break; - - case PROP_TOOLTIP_NOT_AUTHORIZED: - polkit_lock_button_set_not_authorized_tooltip (button, g_value_get_string (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - - -static void -polkit_lock_button_init (PolkitLockButton *button) -{ - button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - POLKIT_TYPE_LOCK_BUTTON, - PolkitLockButtonPrivate); - -} - -static void -polkit_lock_button_constructed (GObject *object) -{ - PolkitLockButton *button = POLKIT_LOCK_BUTTON (object); - GError *error; - - gtk_box_set_spacing (GTK_BOX (button), 2); - - /* TODO: should be async+failable (e.g. GAsyncInitable) instead of this */ - error = NULL; - button->priv->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error); - if (button->priv->authority == NULL) - { - g_critical ("Error getting authority: %s", error->message); - g_error_free (error); - } - g_signal_connect (button->priv->authority, - "changed", - G_CALLBACK (on_authority_changed), - button); - - button->priv->button = gtk_button_new (); - gtk_button_set_relief (GTK_BUTTON (button->priv->button), GTK_RELIEF_NONE); - /* image is set in update_state() */ - g_signal_connect (button->priv->button, - "clicked", - G_CALLBACK (on_clicked), - button); - - gtk_box_pack_start (GTK_BOX (button), - button->priv->button, - FALSE, - FALSE, - 0); - - button->priv->label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (button), - button->priv->label, - FALSE, - FALSE, - 0); - - /* take control of visibility of child widgets */ - gtk_widget_set_no_show_all (button->priv->button, TRUE); - gtk_widget_set_no_show_all (button->priv->label, TRUE); - - if (button->priv->subject == NULL) - { - button->priv->subject = polkit_unix_process_new_for_owner (getpid (), 0, -1); - } - - /* synchronously check on construction - TODO: we could implement GAsyncInitable - * in the future to avoid this sync check - */ - do_sync_check (button); - - update_state (button); - - if (G_OBJECT_CLASS (polkit_lock_button_parent_class)->constructed != NULL) - G_OBJECT_CLASS (polkit_lock_button_parent_class)->constructed (object); -} - -static void -polkit_lock_button_class_init (PolkitLockButtonClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->finalize = polkit_lock_button_finalize; - gobject_class->get_property = polkit_lock_button_get_property; - gobject_class->set_property = polkit_lock_button_set_property; - gobject_class->constructed = polkit_lock_button_constructed; - - g_type_class_add_private (klass, sizeof (PolkitLockButtonPrivate)); - - /** - * PolkitLockButton:action-id: - * - * The action identifier to use for the button. - */ - g_object_class_install_property (gobject_class, - PROP_ACTION_ID, - g_param_spec_string ("action-id", - _("Action Identifier"), - _("The action identifier to use for the button"), - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:is-authorized: - * - * Whether the process is authorized. - */ - g_object_class_install_property (gobject_class, - PROP_IS_AUTHORIZED, - g_param_spec_boolean ("is-authorized", - _("Is Authorized"), - _("Whether the process is authorized"), - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:is-visible: - * - * Whether the widget is visible. - */ - g_object_class_install_property (gobject_class, - PROP_IS_VISIBLE, - g_param_spec_boolean ("is-visible", - _("Is Visible"), - _("Whether the widget is visible"), - TRUE, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:can-obtain: - * - * Whether authorization can be obtained. - */ - g_object_class_install_property (gobject_class, - PROP_CAN_OBTAIN, - g_param_spec_boolean ("can-obtain", - _("Can Obtain"), - _("Whether authorization can be obtained"), - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:text-unlock: - * - * The text to display when prompting the user to unlock. - */ - g_object_class_install_property (gobject_class, - PROP_TEXT_UNLOCK, - g_param_spec_string ("text-unlock", - _("Unlock Text"), - _("The text to display when prompting the user to unlock."), - _("Click to make changes"), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:tooltip-unlock: - * - * The tooltip to display when prompting the user to unlock. - */ - g_object_class_install_property (gobject_class, - PROP_TOOLTIP_UNLOCK, - g_param_spec_string ("tooltip-unlock", - _("Unlock Tooltip"), - _("The tooltip to display when prompting the user to unlock."), - _("Authentication is needed to make changes."), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:text-lock: - * - * The text to display when prompting the user to lock. - */ - g_object_class_install_property (gobject_class, - PROP_TEXT_LOCK, - g_param_spec_string ("text-lock", - _("Lock Text"), - _("The text to display when prompting the user to lock."), - _("Click to prevent changes"), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:tooltip-lock: - * - * The tooltip to display when prompting the user to lock. - */ - g_object_class_install_property (gobject_class, - PROP_TOOLTIP_LOCK, - g_param_spec_string ("tooltip-lock", - _("Lock Tooltip"), - _("The tooltip to display when prompting the user to lock."), - _("To prevent further changes, click the lock."), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:text-lock-down: - * - * The text to display when prompting the user to lock down the action for all users. - */ - g_object_class_install_property (gobject_class, - PROP_TEXT_LOCK_DOWN, - g_param_spec_string ("text-lock-down", - _("Lock Down Text"), - _("The text to display when prompting the user to lock down the action for all users."), - _("Click to lock down"), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:tooltip-lock-down: - * - * The tooltip to display when prompting the user to lock down the action for all users. - */ - g_object_class_install_property (gobject_class, - PROP_TOOLTIP_LOCK_DOWN, - g_param_spec_string ("tooltip-lock-down", - _("Lock Down Tooltip"), - _("The tooltip to display when prompting the user to lock down the action for all users."), - _("To prevent users without administrative privileges from making changes, click the lock."), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:text-not-authorized: - * - * The text to display when the user cannot obtain authorization through authentication. - */ - g_object_class_install_property (gobject_class, - PROP_TEXT_NOT_AUTHORIZED, - g_param_spec_string ("text-not-authorized", - _("Unlock Text"), - _("The text to display when the user cannot obtain authorization through authentication."), - _("Not authorized to make changes"), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton:tooltip-not-authorized: - * - * The tooltip to display when the user cannot obtain authorization through authentication. - */ - g_object_class_install_property (gobject_class, - PROP_TOOLTIP_NOT_AUTHORIZED, - g_param_spec_string ("tooltip-not-authorized", - _("Unlock Tooltip"), - _("The tooltip to display when the user cannot obtain authorization through authentication."), - _("System policy prevents changes. Contact your system administator."), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); - - /** - * PolkitLockButton::changed: - * @button: A #PolkitLockButton. - * - * Emitted when something on @button changes. - */ - signals[CHANGED_SIGNAL] = g_signal_new ("changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (PolkitLockButtonClass, changed), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - -} - -/** - * polkit_lock_button_new: - * @action_id: An action identifer. - * - * Constructs a #PolkitLockButton for @action_id. - * - * Returns: A #PolkitLockButton. - */ -GtkWidget * -polkit_lock_button_new (const gchar *action_id) -{ - g_return_val_if_fail (action_id != NULL, NULL); - - return GTK_WIDGET (g_object_new (POLKIT_TYPE_LOCK_BUTTON, - "action-id", action_id, - NULL)); -} - -static void -update_state (PolkitLockButton *button) -{ - const gchar *text = NULL; - const gchar *tooltip = NULL; - gboolean sensitive = FALSE; - gboolean old_hidden; - GtkWidget *image; - - old_hidden = button->priv->hidden; - button->priv->hidden = FALSE; - - if (button->priv->authorized) - { - text = button->priv->text_lock; - tooltip = button->priv->tooltip_lock; - sensitive = TRUE; - /* if the authorization isn't temporary => ask if user wants to lock the authorization down the - * authority we're using has that capability - */ - if (button->priv->tmp_authz_id == NULL) - { - //button->priv->hidden = TRUE; - } - } - else - { - if (button->priv->can_obtain && button->priv->retains_after_challenge) - { - /* can retain and obtain authorization => show the unlock button */ - text = button->priv->text_unlock; - tooltip = button->priv->tooltip_unlock; - g_free (button->priv->tmp_authz_id); - button->priv->tmp_authz_id = NULL; - sensitive = TRUE; - } - else - { - if (button->priv->can_obtain) - { - /* we can obtain authorization, we just can't retain it => hidden */ - button->priv->hidden = TRUE; - } - else - { - /* cannot even obtain authorization => tell user he can't have a pony */ - text = button->priv->text_not_authorized; - tooltip = button->priv->tooltip_not_authorized; - g_free (button->priv->tmp_authz_id); - button->priv->tmp_authz_id = NULL; - sensitive = FALSE; - } - } - } - - image = gtk_image_new_from_icon_name (button->priv->authorized ? "changes-allow" : "changes-prevent", - GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_button_set_image (GTK_BUTTON (button->priv->button), image); - - if (text != NULL) - { - gtk_label_set_text (GTK_LABEL (button->priv->label), text); - } - - gtk_widget_set_sensitive (button->priv->button, sensitive); - - if (tooltip != NULL) - { - gtk_widget_set_tooltip_markup (GTK_WIDGET (button->priv->label), tooltip); - gtk_widget_set_tooltip_markup (GTK_WIDGET (button->priv->button), tooltip); - } - - if (button->priv->hidden) - { - gtk_widget_hide (button->priv->button); - gtk_widget_hide (button->priv->label); - } - else - { - gtk_widget_show (button->priv->button); - gtk_widget_show (button->priv->label); - } - - if (old_hidden != button->priv->hidden) - g_object_notify (G_OBJECT (button), "is-visible"); -} - -static void -on_authority_changed (PolkitAuthority *authority, - gpointer user_data) -{ - PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data); - initiate_check (button); -} - -static void -process_result (PolkitLockButton *button, - PolkitAuthorizationResult *result) -{ - gboolean old_can_obtain; - gboolean old_authorized; - - old_can_obtain = button->priv->can_obtain; - old_authorized = button->priv->authorized; - button->priv->can_obtain = polkit_authorization_result_get_is_challenge (result); - button->priv->authorized = polkit_authorization_result_get_is_authorized (result); - - /* save the temporary authorization id */ - g_free (button->priv->tmp_authz_id); - button->priv->tmp_authz_id = g_strdup (polkit_authorization_result_get_temporary_authorization_id (result)); - button->priv->retains_after_challenge = polkit_authorization_result_get_retains_authorization (result); - - update_state (button); - - if (old_can_obtain != button->priv->can_obtain || - old_authorized != button->priv->authorized) - { - g_signal_emit (button, - signals[CHANGED_SIGNAL], - 0); - } - - if (old_can_obtain != button->priv->can_obtain) - g_object_notify (G_OBJECT (button), "can-obtain"); - - if (old_authorized != button->priv->authorized) - g_object_notify (G_OBJECT (button), "is-authorized"); -} - -static void -check_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - PolkitAuthority *authority = POLKIT_AUTHORITY (source_object); - PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data); - PolkitAuthorizationResult *result; - GError *error; - - error = NULL; - result = polkit_authority_check_authorization_finish (authority, - res, - &error); - if (error != NULL) - { - g_warning ("Error checking authorization for action id `%s': %s", - button->priv->action_id, - error->message); - g_error_free (error); - } - else - { - process_result (button, result); - } - - if (result != NULL) - g_object_unref (result); - - if (button->priv->check_cancellable != NULL) - { - g_object_unref (button->priv->check_cancellable); - button->priv->check_cancellable = NULL; - } -} - -static void -initiate_check (PolkitLockButton *button) -{ - - /* if we have a check pending already, then do nothing */ - if (button->priv->check_cancellable != NULL) - goto out; - - button->priv->check_cancellable = g_cancellable_new (); - - polkit_authority_check_authorization (button->priv->authority, - button->priv->subject, - button->priv->action_id, - NULL, /* PolkitDetails */ - POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE, - button->priv->check_cancellable, - check_cb, - button); - - out: - ; -} - -static void -do_sync_check (PolkitLockButton *button) -{ - - GError *error; - PolkitAuthorizationResult *result; - - error = NULL; - result = polkit_authority_check_authorization_sync (button->priv->authority, - button->priv->subject, - button->priv->action_id, - NULL, /* PolkitDetails */ - POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE, - NULL, /* cancellable */ - &error); - if (error != NULL) - { - g_warning ("Error sync-checking authorization for action id `%s': %s", - button->priv->action_id, - error->message); - g_error_free (error); - } - else - { - process_result (button, result); - } - - if (result != NULL) - g_object_unref (result); -} - -static void -interactive_check_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - - PolkitAuthority *authority = POLKIT_AUTHORITY (source_object); - PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data); - PolkitAuthorizationResult *result; - PolkitDetails *details; - GError *error; - - error = NULL; - result = polkit_authority_check_authorization_finish (authority, - res, - &error); - if (error != NULL) - { - g_warning ("Error obtaining authorization for action id `%s': %s", - button->priv->action_id, - error->message); - g_error_free (error); - goto out; - } - - /* state is updated in the ::changed signal handler */ - - /* save the temporary authorization id */ - details = polkit_authorization_result_get_details (result); - if (details != NULL) - { - button->priv->tmp_authz_id = g_strdup (polkit_details_lookup (details, - "polkit.temporary_authorization_id")); - } - - out: - if (result != NULL) - g_object_unref (result); - - if (button->priv->interactive_check_cancellable != NULL) - { - g_object_unref (button->priv->interactive_check_cancellable); - button->priv->interactive_check_cancellable = NULL; - } -} - - -static void on_clicked(GtkButton* _button, gpointer user_data) -{ - - PolkitLockButton* button = POLKIT_LOCK_BUTTON(user_data); - - if (!button->priv->authorized && button->priv->can_obtain) - { - - /* if we already have a pending interactive check, then do nothing */ - if (button->priv->interactive_check_cancellable != NULL) - { - goto out; - } - - button->priv->interactive_check_cancellable = g_cancellable_new(); - - polkit_authority_check_authorization(button->priv->authority, button->priv->subject, button->priv->action_id, NULL, /* PolkitDetails */ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, button->priv->interactive_check_cancellable, interactive_check_cb, button); - } - else if (button->priv->authorized && button->priv->tmp_authz_id != NULL) - { - polkit_authority_revoke_temporary_authorization_by_id (button->priv->authority, button->priv->tmp_authz_id, /* cancellable */ NULL, /* callback */ NULL, /* user_data */ NULL); - } - - out: - - update_state(button); -} - -/** - * polkit_lock_button_get_is_authorized: - * @button: A #PolkitLockButton. - * - * Gets whether the process is authorized. - * - * Returns: %TRUE if authorized. - */ -gboolean polkit_lock_button_get_is_authorized(PolkitLockButton* button) -{ - g_return_val_if_fail(POLKIT_IS_LOCK_BUTTON(button), FALSE); - return button->priv->authorized; -} - -/** - * polkit_lock_button_get_can_obtain: - * @button: A #PolkitLockButton. - * - * Gets whether the user can obtain an authorization through - * authentication. - * - * Returns: Whether the authorization is obtainable. - */ -gboolean polkit_lock_button_get_can_obtain(PolkitLockButton* button) -{ - g_return_val_if_fail(POLKIT_IS_LOCK_BUTTON(button), FALSE); - return button->priv->can_obtain; -} - -/** - * polkit_lock_button_get_is_visible: - * @button: A #PolkitLockButton. - * - * Gets whether @button is currently being shown. - * - * Returns: %TRUE if @button has any visible UI elements. - */ -gboolean polkit_lock_button_get_is_visible(PolkitLockButton* button) -{ - g_return_val_if_fail(POLKIT_IS_LOCK_BUTTON(button), FALSE); - return !button->priv->hidden; -} - -/** - * polkit_lock_button_set_unlock_text: - * @button: A #PolkitLockButton. - * @text: The text to set. - * - * Makes @button display @text when not authorized and clicking the button will obtain the authorization. - */ -void polkit_lock_button_set_unlock_text(PolkitLockButton* button, const gchar* text) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(text != NULL); - - if (button->priv->text_unlock != NULL) - { - button->priv->text_unlock = g_strdup(text); - update_state(button); - } - else - { - button->priv->text_unlock = g_strdup(text); - } -} - -/** - * polkit_lock_button_set_lock_text: - * @button: A #PolkitLockButton. - * @text: The text to set. - * - * Makes @button display @text when authorized and clicking the button will revoke the authorization. - */ -void polkit_lock_button_set_lock_text(PolkitLockButton* button, const gchar* text) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(text != NULL); - - if (button->priv->text_lock != NULL) - { - button->priv->text_lock = g_strdup(text); - update_state(button); - } - else - { - button->priv->text_lock = g_strdup(text); - } -} - -/** - * polkit_lock_button_set_lock_down_text: - * @button: A #PolkitLockButton. - * @text: The text to set. - * - * Makes @button display @text when authorized and it is possible to lock down the action. - */ -void polkit_lock_button_set_lock_down_text(PolkitLockButton* button, const gchar* text) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(text != NULL); - - if (button->priv->text_lock_down != NULL) - { - button->priv->text_lock_down = g_strdup(text); - update_state(button); - } - else - { - button->priv->text_lock_down = g_strdup(text); - } -} - -/** - * polkit_lock_button_set_not_authorized_text: - * @button: A #PolkitLockButton. - * @text: The text to set. - * - * Makes @button display @text when an authorization cannot be obtained. - */ -void polkit_lock_button_set_not_authorized_text(PolkitLockButton* button, const gchar* text) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(text != NULL); - - if (button->priv->text_not_authorized != NULL) - { - button->priv->text_not_authorized = g_strdup(text); - update_state(button); - } - else - { - button->priv->text_not_authorized = g_strdup(text); - } -} - - -/** - * polkit_lock_button_set_unlock_tooltip: - * @button: A #PolkitLockButton. - * @tooltip: The text of the tooltip. - * - * Makes @button display @tooltip when not authorized and clicking the button will obtain the authorization. - */ -void polkit_lock_button_set_unlock_tooltip(PolkitLockButton* button, const gchar* tooltip) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(tooltip != NULL); - - if (button->priv->tooltip_unlock != NULL) - { - button->priv->tooltip_unlock = g_strdup(tooltip); - update_state(button); - } - else - { - button->priv->tooltip_unlock = g_strdup(tooltip); - } -} - -/** - * polkit_lock_button_set_lock_tooltip: - * @button: A #PolkitLockButton. - * @tooltip: The text of the tooltip. - * - * Makes @button display @tooltip when authorized and clicking the button will revoke the authorization. - */ -void polkit_lock_button_set_lock_tooltip(PolkitLockButton* button, const gchar* tooltip) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(tooltip != NULL); - - if (button->priv->tooltip_lock != NULL) - { - button->priv->tooltip_lock = g_strdup(tooltip); - update_state (button); - } - else - { - button->priv->tooltip_lock = g_strdup(tooltip); - } -} - -/** - * polkit_lock_button_set_lock_down_tooltip: - * @button: A #PolkitLockButton. - * @tooltip: The text of the tooltip. - * - * Makes @button display @tooltip when authorized and it is possible to lock down the action. - */ -void polkit_lock_button_set_lock_down_tooltip(PolkitLockButton* button, const gchar* tooltip) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(tooltip != NULL); - - if (button->priv->tooltip_lock_down != NULL) - { - button->priv->tooltip_lock_down = g_strdup(tooltip); - update_state(button); - } - else - { - button->priv->tooltip_lock_down = g_strdup(tooltip); - } -} - -/** - * polkit_lock_button_set_not_authorized_tooltip: - * @button: A #PolkitLockButton. - * @tooltip: The text of the tooltip. - * - * Makes @button display @tooltip when an authorization cannot be obtained. - */ -void polkit_lock_button_set_not_authorized_tooltip(PolkitLockButton* button, const gchar* tooltip) -{ - g_return_if_fail(POLKIT_IS_LOCK_BUTTON(button)); - g_return_if_fail(tooltip != NULL); - - if (button->priv->tooltip_not_authorized != NULL) - { - button->priv->tooltip_not_authorized = g_strdup(tooltip); - update_state(button); - } - else - { - button->priv->tooltip_not_authorized = g_strdup(tooltip); - } -} diff --git a/polkitgtkmate/polkitlockbutton.h b/polkitgtkmate/polkitlockbutton.h deleted file mode 100644 index 4360815..0000000 --- a/polkitgtkmate/polkitlockbutton.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: David Zeuthen - */ - -#if !defined(_POLKIT_GTK_MATE_INSIDE_POLKIT_GTK_MATE_H) && !defined(POLKIT_GTK_MATE_COMPILATION) - #error "Only can be included directly, this file may disappear or change contents." -#endif - -#ifndef POLKIT_LOCK_BUTTON_H -#define POLKIT_LOCK_BUTTON_H - -#include - -#define POLKIT_TYPE_LOCK_BUTTON \ - (polkit_lock_button_get_type()) - -#define POLKIT_LOCK_BUTTON(o) \ - (G_TYPE_CHECK_INSTANCE_CAST((o), POLKIT_TYPE_LOCK_BUTTON, PolkitLockButton)) - -#define POLKIT_LOCK_BUTTON_CLASS(k) \ - (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_LOCK_BUTTON, PolkitLockButtonClass)) - -#define POLKIT_IS_LOCK_BUTTON(o) \ - (G_TYPE_CHECK_INSTANCE_TYPE((o), POLKIT_TYPE_LOCK_BUTTON)) - -#define POLKIT_IS_LOCK_BUTTON_CLASS(k) \ - (G_TYPE_CHECK_CLASS_TYPE((k), POLKIT_TYPE_LOCK_BUTTON)) - -#define POLKIT_LOCK_BUTTON_GET_CLASS(o) \ - (G_TYPE_INSTANCE_GET_CLASS((o), POLKIT_TYPE_LOCK_BUTTON, PolkitLockButtonClass)) - -typedef struct _PolkitLockButtonClass PolkitLockButtonClass; -typedef struct _PolkitLockButtonPrivate PolkitLockButtonPrivate; - -/** - * PolkitLockButton: - * @parent: The parent instance. - * - * The #PolkitLockButton structure contains only private data and - * should be accessed using the provided API. - */ -struct _PolkitLockButton { - GtkBox parent; - - /*< private >*/ - PolkitLockButtonPrivate* priv; -}; - -/** - * PolkitLockButtonClass: - * @parent_class: The parent class structure. - * @changed: Signal class handler for the #PolkitLockButton::changed signal. - * - * Class structure for #PolkitLockButton. - */ -struct _PolkitLockButtonClass { - GtkBoxClass parent_class; - - /* Signals */ - void (*changed)(PolkitLockButton* button); - - /*< private >*/ - /* Padding for future expansion */ - void (*_polkit_reserved0)(void); - void (*_polkit_reserved1)(void); - void (*_polkit_reserved2)(void); - void (*_polkit_reserved3)(void); - void (*_polkit_reserved4)(void); - void (*_polkit_reserved5)(void); - void (*_polkit_reserved6)(void); - void (*_polkit_reserved7)(void); - void (*_polkit_reserved8)(void); - void (*_polkit_reserved9)(void); - void (*_polkit_reserved10)(void); - void (*_polkit_reserved11)(void); - void (*_polkit_reserved12)(void); - void (*_polkit_reserved13)(void); - void (*_polkit_reserved14)(void); - void (*_polkit_reserved15)(void); -}; - - -GType polkit_lock_button_get_type(void) G_GNUC_CONST; -GtkWidget* polkit_lock_button_new(const gchar* action_id); -gboolean polkit_lock_button_get_is_authorized(PolkitLockButton* button); -gboolean polkit_lock_button_get_is_visible(PolkitLockButton* button); -gboolean polkit_lock_button_get_can_obtain(PolkitLockButton* button); - -void polkit_lock_button_set_unlock_text(PolkitLockButton* button, const gchar* text); -void polkit_lock_button_set_unlock_tooltip(PolkitLockButton* button, const gchar* tooltip); - -void polkit_lock_button_set_lock_text(PolkitLockButton* button, const gchar* text); -void polkit_lock_button_set_lock_tooltip(PolkitLockButton* button, const gchar* tooltip); - -void polkit_lock_button_set_lock_down_text(PolkitLockButton* button, const gchar* text); -void polkit_lock_button_set_lock_down_tooltip(PolkitLockButton* button, const gchar* tooltip); - -void polkit_lock_button_set_not_authorized_text(PolkitLockButton* button, const gchar* text); -void polkit_lock_button_set_not_authorized_tooltip(PolkitLockButton* button, const gchar* tooltip); - -#endif /* POLKIT_LOCK_BUTTON_H */ -- cgit v1.2.1