kov changed libgksu/trunk/ChangeLog, libgksu/trunk/Makefile.am, libgksu/trunk/configure.ac, libgksu/trunk/gksu-properties/, libgksu/trunk/gksu-properties/Makefile.am, libgksu/trunk/gksu-properties/gksu-properties.c, libgksu/trunk/gksu-properties/gksu-properties.glade, libgksu/trunk/libgksu/defines.h

Gustavo Noronha kov at costa.debian.org
Fri Jun 30 01:38:36 UTC 2006


Mensagem de log: 
wrote a first implementation of gksu-properties capplet


-----


Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog	2006-06-27 00:41:47 UTC (rev 636)
+++ libgksu/trunk/ChangeLog	2006-06-30 01:38:34 UTC (rev 637)
@@ -1,3 +1,12 @@
+2006-06-29  Gustavo Noronha Silva  <kov at debian.org>
+
+	* gksu-properties/*:
+	- start a simple capplet to configure the gksu gconf
+	  preferences
+
+	* libgksu/defines.h:
+	- small adaption so it can better be used by gksu-properties
+
 2006-06-26  Gustavo Noronha Silva  <kov at debian.org>
 
 	* Release 1.9.4

Modified: libgksu/trunk/Makefile.am
===================================================================
--- libgksu/trunk/Makefile.am	2006-06-27 00:41:47 UTC (rev 636)
+++ libgksu/trunk/Makefile.am	2006-06-30 01:38:34 UTC (rev 637)
@@ -2,7 +2,7 @@
 
 DISTCLEANFILES = *~ intltool-extract intltool-merge intltool-update gksu.schemas
 
-SUBDIRS = po libgksuui libgksu docs
+SUBDIRS = po libgksuui libgksu gksu-properties docs
 DIST_SUBDIRS = $(SUBDIRS)
 
 schemasdir       = $(GCONF_SCHEMA_FILE_DIR)

Modified: libgksu/trunk/configure.ac
===================================================================
--- libgksu/trunk/configure.ac	2006-06-27 00:41:47 UTC (rev 636)
+++ libgksu/trunk/configure.ac	2006-06-30 01:38:34 UTC (rev 637)
@@ -41,6 +41,7 @@
 AM_GCONF_SOURCE_2
 
 PKG_CHECK_MODULES(LIBGKSU, [gtk+-2.0 >= 2.4.0, gconf-2.0, libstartup-notification-1.0, gnome-keyring-1, libgtop-2.0])
+PKG_CHECK_MODULES(GKSU_PROPERTIES, [gtk+-2.0 >= 2.4.0, gconf-2.0, libglade-2.0])
 
 # Checks for library functions.
 ALL_LINGUAS="ca cs da de es eu fr hu pl pt_BR ro ru sk nb nl"
@@ -89,6 +90,7 @@
 	libgksu/Makefile
 	libgksu/libgksu2.pc
 	libgksuui/Makefile
+	gksu-properties/Makefile
 	docs/Makefile
 	])
 AC_OUTPUT

Added: libgksu/trunk/gksu-properties/Makefile.am
===================================================================
--- libgksu/trunk/gksu-properties/Makefile.am	2006-06-27 00:41:47 UTC (rev 636)
+++ libgksu/trunk/gksu-properties/Makefile.am	2006-06-30 01:38:34 UTC (rev 637)
@@ -0,0 +1,10 @@
+AM_CFLAGS = -g -O2 -Wall
+INCLUDES = ${GKSU_PROPERTIES_CFLAGS}
+AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" -DDATA_DIR=\"$(datadir)\" -DPREFIX=\"$(prefix)\"
+
+bin_PROGRAMS = gksu-properties
+gksu_properties_LDFLAGS = ${GKSU_PROPERTIES_LIBS}
+gksu_properties_SOURCES = gksu-properties.c
+
+gladedir = ${prefix}/share/${PACKAGE}
+glade_DATA = gksu-properties.glade

Added: libgksu/trunk/gksu-properties/gksu-properties.c
===================================================================
--- libgksu/trunk/gksu-properties/gksu-properties.c	2006-06-27 00:41:47 UTC (rev 636)
+++ libgksu/trunk/gksu-properties/gksu-properties.c	2006-06-30 01:38:34 UTC (rev 637)
@@ -0,0 +1,263 @@
+#include <locale.h>
+#include <string.h>
+#include <glade/glade.h>
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+
+#include "../config.h"
+#include "../libgksu/defines.h"
+
+static GladeXML *gui = NULL;
+static GtkWidget *main_window;
+static GtkWidget *grab_combo;
+static GtkWidget *mode_combo;
+static GConfClient *gconf_client; /* NULL */
+
+gboolean disable_grab = FALSE;
+gboolean force_grab = FALSE;
+gboolean prompt = FALSE;
+gboolean sudo_mode = FALSE;
+
+void
+update_from_gconf ()
+{
+  disable_grab = gconf_client_get_bool (gconf_client, BASE_PATH "disable-grab",
+					NULL);
+
+  force_grab = gconf_client_get_bool (gconf_client, BASE_PATH "force-grab",
+				      NULL);
+
+  prompt = gconf_client_get_bool (gconf_client, BASE_PATH "prompt",
+				  NULL);
+
+  sudo_mode = gconf_client_get_bool (gconf_client, BASE_PATH "sudo-mode",
+				     NULL);
+}
+
+const gchar*
+get_grab_string ()
+{
+  if (prompt)
+    return "prompt";
+
+  if (force_grab)
+    return "force enable";
+
+  if (disable_grab)
+    return "disable";
+
+  return "enable";
+}
+
+void
+update_grab_combo ()
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+
+  const gchar *tmp = NULL;
+  gchar *buffer = NULL;
+  gboolean found = FALSE;
+
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (grab_combo));
+  gtk_tree_model_get_iter_first (model, &iter);
+  tmp = get_grab_string ();
+  do
+    {
+      gtk_tree_model_get (model, &iter, 0, &buffer, -1);
+      if (!strcmp (tmp, buffer))
+	{
+	  g_free (buffer);
+	  found = TRUE;
+	  break;
+	}
+      g_free (buffer);
+    }  while (gtk_tree_model_iter_next (model, &iter));
+
+  if (found)
+    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (grab_combo), &iter);
+}
+
+void
+update_mode_combo ()
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+
+  const gchar *tmp = NULL;
+  gchar *buffer = NULL;
+  gboolean found = FALSE;
+
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (mode_combo));
+  gtk_tree_model_get_iter_first (model, &iter);
+  if (sudo_mode)
+    tmp = "sudo";
+  else
+    tmp = "su";
+  do
+    {
+      gtk_tree_model_get (model, &iter, 0, &buffer, -1);
+      if (!strcmp (tmp, buffer))
+	{
+	  g_free (buffer);
+	  found = TRUE;
+	  break;
+	}
+      g_free (buffer);
+    }  while (gtk_tree_model_iter_next (model, &iter));
+
+  if (found)
+    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (mode_combo), &iter);
+}
+
+void
+create_dialog ()
+{
+  main_window = glade_xml_get_widget (gui, "main_window");
+
+  grab_combo = glade_xml_get_widget (gui, "grab_combo");
+  update_grab_combo ();
+
+  mode_combo = glade_xml_get_widget (gui, "mode_combo");
+  update_mode_combo ();
+
+  gtk_widget_show_all (main_window);
+}
+
+void
+gconf_change_cb (GConfClient *gconf_client, guint cnxn_id,
+		 GConfEntry *entry, gpointer data)
+{
+  update_from_gconf ();
+  update_mode_combo ();
+  update_grab_combo ();
+}
+
+void
+combo_change_cb (GtkWidget *widget, gpointer data)
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
+  gchar *combo_name = (gchar*)data;
+
+  gchar *buffer = NULL;
+
+  model = gtk_combo_box_get_model (combo_box);
+  if (gtk_combo_box_get_active_iter (combo_box, &iter))
+    {
+      gtk_tree_model_get (model, &iter, 0, &buffer, -1);
+      if (!strcmp (combo_name, "mode"))
+	{
+	  if (!strcmp (buffer, "sudo"))
+	    gconf_client_set_bool (gconf_client, BASE_PATH "sudo-mode",
+				   TRUE, NULL);
+	  else
+	    gconf_client_set_bool (gconf_client, BASE_PATH "sudo-mode",
+				   FALSE, NULL);
+	}
+      else
+	{
+	  if (!strcmp (buffer, "enable"))
+	    {
+	      gconf_client_set_bool (gconf_client, BASE_PATH "prompt",
+				     FALSE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "disable-grab",
+				     FALSE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "force-grab",
+				     FALSE, NULL);
+	    }
+	  else if (!strcmp (buffer, "disable"))
+	    {
+	      gconf_client_set_bool (gconf_client, BASE_PATH "prompt",
+				     FALSE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "disable-grab",
+				     TRUE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "force-grab",
+				     FALSE, NULL);
+	    }
+	  else if (!strcmp (buffer, "prompt"))
+	    {
+	      gconf_client_set_bool (gconf_client, BASE_PATH "prompt",
+				     TRUE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "disable-grab",
+				     FALSE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "force-grab",
+				     FALSE, NULL);
+	    }
+	  else if (!strcmp (buffer, "force enable"))
+	    {
+	      gconf_client_set_bool (gconf_client, BASE_PATH "prompt",
+				     FALSE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "disable-grab",
+				     FALSE, NULL);
+	      gconf_client_set_bool (gconf_client, BASE_PATH "force-grab",
+				     TRUE, NULL);
+	    }
+	}
+    }
+}
+
+void
+setup_notifications ()
+{
+  gconf_client_notify_add (gconf_client, GCONF_DIR, gconf_change_cb,
+			   NULL, NULL, NULL);
+
+  g_signal_connect (G_OBJECT(mode_combo), "changed",
+		    G_CALLBACK(combo_change_cb), "mode");
+
+  g_signal_connect (G_OBJECT(grab_combo), "changed",
+		    G_CALLBACK(combo_change_cb), "grab");
+}
+
+int
+main (int argc, char **argv)
+{
+  bindtextdomain (PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (PACKAGE, "UTF-8");
+  textdomain (PACKAGE);
+
+  gtk_init (&argc, &argv);
+
+  if (g_file_test ("gksu-properties.glade", G_FILE_TEST_EXISTS) == TRUE)
+    {
+      gui = glade_xml_new ("gksu-properties.glade", NULL, NULL);
+    }
+  else if (g_file_test (PREFIX "/share/" PACKAGE "/gksu-properties.glade",
+			G_FILE_TEST_EXISTS) == TRUE)
+    {
+      gui = glade_xml_new (PREFIX "/share/" PACKAGE "/gksu-properties.glade", NULL,
+			   NULL);
+    }
+
+  if (!gui) {
+    GtkWidget *dialog;
+
+    dialog = gtk_message_dialog_new (NULL,
+				     0,
+				     GTK_MESSAGE_ERROR,
+				     GTK_BUTTONS_CLOSE,
+				     _("Failed to load glade file; please check your installation."));
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+
+    return 1;
+  }
+
+  glade_xml_signal_autoconnect (gui);
+
+  gconf_client = gconf_client_get_default ();
+
+  update_from_gconf ();
+  create_dialog ();
+  setup_notifications ();
+
+  if (main_window)
+    gtk_main ();
+
+  g_object_unref (gconf_client);
+
+  return 0;
+}

Added: libgksu/trunk/gksu-properties/gksu-properties.glade
===================================================================
--- libgksu/trunk/gksu-properties/gksu-properties.glade	2006-06-27 00:41:47 UTC (rev 636)
+++ libgksu/trunk/gksu-properties/gksu-properties.glade	2006-06-30 01:38:34 UTC (rev 637)
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<glade-interface>
+  <widget class="GtkWindow" id="main_window">
+    <property name="border_width">6</property>
+    <property name="title">Privilege granting preferences</property>
+    <property name="window_position">GTK_WIN_POS_CENTER</property>
+    <signal name="delete_event" handler="gtk_main_quit"/>
+    <child>
+      <widget class="GtkVBox" id="vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">5</property>
+        <child>
+          <widget class="GtkVBox" id="vbox2">
+            <property name="visible">True</property>
+            <property name="border_width">9</property>
+            <property name="spacing">20</property>
+            <child>
+              <widget class="GtkTable" id="table1">
+                <property name="visible">True</property>
+                <property name="n_rows">4</property>
+                <property name="n_columns">3</property>
+                <property name="column_spacing">6</property>
+                <property name="row_spacing">6</property>
+                <child>
+                  <widget class="GtkEventBox" id="eventbox2">
+                    <property name="visible">True</property>
+                    <property name="tooltip">The su mode will require the administrator password; sudo mode will request the user's own password, and needs prior setup of sudo.</property>
+                    <child>
+                      <widget class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="xalign">0,000000</property>
+                        <property name="label" translatable="yes">_Authentication mode:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">mode_combo</property>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEventBox" id="eventbox1">
+                    <property name="visible">True</property>
+                    <property name="tooltip">This setting controls whether the keyboard and mouse should be held exclusively while requesting the password, to avoid that some other application receive the password.</property>
+                    <child>
+                      <widget class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="xalign">0,000000</property>
+                        <property name="label" translatable="yes">_Grab mode:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">grab_combo</property>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="grab_combo">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes">enable
+disable
+force enable
+prompt
+</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="mode_combo">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes">su
+sudo</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="spacer1">
+                    <property name="width_request">18</property>
+                    <property name="visible">True</property>
+                    <property name="xalign">0,000000</property>
+                    <property name="yalign">0,000000</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="x_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="xalign">0,000000</property>
+                    <property name="yalign">0,000000</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Screen Grabbing&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="spacer2">
+                    <property name="width_request">18</property>
+                    <property name="visible">True</property>
+                    <property name="xalign">0,000000</property>
+                    <property name="yalign">0,000000</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label12">
+                    <property name="visible">True</property>
+                    <property name="xalign">0,000000</property>
+                    <property name="yalign">0,000000</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Behavior&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="right_attach">3</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+          </widget>
+        </child>
+        <child>
+          <widget class="GtkHButtonBox" id="hbuttonbox1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="button1">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">gtk-close</property>
+                <property name="use_stock">True</property>
+                <signal name="clicked" handler="gtk_main_quit"/>
+              </widget>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>

Modified: libgksu/trunk/libgksu/defines.h
===================================================================
--- libgksu/trunk/libgksu/defines.h	2006-06-27 00:41:47 UTC (rev 636)
+++ libgksu/trunk/libgksu/defines.h	2006-06-30 01:38:34 UTC (rev 637)
@@ -21,7 +21,8 @@
 #ifndef __DEFINES_H__
 #define __DEFINES_H__
 
-#define BASE_PATH "/apps/gksu/"
+#define GCONF_DIR "/apps/gksu"
+#define BASE_PATH GCONF_DIR"/"
 
 /* Gettext */
 #include <libintl.h>




More information about the gksu-commits mailing list