+2011/06/18 yocto <yocto@users.sourceforge.jp>
+
+ 0.3 Released
+
+ * Enter key is enabled in the dialog box
+ Domain window: profile list dialog
+ Profile window: profile edit dialog
+ Domain, ACL, Exception, Profile, Manager window: add dialog
+
+ * Search dialog enhancement
+ Match case
+ Wrap around
+ Close dialog
+
+ * Path name displayed as it is.
+ Domain, ACL, Exception window: display, search, add
+ The command name of the Process window is still octal.
+ When space and multi byte character, etc. are included in the path name
+ input by an additional dialog, it encloses it with single quotation ['].
+ Single quotes in the path name ['] may contain escaped with a backslash
+ [\'] should be.
+
+ * Statistics window display was changed to display the local date and time.
+
+ * Added support for copy of the cursor line.(Profile window)
+
+ * Added a toolbar to the Manager window.
+
+ * Added a toolbar and Apply button to the Statistics window.
+
+
2011/04/25 yocto <yocto@users.sourceforge.jp>
0.2.1 Update
* Added support for Extraction of redundant ACL entries.
Ctrl+O
- * Added support for copy of the cursor line.(domain、ACL、exception)
+ * Added support for copy of the cursor line.(Domain, ACL, Exception window)
Ctrl+C
* Added support for search dialog.
-2011/04/23 yocto <yocto@users.sourceforge.jp>
+2010/12/18 yocto <yocto@users.sourceforge.jp>
0.1 Released
--- /dev/null
+2011/06/18 yocto <yocto@users.sourceforge.jp>
+
+ 0.3 Released
+
+ * ダイアログでのenter key有効化
+ domainウィンドウ:プロファイル設定ダイアログ
+ profileウィンドウ:プロファイル変更ダイアログ
+ domain, ACL, exception, profile, managerウィンドウ:追加ダイアログ
+
+ * 検索ダイアログに機能追加
+ 大文字と小文字を区別する (M)atch case
+ 折返しも対象にする (W)rap around
+ enterで閉じる Close (d)ialog
+
+ * パス名の漢字等をそのまま表示
+ domain, ACL, exceptionウィンドウの表示、検索、追加で有効
+ processウィンドウのコマンド名は8進表記のまま
+ 追加ダイアログで入力するパス名にスペースや漢字等が含まれる場合は
+ シングルクォーテーション[']で囲む
+ パス名に[']が含まれる場合は\エスケープ[\']する
+
+ * Statisticsの日時をローカルタイム表示に変更
+
+ * カーソル行データコピーを追加:profile
+
+ * managerウィンドウにツールバーを追加
+
+ * Statisticsウィンドウにツールバー、適用ボタンを追加
+
+
+2011/04/25 yocto <yocto@users.sourceforge.jp>
+
+ 0.2.1 Update
+
+ * ドキュメントのインストールディレクトリを
+ 「/usr/doc/gpet/」から「/usr/share/doc/gpet/」に修正
+
+
+2011/04/23 yocto <yocto@users.sourceforge.jp>
+
+ 0.2 Released
+
+ * ベースとなるccs-editpolicyをccstools 1.8.1 20110401版 に変更
+
+ * ACLウィンドウの切離し機能を追加
+ メニュー > 表示 > ACLウィンドウ切離し
+
+ * メニューの memory usage を Statistics に変更
+ ショーカットキー Ctrl+U を Ctrl+S に変更
+
+ * オフラインモードとネットワークモードに対応
+ 現状はccs-editpolicy同様、起動引数で指定です。
+
+ * フォント及び色のリソースファイルに対応 gpetrc.sample 追加
+ 下記のようにコピーして中身を変更してください
+ cp /usr/share/doc/gpetrc.sample ~/.gpetrc
+
+ * プロセスモードのショーカットキーを Ctrl+O から Ctrl+@ に変更
+
+ * ACLの冗長エントリ抽出(パターン化支援)機能を追加
+ ショーカットキー Ctrl+O
+
+ * ウィンドウキャプションにモード表示を追加
+
+ * エントリ追加時にカーソルを追加項目に移動するように変更
+
+ * カーソル行データコピー domain、ACL、exception
+ コピー時にクリップボード(OSバッファ)にもコピーする
+
+ * ダイアログ検索を追加 domain、ACL、exception、profile
+
+
+2010/12/18 yocto <yocto@users.sourceforge.jp>
+
+ 0.1 Released
+
+ * 初期リリース
-gpet 0.2.1 2011-04-25
+gpet 0.3 2011-06-18
gpet (Gui Policy Editor for TOMOYO Linux)
Build / Install / Run / Uninstall
$ sudo apt-get install intltool libgtk2.0-dev libgconf2-dev
-$ tar xjvf gpet-0.2.1.tar.bz2
+$ tar xjvf gpet-0.3.tar.bz2
-$ cd gpet-0.2.1
+$ cd gpet-0.3
$ ./configure --prefix /usr
$ make
*** Instll location ***
-/usr
-├── doc
-│ └── gpet
-│ ├── AUTHORS
-│ ├── COPYING
-│ ├── ChangeLog
-│ ├── INSTALL
-│ ├── NEWS
-│ ├── README
-│ └── gpetrc.sample
-├── sbin
-│ └── gpet
-└── share
- ├── gpet
- │ └── pixmaps
- │ └── tomoyo.png
- └── locale
- └── ja
- └── LC_MESSAGES
- └── gpet.mo
+|-- sbin
+| `-- gpet
+`-- share
+ |-- doc
+ | `-- gpet
+ | |-- AUTHORS
+ | |-- COPYING
+ | |-- ChangeLog
+ | |-- ChangeLog.ja
+ | |-- INSTALL
+ | |-- NEWS
+ | |-- README
+ | `-- gpetrc.sample
+ |-- gpet
+ | `-- pixmaps
+ | `-- tomoyo.png
+ `-- locale
+ `-- ja
+ `-- LC_MESSAGES
+ `-- gpet.mo
*** Uninstall ***
COPYING\
AUTHORS\
ChangeLog\
- ChangeLog.jp\
+ ChangeLog.ja\
INSTALL\
NEWS\
gpetrc.sample
dnl Process this file with autoconf to produce a configure script.
dnl Created by Anjuta application wizard.
-AC_INIT(gpet, 0.2.1)
+AC_INIT(gpet, 0.3)
__GPET=gpet
AC_SUBST(__GPET)
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-04-22 23:05+0900\n"
-"PO-Revision-Date: 2011-04-22 23:04+0900\n"
+"POT-Creation-Date: 2011-06-10 13:56+0900\n"
+"PO-Revision-Date: 2011-06-10 13:56+0900\n"
"Last-Translator: Yoshihiro Kusuno <yocto@users.sourceforge.jp>\n"
"Language-Team: Japanese < >\n"
"Language: \n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../src/gpet.c:1135
+#: ../src/gpet.c:1193
msgid "offline"
msgstr "オフライン"
-#: ../src/gpet.c:1135
+#: ../src/gpet.c:1193
msgid "nework"
msgstr "ネットワーク"
-#: ../src/gpet.c:1135
+#: ../src/gpet.c:1193
msgid "online"
msgstr "オンライン"
-#: ../src/gpet.c:1179 ../src/gpet.c:1184 ../src/menu.c:79
+#: ../src/gpet.c:1237 ../src/gpet.c:1242 ../src/menu.c:79
msgid "Statistics"
msgstr "統計情報"
-#: ../src/gpet.c:1190 ../src/gpet.c:1194 ../src/gpet.c:1199
+#: ../src/gpet.c:1248 ../src/gpet.c:1252 ../src/gpet.c:1257
msgid "Manager Policy"
msgstr "マネージャ 一覧"
-#: ../src/gpet.c:1205 ../src/gpet.c:1209 ../src/gpet.c:1214
+#: ../src/gpet.c:1263 ../src/gpet.c:1267 ../src/gpet.c:1272
msgid "Domain Policy Editor"
msgstr "ドメインポリシーエディタ"
-#: ../src/gpet.c:1385 ../src/gpet.c:1410
+#: ../src/gpet.c:1443 ../src/gpet.c:1468
msgid "gpet"
msgstr "gpet"
#. create tab
-#: ../src/gpet.c:1517 ../src/menu.c:352
+#: ../src/gpet.c:1575 ../src/menu.c:469
msgid "Domain Transition"
msgstr "ドメイン遷移 一覧"
-#: ../src/gpet.c:1518
+#: ../src/gpet.c:1576
msgid "Exception Policy"
msgstr "例外ポリシー 一覧"
-#: ../src/gpet.c:1519
+#: ../src/gpet.c:1577
msgid "Profile"
msgstr "プロファイル 一覧"
msgid "_File"
msgstr "ファイル(_F)"
-#: ../src/menu.c:47 ../src/other.c:47
+#: ../src/menu.c:47 ../src/other.c:48
msgid "_Edit"
msgstr "編集(_E)"
msgid "Set or Edit the selected line"
msgstr "選択した行を修正します。"
-#: ../src/menu.c:56 ../src/other.c:49
+#: ../src/menu.c:56 ../src/other.c:50
msgid "_Add"
msgstr "追加(_A)"
-#: ../src/menu.c:57 ../src/other.c:50
+#: ../src/menu.c:57 ../src/other.c:51
msgid "Append line"
msgstr "追加します。"
-#: ../src/menu.c:58 ../src/other.c:51
+#: ../src/menu.c:58 ../src/other.c:52
msgid "_Delete"
msgstr "削除(_D)"
-#: ../src/menu.c:59 ../src/other.c:52
+#: ../src/menu.c:59 ../src/other.c:53
msgid "Delete the selected line"
msgstr "選択した行を削除します。"
msgstr "冗長なACLエントリを削除するためのサポートをします。"
#: ../src/menu.c:67
-msgid "_Search"
-msgstr "検索(_S)"
+msgid "_Search..."
+msgstr "検索...(_S)"
#: ../src/menu.c:68
msgid "Search for text"
msgstr "再読み込みを行います。"
#: ../src/menu.c:76
-msgid "_Manager"
-msgstr "マネージャ(_M)"
+msgid "_Manager..."
+msgstr "マネージャ...(_M)"
#: ../src/menu.c:77
msgid "Manager Profile Editor"
msgstr "マネージャ 一覧"
#: ../src/menu.c:78
-msgid "_Statistics"
-msgstr "統計情報(_S)"
+msgid "_Statistics..."
+msgstr "統計情報...(_S)"
#: ../src/menu.c:81
msgid "_About"
msgid "Detach ACL window"
msgstr "ドメインポリシーを別ウィンドウで表示します。"
-#: ../src/menu.c:349
+#: ../src/menu.c:466
msgid "Process State"
msgstr "プロセス 一覧"
-#: ../src/menu.c:627
+#: ../src/menu.c:748
#, c-format
msgid ""
"<span foreground='red' size='x-large'><b>Delete</b> the %d selected "
"<span foreground='red' size='x-large'>選択した %d行の例外ポリシーを<b>削除</"
"b>します。</span>"
-#: ../src/menu.c:630
+#: ../src/menu.c:751
#, c-format
msgid ""
"<span foreground='red' size='x-large'><b>Delete</b> the selected exception "
"<span foreground='red' size='x-large'>選択した 例外ポリシーを<b>削除</b>しま"
"す。</span>"
-#: ../src/menu.c:647
+#: ../src/menu.c:768
#, c-format
msgid ""
"<span foreground='red' size='x-large'><b>Delete</b> the %d selected domains?"
"<span foreground='red' size='x-large'>選択した %d行のドメインを<b>削除</b>し"
"ます。</span>"
-#: ../src/menu.c:650
+#: ../src/menu.c:771
#, c-format
msgid ""
"<span foreground='red' size='x-large'><b>Delete</b> the selected domain?</"
"<span foreground='red' size='x-large'>選択した ドメインを<b>削除</b>します。"
"</span>"
-#: ../src/menu.c:669
+#: ../src/menu.c:790
#, c-format
msgid ""
"<span foreground='blue' size='x-large'><b>Delete</b> the %d selected "
"<span foreground='red' size='x-large'>選択した %d行のポリシーを<b>削除</b>し"
"ます。</span>"
-#: ../src/menu.c:672
+#: ../src/menu.c:793
#, c-format
msgid ""
"<span foreground='blue' size='x-large'><b>Delete</b> the selected policy?</"
"<span foreground='red' size='x-large'>選択した ポリシーを<b>削除</b>します。"
"</span>"
-#: ../src/menu.c:813
+#: ../src/menu.c:1027
msgid "Add Domain"
msgstr "ドメインを追加します。"
-#: ../src/menu.c:820
+#: ../src/menu.c:1034
msgid "Add Acl"
msgstr "ドメインに対するアクセス許可を追加します。"
-#: ../src/menu.c:832
+#: ../src/menu.c:1046
msgid "Add Exception"
msgstr "例外ポリシーを追加します。"
-#: ../src/menu.c:840
+#: ../src/menu.c:1054
msgid "Add Profile (0 - 255)"
msgstr "プロファイルを追加します。 (0 - 255)"
-#: ../src/menu.c:976
+#: ../src/menu.c:1196
msgid "Profile list"
msgstr "プロファイルを選択します。"
-#: ../src/menu.c:1039
+#: ../src/menu.c:1271
msgid "Profile Edit"
msgstr "プロファイルを変更します。"
-#: ../src/menu.c:1120
+#: ../src/menu.c:1355
msgid "Yoshihiro Kusuno <yocto@users.sourceforge.jp>"
msgstr "楠野 佳宏 <yocto@users.sourceforge.jp>"
-#: ../src/menu.c:1121
+#: ../src/menu.c:1356
msgid "ccstools --- kumaneko san"
msgstr "ccstools --- 熊猫さん"
-#: ../src/menu.c:1123
+#: ../src/menu.c:1358
msgid "Yoshihiro Kusuno"
msgstr "楠野 佳宏"
-#: ../src/other.c:48
+#: ../src/other.c:49
msgid "Edit the selected line"
msgstr "選択した行を修正します。"
-#: ../src/other.c:224
+#: ../src/other.c:228
msgid "File Selection Dialog"
msgstr "ファイルの選択"
-#: ../src/other.c:264
+#: ../src/other.c:278
msgid "Manager Add"
msgstr "マネージャを追加します。"
-#: ../src/other.c:342
+#: ../src/other.c:358
#, c-format
msgid "Delete the %d selected managers?"
msgstr "選択した %d行のマネージャ登録を削除します。"
-#: ../src/other.c:343
+#: ../src/other.c:359
#, c-format
msgid "Delete the selected manager?"
msgstr "選択したマネージャ登録を削除します。"
-#: ../src/other.c:560
+#: ../src/other.c:598
msgid " "
msgstr " "
-#: ../src/other.c:567
+#: ../src/other.c:605
msgid "Now (bytes)"
msgstr "使用量(バイト)"
-#: ../src/other.c:577
+#: ../src/other.c:615
msgid "Quota (bytes)"
msgstr "最大 (バイト)"
-#: ../src/search.c:366
+#: ../src/search.c:424
msgid "Process Search for :"
msgstr "プロセス 一覧 検索文字列 :"
-#: ../src/search.c:368
+#: ../src/search.c:426
msgid "Domain Search for :"
msgstr "ドメイン 一覧 検索文字列 :"
-#: ../src/search.c:372
+#: ../src/search.c:430
msgid "ACL Search for :"
msgstr "ドメインポリシー 一覧 検索文字列 :"
-#: ../src/search.c:375
+#: ../src/search.c:433
msgid "Exception Search for :"
msgstr "例外ポリシー 一覧 検索文字列 :"
-#: ../src/search.c:378
+#: ../src/search.c:436
msgid "Profile Search for :"
msgstr "プロファイル 一覧 検索文字列 :"
-#: ../src/search.c:382
+#: ../src/search.c:440
msgid "Search for :"
msgstr "検索文字列 :"
-#: ../src/search.c:403
+#: ../src/search.c:475
+msgid "_Match case"
+msgstr "大文字と小文字を区別する(_M)"
+
+#: ../src/search.c:481
+msgid "_Wrap around"
+msgstr "折返しも対象にする(_W)"
+
+#: ../src/search.c:487
+msgid "Close _dialog"
+msgstr "エンターで閉じる(_D)"
+
+#: ../src/search.c:516
msgid "Find"
msgstr "検索"
menu.c \
g_undef.h \
conf.c \
+ conf.h \
process.c \
other.c \
search.c \
#include <glib/gi18n.h>
#include "gpet.h"
+#include "conf.h"
#define PRINT_WARN(err) {g_warning("%s", err->message);g_error_free(err);err = NULL;}
#define DIRECTORY "/apps/gpet"
-#define WINDOW_POSITION DIRECTORY"/window_position"
+#define WINDOW_POSITION DIRECTORY"/window_position"
#define WINDOW_SIZE DIRECTORY"/window_size"
-#define ACL_WINDOW_SIZE DIRECTORY"/acl_window_size"
-#define PANED_POSITION DIRECTORY"/paned_position"
+#define ACL_WINDOW_SIZE DIRECTORY"/acl_window_size"
+#define PANED_POSITION DIRECTORY"/paned_position"
+
+#define SEARCH_DIR DIRECTORY"/search"
+#define MATCH SEARCH_DIR"/match_case"
+#define WRAP SEARCH_DIR"/wrap_around"
+#define CLOSE SEARCH_DIR"/close_dialog"
+
+
+static search_conf_t save_search = {TRUE, FALSE, FALSE};
+
+void get_conf_search(search_conf_t *conf)
+{
+ *conf = save_search;
+}
+
+void put_conf_search(search_conf_t *conf)
+{
+ save_search = *conf;
+}
void read_config(transition_t *tran)
{
gint x, y, w, h;
GtkPaned *paned;
gint paned_position;
+ gboolean tmp_bool;
gtk_widget_set_size_request(tran->window, 640, 480);
gtk_widget_set_size_request(tran->acl_window, 600, 400);
else
PRINT_WARN(err);
}
+
+
+ if (!gconf_client_dir_exists(client, SEARCH_DIR, &err)) {
+ return;
+ }
+
+ tmp_bool = gconf_client_get_bool(client, MATCH, &err);
+ if (!err)
+ save_search.match = tmp_bool;
+ else
+ PRINT_WARN(err);
+
+ tmp_bool = gconf_client_get_bool(client, WRAP, &err);
+ if (!err)
+ save_search.wrap = tmp_bool;
+ else
+ PRINT_WARN(err);
+
+ tmp_bool = gconf_client_get_bool(client, CLOSE, &err);
+ if (!err)
+ save_search.close = tmp_bool;
+ else
+ PRINT_WARN(err);
}
void write_config(transition_t *tran)
PRINT_WARN(err);
}
}
+
+
+ if (!gconf_client_dir_exists(client, SEARCH_DIR, &err)) {
+ gconf_client_add_dir(client, SEARCH_DIR,
+ GCONF_CLIENT_PRELOAD_NONE, &err);
+ }
+ if (err) {
+ PRINT_WARN(err);
+ return;
+ }
+
+ if (!gconf_client_set_bool(client, MATCH, save_search.match, &err))
+ PRINT_WARN(err);
+
+ if (!gconf_client_set_bool(client, WRAP, save_search.wrap, &err))
+ PRINT_WARN(err);
+
+ if (!gconf_client_set_bool(client, CLOSE, save_search.close, &err))
+ PRINT_WARN(err);
}
--- /dev/null
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Gui Policy Editor for TOMOYO Linux
+ *
+ * conf.h
+ * Copyright (C) Yoshihiro Kusuno 2011 <yocto@users.sourceforge.jp>
+ *
+ * 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 Library 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., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+#ifndef __CONF_H__
+#define __CONF_H__
+
+typedef struct _search_conf_t {
+ gboolean match;
+ gboolean wrap;
+ gboolean close;
+} search_conf_t;
+
+
+void get_conf_search(search_conf_t *conf);
+void put_conf_search(search_conf_t *conf);
+
+
+#endif /* __CONF_H__ */
#include "gpet.h"
/*---------------------------------------------------------------------------*/
+/* from util.c (ccs-patch-1.8.1-20110505) */
+static gboolean is_octal_char(const char *str)
+{
+ return *str >= '0' && *str++ <= '3' &&
+ *str >= '0' && *str++ <= '7' &&
+ *str >= '0' && *str <= '7';
+}
+/* from util.c (ccs-patch-1.8.1-20110505) */
+static gchar octal_char_to_binary(const char *str)
+{
+ return ((str[0] - '0') << 6) + ((str[1] - '0') << 3) + (str[2] - '0');
+}
+
+gchar *decode_from_octal_str(const char *name)
+{
+ gchar *tmp, buff[strlen(name)+1];
+
+ if (!name)
+ return NULL;
+
+ tmp = buff;
+ for( ; *name; name++, tmp++) {
+ if (*name == '\\' && is_octal_char(name + 1)) {
+ name++;
+ *tmp = octal_char_to_binary(name);
+ name += 2;
+ } else {
+ *tmp = *name;
+ }
+ }
+ *tmp = *name;
+
+ return g_strdup(buff);
+}
+
+/*---------------------------------------------------------------------------*/
enum tree_column_pos {
COLUMN_INDEX, // data index (invisible)
COLUMN_NUMBER, // n
{
GtkTreeIter iter;
gchar *color = "black";
- gchar *str_num, *str_prof;
+ gchar *str_num, *str_prof, *name;
gchar *line = NULL, *is_dis = NULL, *domain;
const char *sp;
const struct ccs_transition_control_entry *transition_control;
int n, number, redirect_index = -1;
+//g_print("add_tree_store index[%3d] nest[%2d]\n", *index, nest);
+
sp = ccs_domain_name(dp, *index);
for (n = 0; ; n++) {
const char *cp = strchr(sp, ' ');
break;
sp = cp + 1;
}
+ name = decode_from_octal_str(sp);
gtk_tree_store_append(store, &iter, parent_iter);
number = dp->list[*index].number;
}
domain = g_strdup_printf("%s%s%s%s%s",
dp->list[*index].is_dd ? "( " : "",
- sp,
+ name,
dp->list[*index].is_dd ? " )" : "",
line ? line : "",
is_dis ? is_dis : ""
gtk_tree_store_set(store, &iter, COLUMN_DOMAIN_NAME, domain,
COLUMN_COLOR, color,
COLUMN_REDIRECT, redirect_index, -1);
+ g_free(name);
g_free(line);
g_free(is_dis);
g_free(domain);
int index = 0, nest = -1;
store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
- gtk_tree_store_clear(store);
+ gtk_tree_store_clear(store); // TODO 遅い
add_tree_store(store, iter, dp, &index, nest);
}
/*---------------------------------------------------------------------------*/
gtk_list_store_append(store, &iter);
if (alias_flag) {
+ gchar *ope = decode_from_octal_str(
+ generic->list[i].operand);
+
alias = (gchar *)
ccs_directives[generic->list[i].directive].alias;
gtk_list_store_set(store, &iter,
LIST_NUMBER, str_num,
LIST_COLON, ":",
LIST_ALIAS, alias,
- LIST_OPERAND, generic->list[i].operand,
+// LIST_OPERAND, generic->list[i].operand,
+ LIST_OPERAND, ope, // test
-1);
+ g_free(ope); // test
} else {
profile = g_strdup_printf("%3u-",
generic->list[i].directive);
return index;
}
-gchar *get_alias_and_operand(GtkWidget *view)
+gchar *get_alias_and_operand(GtkWidget *view, gboolean alias_flag)
{
GtkTreeSelection *selection;
GtkTreeIter iter;
list = gtk_tree_selection_get_selected_rows(selection, NULL);
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
gtk_tree_model_get_iter(model, &iter, g_list_first(list)->data);
- gtk_tree_model_get(model, &iter,
+ if (alias_flag) {
+ gtk_tree_model_get(model, &iter,
LIST_ALIAS, &alias, LIST_OPERAND, &operand, -1);
- str_buff = g_strdup_printf("%s %s", alias, operand);
+ str_buff = g_strdup_printf("%s %s", alias, operand);
+ g_free(alias);
+ g_free(operand);
+ } else {
+ gtk_tree_model_get(model, &iter,
+ LIST_OPERAND, &operand, -1);
+ str_buff = g_strchug(operand);
+ }
}
return str_buff;
{
GtkWidget *view = NULL;
GtkTreeSelection *selection;
- const char *domain;
gint index;
- gchar *alias = NULL, *operand = NULL, *str_buff = NULL;
- gchar *entry;
+ gchar *alias = NULL, *operand = NULL;
+ gchar *entry, *str_buff = NULL;
int cmp = -1;
case ADDENTRY_DOMAIN_LIST :
view = transition->treeview;
gtk_tree_model_get(model, iter, COLUMN_INDEX, &index, -1);
- domain = ccs_domain_name(transition->dp, index);
- cmp = strcmp(entry, domain);
+ str_buff = decode_from_octal_str(
+ ccs_domain_name(transition->dp, index));
+ cmp = strcmp(entry, str_buff);
break;
case ADDENTRY_ACL_LIST :
view = transition->acl.listview;
g_free(alias);
g_free(operand);
g_free(str_buff);
+ g_free(entry);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
static void cb_selection(GtkTreeSelection *selection,
transition_t *transition)
{
- GtkTreeIter iter;
- gint select_count;
- GtkTreeModel *model;
- GList *list;
- gint index;
+ GtkTreeIter iter;
+ gint select_count;
+ GtkTreeModel *model;
+ GList *list;
+ gint index;
GtkTreePath *path = NULL;
GtkTreeViewColumn *column = NULL;
+ gchar *name;
DEBUG_PRINT("In **************************** \n");
select_count = gtk_tree_selection_count_selected_rows(selection);
g_list_free(list);
gtk_tree_model_get(model, &iter, COLUMN_INDEX, &index, -1);
DEBUG_PRINT("--- index [%4d] ---\n", index);
- gtk_entry_set_text(GTK_ENTRY(transition->domainbar),
- ccs_domain_name(transition->dp, index));
+ name = decode_from_octal_str(ccs_domain_name(transition->dp, index));
+ gtk_entry_set_text(GTK_ENTRY(transition->domainbar), name);
+ g_free(name);
gtk_tree_view_get_cursor(GTK_TREE_VIEW(
transition->acl.listview), &path, &column);
case CCS_SCREEN_PROFILE_LIST :
sens_edt = TRUE;
sens_add = TRUE;
+ sens_cpy = TRUE;
break;
}
gtk_tree_selection_unselect_path(selection, path);
}
+ g_free(str_num);
return FALSE;
}
const char *get_domain_last_name(const int index);
// gpet.c
+gchar *decode_from_octal_str(const char *name);
void add_tree_data(GtkTreeView *treeview, struct ccs_domain_policy *dp);
void add_list_data(generic_list_t *generic, gboolean alias_flag);
gint get_current_domain_index(transition_t *transition);
-gchar *get_alias_and_operand(GtkWidget *view);
+gchar *get_alias_and_operand(GtkWidget *view, gboolean alias_flag);
void set_position_addentry(transition_t *transition, GtkTreePath **path);
void set_sensitive(GtkActionGroup *actions, int task_flag,
enum ccs_screen_type current_page);
GtkWidget *create_menu(GtkWidget *parent, transition_t *transition,
GtkWidget **toolbar);
void disp_statusbar(transition_t *transition, int scr);
+gchar *encode_to_octal_str(const char *str);
void view_cursor_set(GtkWidget *view,
GtkTreePath *path, GtkTreeViewColumn *column);
void refresh_transition(GtkAction *action, transition_t *transition);
while (dst_cnt)
free((void *)((*dst)[--dst_cnt].operand));
+ if (src_cnt < 1)
+ return;
+
*dst = realloc(*dst, src_cnt * sizeof(struct ccs_generic_acl));
if (!(*dst))
ccs_out_of_memory();
N_("_OptimizationSupport"), "<control>O",
N_("Extraction of redundant ACL entries"), G_CALLBACK(optimize_acl)},
- {"Search", GTK_STOCK_FIND, N_("_Search"), "<control>F",
+ {"Search", GTK_STOCK_FIND, N_("_Search..."), "<control>F",
N_("Search for text"), G_CALLBACK(search_input)},
{"SearchBack", GTK_STOCK_GO_BACK, N_("Search_Backwards"), "<control><shift>G",
N_("Search backwards for the same text"), G_CALLBACK(search_back)},
{"Refresh", GTK_STOCK_REFRESH, N_("_Refresh"), "<control>R",
N_("Refresh to the latest information"), G_CALLBACK(refresh_transition)},
- {"Manager", GTK_STOCK_DND, N_("_Manager"), "<control>M",
+ {"Manager", GTK_STOCK_DND, N_("_Manager..."), "<control>M",
N_("Manager Profile Editor"), G_CALLBACK(manager_transition)},
- {"Memory", GTK_STOCK_DND, N_("_Statistics"), "<control>S",
+ {"Memory", GTK_STOCK_DND, N_("_Statistics..."), "<control>S",
N_("Statistics"), G_CALLBACK(memory_transition)},
{"About", GTK_STOCK_ABOUT, N_("_About"), "<alt>A",
transition->contextid, status_str);
g_free(status_str);
}
+/*---------------------------------------------------------------------------*/
+/* from realpath.c (ccs-patch-1.8.1-20110505) */
+gchar *encode_to_octal_str(const char *str)
+{
+ int i;
+ int str_len;
+ int len = 0;
+ const char *p = str;
+ char *cp;
+ char *cp0;
+
+ if (!p)
+ return NULL;
+
+ str_len = strlen(str);
+ for (i = 0; i < str_len; i++) {
+ const unsigned char c = p[i];
+ if (c == '\\')
+// len += 2;
+ len++;
+ else if (c > ' ' && c < 127)
+ len++;
+ else
+ len += 4;
+ }
+ len++;
+
+ /* Reserve space for appending "/". */
+ cp = g_malloc0(len + 10);
+ if (!cp)
+ return NULL;
+
+ cp0 = cp;
+ p = str;
+ for (i = 0; i < str_len; i++) {
+ const unsigned char c = p[i];
+ if (c == '\\') {
+ *cp++ = '\\';
+// *cp++ = '\\';
+ } else if (c > ' ' && c < 127) {
+ *cp++ = c;
+ } else {
+ *cp++ = '\\';
+ *cp++ = (c >> 6) + '0';
+ *cp++ = ((c >> 3) & 7) + '0';
+ *cp++ = (c & 7) + '0';
+ }
+ }
+ return cp0;
+}
+
+static gint encode_copy(gchar *cp, gchar *buff)
+{
+ gchar *str;
+ gint len;
+
+ if (!*cp)
+ return 0;
+
+ str = encode_to_octal_str(cp);
+ strcpy(buff, str);
+ len = strlen(str) - 1;
+ g_free(str);
+
+ return len;
+}
+
+static gchar *escape_str_encode(const char *input)
+{
+ gchar *str, *cp0, *cp1;
+ gchar *tmp, buff[strlen(input)*3+1];
+ gboolean match = FALSE;
+
+ if (!input)
+ return NULL;
+
+ cp0 = str = g_strdup(input);
+ tmp = buff;
+ for( ; *cp0; cp0++, tmp++) {
+ if (*cp0 == '\\' && *(cp0 + 1) == '\'') {
+ *tmp = *++cp0;
+ } else if (*cp0 == '\'') { // start "
+ cp1 = ++cp0;
+ for ( ; *cp0; cp0++) {
+ if (*cp0 == '\\' && *(cp0 + 1) == '\'') {
+ if (cp1 < cp0) {
+ *cp0 = '\0';
+ tmp += encode_copy(cp1, tmp);
+ tmp++;
+ } else {
+ *tmp = *(cp0 + 1);
+ }
+ cp1 = ++cp0;
+ } else if (*cp0 == '\'') { // end "
+ *cp0 = '\0';
+ match = TRUE;
+ break;
+ }
+ }
+
+ if (match) {
+ tmp += encode_copy(cp1, tmp);
+ match = FALSE;
+ } else {
+ g_warning(" [\']pair not match!");
+ cp0 = cp1;
+ *tmp = *cp0;
+ }
+ } else {
+ *tmp = *cp0;
+ }
+ }
+ *tmp = *cp0;
+
+ g_free(str);
+ return g_strdup(buff);
+}
/*-------+---------+---------+---------+---------+---------+---------+--------*/
static void terminate(GtkAction *action, transition_t *transition)
{
index = get_current_domain_index(transition);
view = transition->treeview;
if (index >= 0)
- insert_history_buffer(view, g_strdup(
+ insert_history_buffer(view, decode_from_octal_str(
ccs_domain_name(transition->dp, index)));
break;
case CCS_SCREEN_ACL_LIST :
view = transition->acl.listview;
- insert_history_buffer(view, get_alias_and_operand(view));
+ insert_history_buffer(view, get_alias_and_operand(view, TRUE));
break;
case CCS_SCREEN_EXCEPTION_LIST :
view = transition->exp.listview;
- insert_history_buffer(view, get_alias_and_operand(view));
+ insert_history_buffer(view, get_alias_and_operand(view, TRUE));
+ break;
+ case CCS_SCREEN_PROFILE_LIST :
+ view = transition->prf.listview;
+ insert_history_buffer(view, get_alias_and_operand(view, FALSE));
break;
default :
break;
gchar *get_combo_entry_last(void)
{
- return Last_entry_string;
+ gchar *str, *buff;
+ gchar *cp;
+
+ buff = g_malloc0(strlen(Last_entry_string) + 1);
+ if (!buff)
+ return NULL;
+
+ str = buff;
+ for (cp = Last_entry_string; *cp; cp++) {
+ if (*cp == '\\' && *(cp + 1) == '\'') {
+ *str++ = *++cp;
+ } else if (*cp != '\'') {
+ *str++ = *cp;
+ }
+ }
+ *str = *cp;
+
+//g_print("[%s]\n", buff);
+ return buff;
}
static void insert_history_buffer(GtkWidget *view, gchar *entry)
gtk_clipboard_set_text(clipboard, entry, -1);
for (list = combolist; list; list = g_list_next(list)) {
- if (strcmp(entry, (gchar *)list->data) == 0)
+ if (strcmp(entry, (gchar *)list->data) == 0) {
+ g_free(entry);
return;
+ }
}
combolist = g_list_insert(combolist, entry, 0);
}
}
-static gint combo_entry_activate(GtkWidget *combo, gchar **new_text)
+static gchar *normalize_strdup(gchar *input)
+{
+ gchar *cp;
+ gint len = strlen(input);
+ gchar *str, *buff;
+ gboolean match = FALSE;
+
+ if (len < 1)
+ return NULL;
+
+ cp = input + len - 1;
+ if (g_ascii_isspace(*cp)) {
+ while (len && g_ascii_isspace(*cp)) {
+ cp--;
+ len--;
+ }
+ }
+
+ cp = input;
+ while (len && g_ascii_isspace(*cp)) {
+ cp++;
+ len--;
+ }
+
+ buff = g_malloc0(len + 1);
+ if (!buff)
+ return NULL;
+
+ str = buff;
+ while (len && *cp) {
+ if (*cp == '\\' && *(cp + 1) == '\'') {
+ *str++ = *cp++;
+ len--;
+ } else if (*cp == '\'') {
+ match = match ? FALSE : TRUE;
+ } else {
+ if (!match && g_ascii_isspace(*cp)) {
+ while (g_ascii_isspace(*(cp+1))) {
+ cp++;
+ len--;
+ }
+ }
+ }
+ *str++ = *cp++;
+ len--;
+ }
+ *str = '\0';
+
+//g_print("%2d[%s]\n", len, buff);
+ return buff;
+}
+
+static gint combo_entry_apply(GtkWidget *combo, gchar **new_text)
{
GtkComboBox *combobox;
GList *list;
return 1;
g_free(Last_entry_string);
- Last_entry_string = g_strdup(*new_text);
+ Last_entry_string = normalize_strdup(*new_text);
+ g_free(*new_text);
+ *new_text = g_strdup(Last_entry_string);
for (list = combolist; list; list = g_list_next(list)) {
if (strcmp(*new_text, (gchar *)list->data) == 0) {
return exist_flag ? 1 : 0;
}
+static void cb_combo_entry_activate(GtkEntry *entry, GtkWidget *dialog)
+{
+ const gchar *input = gtk_entry_get_text(entry);
+
+ if (!input || strcmp(input, "") == 0)
+ return;
+
+ gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_APPLY);
+}
+
+/*---------------------------------------------------------------------------*/
static gint append_dialog(transition_t *transition,
gchar *title, gchar **input)
{
NULL);
combo = gtk_combo_box_entry_new_text();
+ g_signal_connect(G_OBJECT(GTK_BIN(combo)->child) , "activate" ,
+ G_CALLBACK(cb_combo_entry_activate), dialog);
+
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
for (list = combolist; list; list = g_list_next(list)) {
response = gtk_dialog_run(GTK_DIALOG(dialog));
if (response == GTK_RESPONSE_APPLY) {
- combo_entry_activate(combo, input);
+ gchar *tmp;
+ combo_entry_apply(combo, input);
+ tmp = escape_str_encode(*input);
+// g_print("[%s]:[%s]\n", *input, tmp);
+ g_free(*input);
+ *input = tmp;
result = 0;
}
gtk_widget_destroy(dialog);
}
}
+static void cb_profile_activate(GtkTreeView *treeview, GtkTreePath *treepath,
+ GtkTreeViewColumn *treeviewcolumn, GtkWidget *dialog)
+{
+ gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_APPLY);
+}
+
static void set_domain(transition_t *transition)
{
GtkTreeSelection *domain_selection;
NULL);
listview = create_list_profile();
+ g_signal_connect(G_OBJECT(listview), "row-activated",
+ G_CALLBACK(cb_profile_activate), dialog);
add_list_profile(listview, &(transition->prf));
view_cursor_set(listview, NULL, NULL);
gtk_container_add(
gtk_widget_destroy(dialog);
}
+static void cb_profile_entry_activate(GtkEntry *entry, GtkWidget *dialog)
+{
+ const gchar *input = gtk_entry_get_text(entry);
+
+ if (!input || strcmp(input, "") == 0)
+ return;
+
+ gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_APPLY);
+}
+
static void edit_profile(transition_t *transition)
{
GtkWidget *dialog;
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
NULL);
+ g_signal_connect(G_OBJECT(entry) , "activate" ,
+ G_CALLBACK(cb_profile_entry_activate), dialog);
+
hbox = gtk_hbox_new(FALSE, 5);
gtk_container_add(
GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
gtk_about_dialog_set_copyright(about,
"Copyright(C) 2010,2011 TOMOYO Linux Project");
gtk_about_dialog_set_comments(about,
- "Gui Policy Editor for TOMOYO Linux 1.8"
- " or AKARI 1.0"
+ "Gui Policy Editor for TOMOYO Linux 1.8.1"
+ " or AKARI 1.0.11"
"\n(based on ccs-editpolicy:ccstools)");
gtk_about_dialog_set_website(about, "http://sourceforge.jp/projects/gpet/");
// gtk_about_dialog_set_website_label(about, "http://tomoyo.sourceforge.jp/");
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <glib/gprintf.h>
#include "gpet.h"
gtk_widget_grab_focus(man->listview);
}
-static void create_manager_view(GtkWidget *dialog, GtkWidget *listview)
+static void create_manager_view(GtkWidget *dialog, GtkWidget *toolbar,
+ GtkWidget *listview)
{
GtkWidget *scrolledwin;
GTK_SCROLLED_WINDOW(scrolledwin), GTK_SHADOW_IN);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+ toolbar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
scrolledwin, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(scrolledwin), listview);
gtk_widget_destroy(dialog);
}
+static void cb_manager_entry_activate(GtkEntry *entry, GtkWidget *dialog)
+{
+ const gchar *input = gtk_entry_get_text(entry);
+
+ if (!input || strcmp(input, "") == 0)
+ return;
+
+ gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_APPLY);
+}
+
static void append_manager(GtkAction *action, other_t *data)
{
GtkWidget *dialog;
GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
entry = gtk_entry_new();
+ g_signal_connect(G_OBJECT(entry) , "activate" ,
+ G_CALLBACK(cb_manager_entry_activate), dialog);
gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
g_object_set_data(G_OBJECT(entry), "parent", (gpointer)dialog);
{
other_t data;
GtkWidget *dialog;
+ GtkWidget *toolbar;
GtkWidget *listview;
gchar *title;
gint response;
NULL);
g_free(title);
- create_dialog_menu(dialog, &data);
+ toolbar = create_dialog_menu(dialog, &data);
listview = create_list_manager();
- create_manager_view(dialog, listview);
+ create_manager_view(dialog, toolbar, listview);
data.dialog = dialog;
data.manager.listview = listview;
transition->current_page = CCS_SCREEN_DOMAIN_LIST;
}
/*-------+---------+---------+---------+---------+---------+---------+--------*/
+static void cnv_local_time(gchar *date, gchar *time)
+{
+ struct tm t, *lt;
+ time_t timet;
+
+ memset(&t, 0, sizeof(t));
+ sscanf(date, "%d/%d/%d", &(t.tm_year), &(t.tm_mon), &(t.tm_mday));
+ sscanf(time, "%d:%d:%d", &(t.tm_hour), &(t.tm_min), &(t.tm_sec));
+
+ t.tm_year -= 1900;
+ t.tm_mon--;
+ timet = timegm(&t);
+ lt = localtime(&timet);
+
+ g_sprintf(date, "%04d/%02d/%02d",
+ lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday);
+ g_sprintf(time, "%02d:%02d:%02d", lt->tm_hour, lt->tm_min, lt->tm_sec);
+}
+
static void get_disp_column(const char *data, gchar **head,
gchar **now_str, gchar **quota_str)
{
memset(name, 0, sizeof(name));
memset(date, 0, sizeof(date));
memset(time, 0, sizeof(time));
- if ((cnt = sscanf(data, "Policy update: %u %s %s %s",
+ if ((cnt = sscanf(data, "Policy update: %u (%s %s %s)",
&now, name, date, time)) >= 1) {
*head = "Policy update";
} else if ((cnt = sscanf(data,
- "Policy violation in learning mode: %u %s %s %s",
+ "Policy violation in learning mode: %u (%s %s %s)",
&now, name, date, time)) >= 1) {
*head = "Policy violation in learning mode";
} else if ((cnt = sscanf(data,
- "Policy violation in permissive mode: %u %s %s %s",
+ "Policy violation in permissive mode: %u (%s %s %s)",
&now, name, date, time)) >= 1) {
*head = "Policy violation in permissive mode";
} else if ((cnt = sscanf(data,
- "Policy violation in enforcing mode: %u %s %s %s",
+ "Policy violation in enforcing mode: %u (%s %s %s)",
&now, name, date, time)) >= 1) {
*head = "Policy violation in enforcing mode";
} else if ((cnt = sscanf(data,
bQuota = FALSE;
*now_str = bNow ? g_strdup_printf("%u", now) : g_strdup("");
- if (strlen(name))
+ if (strlen(name)) {
+ cnv_local_time(date, time);
*quota_str = g_strdup_printf("%s %s %s", name, date, time);
- else
+ } else {
*quota_str = bQuota ? g_strdup_printf("%u", quota) : g_strdup("");
+ }
}
enum mem_column_pos {
return treeview;
}
-static void create_memory_view(GtkWidget *dialog, GtkWidget *listview)
+static void create_memory_view(GtkWidget *dialog, GtkWidget *toolbar,
+ GtkWidget *listview)
{
GtkWidget *scrolledwin;
GTK_SCROLLED_WINDOW(scrolledwin), GTK_SHADOW_IN);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+ toolbar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
scrolledwin, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(scrolledwin), listview);
{
other_t data;
GtkWidget *dialog;
+ GtkWidget *toolbar;
GtkWidget *listview;
gchar *title;
gint response;
dialog = gtk_dialog_new_with_buttons(title,
GTK_WINDOW(transition->window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
g_free(title);
data.dialog = dialog;
data.memory.count = 0;
data.memory.list = NULL;
- create_dialog_menu(dialog, &data);
+ toolbar = create_dialog_menu(dialog, &data);
listview = create_list_memory(&(data.memory));
data.memory.listview = listview;
- create_memory_view(dialog, listview);
+ create_memory_view(dialog, toolbar, listview);
add_list_memory(&(data.memory));
gtk_widget_set_name(dialog, "GpetStatisticsDialog"); // .gpetrc
gtk_widget_show_all(dialog);
+retry_memory:
response = gtk_dialog_run(GTK_DIALOG(dialog));
- if (response == GTK_RESPONSE_APPLY) {
+ if (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_OK) {
char *err_buff = NULL;
DEBUG_PRINT("Apply button was pressed.\n");
if (set_memory(data.memory.list,
g_warning("%s", err_buff);
free(err_buff);
}
+
+ if (response == GTK_RESPONSE_APPLY) {
+ add_list_memory(&(data.memory));
+ goto retry_memory;
+ }
} else {
DEBUG_PRINT("Another response was recieved.\n");
}
#include "gpet.h"
enum task_column_pos {
- COLUMN_INDEX, // data index (invisible)
+ COLUMN_INDEX, // data index (invisible)
COLUMN_NUMBER, // n
- COLUMN_COLON, // :
+ COLUMN_COLON, // :
COLUMN_PROFILE, // profile
- COLUMN_NAME, // process name + pid + domain name
+ COLUMN_NAME, // process name + pid + domain name
N_COLUMNS_TREE
};
{
GtkTreeIter iter;
gchar *str_prof;
+ gchar *str_domain;
gchar *line;
int n = 0, index;
index = tsk->task[*number].index;
str_prof = g_strdup_printf("%3u", tsk->task[*number].profile);
+ str_domain = decode_from_octal_str(tsk->task[*number].domain);
line = g_strdup_printf("%s (%u) %s",
tsk->task[*number].name,
tsk->task[*number].pid,
- tsk->task[*number].domain);
+ str_domain);
gtk_tree_store_set(store, &iter,
COLUMN_INDEX, index,
COLUMN_NUMBER, *number,
COLUMN_COLON, ":",
- COLUMN_PROFILE, str_prof,
+ COLUMN_PROFILE, str_prof,
COLUMN_NAME, line,
-1);
DEBUG_PRINT("[%3d]%3d(%d):%s %s\n", index, *number, nest, str_prof, line);
+ g_free(str_domain);
g_free(str_prof);
g_free(line);
static void cb_selection_proc(GtkTreeSelection *selection,
transition_t *transition)
{
- GtkTreeIter iter;
- gint select_count;
- GtkTreeModel *model;
- GList *list;
- gint index;
+ GtkTreeIter iter;
+ gint select_count;
+ GtkTreeModel *model;
+ GList *list;
+ gint index;
+ gchar *str_domain;
GtkTreePath *path = NULL;
GtkTreeViewColumn *column = NULL;
g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
g_list_free(list);
gtk_tree_model_get(model, &iter, COLUMN_INDEX, &index, -1);
- gtk_entry_set_text(GTK_ENTRY(transition->domainbar),
- transition->tsk.task[index].domain);
+
+ str_domain = decode_from_octal_str(transition->tsk.task[index].domain);
+ gtk_entry_set_text(GTK_ENTRY(transition->domainbar), str_domain);
+ g_free(str_domain);
gtk_tree_view_get_cursor(GTK_TREE_VIEW(
transition->acl.listview), &path, &column);
#include <glib/gi18n.h>
#include "gpet.h"
+#include "conf.h"
typedef struct _search_t {
transition_t *tran;
GtkWidget *combo;
+ GtkWidget *dialog;
} search_t;
#define COMBO_LIST_LIMIT 10
static void search(transition_t *transition, gboolean forward)
{
GtkWidget *view = NULL;
- gint index, count;
+ gint index, start_index, count;
gchar *str_p = NULL;
+ gchar *haystack = NULL;
+ gchar *tmp_entry, *entry = NULL;
+ search_conf_t conf;
- index = get_current_index(transition);
+ if (!S_entry || strcmp(S_entry, "") == 0)
+ return;
+
+ get_conf_search(&conf);
+
+ tmp_entry = encode_to_octal_str(S_entry);
+ entry = conf.match ? g_strdup(tmp_entry) : g_ascii_strup(tmp_entry, -1);
+ g_free(tmp_entry);
+
+ start_index = index = get_current_index(transition);
count = get_list_count(transition);
- while (S_entry) {
- forward ? index++ : index--;
- if (index < 0 || count <= index)
+ while (entry) {
+ if (forward) {
+ index++;
+ if (count <= index) {
+ if (conf.wrap)
+ index = 0;
+ else
+ break;
+ }
+ } else {
+ index--;
+ if (index < 0) {
+ if (conf.wrap)
+ index = count - 1;
+ else
+ break;
+ }
+ }
+ if (index == start_index)
break;
switch((int)transition->current_page) {
break;
}
- if(g_strrstr(str_p, S_entry)) {
+ g_free(haystack);
+ haystack = conf.match ?
+ g_strdup(str_p) : g_ascii_strup(str_p, -1);
+
+ if (transition->current_page != CCS_SCREEN_DOMAIN_LIST)
+ g_free(str_p);
+
+ if(g_strrstr(haystack, entry)) {
GtkTreeModel *model;
put_locate_index(transition, index);
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
gtk_tree_model_foreach(model,
(GtkTreeModelForeachFunc)search_pos_list, transition);
+ g_free(haystack);
break;
}
}
- if (transition->current_page != CCS_SCREEN_DOMAIN_LIST)
- g_free(str_p);
+ g_free(entry);
gtk_action_set_sensitive(gtk_action_group_get_action(
transition->actions, "SearchBack"), TRUE);
}
}
-static void cb_combo_entry_activate(GtkEntry *entry, search_t *srch)
+static void cb_search_entry_activate(GtkEntry *entry, search_t *srch)
{
GtkComboBox *combobox;
gchar *new_text;
combobox = GTK_COMBO_BOX(srch->combo);
new_text = gtk_combo_box_get_active_text(combobox);
- if(!new_text || strcmp(new_text, "") == 0)
+ if (!new_text || strcmp(new_text, "") == 0) {
return;
+ }
g_free(S_entry);
S_entry = g_strdup(new_text);
-// g_print("cb_combo_entry_activate[%s]\n", new_text);
+// g_print("cb_search_entry_activate[%s]\n", new_text);
for (list = combolist; list; list = g_list_next(list)) {
if (strcmp(new_text, (gchar *)list->data) == 0) {
}
}
- if (entry)
+ if (entry) {
+ search_conf_t conf;
search(srch->tran, TRUE);
+ get_conf_search(&conf);
+ if (conf.close)
+ gtk_dialog_response(GTK_DIALOG(srch->dialog),
+ GTK_RESPONSE_CLOSE);
+ }
}
static void cb_btn_prev_clicked(GtkButton *widget , search_t *srch)
{
- cb_combo_entry_activate(NULL, srch);
+ search_conf_t conf;
+ cb_search_entry_activate(NULL, srch);
search(srch->tran, FALSE);
+ get_conf_search(&conf);
+ if (conf.close)
+ gtk_dialog_response(GTK_DIALOG(srch->dialog),
+ GTK_RESPONSE_CLOSE);
}
static void cb_btn_next_clicked(GtkButton *widget , search_t *srch)
{
- cb_combo_entry_activate(NULL, srch);
+ search_conf_t conf;
+ cb_search_entry_activate(NULL, srch);
search(srch->tran, TRUE);
+ get_conf_search(&conf);
+ if (conf.close)
+ gtk_dialog_response(GTK_DIALOG(srch->dialog),
+ GTK_RESPONSE_CLOSE);
}
/*-------+---------+---------+---------+---------+---------+---------+--------*/
GList *insert_item(GtkComboBox *combobox,
return title;
}
+static void cb_toggled_match(GtkToggleButton *widget, search_conf_t *conf)
+{
+ conf->match = gtk_toggle_button_get_active(widget);
+ put_conf_search(conf);
+}
+static void cb_toggled_wrap(GtkToggleButton *widget, search_conf_t *conf)
+{
+ conf->wrap = gtk_toggle_button_get_active(widget);
+ put_conf_search(conf);
+}
+static void cb_toggled_close(GtkToggleButton *widget, search_conf_t *conf)
+{
+ conf->close = gtk_toggle_button_get_active(widget);
+ put_conf_search(conf);
+}
+
+static void create_check_box(GtkWidget *parent, search_conf_t *conf)
+{
+ GtkWidget *hbox, *vbox_l, *vbox_r;
+ GtkWidget *match, *wrap, *close;
+
+ hbox = gtk_hbox_new(FALSE, 15);
+ gtk_box_pack_start(GTK_BOX(parent), hbox, TRUE, TRUE, 10);
+
+ vbox_l = gtk_vbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(hbox), vbox_l, TRUE, FALSE, 0);
+ vbox_r = gtk_vbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(hbox), vbox_r, TRUE, FALSE, 0);
+
+ match = gtk_check_button_new_with_mnemonic(_("_Match case"));
+ gtk_box_pack_start(GTK_BOX(vbox_l), match, TRUE, FALSE, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(match), conf->match);
+ g_signal_connect(G_OBJECT(match), "toggled",
+ G_CALLBACK(cb_toggled_match), conf);
+
+ wrap = gtk_check_button_new_with_mnemonic(_("_Wrap around"));
+ gtk_box_pack_start(GTK_BOX(vbox_l), wrap, TRUE, FALSE, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wrap), conf->wrap);
+ g_signal_connect(G_OBJECT(wrap), "toggled",
+ G_CALLBACK(cb_toggled_wrap), conf);
+
+ close = gtk_check_button_new_with_mnemonic(_("Close _dialog"));
+ gtk_box_pack_start(GTK_BOX(vbox_r), close, FALSE, FALSE, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(close), conf->close);
+ g_signal_connect(G_OBJECT(close), "toggled",
+ G_CALLBACK(cb_toggled_close), conf);
+
+/*
+ 大文字と小文字を区別する (M)atch case
+ 折返しも対象にする (W)rap around
+ enterで閉じる Close (d)ialog
+*/
+}
+
void search_input(GtkAction *action, transition_t *transition)
{
GtkWidget *dialog, *parent;
GtkWidget *btn_next, *btn_prev;
GList *list;
search_t srch;
+ search_conf_t conf;
gint response;
parent = (transition->acl_detached &&
entry = gtk_combo_box_entry_new_text();
srch.tran = transition;
srch.combo = entry;
+ srch.dialog = dialog;
g_signal_connect(G_OBJECT(entry) , "changed",
G_CALLBACK(cb_combo_changed), NULL);
g_signal_connect(G_OBJECT(GTK_BIN(entry)->child) , "activate" ,
- G_CALLBACK(cb_combo_entry_activate), &srch);
+ G_CALLBACK(cb_search_entry_activate), &srch);
gtk_box_pack_start(GTK_BOX(vbox_l), entry, FALSE, FALSE, 0);
for (list = combolist; list; list = g_list_next(list)) {
}
gtk_combo_box_set_active(GTK_COMBO_BOX(entry), 0);
+ get_conf_search(&conf);
+ create_check_box(vbox_l, &conf);
+
vbox_r = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(hbox), vbox_r, FALSE, FALSE, 0);
btn_prev = gtk_button_new_from_stock(GTK_STOCK_GO_BACK);
- gtk_box_pack_start(GTK_BOX(vbox_r), btn_prev, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox_r), btn_prev, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(btn_prev) , "clicked" ,
G_CALLBACK (cb_btn_prev_clicked) , &srch);
btn_next = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD);
- gtk_box_pack_start(GTK_BOX(vbox_r), btn_next, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox_r), btn_next, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(btn_next) , "clicked" ,
G_CALLBACK (cb_btn_next_clicked) , &srch);
- gtk_widget_set_size_request(dialog, 400, -1);
+ gtk_widget_set_size_request(dialog, 520, -1);
put_locate_index(transition, get_current_index(transition));
gtk_widget_show_all(dialog);