mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-01 06:45:38 +00:00
* Added context menu to event list
- Provides remove/profile options * Added initial profiler tool launcher
This commit is contained in:
@@ -242,9 +242,8 @@ void applet_about(BonoboUIComponent * uic)
|
|||||||
{
|
{
|
||||||
const gchar *license =
|
const gchar *license =
|
||||||
_("AppArmorApplet is free software; you can redistribute it and/or modify\n"
|
_("AppArmorApplet is free software; you can redistribute it and/or modify\n"
|
||||||
"it under the terms of the GNU General Public License as published by\n"
|
"it under the terms of the GNU General Public License, version 2, as published by\n"
|
||||||
"the Free Software Foundation; either version 2 of the License, or\n"
|
"the Free Software Foundation.");
|
||||||
"(at your option) any later version.");
|
|
||||||
|
|
||||||
const gchar *authors[] = {
|
const gchar *authors[] = {
|
||||||
"Matt Barringer <mbarringer@suse.de>",
|
"Matt Barringer <mbarringer@suse.de>",
|
||||||
@@ -274,7 +273,7 @@ void applet_prefs (BonoboUIComponent *uic)
|
|||||||
gboolean on_button_press (GtkWidget *event_box,
|
gboolean on_button_press (GtkWidget *event_box,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
if (event->button != 1)
|
if (event->button != 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -290,19 +289,20 @@ gboolean on_button_press (GtkWidget *event_box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
void reject_button_press (GtkDialog * dialog, gint answer, gpointer data)
|
|
||||||
{
|
|
||||||
if (answer == GTK_RESPONSE_OK || answer == GTK_RESPONSE_CANCEL)
|
|
||||||
{
|
|
||||||
gtk_widget_hide(apparmor_applet->reject_dialog);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reject_window_close (GtkDialog * dialog, gpointer data)
|
/* Decrement the event count and reset the icon/tooltip state if necessary */
|
||||||
|
void decrement_event_count(gint decrement)
|
||||||
{
|
{
|
||||||
gtk_widget_hide(apparmor_applet->reject_dialog);
|
apparmor_applet->alert_count = apparmor_applet->alert_count - decrement;
|
||||||
|
|
||||||
|
if (apparmor_applet->alert_count <= 0)
|
||||||
|
{
|
||||||
|
apparmor_applet->alert_count= 0;
|
||||||
|
apparmor_applet->uncleared_alerts = FALSE;
|
||||||
|
set_appropriate_icon();
|
||||||
|
set_tooltip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PANEL_APPLET_BONOBO_FACTORY("OAFIID:AppArmorApplet_Factory",
|
PANEL_APPLET_BONOBO_FACTORY("OAFIID:AppArmorApplet_Factory",
|
||||||
|
@@ -1,6 +1,12 @@
|
|||||||
#ifndef __APPARMOR_APPLET_H
|
#ifndef __APPARMOR_APPLET_H
|
||||||
#define __APPARMOR_APPLET_H
|
#define __APPARMOR_APPLET_H
|
||||||
|
|
||||||
|
#include <panel-applet.h>
|
||||||
|
|
||||||
|
#define CONF_PATH "/apps/AppArmor/apparmor-applet"
|
||||||
|
#define CONF_PROFILE_KEY "/apps/AppArmor/apparmor-applet/profiler"
|
||||||
|
#define CONF_PATH_KEY "/apps/AppArmor/apparmor-applet/path"
|
||||||
|
|
||||||
struct _apparmor_applet
|
struct _apparmor_applet
|
||||||
{
|
{
|
||||||
GtkWidget *applet;
|
GtkWidget *applet;
|
||||||
@@ -26,7 +32,6 @@ gboolean on_button_press (GtkWidget *event_box,
|
|||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
void insert_into_list(char *name);
|
void insert_into_list(char *name);
|
||||||
void reject_button_press (GtkDialog * dialog, gint answer, gpointer data);
|
void decrement_event_count(gint decrement);
|
||||||
void reject_window_close (GtkDialog * dialog, gpointer data);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -10,99 +10,120 @@
|
|||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <gconf/gconf-client.h>
|
||||||
#include "preferences_dialog.h"
|
#include "preferences_dialog.h"
|
||||||
|
#include "apparmor-applet.h"
|
||||||
|
|
||||||
|
GtkWidget *profile_combobox;
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
create_preferences_dialog (void)
|
create_preferences_dialog (void)
|
||||||
{
|
{
|
||||||
GtkWidget *preferences_dialog;
|
GtkWidget *preferences_dialog;
|
||||||
GtkWidget *preferences_vbox;
|
GtkWidget *preferences_vbox;
|
||||||
GtkWidget *layout_table;
|
GtkWidget *layout_table;
|
||||||
GtkWidget *profile_label;
|
GtkWidget *profile_label;
|
||||||
GtkWidget *path_label;
|
GtkWidget *path_label;
|
||||||
GtkWidget *path_entry;
|
GtkWidget *preferences_buttonbox;
|
||||||
GtkWidget *profile_combobox;
|
GtkWidget *cancel_button;
|
||||||
GtkWidget *preferences_buttonbox;
|
GtkWidget *ok_button;
|
||||||
GtkWidget *cancel_button;
|
GtkWidget *path_entry;
|
||||||
GtkWidget *ok_button;
|
|
||||||
|
|
||||||
preferences_dialog = gtk_dialog_new ();
|
GConfClient *client;
|
||||||
gtk_widget_set_name (preferences_dialog, "preferences_dialog");
|
int active_combo;
|
||||||
gtk_window_set_title (GTK_WINDOW (preferences_dialog), _("AppArmor Desktop Preferences"));
|
client = gconf_client_get_default();
|
||||||
gtk_window_set_position (GTK_WINDOW (preferences_dialog), GTK_WIN_POS_CENTER);
|
active_combo = gconf_client_get_int(client, CONF_PROFILE_KEY, NULL);
|
||||||
gtk_window_set_modal (GTK_WINDOW (preferences_dialog), TRUE);
|
|
||||||
gtk_window_set_type_hint (GTK_WINDOW (preferences_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
|
|
||||||
|
|
||||||
preferences_vbox = GTK_DIALOG (preferences_dialog)->vbox;
|
preferences_dialog = gtk_dialog_new ();
|
||||||
gtk_widget_set_name (preferences_vbox, "preferences_vbox");
|
gtk_widget_set_name (preferences_dialog, "preferences_dialog");
|
||||||
gtk_widget_show (preferences_vbox);
|
gtk_window_set_title (GTK_WINDOW (preferences_dialog), _("AppArmor Desktop Preferences"));
|
||||||
|
gtk_window_set_position (GTK_WINDOW (preferences_dialog), GTK_WIN_POS_CENTER);
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (preferences_dialog), TRUE);
|
||||||
|
gtk_window_set_type_hint (GTK_WINDOW (preferences_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
|
||||||
|
|
||||||
|
preferences_vbox = GTK_DIALOG (preferences_dialog)->vbox;
|
||||||
|
gtk_widget_set_name (preferences_vbox, "preferences_vbox");
|
||||||
|
gtk_widget_show (preferences_vbox);
|
||||||
|
|
||||||
|
layout_table = gtk_table_new (2, 2, FALSE);
|
||||||
|
gtk_widget_set_name (layout_table, "layout_table");
|
||||||
|
gtk_widget_show (layout_table);
|
||||||
|
gtk_box_pack_start (GTK_BOX (preferences_vbox), layout_table, FALSE, TRUE, 0);
|
||||||
|
gtk_table_set_col_spacings (GTK_TABLE (layout_table), 10);
|
||||||
|
|
||||||
|
profile_label = gtk_label_new (_("Profile Generation"));
|
||||||
|
gtk_widget_set_name (profile_label, "profile_label");
|
||||||
|
gtk_widget_show (profile_label);
|
||||||
|
gtk_table_attach (GTK_TABLE (layout_table), profile_label, 0, 1, 0, 1,
|
||||||
|
(GtkAttachOptions) (GTK_FILL),
|
||||||
|
(GtkAttachOptions) (0), 0, 0);
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (profile_label), 0, 0.5);
|
||||||
|
|
||||||
|
path_label = gtk_label_new (_("Path"));
|
||||||
|
gtk_widget_set_name (path_label, "path_label");
|
||||||
|
gtk_widget_show (path_label);
|
||||||
|
gtk_table_attach (GTK_TABLE (layout_table), path_label, 0, 1, 1, 2,
|
||||||
|
(GtkAttachOptions) (GTK_FILL),
|
||||||
|
(GtkAttachOptions) (0), 0, 0);
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (path_label), 0, 0.5);
|
||||||
|
|
||||||
|
path_entry = gtk_entry_new ();
|
||||||
|
gtk_widget_set_name (path_entry, "path_entry");
|
||||||
|
gtk_widget_show (path_entry);
|
||||||
|
gtk_table_attach (GTK_TABLE (layout_table), path_entry, 1, 2, 1, 2,
|
||||||
|
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||||
|
(GtkAttachOptions) (0), 0, 0);
|
||||||
|
gtk_entry_set_invisible_char (GTK_ENTRY (path_entry), 9679);
|
||||||
|
|
||||||
|
|
||||||
|
profile_combobox = gtk_combo_box_new_text ();
|
||||||
|
gtk_widget_set_name (profile_combobox, "profile_combobox");
|
||||||
|
gtk_widget_show (profile_combobox);
|
||||||
|
gtk_table_attach (GTK_TABLE (layout_table), profile_combobox, 1, 2, 0, 1,
|
||||||
|
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||||
|
(GtkAttachOptions) (GTK_FILL), 0, 0);
|
||||||
|
gtk_combo_box_append_text (GTK_COMBO_BOX (profile_combobox), _("YAST"));
|
||||||
|
gtk_combo_box_append_text (GTK_COMBO_BOX (profile_combobox), _("genprof"));
|
||||||
|
gtk_combo_box_set_active(GTK_COMBO_BOX(profile_combobox), active_combo);
|
||||||
|
|
||||||
layout_table = gtk_table_new (2, 2, FALSE);
|
preferences_buttonbox = GTK_DIALOG (preferences_dialog)->action_area;
|
||||||
gtk_widget_set_name (layout_table, "layout_table");
|
gtk_widget_set_name (preferences_buttonbox, "preferences_buttonbox");
|
||||||
gtk_widget_show (layout_table);
|
gtk_widget_show (preferences_buttonbox);
|
||||||
gtk_box_pack_start (GTK_BOX (preferences_vbox), layout_table, FALSE, TRUE, 0);
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (preferences_buttonbox), GTK_BUTTONBOX_END);
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (layout_table), 10);
|
|
||||||
|
cancel_button = gtk_button_new_from_stock ("gtk-cancel");
|
||||||
profile_label = gtk_label_new (_("Profile Generation"));
|
gtk_widget_set_name (cancel_button, "cancel_button");
|
||||||
gtk_widget_set_name (profile_label, "profile_label");
|
gtk_widget_show (cancel_button);
|
||||||
gtk_widget_show (profile_label);
|
gtk_dialog_add_action_widget (GTK_DIALOG (preferences_dialog), cancel_button, GTK_RESPONSE_CANCEL);
|
||||||
gtk_table_attach (GTK_TABLE (layout_table), profile_label, 0, 1, 0, 1,
|
GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
|
||||||
(GtkAttachOptions) (GTK_FILL),
|
|
||||||
(GtkAttachOptions) (0), 0, 0);
|
ok_button = gtk_button_new_from_stock ("gtk-ok");
|
||||||
gtk_misc_set_alignment (GTK_MISC (profile_label), 0, 0.5);
|
gtk_widget_set_name (ok_button, "ok_button");
|
||||||
|
gtk_widget_show (ok_button);
|
||||||
path_label = gtk_label_new (_("Path"));
|
gtk_dialog_add_action_widget (GTK_DIALOG (preferences_dialog), ok_button, GTK_RESPONSE_OK);
|
||||||
gtk_widget_set_name (path_label, "path_label");
|
GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
|
||||||
gtk_widget_show (path_label);
|
|
||||||
gtk_table_attach (GTK_TABLE (layout_table), path_label, 0, 1, 1, 2,
|
g_signal_connect(preferences_dialog, "response",
|
||||||
(GtkAttachOptions) (GTK_FILL),
|
|
||||||
(GtkAttachOptions) (0), 0, 0);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (path_label), 0, 0.5);
|
|
||||||
|
|
||||||
path_entry = gtk_entry_new ();
|
|
||||||
gtk_widget_set_name (path_entry, "path_entry");
|
|
||||||
gtk_widget_show (path_entry);
|
|
||||||
gtk_table_attach (GTK_TABLE (layout_table), path_entry, 1, 2, 1, 2,
|
|
||||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
||||||
(GtkAttachOptions) (0), 0, 0);
|
|
||||||
gtk_entry_set_invisible_char (GTK_ENTRY (path_entry), 9679);
|
|
||||||
|
|
||||||
profile_combobox = gtk_combo_box_new_text ();
|
|
||||||
gtk_widget_set_name (profile_combobox, "profile_combobox");
|
|
||||||
gtk_widget_show (profile_combobox);
|
|
||||||
gtk_table_attach (GTK_TABLE (layout_table), profile_combobox, 1, 2, 0, 1,
|
|
||||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
||||||
(GtkAttachOptions) (GTK_FILL), 0, 0);
|
|
||||||
gtk_combo_box_append_text (GTK_COMBO_BOX (profile_combobox), _("YAST"));
|
|
||||||
gtk_combo_box_append_text (GTK_COMBO_BOX (profile_combobox), _("genprof"));
|
|
||||||
|
|
||||||
preferences_buttonbox = GTK_DIALOG (preferences_dialog)->action_area;
|
|
||||||
gtk_widget_set_name (preferences_buttonbox, "preferences_buttonbox");
|
|
||||||
gtk_widget_show (preferences_buttonbox);
|
|
||||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (preferences_buttonbox), GTK_BUTTONBOX_END);
|
|
||||||
|
|
||||||
cancel_button = gtk_button_new_from_stock ("gtk-cancel");
|
|
||||||
gtk_widget_set_name (cancel_button, "cancel_button");
|
|
||||||
gtk_widget_show (cancel_button);
|
|
||||||
gtk_dialog_add_action_widget (GTK_DIALOG (preferences_dialog), cancel_button, GTK_RESPONSE_CANCEL);
|
|
||||||
GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
|
|
||||||
|
|
||||||
ok_button = gtk_button_new_from_stock ("gtk-ok");
|
|
||||||
gtk_widget_set_name (ok_button, "ok_button");
|
|
||||||
gtk_widget_show (ok_button);
|
|
||||||
gtk_dialog_add_action_widget (GTK_DIALOG (preferences_dialog), ok_button, GTK_RESPONSE_OK);
|
|
||||||
GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
|
|
||||||
|
|
||||||
g_signal_connect(preferences_dialog, "response",
|
|
||||||
G_CALLBACK(button_press),
|
G_CALLBACK(button_press),
|
||||||
NULL);
|
NULL);
|
||||||
return preferences_dialog;
|
return preferences_dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void button_press (GtkDialog * dialog, gint answer, gpointer data)
|
void
|
||||||
|
button_press (GtkDialog * dialog, gint answer, gpointer data)
|
||||||
{
|
{
|
||||||
if (answer == GTK_RESPONSE_OK || answer == GTK_RESPONSE_CANCEL)
|
if (answer == GTK_RESPONSE_OK || answer == GTK_RESPONSE_CANCEL)
|
||||||
{
|
{
|
||||||
|
if (answer == GTK_RESPONSE_OK)
|
||||||
|
{
|
||||||
|
int active = gtk_combo_box_get_active (GTK_COMBO_BOX(profile_combobox));
|
||||||
|
if (active <= -1)
|
||||||
|
active = 0;
|
||||||
|
|
||||||
|
GConfClient *client;
|
||||||
|
client = gconf_client_get_default();
|
||||||
|
gconf_client_set_int(client, CONF_PROFILE_KEY, active, NULL);
|
||||||
|
}
|
||||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
gtk_widget_destroy(GTK_WIDGET(dialog));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,15 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <gconf/gconf-client.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <panel-applet.h>
|
#include <panel-applet.h>
|
||||||
|
#include <libgnome/libgnome.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
@@ -17,90 +19,254 @@
|
|||||||
static void
|
static void
|
||||||
add_columns (GtkTreeView *treeview)
|
add_columns (GtkTreeView *treeview)
|
||||||
{
|
{
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
GtkTreeViewColumn *column;
|
GtkTreeViewColumn *column;
|
||||||
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
|
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
|
||||||
|
|
||||||
/* column for fixed toggles */
|
/* column for fixed toggles */
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
|
|
||||||
column = gtk_tree_view_column_new_with_attributes ("Program Name",
|
column = gtk_tree_view_column_new_with_attributes ("Program Name",
|
||||||
renderer,
|
renderer,
|
||||||
"text", 0,
|
"text", 0,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_tree_view_column_set_sort_column_id (column, 0);
|
gtk_tree_view_column_set_sort_column_id (column, 0);
|
||||||
gtk_tree_view_append_column (treeview, column);
|
gtk_tree_view_append_column (treeview, column);
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
column = gtk_tree_view_column_new_with_attributes ("Rejection Count",
|
column = gtk_tree_view_column_new_with_attributes ("Rejection Count",
|
||||||
renderer,
|
renderer,
|
||||||
"text", 1,
|
"text", 1,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_tree_view_column_set_sort_column_id (column, 1);
|
gtk_tree_view_column_set_sort_column_id (column, 1);
|
||||||
gtk_tree_view_append_column (treeview, column);
|
gtk_tree_view_append_column (treeview, column);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
create_reject_dialog (GtkListStore *store)
|
create_reject_dialog (GtkListStore *store)
|
||||||
{
|
{
|
||||||
GtkWidget *reject_dialog;
|
GtkWidget *reject_dialog;
|
||||||
GtkWidget *reject_vbox;
|
GtkWidget *reject_vbox;
|
||||||
GtkWidget *reject_list_scrolledwindow;
|
GtkWidget *reject_list_scrolledwindow;
|
||||||
GtkWidget *program_list;
|
GtkWidget *program_list;
|
||||||
GtkWidget *reject_button_area;
|
GtkWidget *reject_button_area;
|
||||||
GtkWidget *cancel_button;
|
GtkWidget *cancel_button;
|
||||||
GtkWidget *ok_button;
|
GtkWidget *ok_button;
|
||||||
GtkTreeIter listIter;
|
GtkTreeIter listIter;
|
||||||
|
|
||||||
|
reject_dialog = gtk_dialog_new ();
|
||||||
|
gtk_widget_set_name (reject_dialog, "reject_dialog");
|
||||||
|
gtk_window_set_title (GTK_WINDOW (reject_dialog), _("AppArmor Rejections"));
|
||||||
|
gtk_window_set_type_hint (GTK_WINDOW (reject_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
|
||||||
|
gtk_window_set_modal(GTK_WINDOW(reject_dialog), TRUE);
|
||||||
|
|
||||||
|
reject_vbox = GTK_DIALOG (reject_dialog)->vbox;
|
||||||
|
gtk_widget_set_name (reject_vbox, "reject_vbox");
|
||||||
|
gtk_widget_show (reject_vbox);
|
||||||
|
|
||||||
|
reject_list_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_widget_set_name (reject_list_scrolledwindow, "reject_list_scrolledwindow");
|
||||||
|
gtk_widget_show (reject_list_scrolledwindow);
|
||||||
|
gtk_box_pack_start (GTK_BOX (reject_vbox), reject_list_scrolledwindow, TRUE, TRUE, 0);
|
||||||
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (reject_list_scrolledwindow), GTK_SHADOW_IN);
|
||||||
|
|
||||||
|
program_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
|
||||||
|
gtk_widget_set_name (program_list, "program_list");
|
||||||
|
gtk_widget_show (program_list);
|
||||||
|
gtk_container_add (GTK_CONTAINER (reject_list_scrolledwindow), program_list);
|
||||||
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (program_list), TRUE);
|
||||||
|
add_columns (GTK_TREE_VIEW (program_list));
|
||||||
|
|
||||||
|
reject_button_area = GTK_DIALOG (reject_dialog)->action_area;
|
||||||
|
gtk_widget_set_name (reject_button_area, "reject_button_area");
|
||||||
|
gtk_widget_show (reject_button_area);
|
||||||
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (reject_button_area), GTK_BUTTONBOX_END);
|
||||||
|
|
||||||
|
cancel_button = gtk_button_new_from_stock ("gtk-cancel");
|
||||||
|
gtk_widget_set_name (cancel_button, "cancel_button");
|
||||||
|
gtk_widget_show (cancel_button);
|
||||||
|
gtk_dialog_add_action_widget (GTK_DIALOG (reject_dialog), cancel_button, GTK_RESPONSE_CANCEL);
|
||||||
|
GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
|
||||||
|
|
||||||
|
ok_button = gtk_button_new_from_stock ("gtk-ok");
|
||||||
|
gtk_widget_set_name (ok_button, "ok_button");
|
||||||
|
gtk_widget_show (ok_button);
|
||||||
|
gtk_dialog_add_action_widget (GTK_DIALOG (reject_dialog), ok_button, GTK_RESPONSE_OK);
|
||||||
|
GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
|
||||||
|
|
||||||
|
g_signal_connect(reject_dialog,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK(reject_button_press),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect(reject_dialog,
|
||||||
|
"delete-event",
|
||||||
|
G_CALLBACK(reject_window_close),
|
||||||
|
NULL);
|
||||||
|
|
||||||
reject_dialog = gtk_dialog_new ();
|
g_signal_connect(program_list,
|
||||||
gtk_widget_set_name (reject_dialog, "reject_dialog");
|
"button-press-event",
|
||||||
gtk_window_set_title (GTK_WINDOW (reject_dialog), _("AppArmor Rejections"));
|
G_CALLBACK(popup_button_pressed),
|
||||||
gtk_window_set_type_hint (GTK_WINDOW (reject_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
|
NULL);
|
||||||
gtk_window_set_modal(GTK_WINDOW(reject_dialog), TRUE);
|
|
||||||
|
|
||||||
reject_vbox = GTK_DIALOG (reject_dialog)->vbox;
|
g_signal_connect(program_list,
|
||||||
gtk_widget_set_name (reject_vbox, "reject_vbox");
|
"popup-menu",
|
||||||
gtk_widget_show (reject_vbox);
|
G_CALLBACK(view_on_popup_menu),
|
||||||
|
NULL);
|
||||||
reject_list_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
|
||||||
gtk_widget_set_name (reject_list_scrolledwindow, "reject_list_scrolledwindow");
|
gtk_widget_grab_focus (program_list);
|
||||||
gtk_widget_show (reject_list_scrolledwindow);
|
gtk_window_set_default_size(GTK_WINDOW(reject_dialog), 500, 400);
|
||||||
gtk_box_pack_start (GTK_BOX (reject_vbox), reject_list_scrolledwindow, TRUE, TRUE, 0);
|
return reject_dialog;
|
||||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (reject_list_scrolledwindow), GTK_SHADOW_IN);
|
|
||||||
|
|
||||||
program_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
|
|
||||||
gtk_widget_set_name (program_list, "program_list");
|
|
||||||
gtk_widget_show (program_list);
|
|
||||||
gtk_container_add (GTK_CONTAINER (reject_list_scrolledwindow), program_list);
|
|
||||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (program_list), TRUE);
|
|
||||||
add_columns (GTK_TREE_VIEW (program_list));
|
|
||||||
|
|
||||||
reject_button_area = GTK_DIALOG (reject_dialog)->action_area;
|
|
||||||
gtk_widget_set_name (reject_button_area, "reject_button_area");
|
|
||||||
gtk_widget_show (reject_button_area);
|
|
||||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (reject_button_area), GTK_BUTTONBOX_END);
|
|
||||||
|
|
||||||
cancel_button = gtk_button_new_from_stock ("gtk-cancel");
|
|
||||||
gtk_widget_set_name (cancel_button, "cancel_button");
|
|
||||||
gtk_widget_show (cancel_button);
|
|
||||||
gtk_dialog_add_action_widget (GTK_DIALOG (reject_dialog), cancel_button, GTK_RESPONSE_CANCEL);
|
|
||||||
GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
|
|
||||||
|
|
||||||
ok_button = gtk_button_new_from_stock ("gtk-ok");
|
|
||||||
gtk_widget_set_name (ok_button, "ok_button");
|
|
||||||
gtk_widget_show (ok_button);
|
|
||||||
gtk_dialog_add_action_widget (GTK_DIALOG (reject_dialog), ok_button, GTK_RESPONSE_OK);
|
|
||||||
GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
|
|
||||||
|
|
||||||
g_signal_connect(reject_dialog, "response",
|
|
||||||
G_CALLBACK(reject_button_press),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_signal_connect(reject_dialog, "delete-event",
|
|
||||||
G_CALLBACK(reject_window_close),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_widget_grab_focus (program_list);
|
|
||||||
return reject_dialog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void reject_button_press (GtkDialog * dialog, gint answer, gpointer data)
|
||||||
|
{
|
||||||
|
if (answer == GTK_RESPONSE_OK || answer == GTK_RESPONSE_CANCEL)
|
||||||
|
{
|
||||||
|
gtk_widget_hide(GTK_WIDGET(dialog));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reject_window_close (GtkDialog * dialog, gpointer data)
|
||||||
|
{
|
||||||
|
gtk_widget_hide(GTK_WIDGET(dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
handle_popup_profile (GtkWidget *menuitem, gpointer userdata)
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview = GTK_TREE_VIEW(userdata);
|
||||||
|
GConfClient *client = gconf_client_get_default();
|
||||||
|
|
||||||
|
int profiler_type = gconf_client_get_int(client, CONF_PROFILE_KEY, NULL);
|
||||||
|
char *cmdline;
|
||||||
|
|
||||||
|
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeModel *model = gtk_tree_view_get_model(treeview);
|
||||||
|
gchar *str_data = NULL;
|
||||||
|
|
||||||
|
if (gtk_tree_selection_get_selected(selection, &model, &iter) == TRUE)
|
||||||
|
{
|
||||||
|
|
||||||
|
gint int_data;
|
||||||
|
GtkListStore *store = GTK_LIST_STORE(model);
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
0, &str_data,
|
||||||
|
1, &int_data,
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0 is YAST, 1 is genprof
|
||||||
|
if ((profiler_type == 0) && (str_data != NULL))
|
||||||
|
{
|
||||||
|
cmdline = "/opt/gnome/bin/gnomesu /sbin/yast2 LogProf";
|
||||||
|
gnome_execute_terminal_shell(NULL, cmdline);
|
||||||
|
}
|
||||||
|
else if ((profiler_type == 1) && (str_data != NULL))
|
||||||
|
{
|
||||||
|
/* /usr/sbin/genprof */
|
||||||
|
cmdline = (char *) malloc(41 + strlen(str_data));
|
||||||
|
strcpy(cmdline, "/opt/gnome/bin/gnomesu /usr/sbin/genprof ");
|
||||||
|
strcat(cmdline, str_data);
|
||||||
|
gnome_execute_terminal_shell(NULL, cmdline);
|
||||||
|
free(cmdline);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str_data != NULL)
|
||||||
|
g_free (str_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
handle_popup_remove (GtkWidget *menuitem, gpointer userdata)
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview = GTK_TREE_VIEW(userdata);
|
||||||
|
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeModel *model = gtk_tree_view_get_model(treeview);
|
||||||
|
if (gtk_tree_selection_get_selected(selection, &model, &iter) == TRUE)
|
||||||
|
{
|
||||||
|
gchar *str_data;
|
||||||
|
gint int_data;
|
||||||
|
GtkListStore *store = GTK_LIST_STORE(model);
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
0, &str_data,
|
||||||
|
1, &int_data,
|
||||||
|
-1);
|
||||||
|
g_free (str_data);
|
||||||
|
decrement_event_count(int_data);
|
||||||
|
gtk_list_store_remove(store, &iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
display_popup_menu (GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
|
||||||
|
{
|
||||||
|
GtkWidget *menu, *remove_item, *profile_item;
|
||||||
|
|
||||||
|
menu = gtk_menu_new();
|
||||||
|
|
||||||
|
profile_item = gtk_menu_item_new_with_label(_("Profile application"));
|
||||||
|
remove_item = gtk_menu_item_new_with_label(_("Remove from list"));
|
||||||
|
|
||||||
|
g_signal_connect(remove_item,
|
||||||
|
"activate",
|
||||||
|
G_CALLBACK(handle_popup_remove),
|
||||||
|
treeview);
|
||||||
|
g_signal_connect(profile_item,
|
||||||
|
"activate",
|
||||||
|
G_CALLBACK(handle_popup_profile),
|
||||||
|
treeview);
|
||||||
|
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), profile_item);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), remove_item);
|
||||||
|
|
||||||
|
gtk_widget_show_all(menu);
|
||||||
|
|
||||||
|
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
|
||||||
|
(event != NULL) ? event->button : 0,
|
||||||
|
gdk_event_get_time((GdkEvent*)event));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
popup_button_pressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
|
||||||
|
{
|
||||||
|
if (event->type == GDK_BUTTON_PRESS && event->button == 3)
|
||||||
|
{
|
||||||
|
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
|
||||||
|
|
||||||
|
if (gtk_tree_selection_count_selected_rows(selection) <= 1)
|
||||||
|
{
|
||||||
|
GtkTreePath *path;
|
||||||
|
if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
|
||||||
|
(gint) event->x,
|
||||||
|
(gint) event->y,
|
||||||
|
&path, NULL, NULL, NULL))
|
||||||
|
{
|
||||||
|
gtk_tree_selection_unselect_all(selection);
|
||||||
|
gtk_tree_selection_select_path(selection, path);
|
||||||
|
gtk_tree_path_free(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
display_popup_menu(treeview, event, userdata);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
view_on_popup_menu (GtkWidget *treeview, gpointer userdata)
|
||||||
|
{
|
||||||
|
display_popup_menu(treeview, NULL, userdata);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2,5 +2,12 @@
|
|||||||
#define REJECT_LIST_H
|
#define REJECT_LIST_H
|
||||||
|
|
||||||
GtkWidget* create_reject_dialog (GtkListStore *store);
|
GtkWidget* create_reject_dialog (GtkListStore *store);
|
||||||
|
void reject_button_press (GtkDialog * dialog, gint answer, gpointer data);
|
||||||
|
void reject_window_close (GtkDialog * dialog, gpointer data);
|
||||||
|
void handle_popup_profile (GtkWidget *menuitem, gpointer userdata);
|
||||||
|
void handle_popup_remove (GtkWidget *menuitem, gpointer userdata);
|
||||||
|
void display_popup_menu (GtkWidget *treeview, GdkEventButton *event, gpointer userdata);
|
||||||
|
gboolean popup_button_pressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata);
|
||||||
|
gboolean view_on_popup_menu (GtkWidget *treeview, gpointer userdata);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user