conf = read_config_to_array("/home/" . $_SERVER["USER"] . "/.config/supreme.conf"); $css_provider = new GtkCssProvider(); $css_provider->load_from_data($this->css); $style_context = new GtkStyleContext(); $style_context->add_provider_for_screen($css_provider, 600); $this->notifications = new GtkBox(GtkOrientation::VERTICAL); $this->notifications->set_homogeneous(false); // ============================ Стиль всплывающих уведомлений $label = new GtkLabel("\nНастройки отображения\n"); $label->set_name("bold_1"); $this->notifications->add($label); $notifystylebox = new GtkBox(GtkOrientation::VERTICAL, 5); $notifystylebox->set_name("box"); $notifystylebox->set_homogeneous(false); $trunc_long = GtkCheckButton::new_with_label("Обрезать длинные сообщения, чтобы они умещались на экран"); if ($this->conf["notifications_truncate_long"]=="1") {$trunc_long->set_active(true);} $notifystylebox->add($trunc_long); $trunc_long->connect("clicked", function ($widget) { write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_truncate_long",$widget->get_active()); }); $close_timeout = GtkCheckButton::new_with_label("Автоматически закрывать уведомление по таймауту"); if ($this->conf["notifications_close_timeout"]=="1") {$close_timeout->set_active(true);} $notifystylebox->add($close_timeout); $close_timeout->connect("clicked", function ($widget) { write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_close_timeout",$widget->get_active()); }); $label = new GtkLabel("\nНажатие на уведомление"); $label->set_halign(1); $notifystylebox->add($label); $comb2 = new GtkRadioButton(NULL); $act = GtkRadioButton::new_with_label("Активирует содержимое"); $act->join_group($comb2); $act->connect("clicked", function ($widget) { if ($widget->get_active()==1) {write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_click_action","action");} }); $notifystylebox->add($act); $cls = GtkRadioButton::new_with_label("Закрывает уведомление"); $cls->join_group($comb2); $cls->connect("clicked", function ($widget) { if ($widget->get_active()==1) {write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_click_action","close");} }); if ($this->conf["notifications_click_action"]=="action") {$act->set_active(true);} else {$cls->set_active(true);} $notifystylebox->add($cls); $countbox = new GtkBox(GtkOrientation::HORIZONTAL, 10); $countbox->set_size_request(150, -1); $countbox->set_homogeneous(false); $countbox->set_spacing(10); $countbox->set_hexpand(false); $countbox->set_hexpand_set(false); $scalebox = new GtkBox(GtkOrientation::VERTICAL, 0); $scalebox->set_spacing(0); $scalebox->set_size_request(100, -1); $scalebox->set_homogeneous(true); $amount = new GtkAdjustment($this->conf["notifications_amount_show"], 1, 10, 1, 1, 1); $scale = new GtkScale(GtkOrientation::HORIZONTAL, $amount, false); $amount->connect("value-changed", function ($adj) { global $scalelabel; $amount = round($adj->get_value(),0); $scalelabel->set_text("$amount"); write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_amount_show","$amount"); }); $scalelabel = new GtkLabel($this->conf["notifications_amount_show"]); $scalebox->add($scalelabel); $scalebox->add($scale); $label = new GtkLabel("Количество одновременно отображаемых уведомлений"); $countbox->add($scalebox); $countbox->add($label); $notifystylebox->add($countbox); $label = new GtkLabel("\nРасположение всплывающих уведомлений\n"); $label->set_name("bold_1"); $notifystylebox->add($label); $comb2 = new GtkRadioButton(NULL); $top = GtkRadioButton::new_with_label("Сверху"); $top->join_group($comb2); $top->connect("clicked", function ($widget) { if ($widget->get_active()==1) {write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_position","top");} }); $notifystylebox->add($top); $bottom = GtkRadioButton::new_with_label("Снизу"); $bottom->join_group($comb2); $bottom->connect("clicked", function ($widget) { if ($widget->get_active()==1) {write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_position","bottom");} }); $notifystylebox->add($bottom); if ($this->conf["notifications_position"]=="top") {$top->set_active(true);} else {$bottom->set_active(true);} $label = new GtkLabel("\nВнешний вид уведомления\n"); $label->set_name("bold_1"); $notifystylebox->add($label); $comb2 = new GtkRadioButton(NULL); $default = GtkRadioButton::new_with_label("Согласно цветовым настройкам темы"); $default->join_group($comb2); $default->connect("clicked", function ($widget) { if ($widget->get_active()==1) {write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_theme","default");} }); $notifystylebox->add($default); $inverted = GtkRadioButton::new_with_label("Инвертированный"); $inverted->join_group($comb2); $inverted->connect("clicked", function ($widget) { if ($widget->get_active()==1) {write_parameter("/home/" . $_SERVER["USER"] . "/.config/supreme.conf","notifications_theme","inverted");} }); $label = new GtkLabel("Инвентированный внешний вид меняет местами цвета шрифта и фона, делая\n уведомление более заметным\n\n"); $label->set_name("comment"); if ($this->conf["notifications_theme"]=="inverted") {$inverted->set_active(true);} else {$default->set_active(true);} $notifystylebox->add($inverted); $notifystylebox->add($label); $label = new GtkLabel("Хотите изменить тему? Нажмите здесь\n\n"); $label->set_use_markup(true); $label->connect("button-press-event", function($widget) { // connect menu to event activate global $window; $window->destroy(); exec("/system/supreme/control/index.php appearance > /dev/null &"); exit(); }); $notifystylebox->add($label); $this->notifications->add($notifystylebox); $testbutton = new GtkButton(); $testbutton->set_label("Вывести тестовое уведомление"); $testbutton->connect("clicked", function($widget) { // connect menu to event activate global $window; $number = rand(1,10000); exec("notify-send 'Сьешь еще этих мягких французских булок, да выпей чаю' 'Test # $number' -i 'applications-system'> /dev/null &"); }); $this->notifications->add($testbutton); $c=exec("ps aux | grep notifyd | grep php | grep -v grep"); if ($c=="") { $label = new GtkLabel("\nКажется, системный сервис уведомлений не запущен.\nЗапустить его можно командой /system/supreme/utils/notifyd.php\nИ хотя Вы можете использовать любые демоны уведомлений,\nданные настройки работают только для системного сервиса.\n"); $label->set_selectable(true); $label->set_name("warning"); $notifystylebox->add($label); } $contentbox->add($this->notifications); $contentbox->show_all(); print_r($window); } } ?>