static void constructed (GObject *object) { NmnModelPrivate *priv = GET_PRIVATE (object); NMListModel *child_model; DBusGConnection *bus; if (G_OBJECT_CLASS (nmn_model_parent_class)->constructed) G_OBJECT_CLASS (nmn_model_parent_class)->constructed (object); child_model = NM_LIST_MODEL (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (object))); priv->client = nm_list_model_get_client (child_model); bus = nm_object_get_connection (NM_OBJECT (priv->client)); priv->user_settings = NM_SETTINGS_INTERFACE (nm_gconf_settings_new (bus)); priv->system_settings = NM_SETTINGS_INTERFACE (nm_remote_settings_system_new (bus)); nm_list_model_add_settings (child_model, priv->user_settings); nm_list_model_add_settings (child_model, priv->system_settings); g_signal_connect (priv->client, "notify::" NM_CLIENT_STATE, G_CALLBACK (nm_client_state_changed), object); g_signal_connect (priv->client, "notify::" NM_CLIENT_WIRELESS_ENABLED, G_CALLBACK (nm_wireless_state_changed), object); g_signal_connect (priv->client, "notify::" NM_CLIENT_WIRELESS_HARDWARE_ENABLED, G_CALLBACK (nm_wireless_state_changed), object); nm_wireless_state_changed (priv->client, NULL, object); nm_client_state_changed (priv->client, NULL, object); if (request_dbus_name (bus)) dbus_g_connection_register_g_object (bus, NM_DBUS_PATH_SETTINGS, G_OBJECT (priv->user_settings)); }
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; }