int main(int argc, char *argv[]) { pid_t pID = fork(); if(pID == 0) { // child pa_devicelist_t pa_input_devicelist[16]; pa_devicelist_t pa_output_devicelist[16]; if (pa_get_devicelist(pa_input_devicelist, pa_output_devicelist) < 0) { fprintf(stderr, "failed to get device list\n"); return 1; } init_app_indicator(argc, argv); fill_app_indicator(pa_input_devicelist, pa_output_devicelist); gtk_main (); return 0; } else if(pID < 0) { fprintf(stderr, "Failed to fork\n"); exit(1); } else { return 0; } }
DrWright * drwright_new (void) { DrWright *dr; GtkWidget *item; MateConfClient *client; GtkActionGroup *action_group; static const char ui_description[] = "<ui>" " <popup name='Pop'>" " <menuitem action='Preferences'/>" " <menuitem action='About'/>" " <separator/>" " <menuitem action='TakeABreak'/>" " </popup>" "</ui>"; dr = g_new0 (DrWright, 1); client = mateconf_client_get_default (); mateconf_client_add_dir (client, MATECONF_PATH, MATECONF_CLIENT_PRELOAD_NONE, NULL); mateconf_client_notify_add (client, MATECONF_PATH, mateconf_notify_cb, dr, NULL, NULL); dr->type_time = 60 * mateconf_client_get_int ( client, MATECONF_PATH "/type_time", NULL); dr->warn_time = MIN (dr->type_time / 12, 60*3); dr->break_time = 60 * mateconf_client_get_int ( client, MATECONF_PATH "/break_time", NULL); dr->enabled = mateconf_client_get_bool ( client, MATECONF_PATH "/enabled", NULL); g_object_unref (client); if (debug) { setup_debug_values (dr); } dr->ui_manager = gtk_ui_manager_new (); action_group = gtk_action_group_new ("MenuActions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, actions, G_N_ELEMENTS (actions), dr); gtk_ui_manager_insert_action_group (dr->ui_manager, action_group, 0); gtk_ui_manager_add_ui_from_string (dr->ui_manager, ui_description, -1, NULL); item = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop/TakeABreak"); gtk_widget_set_sensitive (item, dr->enabled); dr->timer = drw_timer_new (); dr->idle_timer = drw_timer_new (); dr->state = STATE_START; dr->monitor = drw_monitor_new (); g_signal_connect (dr->monitor, "activity", G_CALLBACK (activity_detected_cb), dr); #ifdef HAVE_APP_INDICATOR init_app_indicator (dr); #else dr->neutral_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar.png", NULL); dr->red_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-red.png", NULL); dr->green_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-green.png", NULL); dr->disabled_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-disabled.png", NULL); init_tray_icon (dr); #endif /* HAVE_APP_INDICATOR */ g_timeout_add_seconds (12, (GSourceFunc) update_status, dr); g_timeout_add_seconds (1, (GSourceFunc) maybe_change_state, dr); return dr; }