static void state_changed_cb (ParoleProviderPlayer *player, const ParoleStream *stream, ParoleState state, TrayProvider *tray) { tray->state = state; if ( tray->menu ) { gtk_widget_destroy (tray->menu); tray->menu = NULL; g_signal_emit_by_name (G_OBJECT (tray->tray), "popup-menu", 0, gtk_get_current_event_time ()); } #ifdef HAVE_LIBNOTIFY if ( state == PAROLE_STATE_PLAYING ) { notify_playing (tray, stream); } else if ( state <= PAROLE_STATE_PAUSED ) { close_notification (tray); if ( state < PAROLE_STATE_PAUSED ) tray->notify = TRUE; } #endif }
static gboolean cancel_request(DBusGMethodInvocation *context, gpointer user_data) { DBusGProxy *adapter = user_data; GList *list; GError *result; input_data *input; input = g_new0(input_data, 1); input->path = g_strdup(dbus_g_proxy_get_path(adapter)); list = g_list_find_custom(input_list, input, input_compare); g_free(input->path); g_free(input); if (!list || !list->data) return FALSE; input = list->data; close_notification(); result = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT, "Agent callback cancelled"); dbus_g_method_return_error(input->context, result); input_free(input); return TRUE; }
void show_agents(void) { close_notification(); g_list_foreach(input_list, show_dialog, NULL); disable_blinking(); }
/* * open a notification window (expires in 5 seconds) to say thank you * to the user for his bug feedback. */ static void sent_an_oops(void) { char *summary = _("Kernel bug diagnostic information sent"); char *message = NULL; char *message_1 = _("Diagnostic information from your Linux kernel has been " "sent to http://oops.kernel.org/ " "for the Linux kernel developers to work on. \n" "Thank you for contributing to improve the quality of the Linux kernel.\n"); char *message_2 = _("Diagnostic information from your Linux kernel has been " "sent to http://oops.kernel.org " "for the Linux kernel developers to work on. \n" "Thank you for contributing to improve the quality of the Linux kernel.\n" "You can view your submitted oops here: %s\n"); NotifyActionCallback callback = notify_action; close_notification(); if (strlen(url_to_oops)==0) message = g_strdup_printf("%s", message_1); else message = g_strdup_printf(message_2, url_to_oops); url_to_oops[0] = 0; #if NOTIFY_CHECK_VERSION(0,7,0) notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png"); #else notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png", NULL); #endif notify_notification_set_timeout(notify, 5000); notify_notification_set_urgency(notify, NOTIFY_URGENCY_LOW); notify_notification_add_action(notify, "default", "action", callback, "default", NULL); if (user_preference <= 0) notify_notification_add_action(notify, "always", _("Always"), callback, "always", NULL); notify_notification_add_action(notify, "never", _("Never again"), callback, "never", NULL); notify_notification_show(notify, NULL); g_free(message); }
void cleanup_notification(void) { close_notification(); g_object_unref(statusicon); g_free (icon_name); icon_name = NULL; g_free (tooltip); tooltip = NULL; notify_uninit(); }
static void got_a_message(void) { char *summary = _("Your system had a kernel failure"); char *message = _("There is diagnostic information available for this failure." " Do you want to submit this information to the http://oops.kernel.org/" " website for use by the Linux kernel developers?\n"); NotifyActionCallback callback = notify_action; /* if there's a notification active already, close it first */ close_notification(); #if NOTIFY_CHECK_VERSION(0,7,0) notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png"); #else notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png", NULL); #endif notify_notification_set_timeout(notify, 0); notify_notification_set_urgency(notify, NOTIFY_URGENCY_CRITICAL); /* * add the buttons and default action */ notify_notification_add_action(notify, "default", "action", callback, "default", NULL); notify_notification_add_action(notify, "always", _("Always"), callback, "always", NULL); notify_notification_add_action(notify, "yes", _("Yes"), callback, "yes", NULL); notify_notification_add_action(notify, "no", _("No"), callback, "no", NULL); notify_notification_add_action(notify, "never", _("Never"), callback, "never", NULL); if (detail_file_name) { notify_notification_add_action(notify, "details", _("Show Details"), detail_action, "details", NULL); } notify_notification_show(notify, NULL); }
void cleanup_notification(void) { close_notification(); #ifdef HAVE_APP_INDICATOR g_object_unref (indicator); #else g_object_unref (statusicon); #endif /* HAVE_APP_INDICATOR */ g_object_unref (icon_enabled); g_object_unref (icon_disabled); g_free (tooltip); tooltip = NULL; notify_uninit(); }
static void tray_provider_finalize (GObject *object) { TrayProvider *tray; tray = TRAY_PROVIDER (object); if ( GTK_IS_WIDGET (tray->window) && g_signal_handler_is_connected (tray->window, tray->sig) ) g_signal_handler_disconnect (tray->window, tray->sig); #ifdef HAVE_LIBNOTIFY close_notification (tray); #endif g_object_unref (G_OBJECT (tray->tray)); G_OBJECT_CLASS (tray_provider_parent_class)->finalize (object); }
void on_status ( OrgZlbruceEyerestBasic *object, guint arg_time_remain, const gchar *arg_state) { time_t time_remain = arg_time_remain; static gchar time_str[PATH_MAX]; struct tm* tm = localtime(&time_remain); int len = 0; if(tm == NULL) { len = g_snprintf(time_str, sizeof(time_str), "%lu", (unsigned long)time); } else { len = strftime(time_str, sizeof(time_str), "%M:%S", tm); } //g_printf("time_str = %s, state = %s\n", time_str, arg_state); gtk_menu_item_set_label(GTK_MENU_ITEM(menu_item_state), time_str); gtk_status_icon_set_tooltip_text (tray_icon, time_str); if(arg_time_remain < 60) { if(!g_notified) { send_notification(time_str, arg_time_remain); } } else { g_notified = FALSE; if(g_notify_id != 0) { close_notification(); } } }
int main(int argc, char *argv[]) { DBusError error; /* Initialize translation stuff */ setlocale(LC_ALL, ""); bindtextdomain("kerneloops", "/usr/share/locale"); textdomain("kerneloops"); gtk_init(&argc, &argv); /* read the config file early; we may be able to bug out of stuff */ read_config(); /* * initialize the dbus connection; we want to listen to the system * bus (which is where all daemons send their messages */ dbus_error_init(&error); bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); if (bus == NULL) { g_printerr(_("Connecting to system bus failed: %s\n"), error.message); dbus_error_free(&error); exit(EXIT_FAILURE); } /* hook dbus into the main loop */ dbus_connection_setup_with_g_main(bus, NULL); statusicon = gtk_status_icon_new_from_file("/usr/share/kerneloops/icon.png"); gtk_status_icon_set_tooltip(statusicon, _("kerneloops client")); notify_init("kerneloops-ui"); /* by default, don't show our icon */ gtk_status_icon_set_visible(statusicon, FALSE); /* set the dbus message to listen for */ dbus_bus_add_match(bus, "type='signal',interface='org.kerneloops.submit.permission'", &error); dbus_bus_add_match(bus, "type='signal',interface='org.kerneloops.submit.sent'", &error); dbus_bus_add_match(bus, "type='signal',interface='org.kerneloops.submit.url'", &error); dbus_connection_add_filter(bus, dbus_gotmessage, NULL, NULL); /* * if the user said always/never in the config file, let the daemon * know right away */ if (user_preference < 0) send_permission("never"); if (user_preference > 0) send_permission("always"); /* send a ping to the userspace daemon to see if it has pending oopses */ trigger_daemon(); gtk_main(); close_notification(); return 0; }