static void daemon_init (Daemon *daemon) { daemon->priv = DAEMON_GET_PRIVATE (daemon); daemon->priv->extension_ifaces = daemon_read_extension_ifaces (); daemon->priv->users = create_users_hash_table (); daemon->priv->passwd_monitor = setup_monitor (daemon, PATH_PASSWD, on_users_monitor_changed); daemon->priv->shadow_monitor = setup_monitor (daemon, PATH_SHADOW, on_users_monitor_changed); daemon->priv->group_monitor = setup_monitor (daemon, PATH_GROUP, on_users_monitor_changed); daemon->priv->wtmp_monitor = setup_monitor (daemon, wtmp_helper_get_path_for_monitor (), on_users_monitor_changed); daemon->priv->gdm_monitor = setup_monitor (daemon, PATH_GDM_CUSTOM, on_gdm_monitor_changed); reload_users_timeout (daemon); queue_reload_autologin (daemon); }
static void monitor_apply_options_cb(GtkWidget *button, t_global_monitor *global) { gint i; if (global->monitor->options.label_text) { g_free(global->monitor->options.label_text); } global->monitor->options.label_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->opt_entry))); setup_monitor(global); if (global->monitor->options.network_device) { g_free(global->monitor->options.network_device); } global->monitor->options.network_device = g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->net_entry))); setup_monitor(global); for( i = 0; i < SUM; i++ ) { global->monitor->options.max[i] = strtod( g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->max_entry[i]))), NULL ) * 1024; } global->monitor->options.update_interval = (gint)(gtk_spin_button_get_value( GTK_SPIN_BUTTON(global->monitor->update_spinner) ) * 1000 + 0.5); setup_monitor(global); }
static void on_save_finished (GObject* file, GAsyncResult* result, gpointer data) { SourceviewIO* sio = SOURCEVIEW_IO(data); AnjutaShell* shell = ANJUTA_PLUGIN (sio->sv->priv->plugin)->shell; GError* err = NULL; g_file_replace_contents_finish (G_FILE (file), result, NULL, &err); g_free (sio->write_buffer); sio->write_buffer = NULL; if (err) { g_signal_emit_by_name (sio, "save-failed", err); g_error_free (err); } else { set_display_name (sio); setup_monitor (sio); g_signal_emit_by_name (sio, "save-finished"); } g_object_unref (sio); anjuta_shell_saving_pop (shell); }
static void change_color(GtkWidget *button, t_global_monitor *global, gint type) { GtkWidget *dialog; GtkColorSelection *colorsel; gint response; dialog = gtk_color_selection_dialog_new(_("Select color")); gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(global->opt_dialog)); colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel); gtk_color_selection_set_previous_color(colorsel, &global->monitor->options.color[type]); gtk_color_selection_set_current_color(colorsel, &global->monitor->options.color[type]); gtk_color_selection_set_has_palette(colorsel, TRUE); response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == GTK_RESPONSE_OK) { gtk_color_selection_get_current_color(colorsel, &global->monitor->options.color[type]); gtk_widget_modify_bg(global->monitor->opt_da[type], GTK_STATE_NORMAL, &global->monitor->options.color[type]); setup_monitor(global); } gtk_widget_destroy(dialog); }
static void label_toggled(GtkWidget *check_button, t_global_monitor *global) { global->monitor->options.use_label = !global->monitor->options.use_label; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(global->monitor->opt_use_label), global->monitor->options.use_label); gtk_widget_set_sensitive(GTK_WIDGET(global->monitor->opt_entry), global->monitor->options.use_label); setup_monitor(global); }
int main(int argc, char **argv) { int i, j, result = 0; // process flags for -v verbose, -t terminate, -h help for (i = 1; i < argc; i++) { if (argv[i] && argv[i][0] == '-') { int len = strlen(argv[i]); for (j = 1; j < len; j++) { switch (argv[i][j]) { case 'h': printf("testmonitor.c: possible arguments " "-q quiet (suppress output), " "-t terminate automatically, " "-h help\n"); return 1; break; case 'q': verbose = 0; break; case 't': terminate = 1; break; default: break; } } } } signal(SIGINT, ctrlc); if (setup_monitor()) { printf("Error initializing monitor.\n"); result = 1; goto done; } mapper_db_add_device_callback(db, on_device, 0); mapper_db_add_signal_callback(db, on_signal, 0); mapper_db_add_connection_callback(db, on_connection, 0); mapper_db_add_link_callback(db, on_link, 0); loop(); done: mapper_db_remove_device_callback(db, on_device, 0); mapper_db_remove_signal_callback(db, on_signal, 0); mapper_db_remove_connection_callback(db, on_connection, 0); mapper_db_remove_link_callback(db, on_link, 0); cleanup_monitor(); return result; }
static void network_changed(GtkWidget *button, t_global_monitor *global) { if (global->monitor->options.network_device) { g_free(global->monitor->options.network_device); } global->monitor->options.network_device = g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->net_entry))); setup_monitor(global); }
static void max_label_changed(GtkWidget *button, t_global_monitor *global) { gint i; for( i = 0; i < SUM; i++ ) { global->monitor->options.max[i] = strtod( g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->max_entry[i]))), NULL ) * 1024; } setup_monitor(global); }
static void label_changed(GtkWidget *button, t_global_monitor *global) { if (global->monitor->options.label_text) { g_free(global->monitor->options.label_text); } global->monitor->options.label_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->opt_entry))); setup_monitor(global); }
static void on_read_finished (GObject* input, GAsyncResult* result, gpointer data) { SourceviewIO* sio = SOURCEVIEW_IO(data); GInputStream* input_stream = G_INPUT_STREAM(input); gsize current_bytes = 0; GError* err = NULL; current_bytes = g_input_stream_read_finish (input_stream, result, &err); if (err) { g_signal_emit_by_name (sio, "open-failed", err); g_error_free (err); g_object_unref (input_stream); g_free (sio->read_buffer); sio->read_buffer = NULL; sio->bytes_read = 0; return; } sio->bytes_read += current_bytes; if (current_bytes != 0) { sio->read_buffer = g_realloc (sio->read_buffer, sio->bytes_read + READ_SIZE); g_input_stream_read_async (G_INPUT_STREAM (input_stream), sio->read_buffer + sio->bytes_read, READ_SIZE, G_PRIORITY_LOW, sio->cancel, on_read_finished, sio); return; } else { if (append_buffer (sio, sio->bytes_read)) g_signal_emit_by_name (sio, "open-finished"); sio->bytes_read = 0; g_object_unref (input_stream); setup_monitor (sio); g_free (sio->read_buffer); sio->read_buffer = NULL; } }
static void max_label_toggled(GtkWidget *check_button, t_global_monitor *global) { gint i; global->monitor->options.auto_max = !global->monitor->options.auto_max; for( i = 0; i < SUM; i++ ) { gtk_widget_set_sensitive(GTK_WIDGET(global->monitor->max_hbox[i]), !(global->monitor->options.auto_max)); /* reset maximum if necessary */ if( global->monitor->options.auto_max ) { global->monitor->net_max[i] = INIT_MAX; } } setup_monitor(global); }
static void monitor_set_size(Control *ctrl, int size) { /* do the resize */ t_global_monitor *global; gint i; global = (t_global_monitor *)ctrl->data; for (i = 0; i < SUM; i++) { if (settings.orientation == HORIZONTAL) { gtk_widget_set_size_request(GTK_WIDGET(global->monitor->status[i]), 6 + 2 * size, icon_size[size]); } else { gtk_widget_set_size_request(GTK_WIDGET(global->monitor->status[i]), icon_size[size], 6 + 2 * size); } gtk_widget_queue_resize(GTK_WIDGET(global->monitor->status[i])); } setup_monitor(global); }
int main(int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; memset (&the_rebinder, 0, sizeof (Rebinder)); g_type_init (); /* Options */ context = g_option_context_new ("- key rebinder"); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("Failed to parse options: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } #ifdef REBINDER_ENABLE_DEBUG rebinder_debug_init (); #endif if (opt_configure) { /* lauched in configuration mode */ if (request_dbus_name (MEX_REBINDER_CONFIGURE_DBUS_INTERFACE) == FALSE) { g_message ("Could not request DBus name"); return EXIT_SUCCESS; } clutter_init (&argc, &argv); /* we expect to be build against clutter-glx */ the_rebinder.dpy = clutter_x11_get_default_display (); the_rebinder.config = rebinder_configure (&the_rebinder, NULL, is_evdev_enabled (), is_fullscreen_enabled ()); clutter_main (); rebinder_configure_free (the_rebinder.config); } else { /* launched in daemon mode */ MexRebinder *rebinder; gboolean registered; rebinder = mex_rebinder_new (); registered = mex_rebinder_register (rebinder, MEX_REBINDER_DBUS_INTERFACE, MEX_REBINDER_DBUS_PATH, &error); if (registered == FALSE) { const gchar prefix[] = "Could not request DBus name"; if (error) g_message ("%s: %s", prefix, error->message); else g_message ("%s", prefix); return EXIT_FAILURE; } g_signal_connect (rebinder, "quit", G_CALLBACK (on_rebinder_quit), &the_rebinder); the_rebinder.dpy = XOpenDisplay (NULL); if (G_UNLIKELY (the_rebinder.dpy == NULL)) { g_error ("Could not open display"); return EXIT_FAILURE; } the_rebinder.fake = fakekey_init (the_rebinder.dpy); if (G_UNLIKELY (the_rebinder.fake == NULL)) { g_error ("Could not initialize fakekey"); return EXIT_FAILURE; } if (opt_no_daemon == FALSE) daemon (0, 0); signal (SIGINT, on_int_term_signaled); signal (SIGTERM, on_int_term_signaled); the_rebinder.original_bindings = g_array_new (FALSE, FALSE, sizeof (Binding)); /* listens to evdev events and setup everything needed */ if (is_evdev_enabled ()) { the_rebinder.evdev_manager = rebinder_evdev_manager_get_default (); rebinder_evdev_manager_set_key_notifier (the_rebinder.evdev_manager, on_evdev_key_pressed, &the_rebinder); the_rebinder.evdev_bindings = g_ptr_array_new_with_free_func (free_binding); } load_bindings (&the_rebinder); setup_monitor (&the_rebinder); the_rebinder.mainloop = g_main_loop_new (NULL, TRUE); g_main_loop_run (the_rebinder.mainloop); restore_bindings (&the_rebinder); g_main_loop_unref (the_rebinder.mainloop); g_object_unref (the_rebinder.monitor); } return EXIT_SUCCESS; }
static void monitor_read_config(Control *ctrl, xmlNodePtr node) { xmlChar *value; t_global_monitor *global; global = (t_global_monitor *)ctrl->data; if (node == NULL || node->children == NULL) { return; } for (node = node->children; node; node = node->next) { if (xmlStrEqual(node->name, (const xmlChar *)MONITOR_ROOT)) { if ((value = xmlGetProp(node, (const xmlChar *)"Use_Label"))) { global->monitor->options.use_label = atoi(value); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *)"Color_In"))) { gdk_color_parse(value, &global->monitor->options.color[IN]); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *)"Color_Out"))) { gdk_color_parse(value, &global->monitor->options.color[OUT]); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *) "Text"))) { if (global->monitor->options.label_text) g_free(global->monitor->options.label_text); global->monitor->options.label_text = g_strdup((gchar *)value); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *) "Network_Device"))) { if (global->monitor->options.network_device) g_free(global->monitor->options.network_device); global->monitor->options.network_device = g_strdup((gchar *)value); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *) "Max_In"))) { global->monitor->options.max[IN] = atoi( value ); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *) "Max_Out"))) { global->monitor->options.max[OUT] = atol( value ); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *) "Auto_Max"))) { global->monitor->options.auto_max = atol(value); g_free(value); } if ((value = xmlGetProp(node, (const xmlChar *) "Update_Interval"))) { global->monitor->options.update_interval = atoi(value); g_free(value); } break; } } setup_monitor(global); }